Changeset 3182831
- Timestamp:
- 11/06/2024 05:30:52 AM (17 months ago)
- Location:
- show-hide-section-block
- Files:
-
- 34 added
- 2 deleted
- 34 edited
- 1 copied
-
tags/3.0.0 (copied) (copied from show-hide-section-block/trunk)
-
tags/3.0.0/.wordpress-org (deleted)
-
tags/3.0.0/LICENSE (modified) (1 diff)
-
tags/3.0.0/build/show-hide-details (added)
-
tags/3.0.0/build/show-hide-details/block.json (added)
-
tags/3.0.0/build/show-hide-details/index.asset.php (added)
-
tags/3.0.0/build/show-hide-details/index.js (added)
-
tags/3.0.0/build/show-hide-group/block.json (modified) (1 diff)
-
tags/3.0.0/build/show-hide-group/index.asset.php (modified) (1 diff)
-
tags/3.0.0/build/show-hide-group/index.js (modified) (1 diff)
-
tags/3.0.0/build/show-hide-group/view.asset.php (modified) (1 diff)
-
tags/3.0.0/build/show-hide-group/view.js (modified) (1 diff)
-
tags/3.0.0/build/show-hide-section/block.json (modified) (1 diff)
-
tags/3.0.0/build/show-hide-section/index.asset.php (modified) (1 diff)
-
tags/3.0.0/build/show-hide-section/index.js (modified) (1 diff)
-
tags/3.0.0/build/show-hide-summary (added)
-
tags/3.0.0/build/show-hide-summary/block.json (added)
-
tags/3.0.0/build/show-hide-summary/index.asset.php (added)
-
tags/3.0.0/build/show-hide-summary/index.js (added)
-
tags/3.0.0/languages/show-hide-section-block.pot (modified) (2 diffs)
-
tags/3.0.0/plugin.php (modified) (3 diffs)
-
tags/3.0.0/readme.txt (modified) (4 diffs)
-
tags/3.0.0/src/show-hide-details (added)
-
tags/3.0.0/src/show-hide-details/block.json (added)
-
tags/3.0.0/src/show-hide-details/index.js (added)
-
tags/3.0.0/src/show-hide-details/index.php (added)
-
tags/3.0.0/src/show-hide-group/block.json (modified) (1 diff)
-
tags/3.0.0/src/show-hide-group/index.js (modified) (7 diffs)
-
tags/3.0.0/src/show-hide-group/view.js (modified) (1 diff)
-
tags/3.0.0/src/show-hide-section/block.json (modified) (2 diffs)
-
tags/3.0.0/src/show-hide-section/deprecated.js (added)
-
tags/3.0.0/src/show-hide-section/index.js (modified) (2 diffs)
-
tags/3.0.0/src/show-hide-summary (added)
-
tags/3.0.0/src/show-hide-summary/block.json (added)
-
tags/3.0.0/src/show-hide-summary/index.js (added)
-
tags/3.0.0/src/show-hide-summary/index.php (added)
-
trunk/.wordpress-org (deleted)
-
trunk/LICENSE (modified) (1 diff)
-
trunk/build/show-hide-details (added)
-
trunk/build/show-hide-details/block.json (added)
-
trunk/build/show-hide-details/index.asset.php (added)
-
trunk/build/show-hide-details/index.js (added)
-
trunk/build/show-hide-group/block.json (modified) (1 diff)
-
trunk/build/show-hide-group/index.asset.php (modified) (1 diff)
-
trunk/build/show-hide-group/index.js (modified) (1 diff)
-
trunk/build/show-hide-group/view.asset.php (modified) (1 diff)
-
trunk/build/show-hide-group/view.js (modified) (1 diff)
-
trunk/build/show-hide-section/block.json (modified) (1 diff)
-
trunk/build/show-hide-section/index.asset.php (modified) (1 diff)
-
trunk/build/show-hide-section/index.js (modified) (1 diff)
-
trunk/build/show-hide-summary (added)
-
trunk/build/show-hide-summary/block.json (added)
-
trunk/build/show-hide-summary/index.asset.php (added)
-
trunk/build/show-hide-summary/index.js (added)
-
trunk/languages/show-hide-section-block.pot (modified) (2 diffs)
-
trunk/plugin.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/src/show-hide-details (added)
-
trunk/src/show-hide-details/block.json (added)
-
trunk/src/show-hide-details/index.js (added)
-
trunk/src/show-hide-details/index.php (added)
-
trunk/src/show-hide-group/block.json (modified) (1 diff)
-
trunk/src/show-hide-group/index.js (modified) (7 diffs)
-
trunk/src/show-hide-group/view.js (modified) (1 diff)
-
trunk/src/show-hide-section/block.json (modified) (2 diffs)
-
trunk/src/show-hide-section/deprecated.js (added)
-
trunk/src/show-hide-section/index.js (modified) (2 diffs)
-
trunk/src/show-hide-summary (added)
-
trunk/src/show-hide-summary/block.json (added)
-
trunk/src/show-hide-summary/index.js (added)
-
trunk/src/show-hide-summary/index.php (added)
Legend:
- Unmodified
- Added
- Removed
-
show-hide-section-block/tags/3.0.0/LICENSE
r2874431 r3182831 1 1 Show/Hide Section Block - a plugin for WordPress 2 2 3 Copyright 2020-202 3by Happy Prime3 Copyright 2020-2024 by Happy Prime 4 4 5 5 This program is free software; you can redistribute it and/or modify -
show-hide-section-block/tags/3.0.0/build/show-hide-group/block.json
r2905297 r3182831 1 1 { 2 "$schema": "https://json.schemastore.org/block.json",3 "apiVersion": 2,4 "name": "happyprime/show-hide-group",5 "title": "Show Hide Group",6 "textdomain": "show-hide-section-block",7 "category": "widgets",8 "description": "A group of accessible summaries that can be toggled to show or hide additional details.",9 "icon": "hidden",10 "attributes": {11 "hasToggle": {12 "type": "boolean",13 "default": false14 }15 },16 "supports": {17 "align": true,18 "alignWide": true,19 "anchor": true,20 "color": {21 "background": true,22 "enableContrastChecker": true,23 "text": true,24 "link": true,25 "gradients": true26 },27 "defaultStylePicker": true,28 "dimensions": {29 "minHeight": true30 },31 "html": false,32 "position": {33 "sticky": false34 },35 "spacing": {36 "margin": true,37 "padding": true38 },39 "typography": {40 "fontSize": true,41 "lineHeight": true42 }43 },44 "editorScript": "file:index.js",45 "viewScript": "file:view.js"2 "$schema": "https://json.schemastore.org/block.json", 3 "apiVersion": 3, 4 "name": "happyprime/show-hide-group", 5 "title": "Show Hide Group", 6 "textdomain": "show-hide-section-block", 7 "category": "widgets", 8 "description": "A group of accessible summaries that can be toggled to show or hide additional details.", 9 "icon": "hidden", 10 "attributes": { 11 "hasToggle": { 12 "type": "boolean", 13 "default": false 14 } 15 }, 16 "supports": { 17 "align": true, 18 "alignWide": true, 19 "anchor": true, 20 "color": { 21 "background": true, 22 "enableContrastChecker": true, 23 "text": true, 24 "link": true, 25 "gradients": true 26 }, 27 "defaultStylePicker": true, 28 "dimensions": { 29 "minHeight": true 30 }, 31 "html": false, 32 "position": { 33 "sticky": false 34 }, 35 "spacing": { 36 "margin": true, 37 "padding": true 38 }, 39 "typography": { 40 "fontSize": true, 41 "lineHeight": true 42 } 43 }, 44 "editorScript": "file:index.js", 45 "viewScript": "file:view.js" 46 46 } -
show-hide-section-block/tags/3.0.0/build/show-hide-group/index.asset.php
r2905297 r3182831 1 <?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp- element', 'wp-i18n'), 'version' => '9821368a8f1930a9690c');1 <?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-i18n'), 'version' => '70bf254dd1647cf40738'); -
show-hide-section-block/tags/3.0.0/build/show-hide-group/index.js
r2905297 r3182831 1 !function(){"use strict";var e=window.wp.element,t=window.wp.blocks,o=window.wp.blockEditor,l=window.wp.components,a=window.wp.data,i=window.wp.i18n,n=JSON.parse('{"$schema":"https://json.schemastore.org/block.json","apiVersion":2,"name":"happyprime/show-hide-group","title":"Show Hide Group","textdomain":"show-hide-section-block","category":"widgets","description":"A group of accessible summaries that can be toggled to show or hide additional details.","icon":"hidden","attributes":{"hasToggle":{"type":"boolean","default":false}},"supports":{"align":true,"alignWide":true,"anchor":true,"color":{"background":true,"enableContrastChecker":true,"text":true,"link":true,"gradients":true},"defaultStylePicker":true,"dimensions":{"minHeight":true},"html":false,"position":{"sticky":false},"spacing":{"margin":true,"padding":true},"typography":{"fontSize":true,"lineHeight":true}},"editorScript":"file:index.js","viewScript":"file:view.js"}');(0,t.registerBlockType)(n,{edit:t=>{const{attributes:{hasToggle:n},setAttributes:r}=t,s=(0,a.useSelect)((e=>e("core/block-editor").getBlocks(t.clientId)));return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(o.InspectorControls,null,(0,e.createElement)(l.PanelBody,null,(0,e.createElement)(l.ToggleControl,{label:(0,i.__)("Has open/close all toggle","show-hide-section-block"),help:n?(0,i.__)("Open/close all toggle will display.","show-hide-section-block"):(0,i.__)("Open/close all toggle will not display.","show-hide-section-block"),checked:n,onChange:e=>{r({hasToggle:e})}}))),(0,e.createElement)("div",(0,o.useBlockProps)(),n&&(0,e.createElement)("button",{className:"toggle-all","aria-expanded":"false",onClick:e=>{!1===e.target.ariaExpanded?(s.forEach((e=>{(0,a.dispatch)("core/block-editor").updateBlockAttributes(e.clientId,{isOpen:!0})})),e.target.innerText=(0,i.__)("Close all","show-hide-section-block"),e.target.ariaExpanded=!0):(s.forEach((e=>{(0,a.dispatch)("core/block-editor").updateBlockAttributes(e.clientId,{isOpen:!1})})),e.target.innerText=(0,i.__)("Open all","show-hide-section-block"),e.target.ariaExpanded=!1)}},(0,i.__)("Open all","show-hide-section-block")),(0,e.createElement)(o.InnerBlocks,{allowedBlocks:["happyprime/show-hide-section"],template:[["happyprime/show-hide-section",{},[["core/paragraph",{}]]],["happyprime/show-hide-section",{},[["core/paragraph",{}]]]],templateLock:!1})))},save:t=>{const{attributes:{hasToggle:l}}=t;return(0,e.createElement)("div",o.useBlockProps.save(),l&&(0,e.createElement)("button",{className:"toggle-all","aria-expanded":"false"},(0,i.__)("Open all","show-hide-section-block")),(0,e.createElement)(o.InnerBlocks.Content,null))}})}();1 (()=>{"use strict";const e=window.wp.blocks,t=window.wp.blockEditor,o=window.wp.components,l=window.wp.data,a=window.wp.i18n,i=JSON.parse('{"$schema":"https://json.schemastore.org/block.json","apiVersion":3,"name":"happyprime/show-hide-group","title":"Show Hide Group","textdomain":"show-hide-section-block","category":"widgets","description":"A group of accessible summaries that can be toggled to show or hide additional details.","icon":"hidden","attributes":{"hasToggle":{"type":"boolean","default":false}},"supports":{"align":true,"alignWide":true,"anchor":true,"color":{"background":true,"enableContrastChecker":true,"text":true,"link":true,"gradients":true},"defaultStylePicker":true,"dimensions":{"minHeight":true},"html":false,"position":{"sticky":false},"spacing":{"margin":true,"padding":true},"typography":{"fontSize":true,"lineHeight":true}},"editorScript":"file:index.js","viewScript":"file:view.js"}');(0,e.registerBlockType)(i,{edit:e=>{const{attributes:{hasToggle:i},setAttributes:n}=e,s=(0,l.useSelect)((t=>t("core/block-editor").getBlocks(e.clientId)));return React.createElement(React.Fragment,null,React.createElement(t.InspectorControls,null,React.createElement(o.PanelBody,null,React.createElement(o.ToggleControl,{label:(0,a.__)("Has open/close all toggle","show-hide-section-block"),help:i?(0,a.__)("Open/close all toggle will display.","show-hide-section-block"):(0,a.__)("Open/close all toggle will not display.","show-hide-section-block"),checked:i,onChange:e=>{n({hasToggle:e})}}))),React.createElement("div",(0,t.useBlockProps)(),i&&React.createElement("button",{className:"toggle-all","aria-expanded":"false",onClick:e=>{!1===e.target.ariaExpanded?(s.forEach((e=>{(0,l.dispatch)("core/block-editor").updateBlockAttributes(e.clientId,{isOpen:!0})})),e.target.innerText=(0,a.__)("Close all","show-hide-section-block"),e.target.ariaExpanded=!0):(s.forEach((e=>{(0,l.dispatch)("core/block-editor").updateBlockAttributes(e.clientId,{isOpen:!1})})),e.target.innerText=(0,a.__)("Open all","show-hide-section-block"),e.target.ariaExpanded=!1)}},(0,a.__)("Open all","show-hide-section-block")),React.createElement(t.InnerBlocks,{allowedBlocks:["happyprime/show-hide-section"],template:[["happyprime/show-hide-section",{}]],templateLock:!1})))},save:e=>{const{attributes:{hasToggle:o}}=e;return React.createElement("div",t.useBlockProps.save(),o&&React.createElement("button",{className:"toggle-all","aria-expanded":"false"},(0,a.__)("Open all","show-hide-section-block")),React.createElement(t.InnerBlocks.Content,null))}})})(); -
show-hide-section-block/tags/3.0.0/build/show-hide-group/view.asset.php
r2905297 r3182831 1 <?php return array('dependencies' => array(), 'version' => ' c1c493ae492c636904dd');1 <?php return array('dependencies' => array(), 'version' => 'fbf381460e85f307651f'); -
show-hide-section-block/tags/3.0.0/build/show-hide-group/view.js
r2905297 r3182831 1 !function(){{const e=()=>{const e=document.querySelectorAll(".wp-block-happyprime-show-hide-group .toggle-all");e.length>0&&e.forEach((e=>e.addEventListener("click",(()=>{const t=e.parentElement.querySelectorAll("details.wp-block-happyprime-show-hide-section");"true"!==e.ariaExpanded?(t.forEach((e=>{e.setAttribute("open","true")})),e.innerText="Close All",e.ariaExpanded="true"):(t.forEach((e=>{e.removeAttribute("open")})),e.innerText="Open All",e.ariaExpanded="false")}))))};document.addEventListener("DOMContentLoaded",e)}}();1 (()=>{{const e=()=>{const e=document.querySelectorAll(".wp-block-happyprime-show-hide-group .toggle-all");e.length>0&&e.forEach((e=>e.addEventListener("click",(()=>{const t=e.parentElement.querySelectorAll("details.wp-block-happyprime-show-hide-section");"true"!==e.ariaExpanded?(t.forEach((e=>{e.setAttribute("open","true")})),e.innerText="Close All",e.ariaExpanded="true"):(t.forEach((e=>{e.removeAttribute("open")})),e.innerText="Open All",e.ariaExpanded="false")}))))};document.addEventListener("DOMContentLoaded",e)}})(); -
show-hide-section-block/tags/3.0.0/build/show-hide-section/block.json
r2905297 r3182831 1 1 { 2 "$schema": "https://json.schemastore.org/block.json", 3 "apiVersion": 2, 4 "name": "happyprime/show-hide-section", 5 "title": "Show Hide Section", 6 "textdomain": "show-hide-section-block", 7 "category": "widgets", 8 "description": "A section of collapsible content contained in a details element with a summary.", 9 "icon": "media-document", 10 "parent": [ 11 "happyprime/show-hide-group" 12 ], 13 "attributes": { 14 "isOpen": { 15 "type": "boolean", 16 "default": false 17 }, 18 "summary": { 19 "type": "string", 20 "source": "html", 21 "selector": "summary" 22 } 23 }, 24 "supports": { 25 "anchor": true, 26 "align": true, 27 "alignWide": true, 28 "color": { 29 "background": true, 30 "enableContrastChecker": true, 31 "text": true, 32 "link": true, 33 "gradients": true 34 }, 35 "defaultStylePicker": true, 36 "dimensions": { 37 "minHeight": true 38 }, 39 "html": false, 40 "multiple": true, 41 "position": { 42 "sticky": false 43 }, 44 "spacing": { 45 "margin": true, 46 "padding": true 47 }, 48 "typography": { 49 "fontSize": true, 50 "lineHeight": true 51 } 52 }, 53 "editorScript": "file:index.js" 2 "$schema": "https://json.schemastore.org/block.json", 3 "apiVersion": 3, 4 "name": "happyprime/show-hide-section", 5 "title": "Show Hide Section", 6 "textdomain": "show-hide-section-block", 7 "category": "widgets", 8 "description": "A section of collapsible content contained in a details element with a summary.", 9 "icon": "media-document", 10 "parent": [ "happyprime/show-hide-group" ], 11 "attributes": { 12 "isOpen": { 13 "type": "boolean", 14 "default": false 15 } 16 }, 17 "supports": { 18 "anchor": true, 19 "align": true, 20 "alignWide": true, 21 "color": { 22 "background": true, 23 "enableContrastChecker": true, 24 "text": true, 25 "link": true, 26 "gradients": true 27 }, 28 "defaultStylePicker": true, 29 "dimensions": { 30 "minHeight": true 31 }, 32 "html": false, 33 "multiple": true, 34 "position": { 35 "sticky": false 36 }, 37 "spacing": { 38 "margin": true, 39 "padding": true 40 }, 41 "typography": { 42 "fontSize": true, 43 "lineHeight": true 44 } 45 }, 46 "editorScript": "file:index.js" 54 47 } -
show-hide-section-block/tags/3.0.0/build/show-hide-section/index.asset.php
r2905297 r3182831 1 <?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp- element', 'wp-i18n'), 'version' => 'b7962f8806702068f778');1 <?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-i18n'), 'version' => 'beb08742a35f54543878'); -
show-hide-section-block/tags/3.0.0/build/show-hide-section/index.js
r2905297 r3182831 1 !function(){"use strict";function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},e.apply(this,arguments)}var t=window.wp.element,n=window.wp.blocks,r=window.wp.blockEditor,o=window.wp.i18n,i=JSON.parse('{"$schema":"https://json.schemastore.org/block.json","apiVersion":2,"name":"happyprime/show-hide-section","title":"Show Hide Section","textdomain":"show-hide-section-block","category":"widgets","description":"A section of collapsible content contained in a details element with a summary.","icon":"media-document","parent":["happyprime/show-hide-group"],"attributes":{"isOpen":{"type":"boolean","default":false},"summary":{"type":"string","source":"html","selector":"summary"}},"supports":{"anchor":true,"align":true,"alignWide":true,"color":{"background":true,"enableContrastChecker":true,"text":true,"link":true,"gradients":true},"defaultStylePicker":true,"dimensions":{"minHeight":true},"html":false,"multiple":true,"position":{"sticky":false},"spacing":{"margin":true,"padding":true},"typography":{"fontSize":true,"lineHeight":true}},"editorScript":"file:index.js"}');(0,n.registerBlockType)(i,{edit:n=>{const{attributes:{isOpen:i,summary:a},setAttributes:s}=n;return(0,t.createElement)("details",e({},(0,r.useBlockProps)(),{open:i}),(0,t.createElement)(r.RichText,{tagName:"summary",label:(0,o.__)("Summary","show-hide-section-block"),placeholder:(0,o.__)("Summary","show-hide-section-block"),value:a,allowedFormats:["core/bold","core/italic"],onChange:e=>{s({summary:e})},onKeyUp:e=>{" "===e.key&&(e.preventDefault(),(e=>{const{ownerDocument:t}=e,{defaultView:n}=t,r=n.getSelection().getRangeAt(0),o=document.createTextNode(" ");r.deleteContents(),r.insertNode(o),r.setStartAfter(o)})(e.target))}}),(0,t.createElement)(r.InnerBlocks,null))},save:e=>{const{attributes:{summary:n}}=e;return(0,t.createElement)("details",r.useBlockProps.save(),(0,t.createElement)("summary",null,(0,t.createElement)(r.RichText.Content,{tag:"summary",value:n})),(0,t.createElement)(r.InnerBlocks.Content,null))}})}();1 (()=>{"use strict";const e=window.wp.blocks,t=window.wp.blockEditor,s=window.wp.i18n,i=JSON.parse('{"$schema":"https://json.schemastore.org/block.json","apiVersion":3,"name":"happyprime/show-hide-section","title":"Show Hide Section","textdomain":"show-hide-section-block","category":"widgets","description":"A section of collapsible content contained in a details element with a summary.","icon":"media-document","parent":["happyprime/show-hide-group"],"attributes":{"isOpen":{"type":"boolean","default":false}},"supports":{"anchor":true,"align":true,"alignWide":true,"color":{"background":true,"enableContrastChecker":true,"text":true,"link":true,"gradients":true},"defaultStylePicker":true,"dimensions":{"minHeight":true},"html":false,"multiple":true,"position":{"sticky":false},"spacing":{"margin":true,"padding":true},"typography":{"fontSize":true,"lineHeight":true}},"editorScript":"file:index.js"}'),a=[{attributes:{summary:{type:"string",source:"html",selector:"summary"}},save:({attributes:e})=>React.createElement("details",t.useBlockProps.save(),React.createElement("summary",null,e.summary),React.createElement(t.InnerBlocks.Content,null)),migrate:(t,s)=>[{},[(0,e.createBlock)("happyprime/show-hide-summary",{summary:t.summary}),(0,e.createBlock)("happyprime/show-hide-details",{},s)]],supports:{html:!0,anchor:!0},isEligible:({summary:e})=>"string"==typeof e&&e.length>0}];(0,e.registerBlockType)(i,{edit:e=>{const{attributes:{isOpen:i},setAttributes:a,isSelected:r}=e,o=[["happyprime/show-hide-summary",{summary:(0,s.__)("Summary","show-hide-section-block")}],["happyprime/show-hide-details",{details:(0,s.__)("Details","show-hide-section-block")}]];return React.createElement("div",(0,t.useBlockProps)(),React.createElement(t.InnerBlocks,{template:o,allowedBlocks:["happyprime/show-hide-summary","happyprime/show-hide-details"],templateLock:"all"}))},save:()=>React.createElement("details",t.useBlockProps.save(),React.createElement(t.InnerBlocks.Content,null)),deprecated:a})})(); -
show-hide-section-block/tags/3.0.0/languages/show-hide-section-block.pot
r2874431 r3182831 1 # Copyright (C) 202 3Happy Prime1 # Copyright (C) 2024 Happy Prime 2 2 # This file is distributed under the same license as the Show / Hide Section Block plugin. 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Show / Hide Section Block 2.0.0\n"5 "Project-Id-Version: Show / Hide Section Block 3.0.0\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/show-hide-section-block\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 202 3-03-03T16:41:52+00:00\n"12 "POT-Creation-Date: 2024-11-06T05:29:22+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 "X-Generator: WP-CLI 2. 6.0\n"14 "X-Generator: WP-CLI 2.10.0\n" 15 15 "X-Domain: show-hide-section-block\n" 16 16 17 17 #. Plugin Name of the plugin 18 #: plugin.php 18 19 msgid "Show / Hide Section Block" 19 20 msgstr "" 20 21 21 22 #. Plugin URI of the plugin 22 msgid "https://github.com/happyprime/show-hide-section" 23 #: plugin.php 24 msgid "https://wordpress.org/plugins/show-hide-section-block/" 23 25 msgstr "" 24 26 25 27 #. Description of the plugin 28 #: plugin.php 26 29 msgid "Display an accessible show/hide interface with details and summary elements." 27 30 msgstr "" 28 31 29 32 #. Author of the plugin 33 #: plugin.php 30 34 msgid "Happy Prime" 31 35 msgstr "" 32 36 33 37 #. Author URI of the plugin 38 #: plugin.php 34 39 msgid "https://happyprime.co/" 35 40 msgstr "" 36 41 37 #: blocks/show-hide-group/index.js:37 38 #: build/show-hide-group.js:1 42 #: build/show-hide-details/index.js:1 43 #: src/show-hide-details/index.js:12 44 msgid "Remaining" 45 msgstr "" 46 47 #: build/show-hide-group/index.js:1 48 #: src/show-hide-group/index.js:57 49 msgid "Has open/close all toggle" 50 msgstr "" 51 52 #: build/show-hide-group/index.js:1 53 #: src/show-hide-group/index.js:63 54 msgid "Open/close all toggle will display." 55 msgstr "" 56 57 #: build/show-hide-group/index.js:1 58 #: src/show-hide-group/index.js:67 59 msgid "Open/close all toggle will not display." 60 msgstr "" 61 62 #: build/show-hide-group/index.js:1 63 #: src/show-hide-group/index.js:37 39 64 msgid "Close all" 40 65 msgstr "" 41 66 42 #: b locks/show-hide-group/index.js:4743 #: blocks/show-hide-group/index.js:8644 #: blocks/show-hide-group/index.js:11945 #: build/show-hide-group.js:167 #: build/show-hide-group/index.js:1 68 #: src/show-hide-group/index.js:47 69 #: src/show-hide-group/index.js:86 70 #: src/show-hide-group/index.js:108 46 71 msgid "Open all" 47 72 msgstr "" 48 73 49 #: blocks/show-hide-group/index.js:57 50 #: build/show-hide-group.js:1 51 msgid "Has open/close all toggle" 52 msgstr "" 53 54 #: blocks/show-hide-group/index.js:63 55 #: build/show-hide-group.js:1 56 msgid "Open/close all toggle will display." 57 msgstr "" 58 59 #: blocks/show-hide-group/index.js:67 60 #: build/show-hide-group.js:1 61 msgid "Open/close all toggle will not display." 62 msgstr "" 63 64 #: blocks/show-hide-section/index.js:37 65 #: blocks/show-hide-section/index.js:38 66 #: build/show-hide-section.js:1 74 #: build/show-hide-section/index.js:1 75 #: build/show-hide-summary/index.js:1 76 #: src/show-hide-section/index.js:20 77 #: src/show-hide-summary/index.js:18 78 #: src/show-hide-summary/index.js:19 67 79 msgid "Summary" 68 80 msgstr "" 69 81 70 #: blocks/show-hide-group/block.json 82 #: build/show-hide-section/index.js:1 83 #: src/show-hide-section/index.js:24 84 msgid "Details" 85 msgstr "" 86 87 #: build/show-hide-details/block.json 88 #: src/show-hide-details/block.json 89 msgctxt "block title" 90 msgid "Show Hide Details" 91 msgstr "" 92 93 #: build/show-hide-details/block.json 94 #: src/show-hide-details/block.json 95 msgctxt "block description" 96 msgid "The remaining content in a details section." 97 msgstr "" 98 99 #: build/show-hide-group/block.json 100 #: src/show-hide-group/block.json 71 101 msgctxt "block title" 72 102 msgid "Show Hide Group" 73 103 msgstr "" 74 104 75 #: blocks/show-hide-group/block.json 105 #: build/show-hide-group/block.json 106 #: src/show-hide-group/block.json 76 107 msgctxt "block description" 77 108 msgid "A group of accessible summaries that can be toggled to show or hide additional details." 78 109 msgstr "" 79 110 80 #: blocks/show-hide-section/block.json 111 #: build/show-hide-section/block.json 112 #: src/show-hide-section/block.json 81 113 msgctxt "block title" 82 114 msgid "Show Hide Section" 83 115 msgstr "" 84 116 85 #: blocks/show-hide-section/block.json 117 #: build/show-hide-section/block.json 118 #: src/show-hide-section/block.json 86 119 msgctxt "block description" 87 120 msgid "A section of collapsible content contained in a details element with a summary." 88 121 msgstr "" 122 123 #: build/show-hide-summary/block.json 124 #: src/show-hide-summary/block.json 125 msgctxt "block title" 126 msgid "Show Hide Summary" 127 msgstr "" 128 129 #: build/show-hide-summary/block.json 130 #: src/show-hide-summary/block.json 131 msgctxt "block description" 132 msgid "The summary element in a details section." 133 msgstr "" -
show-hide-section-block/tags/3.0.0/plugin.php
r2905805 r3182831 3 3 * Plugin Name: Show / Hide Section Block 4 4 * Description: Display an accessible show/hide interface with details and summary elements. 5 * Version: 2.0.35 * Version: 3.0.0 6 6 * Plugin URI: https://wordpress.org/plugins/show-hide-section-block/ 7 7 * Author: Happy Prime … … 9 9 * Text Domain: show-hide-section-block 10 10 * Domain Path: /languages 11 * Requires at least: 6. 111 * Requires at least: 6.4 12 12 * Requires PHP: 7.4 13 13 * … … 33 33 define( 'HP_SHS_PLUGIN_FILE', __FILE__ ); 34 34 35 require_once __DIR__ . '/src/show-hide-details/index.php'; 35 36 require_once __DIR__ . '/src/show-hide-group/index.php'; 36 37 require_once __DIR__ . '/src/show-hide-section/index.php'; 38 require_once __DIR__ . '/src/show-hide-summary/index.php'; -
show-hide-section-block/tags/3.0.0/readme.txt
r2905805 r3182831 2 2 Contributors: happyprime, jeremyfelt, slocker, philcable 3 3 Tags: collapsible, details, summary 4 Requires at least: 6. 15 Tested up to: 6. 26 Stable tag: 2.0.34 Requires at least: 6.4 5 Tested up to: 6.7 6 Stable tag: 3.0.0 7 7 License: GPLv2 or later 8 8 Requires PHP: 7.4 … … 12 12 ## Description 13 13 14 Show / Hide Section Block provides two blocks: a Show / Hide Group block that is populated with one or more Show / Hide Section blocks. 14 Show / Hide Section Block provides four blocks that are used to display a group of `<details>` elements that each contain a `<summary>` and an arbitrary number of additional blocks. 15 16 * The Show Hide Group block is a wrapping `<div>`. 17 * The Show Hide Section block is a wrapping `<details>`. One or more of these blocks is added to a Show Hide Group block. 18 * The Show Hide Summary block contains the content for a `<summary>` tag. One of these blocks is inside each Show Hide Section block. 19 * The Show Hide Details block contains arbitrary content. One of these blocks is added inside each Show Hide Section block. 15 20 16 21 The HTML output for an individual section is: 17 22 18 23 <!-- Each section block has a details element. --> 19 <details >24 <details class="wp-block-happyprime-show-hide-section"> 20 25 <!-- Each details element has a summary and additional, collapsible content. --> 21 <summary >Summary text</summary>26 <summary class="wp-block-happyprime-show-hide-summary">Summary text</summary> 22 27 <!-- Additional inner blocks of any type are populated here. --> 23 28 </details> … … 25 30 The HTML output for the group is: 26 31 27 <div> 28 <details> 29 <summary></summary> 32 <div class="wp-block-happyprime-show-hide-group"> 33 <!-- Optional based on attribute --> 34 <button class="toggle-all" aria-expanded="false">Open all</button> 35 <details class="wp-block-happyprime-show-hide-section"> 36 <summary class="wp-block-happyprime-show-hide-summary"></summary> 30 37 <!-- Additional blocks to be shown/hidden --> 31 38 </details> 32 <details >33 <summary ></summary>39 <details class="wp-block-happyprime-show-hide-section"> 40 <summary class="wp-block-happyprime-show-hide-summary"></summary> 34 41 <!-- Additional blocks to be shown hidden --> 35 42 </details> … … 39 46 An option is provided in the block's side panel to toggle an "Open all"/"Close all" button. If this is toggled on for a block, an additional `<button>` element will be inserted and JavaScript will be used on the front-end to control the show/hide behavior of all `<details>` elements in the group at once. 40 47 41 If the toggle is off, no JavaScript is loaded on the front end .48 If the toggle is off, no JavaScript is loaded on the front end and only the browser's default behavior is used for opening and closing `<details>` elements. 42 49 43 50 ## Changelog 51 52 ### 3.0.0 53 54 * Refactor block markup to improve editorial experience and formatting options. 55 * Introduce `happyprime/show-hide-summary` block to manage `<summary>` content. 56 * Introduce `happyprime/show-hide-details` block to manage remaningin `<details>` content. 57 * Upgrade `happyprime/show-hide-group` and `happyprime/show-hide-section` blocks to API v3. 58 * Add a deprecation routine to transform 2.0.x block markup into the new format. 59 * Replace `@wordpress/scripts` with slimmer build configuration. 60 * Bump minimum WordPress version to 6.4; confirm compatibility with 6.7. 44 61 45 62 ### 2.0.3 -
show-hide-section-block/tags/3.0.0/src/show-hide-group/block.json
r2905297 r3182831 1 1 { 2 2 "$schema": "https://json.schemastore.org/block.json", 3 "apiVersion": 2,3 "apiVersion": 3, 4 4 "name": "happyprime/show-hide-group", 5 5 "title": "Show Hide Group", -
show-hide-section-block/tags/3.0.0/src/show-hide-group/index.js
r2905297 r3182831 12 12 import metadata from './block.json'; 13 13 14 const Edit = ( props) => {14 const Edit = (props) => { 15 15 const { 16 16 attributes: { hasToggle }, … … 18 18 } = props; 19 19 20 const details = useSelect( ( select) => {21 const currentBlocks = select( 'core/block-editor').getBlocks(20 const details = useSelect((select) => { 21 const currentBlocks = select('core/block-editor').getBlocks( 22 22 props.clientId 23 23 ); 24 24 25 25 return currentBlocks; 26 } );26 }); 27 27 28 const toggleAllSections = ( evt) => {29 if ( false === evt.target.ariaExpanded) {30 details.forEach( ( detail) => {31 dispatch( 'core/block-editor').updateBlockAttributes(28 const toggleAllSections = (evt) => { 29 if (false === evt.target.ariaExpanded) { 30 details.forEach((detail) => { 31 dispatch('core/block-editor').updateBlockAttributes( 32 32 detail.clientId, 33 33 { isOpen: true } 34 34 ); 35 } );35 }); 36 36 37 evt.target.innerText = __( 'Close all', 'show-hide-section-block');37 evt.target.innerText = __('Close all', 'show-hide-section-block'); 38 38 evt.target.ariaExpanded = true; 39 39 } else { 40 details.forEach( ( detail) => {41 dispatch( 'core/block-editor').updateBlockAttributes(40 details.forEach((detail) => { 41 dispatch('core/block-editor').updateBlockAttributes( 42 42 detail.clientId, 43 43 { isOpen: false } 44 44 ); 45 } );45 }); 46 46 47 evt.target.innerText = __( 'Open all', 'show-hide-section-block');47 evt.target.innerText = __('Open all', 'show-hide-section-block'); 48 48 evt.target.ariaExpanded = false; 49 49 } … … 55 55 <PanelBody> 56 56 <ToggleControl 57 label={ __(57 label={__( 58 58 'Has open/close all toggle', 59 59 'show-hide-section-block' 60 ) }60 )} 61 61 help={ 62 62 hasToggle … … 64 64 'Open/close all toggle will display.', 65 65 'show-hide-section-block' 66 )66 ) 67 67 : __( 68 68 'Open/close all toggle will not display.', 69 69 'show-hide-section-block' 70 )70 ) 71 71 } 72 checked={ hasToggle}73 onChange={ ( value) => {74 setAttributes( { hasToggle: value });75 } }72 checked={hasToggle} 73 onChange={(value) => { 74 setAttributes({ hasToggle: value }); 75 }} 76 76 /> 77 77 </PanelBody> 78 78 </InspectorControls> 79 <div { ...useBlockProps()}>80 { hasToggle && (79 <div {...useBlockProps()}> 80 {hasToggle && ( 81 81 <button 82 82 className="toggle-all" 83 83 aria-expanded="false" 84 onClick={ toggleAllSections}84 onClick={toggleAllSections} 85 85 > 86 { __( 'Open all', 'show-hide-section-block' )}86 {__('Open all', 'show-hide-section-block')} 87 87 </button> 88 ) }88 )} 89 89 <InnerBlocks 90 allowedBlocks={ [ 'happyprime/show-hide-section' ] } 91 template={ [ 92 [ 93 'happyprime/show-hide-section', 94 {}, 95 [ [ 'core/paragraph', {} ] ], 96 ], 97 [ 98 'happyprime/show-hide-section', 99 {}, 100 [ [ 'core/paragraph', {} ] ], 101 ], 102 ] } 103 templateLock={ false } 90 allowedBlocks={['happyprime/show-hide-section']} 91 template={[['happyprime/show-hide-section', {}]]} 92 templateLock={false} 104 93 /> 105 94 </div> … … 108 97 }; 109 98 110 const Save = ( props) => {99 const Save = (props) => { 111 100 const { 112 101 attributes: { hasToggle }, … … 114 103 115 104 return ( 116 <div { ...useBlockProps.save()}>117 { hasToggle && (105 <div {...useBlockProps.save()}> 106 {hasToggle && ( 118 107 <button className="toggle-all" aria-expanded="false"> 119 { __( 'Open all', 'show-hide-section-block' )}108 {__('Open all', 'show-hide-section-block')} 120 109 </button> 121 ) }110 )} 122 111 <InnerBlocks.Content /> 123 112 </div> … … 126 115 127 116 // Register the block. 128 registerBlockType( metadata, {117 registerBlockType(metadata, { 129 118 edit: Edit, 130 119 save: Save, 131 } );120 }); -
show-hide-section-block/tags/3.0.0/src/show-hide-group/view.js
r2905297 r3182831 5 5 ); 6 6 7 if ( toggleAll.length > 0) {8 toggleAll.forEach( ( toggle) =>9 toggle.addEventListener( 'click', () => {7 if (toggleAll.length > 0) { 8 toggleAll.forEach((toggle) => 9 toggle.addEventListener('click', () => { 10 10 const details = toggle.parentElement.querySelectorAll( 11 11 'details.wp-block-happyprime-show-hide-section' 12 12 ); 13 13 14 if ( 'true' !== toggle.ariaExpanded) {15 details.forEach( ( detail) => {16 detail.setAttribute( 'open', 'true');17 } );14 if ('true' !== toggle.ariaExpanded) { 15 details.forEach((detail) => { 16 detail.setAttribute('open', 'true'); 17 }); 18 18 19 19 toggle.innerText = 'Close All'; 20 20 toggle.ariaExpanded = 'true'; 21 21 } else { 22 details.forEach( ( detail) => {23 detail.removeAttribute( 'open');24 } );22 details.forEach((detail) => { 23 detail.removeAttribute('open'); 24 }); 25 25 26 26 toggle.innerText = 'Open All'; 27 27 toggle.ariaExpanded = 'false'; 28 28 } 29 } )29 }) 30 30 ); 31 31 } 32 32 }; 33 33 34 document.addEventListener( 'DOMContentLoaded', handleToggleButton);34 document.addEventListener('DOMContentLoaded', handleToggleButton); 35 35 } -
show-hide-section-block/tags/3.0.0/src/show-hide-section/block.json
r2905297 r3182831 1 1 { 2 2 "$schema": "https://json.schemastore.org/block.json", 3 "apiVersion": 2,3 "apiVersion": 3, 4 4 "name": "happyprime/show-hide-section", 5 5 "title": "Show Hide Section", … … 13 13 "type": "boolean", 14 14 "default": false 15 },16 "summary": {17 "type": "string",18 "source": "html",19 "selector": "summary"20 15 } 21 16 }, -
show-hide-section-block/tags/3.0.0/src/show-hide-section/index.js
r2905297 r3182831 1 1 import { registerBlockType } from '@wordpress/blocks'; 2 import { InnerBlocks, RichText,useBlockProps } from '@wordpress/block-editor';2 import { InnerBlocks, useBlockProps } from '@wordpress/block-editor'; 3 3 import { __ } from '@wordpress/i18n'; 4 4 5 5 // Internal dependencies. 6 6 import metadata from './block.json'; 7 import deprecated from './deprecated'; 7 8 8 const Edit = ( props) => {9 const Edit = (props) => { 9 10 const { 10 attributes: { isOpen , summary},11 attributes: { isOpen }, 11 12 setAttributes, 13 isSelected, 12 14 } = props; 13 15 14 /** 15 * Insert a space at the current position of the cursor and then adjust 16 * the cursor position, accounting for any selection it has made. 17 * 18 * @param {Node} node 19 */ 20 const insertSpace = ( node ) => { 21 const { ownerDocument } = node; 22 const { defaultView } = ownerDocument; 23 24 const sel = defaultView.getSelection(); 25 const range = sel.getRangeAt( 0 ); 26 const textNode = document.createTextNode( ' ' ); 27 28 range.deleteContents(); 29 range.insertNode( textNode ); 30 range.setStartAfter( textNode ); 31 }; 16 // Create an inner blocks template for the content. 17 const TEMPLATE = [ 18 [ 19 'happyprime/show-hide-summary', 20 { summary: __('Summary', 'show-hide-section-block') }, 21 ], 22 [ 23 'happyprime/show-hide-details', 24 { details: __('Details', 'show-hide-section-block') }, 25 ], 26 ]; 32 27 33 28 return ( 34 <details { ...useBlockProps() } open={ isOpen }> 35 <RichText 36 tagName="summary" 37 label={ __( 'Summary', 'show-hide-section-block' ) } 38 placeholder={ __( 'Summary', 'show-hide-section-block' ) } 39 value={ summary } 40 allowedFormats={ [ 'core/bold', 'core/italic' ] } 41 onChange={ ( value ) => { 42 setAttributes( { summary: value } ); 43 } } 44 onKeyUp={ ( evt ) => { 45 if ( ' ' === evt.key ) { 46 evt.preventDefault(); // Stop the details element from toggling. 47 insertSpace( evt.target ); // But make sure the space character is added. 48 } 49 } } 29 <div {...useBlockProps()}> 30 <InnerBlocks 31 template={TEMPLATE} 32 allowedBlocks={[ 33 'happyprime/show-hide-summary', 34 'happyprime/show-hide-details', 35 ]} 36 templateLock="all" 50 37 /> 51 <InnerBlocks /> 52 </details> 38 </div> 53 39 ); 54 40 }; 55 41 56 const Save = ( props ) => { 57 const { 58 attributes: { summary }, 59 } = props; 60 42 const Save = () => { 61 43 return ( 62 <details { ...useBlockProps.save() }> 63 <summary> 64 <RichText.Content tag={ 'summary' } value={ summary } /> 65 </summary> 44 <details {...useBlockProps.save()}> 66 45 <InnerBlocks.Content /> 67 46 </details> … … 70 49 71 50 // Register the block. 72 registerBlockType( metadata, {51 registerBlockType(metadata, { 73 52 edit: Edit, 74 53 save: Save, 75 } ); 54 deprecated, 55 }); -
show-hide-section-block/trunk/LICENSE
r2874431 r3182831 1 1 Show/Hide Section Block - a plugin for WordPress 2 2 3 Copyright 2020-202 3by Happy Prime3 Copyright 2020-2024 by Happy Prime 4 4 5 5 This program is free software; you can redistribute it and/or modify -
show-hide-section-block/trunk/build/show-hide-group/block.json
r2905297 r3182831 1 1 { 2 "$schema": "https://json.schemastore.org/block.json",3 "apiVersion": 2,4 "name": "happyprime/show-hide-group",5 "title": "Show Hide Group",6 "textdomain": "show-hide-section-block",7 "category": "widgets",8 "description": "A group of accessible summaries that can be toggled to show or hide additional details.",9 "icon": "hidden",10 "attributes": {11 "hasToggle": {12 "type": "boolean",13 "default": false14 }15 },16 "supports": {17 "align": true,18 "alignWide": true,19 "anchor": true,20 "color": {21 "background": true,22 "enableContrastChecker": true,23 "text": true,24 "link": true,25 "gradients": true26 },27 "defaultStylePicker": true,28 "dimensions": {29 "minHeight": true30 },31 "html": false,32 "position": {33 "sticky": false34 },35 "spacing": {36 "margin": true,37 "padding": true38 },39 "typography": {40 "fontSize": true,41 "lineHeight": true42 }43 },44 "editorScript": "file:index.js",45 "viewScript": "file:view.js"2 "$schema": "https://json.schemastore.org/block.json", 3 "apiVersion": 3, 4 "name": "happyprime/show-hide-group", 5 "title": "Show Hide Group", 6 "textdomain": "show-hide-section-block", 7 "category": "widgets", 8 "description": "A group of accessible summaries that can be toggled to show or hide additional details.", 9 "icon": "hidden", 10 "attributes": { 11 "hasToggle": { 12 "type": "boolean", 13 "default": false 14 } 15 }, 16 "supports": { 17 "align": true, 18 "alignWide": true, 19 "anchor": true, 20 "color": { 21 "background": true, 22 "enableContrastChecker": true, 23 "text": true, 24 "link": true, 25 "gradients": true 26 }, 27 "defaultStylePicker": true, 28 "dimensions": { 29 "minHeight": true 30 }, 31 "html": false, 32 "position": { 33 "sticky": false 34 }, 35 "spacing": { 36 "margin": true, 37 "padding": true 38 }, 39 "typography": { 40 "fontSize": true, 41 "lineHeight": true 42 } 43 }, 44 "editorScript": "file:index.js", 45 "viewScript": "file:view.js" 46 46 } -
show-hide-section-block/trunk/build/show-hide-group/index.asset.php
r2905297 r3182831 1 <?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp- element', 'wp-i18n'), 'version' => '9821368a8f1930a9690c');1 <?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-i18n'), 'version' => '70bf254dd1647cf40738'); -
show-hide-section-block/trunk/build/show-hide-group/index.js
r2905297 r3182831 1 !function(){"use strict";var e=window.wp.element,t=window.wp.blocks,o=window.wp.blockEditor,l=window.wp.components,a=window.wp.data,i=window.wp.i18n,n=JSON.parse('{"$schema":"https://json.schemastore.org/block.json","apiVersion":2,"name":"happyprime/show-hide-group","title":"Show Hide Group","textdomain":"show-hide-section-block","category":"widgets","description":"A group of accessible summaries that can be toggled to show or hide additional details.","icon":"hidden","attributes":{"hasToggle":{"type":"boolean","default":false}},"supports":{"align":true,"alignWide":true,"anchor":true,"color":{"background":true,"enableContrastChecker":true,"text":true,"link":true,"gradients":true},"defaultStylePicker":true,"dimensions":{"minHeight":true},"html":false,"position":{"sticky":false},"spacing":{"margin":true,"padding":true},"typography":{"fontSize":true,"lineHeight":true}},"editorScript":"file:index.js","viewScript":"file:view.js"}');(0,t.registerBlockType)(n,{edit:t=>{const{attributes:{hasToggle:n},setAttributes:r}=t,s=(0,a.useSelect)((e=>e("core/block-editor").getBlocks(t.clientId)));return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(o.InspectorControls,null,(0,e.createElement)(l.PanelBody,null,(0,e.createElement)(l.ToggleControl,{label:(0,i.__)("Has open/close all toggle","show-hide-section-block"),help:n?(0,i.__)("Open/close all toggle will display.","show-hide-section-block"):(0,i.__)("Open/close all toggle will not display.","show-hide-section-block"),checked:n,onChange:e=>{r({hasToggle:e})}}))),(0,e.createElement)("div",(0,o.useBlockProps)(),n&&(0,e.createElement)("button",{className:"toggle-all","aria-expanded":"false",onClick:e=>{!1===e.target.ariaExpanded?(s.forEach((e=>{(0,a.dispatch)("core/block-editor").updateBlockAttributes(e.clientId,{isOpen:!0})})),e.target.innerText=(0,i.__)("Close all","show-hide-section-block"),e.target.ariaExpanded=!0):(s.forEach((e=>{(0,a.dispatch)("core/block-editor").updateBlockAttributes(e.clientId,{isOpen:!1})})),e.target.innerText=(0,i.__)("Open all","show-hide-section-block"),e.target.ariaExpanded=!1)}},(0,i.__)("Open all","show-hide-section-block")),(0,e.createElement)(o.InnerBlocks,{allowedBlocks:["happyprime/show-hide-section"],template:[["happyprime/show-hide-section",{},[["core/paragraph",{}]]],["happyprime/show-hide-section",{},[["core/paragraph",{}]]]],templateLock:!1})))},save:t=>{const{attributes:{hasToggle:l}}=t;return(0,e.createElement)("div",o.useBlockProps.save(),l&&(0,e.createElement)("button",{className:"toggle-all","aria-expanded":"false"},(0,i.__)("Open all","show-hide-section-block")),(0,e.createElement)(o.InnerBlocks.Content,null))}})}();1 (()=>{"use strict";const e=window.wp.blocks,t=window.wp.blockEditor,o=window.wp.components,l=window.wp.data,a=window.wp.i18n,i=JSON.parse('{"$schema":"https://json.schemastore.org/block.json","apiVersion":3,"name":"happyprime/show-hide-group","title":"Show Hide Group","textdomain":"show-hide-section-block","category":"widgets","description":"A group of accessible summaries that can be toggled to show or hide additional details.","icon":"hidden","attributes":{"hasToggle":{"type":"boolean","default":false}},"supports":{"align":true,"alignWide":true,"anchor":true,"color":{"background":true,"enableContrastChecker":true,"text":true,"link":true,"gradients":true},"defaultStylePicker":true,"dimensions":{"minHeight":true},"html":false,"position":{"sticky":false},"spacing":{"margin":true,"padding":true},"typography":{"fontSize":true,"lineHeight":true}},"editorScript":"file:index.js","viewScript":"file:view.js"}');(0,e.registerBlockType)(i,{edit:e=>{const{attributes:{hasToggle:i},setAttributes:n}=e,s=(0,l.useSelect)((t=>t("core/block-editor").getBlocks(e.clientId)));return React.createElement(React.Fragment,null,React.createElement(t.InspectorControls,null,React.createElement(o.PanelBody,null,React.createElement(o.ToggleControl,{label:(0,a.__)("Has open/close all toggle","show-hide-section-block"),help:i?(0,a.__)("Open/close all toggle will display.","show-hide-section-block"):(0,a.__)("Open/close all toggle will not display.","show-hide-section-block"),checked:i,onChange:e=>{n({hasToggle:e})}}))),React.createElement("div",(0,t.useBlockProps)(),i&&React.createElement("button",{className:"toggle-all","aria-expanded":"false",onClick:e=>{!1===e.target.ariaExpanded?(s.forEach((e=>{(0,l.dispatch)("core/block-editor").updateBlockAttributes(e.clientId,{isOpen:!0})})),e.target.innerText=(0,a.__)("Close all","show-hide-section-block"),e.target.ariaExpanded=!0):(s.forEach((e=>{(0,l.dispatch)("core/block-editor").updateBlockAttributes(e.clientId,{isOpen:!1})})),e.target.innerText=(0,a.__)("Open all","show-hide-section-block"),e.target.ariaExpanded=!1)}},(0,a.__)("Open all","show-hide-section-block")),React.createElement(t.InnerBlocks,{allowedBlocks:["happyprime/show-hide-section"],template:[["happyprime/show-hide-section",{}]],templateLock:!1})))},save:e=>{const{attributes:{hasToggle:o}}=e;return React.createElement("div",t.useBlockProps.save(),o&&React.createElement("button",{className:"toggle-all","aria-expanded":"false"},(0,a.__)("Open all","show-hide-section-block")),React.createElement(t.InnerBlocks.Content,null))}})})(); -
show-hide-section-block/trunk/build/show-hide-group/view.asset.php
r2905297 r3182831 1 <?php return array('dependencies' => array(), 'version' => ' c1c493ae492c636904dd');1 <?php return array('dependencies' => array(), 'version' => 'fbf381460e85f307651f'); -
show-hide-section-block/trunk/build/show-hide-group/view.js
r2905297 r3182831 1 !function(){{const e=()=>{const e=document.querySelectorAll(".wp-block-happyprime-show-hide-group .toggle-all");e.length>0&&e.forEach((e=>e.addEventListener("click",(()=>{const t=e.parentElement.querySelectorAll("details.wp-block-happyprime-show-hide-section");"true"!==e.ariaExpanded?(t.forEach((e=>{e.setAttribute("open","true")})),e.innerText="Close All",e.ariaExpanded="true"):(t.forEach((e=>{e.removeAttribute("open")})),e.innerText="Open All",e.ariaExpanded="false")}))))};document.addEventListener("DOMContentLoaded",e)}}();1 (()=>{{const e=()=>{const e=document.querySelectorAll(".wp-block-happyprime-show-hide-group .toggle-all");e.length>0&&e.forEach((e=>e.addEventListener("click",(()=>{const t=e.parentElement.querySelectorAll("details.wp-block-happyprime-show-hide-section");"true"!==e.ariaExpanded?(t.forEach((e=>{e.setAttribute("open","true")})),e.innerText="Close All",e.ariaExpanded="true"):(t.forEach((e=>{e.removeAttribute("open")})),e.innerText="Open All",e.ariaExpanded="false")}))))};document.addEventListener("DOMContentLoaded",e)}})(); -
show-hide-section-block/trunk/build/show-hide-section/block.json
r2905297 r3182831 1 1 { 2 "$schema": "https://json.schemastore.org/block.json", 3 "apiVersion": 2, 4 "name": "happyprime/show-hide-section", 5 "title": "Show Hide Section", 6 "textdomain": "show-hide-section-block", 7 "category": "widgets", 8 "description": "A section of collapsible content contained in a details element with a summary.", 9 "icon": "media-document", 10 "parent": [ 11 "happyprime/show-hide-group" 12 ], 13 "attributes": { 14 "isOpen": { 15 "type": "boolean", 16 "default": false 17 }, 18 "summary": { 19 "type": "string", 20 "source": "html", 21 "selector": "summary" 22 } 23 }, 24 "supports": { 25 "anchor": true, 26 "align": true, 27 "alignWide": true, 28 "color": { 29 "background": true, 30 "enableContrastChecker": true, 31 "text": true, 32 "link": true, 33 "gradients": true 34 }, 35 "defaultStylePicker": true, 36 "dimensions": { 37 "minHeight": true 38 }, 39 "html": false, 40 "multiple": true, 41 "position": { 42 "sticky": false 43 }, 44 "spacing": { 45 "margin": true, 46 "padding": true 47 }, 48 "typography": { 49 "fontSize": true, 50 "lineHeight": true 51 } 52 }, 53 "editorScript": "file:index.js" 2 "$schema": "https://json.schemastore.org/block.json", 3 "apiVersion": 3, 4 "name": "happyprime/show-hide-section", 5 "title": "Show Hide Section", 6 "textdomain": "show-hide-section-block", 7 "category": "widgets", 8 "description": "A section of collapsible content contained in a details element with a summary.", 9 "icon": "media-document", 10 "parent": [ "happyprime/show-hide-group" ], 11 "attributes": { 12 "isOpen": { 13 "type": "boolean", 14 "default": false 15 } 16 }, 17 "supports": { 18 "anchor": true, 19 "align": true, 20 "alignWide": true, 21 "color": { 22 "background": true, 23 "enableContrastChecker": true, 24 "text": true, 25 "link": true, 26 "gradients": true 27 }, 28 "defaultStylePicker": true, 29 "dimensions": { 30 "minHeight": true 31 }, 32 "html": false, 33 "multiple": true, 34 "position": { 35 "sticky": false 36 }, 37 "spacing": { 38 "margin": true, 39 "padding": true 40 }, 41 "typography": { 42 "fontSize": true, 43 "lineHeight": true 44 } 45 }, 46 "editorScript": "file:index.js" 54 47 } -
show-hide-section-block/trunk/build/show-hide-section/index.asset.php
r2905297 r3182831 1 <?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp- element', 'wp-i18n'), 'version' => 'b7962f8806702068f778');1 <?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-i18n'), 'version' => 'beb08742a35f54543878'); -
show-hide-section-block/trunk/build/show-hide-section/index.js
r2905297 r3182831 1 !function(){"use strict";function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},e.apply(this,arguments)}var t=window.wp.element,n=window.wp.blocks,r=window.wp.blockEditor,o=window.wp.i18n,i=JSON.parse('{"$schema":"https://json.schemastore.org/block.json","apiVersion":2,"name":"happyprime/show-hide-section","title":"Show Hide Section","textdomain":"show-hide-section-block","category":"widgets","description":"A section of collapsible content contained in a details element with a summary.","icon":"media-document","parent":["happyprime/show-hide-group"],"attributes":{"isOpen":{"type":"boolean","default":false},"summary":{"type":"string","source":"html","selector":"summary"}},"supports":{"anchor":true,"align":true,"alignWide":true,"color":{"background":true,"enableContrastChecker":true,"text":true,"link":true,"gradients":true},"defaultStylePicker":true,"dimensions":{"minHeight":true},"html":false,"multiple":true,"position":{"sticky":false},"spacing":{"margin":true,"padding":true},"typography":{"fontSize":true,"lineHeight":true}},"editorScript":"file:index.js"}');(0,n.registerBlockType)(i,{edit:n=>{const{attributes:{isOpen:i,summary:a},setAttributes:s}=n;return(0,t.createElement)("details",e({},(0,r.useBlockProps)(),{open:i}),(0,t.createElement)(r.RichText,{tagName:"summary",label:(0,o.__)("Summary","show-hide-section-block"),placeholder:(0,o.__)("Summary","show-hide-section-block"),value:a,allowedFormats:["core/bold","core/italic"],onChange:e=>{s({summary:e})},onKeyUp:e=>{" "===e.key&&(e.preventDefault(),(e=>{const{ownerDocument:t}=e,{defaultView:n}=t,r=n.getSelection().getRangeAt(0),o=document.createTextNode(" ");r.deleteContents(),r.insertNode(o),r.setStartAfter(o)})(e.target))}}),(0,t.createElement)(r.InnerBlocks,null))},save:e=>{const{attributes:{summary:n}}=e;return(0,t.createElement)("details",r.useBlockProps.save(),(0,t.createElement)("summary",null,(0,t.createElement)(r.RichText.Content,{tag:"summary",value:n})),(0,t.createElement)(r.InnerBlocks.Content,null))}})}();1 (()=>{"use strict";const e=window.wp.blocks,t=window.wp.blockEditor,s=window.wp.i18n,i=JSON.parse('{"$schema":"https://json.schemastore.org/block.json","apiVersion":3,"name":"happyprime/show-hide-section","title":"Show Hide Section","textdomain":"show-hide-section-block","category":"widgets","description":"A section of collapsible content contained in a details element with a summary.","icon":"media-document","parent":["happyprime/show-hide-group"],"attributes":{"isOpen":{"type":"boolean","default":false}},"supports":{"anchor":true,"align":true,"alignWide":true,"color":{"background":true,"enableContrastChecker":true,"text":true,"link":true,"gradients":true},"defaultStylePicker":true,"dimensions":{"minHeight":true},"html":false,"multiple":true,"position":{"sticky":false},"spacing":{"margin":true,"padding":true},"typography":{"fontSize":true,"lineHeight":true}},"editorScript":"file:index.js"}'),a=[{attributes:{summary:{type:"string",source:"html",selector:"summary"}},save:({attributes:e})=>React.createElement("details",t.useBlockProps.save(),React.createElement("summary",null,e.summary),React.createElement(t.InnerBlocks.Content,null)),migrate:(t,s)=>[{},[(0,e.createBlock)("happyprime/show-hide-summary",{summary:t.summary}),(0,e.createBlock)("happyprime/show-hide-details",{},s)]],supports:{html:!0,anchor:!0},isEligible:({summary:e})=>"string"==typeof e&&e.length>0}];(0,e.registerBlockType)(i,{edit:e=>{const{attributes:{isOpen:i},setAttributes:a,isSelected:r}=e,o=[["happyprime/show-hide-summary",{summary:(0,s.__)("Summary","show-hide-section-block")}],["happyprime/show-hide-details",{details:(0,s.__)("Details","show-hide-section-block")}]];return React.createElement("div",(0,t.useBlockProps)(),React.createElement(t.InnerBlocks,{template:o,allowedBlocks:["happyprime/show-hide-summary","happyprime/show-hide-details"],templateLock:"all"}))},save:()=>React.createElement("details",t.useBlockProps.save(),React.createElement(t.InnerBlocks.Content,null)),deprecated:a})})(); -
show-hide-section-block/trunk/languages/show-hide-section-block.pot
r2874431 r3182831 1 # Copyright (C) 202 3Happy Prime1 # Copyright (C) 2024 Happy Prime 2 2 # This file is distributed under the same license as the Show / Hide Section Block plugin. 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Show / Hide Section Block 2.0.0\n"5 "Project-Id-Version: Show / Hide Section Block 3.0.0\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/show-hide-section-block\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 202 3-03-03T16:41:52+00:00\n"12 "POT-Creation-Date: 2024-11-06T05:29:22+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 "X-Generator: WP-CLI 2. 6.0\n"14 "X-Generator: WP-CLI 2.10.0\n" 15 15 "X-Domain: show-hide-section-block\n" 16 16 17 17 #. Plugin Name of the plugin 18 #: plugin.php 18 19 msgid "Show / Hide Section Block" 19 20 msgstr "" 20 21 21 22 #. Plugin URI of the plugin 22 msgid "https://github.com/happyprime/show-hide-section" 23 #: plugin.php 24 msgid "https://wordpress.org/plugins/show-hide-section-block/" 23 25 msgstr "" 24 26 25 27 #. Description of the plugin 28 #: plugin.php 26 29 msgid "Display an accessible show/hide interface with details and summary elements." 27 30 msgstr "" 28 31 29 32 #. Author of the plugin 33 #: plugin.php 30 34 msgid "Happy Prime" 31 35 msgstr "" 32 36 33 37 #. Author URI of the plugin 38 #: plugin.php 34 39 msgid "https://happyprime.co/" 35 40 msgstr "" 36 41 37 #: blocks/show-hide-group/index.js:37 38 #: build/show-hide-group.js:1 42 #: build/show-hide-details/index.js:1 43 #: src/show-hide-details/index.js:12 44 msgid "Remaining" 45 msgstr "" 46 47 #: build/show-hide-group/index.js:1 48 #: src/show-hide-group/index.js:57 49 msgid "Has open/close all toggle" 50 msgstr "" 51 52 #: build/show-hide-group/index.js:1 53 #: src/show-hide-group/index.js:63 54 msgid "Open/close all toggle will display." 55 msgstr "" 56 57 #: build/show-hide-group/index.js:1 58 #: src/show-hide-group/index.js:67 59 msgid "Open/close all toggle will not display." 60 msgstr "" 61 62 #: build/show-hide-group/index.js:1 63 #: src/show-hide-group/index.js:37 39 64 msgid "Close all" 40 65 msgstr "" 41 66 42 #: b locks/show-hide-group/index.js:4743 #: blocks/show-hide-group/index.js:8644 #: blocks/show-hide-group/index.js:11945 #: build/show-hide-group.js:167 #: build/show-hide-group/index.js:1 68 #: src/show-hide-group/index.js:47 69 #: src/show-hide-group/index.js:86 70 #: src/show-hide-group/index.js:108 46 71 msgid "Open all" 47 72 msgstr "" 48 73 49 #: blocks/show-hide-group/index.js:57 50 #: build/show-hide-group.js:1 51 msgid "Has open/close all toggle" 52 msgstr "" 53 54 #: blocks/show-hide-group/index.js:63 55 #: build/show-hide-group.js:1 56 msgid "Open/close all toggle will display." 57 msgstr "" 58 59 #: blocks/show-hide-group/index.js:67 60 #: build/show-hide-group.js:1 61 msgid "Open/close all toggle will not display." 62 msgstr "" 63 64 #: blocks/show-hide-section/index.js:37 65 #: blocks/show-hide-section/index.js:38 66 #: build/show-hide-section.js:1 74 #: build/show-hide-section/index.js:1 75 #: build/show-hide-summary/index.js:1 76 #: src/show-hide-section/index.js:20 77 #: src/show-hide-summary/index.js:18 78 #: src/show-hide-summary/index.js:19 67 79 msgid "Summary" 68 80 msgstr "" 69 81 70 #: blocks/show-hide-group/block.json 82 #: build/show-hide-section/index.js:1 83 #: src/show-hide-section/index.js:24 84 msgid "Details" 85 msgstr "" 86 87 #: build/show-hide-details/block.json 88 #: src/show-hide-details/block.json 89 msgctxt "block title" 90 msgid "Show Hide Details" 91 msgstr "" 92 93 #: build/show-hide-details/block.json 94 #: src/show-hide-details/block.json 95 msgctxt "block description" 96 msgid "The remaining content in a details section." 97 msgstr "" 98 99 #: build/show-hide-group/block.json 100 #: src/show-hide-group/block.json 71 101 msgctxt "block title" 72 102 msgid "Show Hide Group" 73 103 msgstr "" 74 104 75 #: blocks/show-hide-group/block.json 105 #: build/show-hide-group/block.json 106 #: src/show-hide-group/block.json 76 107 msgctxt "block description" 77 108 msgid "A group of accessible summaries that can be toggled to show or hide additional details." 78 109 msgstr "" 79 110 80 #: blocks/show-hide-section/block.json 111 #: build/show-hide-section/block.json 112 #: src/show-hide-section/block.json 81 113 msgctxt "block title" 82 114 msgid "Show Hide Section" 83 115 msgstr "" 84 116 85 #: blocks/show-hide-section/block.json 117 #: build/show-hide-section/block.json 118 #: src/show-hide-section/block.json 86 119 msgctxt "block description" 87 120 msgid "A section of collapsible content contained in a details element with a summary." 88 121 msgstr "" 122 123 #: build/show-hide-summary/block.json 124 #: src/show-hide-summary/block.json 125 msgctxt "block title" 126 msgid "Show Hide Summary" 127 msgstr "" 128 129 #: build/show-hide-summary/block.json 130 #: src/show-hide-summary/block.json 131 msgctxt "block description" 132 msgid "The summary element in a details section." 133 msgstr "" -
show-hide-section-block/trunk/plugin.php
r2905805 r3182831 3 3 * Plugin Name: Show / Hide Section Block 4 4 * Description: Display an accessible show/hide interface with details and summary elements. 5 * Version: 2.0.35 * Version: 3.0.0 6 6 * Plugin URI: https://wordpress.org/plugins/show-hide-section-block/ 7 7 * Author: Happy Prime … … 9 9 * Text Domain: show-hide-section-block 10 10 * Domain Path: /languages 11 * Requires at least: 6. 111 * Requires at least: 6.4 12 12 * Requires PHP: 7.4 13 13 * … … 33 33 define( 'HP_SHS_PLUGIN_FILE', __FILE__ ); 34 34 35 require_once __DIR__ . '/src/show-hide-details/index.php'; 35 36 require_once __DIR__ . '/src/show-hide-group/index.php'; 36 37 require_once __DIR__ . '/src/show-hide-section/index.php'; 38 require_once __DIR__ . '/src/show-hide-summary/index.php'; -
show-hide-section-block/trunk/readme.txt
r2905805 r3182831 2 2 Contributors: happyprime, jeremyfelt, slocker, philcable 3 3 Tags: collapsible, details, summary 4 Requires at least: 6. 15 Tested up to: 6. 26 Stable tag: 2.0.34 Requires at least: 6.4 5 Tested up to: 6.7 6 Stable tag: 3.0.0 7 7 License: GPLv2 or later 8 8 Requires PHP: 7.4 … … 12 12 ## Description 13 13 14 Show / Hide Section Block provides two blocks: a Show / Hide Group block that is populated with one or more Show / Hide Section blocks. 14 Show / Hide Section Block provides four blocks that are used to display a group of `<details>` elements that each contain a `<summary>` and an arbitrary number of additional blocks. 15 16 * The Show Hide Group block is a wrapping `<div>`. 17 * The Show Hide Section block is a wrapping `<details>`. One or more of these blocks is added to a Show Hide Group block. 18 * The Show Hide Summary block contains the content for a `<summary>` tag. One of these blocks is inside each Show Hide Section block. 19 * The Show Hide Details block contains arbitrary content. One of these blocks is added inside each Show Hide Section block. 15 20 16 21 The HTML output for an individual section is: 17 22 18 23 <!-- Each section block has a details element. --> 19 <details >24 <details class="wp-block-happyprime-show-hide-section"> 20 25 <!-- Each details element has a summary and additional, collapsible content. --> 21 <summary >Summary text</summary>26 <summary class="wp-block-happyprime-show-hide-summary">Summary text</summary> 22 27 <!-- Additional inner blocks of any type are populated here. --> 23 28 </details> … … 25 30 The HTML output for the group is: 26 31 27 <div> 28 <details> 29 <summary></summary> 32 <div class="wp-block-happyprime-show-hide-group"> 33 <!-- Optional based on attribute --> 34 <button class="toggle-all" aria-expanded="false">Open all</button> 35 <details class="wp-block-happyprime-show-hide-section"> 36 <summary class="wp-block-happyprime-show-hide-summary"></summary> 30 37 <!-- Additional blocks to be shown/hidden --> 31 38 </details> 32 <details >33 <summary ></summary>39 <details class="wp-block-happyprime-show-hide-section"> 40 <summary class="wp-block-happyprime-show-hide-summary"></summary> 34 41 <!-- Additional blocks to be shown hidden --> 35 42 </details> … … 39 46 An option is provided in the block's side panel to toggle an "Open all"/"Close all" button. If this is toggled on for a block, an additional `<button>` element will be inserted and JavaScript will be used on the front-end to control the show/hide behavior of all `<details>` elements in the group at once. 40 47 41 If the toggle is off, no JavaScript is loaded on the front end .48 If the toggle is off, no JavaScript is loaded on the front end and only the browser's default behavior is used for opening and closing `<details>` elements. 42 49 43 50 ## Changelog 51 52 ### 3.0.0 53 54 * Refactor block markup to improve editorial experience and formatting options. 55 * Introduce `happyprime/show-hide-summary` block to manage `<summary>` content. 56 * Introduce `happyprime/show-hide-details` block to manage remaningin `<details>` content. 57 * Upgrade `happyprime/show-hide-group` and `happyprime/show-hide-section` blocks to API v3. 58 * Add a deprecation routine to transform 2.0.x block markup into the new format. 59 * Replace `@wordpress/scripts` with slimmer build configuration. 60 * Bump minimum WordPress version to 6.4; confirm compatibility with 6.7. 44 61 45 62 ### 2.0.3 -
show-hide-section-block/trunk/src/show-hide-group/block.json
r2905297 r3182831 1 1 { 2 2 "$schema": "https://json.schemastore.org/block.json", 3 "apiVersion": 2,3 "apiVersion": 3, 4 4 "name": "happyprime/show-hide-group", 5 5 "title": "Show Hide Group", -
show-hide-section-block/trunk/src/show-hide-group/index.js
r2905297 r3182831 12 12 import metadata from './block.json'; 13 13 14 const Edit = ( props) => {14 const Edit = (props) => { 15 15 const { 16 16 attributes: { hasToggle }, … … 18 18 } = props; 19 19 20 const details = useSelect( ( select) => {21 const currentBlocks = select( 'core/block-editor').getBlocks(20 const details = useSelect((select) => { 21 const currentBlocks = select('core/block-editor').getBlocks( 22 22 props.clientId 23 23 ); 24 24 25 25 return currentBlocks; 26 } );26 }); 27 27 28 const toggleAllSections = ( evt) => {29 if ( false === evt.target.ariaExpanded) {30 details.forEach( ( detail) => {31 dispatch( 'core/block-editor').updateBlockAttributes(28 const toggleAllSections = (evt) => { 29 if (false === evt.target.ariaExpanded) { 30 details.forEach((detail) => { 31 dispatch('core/block-editor').updateBlockAttributes( 32 32 detail.clientId, 33 33 { isOpen: true } 34 34 ); 35 } );35 }); 36 36 37 evt.target.innerText = __( 'Close all', 'show-hide-section-block');37 evt.target.innerText = __('Close all', 'show-hide-section-block'); 38 38 evt.target.ariaExpanded = true; 39 39 } else { 40 details.forEach( ( detail) => {41 dispatch( 'core/block-editor').updateBlockAttributes(40 details.forEach((detail) => { 41 dispatch('core/block-editor').updateBlockAttributes( 42 42 detail.clientId, 43 43 { isOpen: false } 44 44 ); 45 } );45 }); 46 46 47 evt.target.innerText = __( 'Open all', 'show-hide-section-block');47 evt.target.innerText = __('Open all', 'show-hide-section-block'); 48 48 evt.target.ariaExpanded = false; 49 49 } … … 55 55 <PanelBody> 56 56 <ToggleControl 57 label={ __(57 label={__( 58 58 'Has open/close all toggle', 59 59 'show-hide-section-block' 60 ) }60 )} 61 61 help={ 62 62 hasToggle … … 64 64 'Open/close all toggle will display.', 65 65 'show-hide-section-block' 66 )66 ) 67 67 : __( 68 68 'Open/close all toggle will not display.', 69 69 'show-hide-section-block' 70 )70 ) 71 71 } 72 checked={ hasToggle}73 onChange={ ( value) => {74 setAttributes( { hasToggle: value });75 } }72 checked={hasToggle} 73 onChange={(value) => { 74 setAttributes({ hasToggle: value }); 75 }} 76 76 /> 77 77 </PanelBody> 78 78 </InspectorControls> 79 <div { ...useBlockProps()}>80 { hasToggle && (79 <div {...useBlockProps()}> 80 {hasToggle && ( 81 81 <button 82 82 className="toggle-all" 83 83 aria-expanded="false" 84 onClick={ toggleAllSections}84 onClick={toggleAllSections} 85 85 > 86 { __( 'Open all', 'show-hide-section-block' )}86 {__('Open all', 'show-hide-section-block')} 87 87 </button> 88 ) }88 )} 89 89 <InnerBlocks 90 allowedBlocks={ [ 'happyprime/show-hide-section' ] } 91 template={ [ 92 [ 93 'happyprime/show-hide-section', 94 {}, 95 [ [ 'core/paragraph', {} ] ], 96 ], 97 [ 98 'happyprime/show-hide-section', 99 {}, 100 [ [ 'core/paragraph', {} ] ], 101 ], 102 ] } 103 templateLock={ false } 90 allowedBlocks={['happyprime/show-hide-section']} 91 template={[['happyprime/show-hide-section', {}]]} 92 templateLock={false} 104 93 /> 105 94 </div> … … 108 97 }; 109 98 110 const Save = ( props) => {99 const Save = (props) => { 111 100 const { 112 101 attributes: { hasToggle }, … … 114 103 115 104 return ( 116 <div { ...useBlockProps.save()}>117 { hasToggle && (105 <div {...useBlockProps.save()}> 106 {hasToggle && ( 118 107 <button className="toggle-all" aria-expanded="false"> 119 { __( 'Open all', 'show-hide-section-block' )}108 {__('Open all', 'show-hide-section-block')} 120 109 </button> 121 ) }110 )} 122 111 <InnerBlocks.Content /> 123 112 </div> … … 126 115 127 116 // Register the block. 128 registerBlockType( metadata, {117 registerBlockType(metadata, { 129 118 edit: Edit, 130 119 save: Save, 131 } );120 }); -
show-hide-section-block/trunk/src/show-hide-group/view.js
r2905297 r3182831 5 5 ); 6 6 7 if ( toggleAll.length > 0) {8 toggleAll.forEach( ( toggle) =>9 toggle.addEventListener( 'click', () => {7 if (toggleAll.length > 0) { 8 toggleAll.forEach((toggle) => 9 toggle.addEventListener('click', () => { 10 10 const details = toggle.parentElement.querySelectorAll( 11 11 'details.wp-block-happyprime-show-hide-section' 12 12 ); 13 13 14 if ( 'true' !== toggle.ariaExpanded) {15 details.forEach( ( detail) => {16 detail.setAttribute( 'open', 'true');17 } );14 if ('true' !== toggle.ariaExpanded) { 15 details.forEach((detail) => { 16 detail.setAttribute('open', 'true'); 17 }); 18 18 19 19 toggle.innerText = 'Close All'; 20 20 toggle.ariaExpanded = 'true'; 21 21 } else { 22 details.forEach( ( detail) => {23 detail.removeAttribute( 'open');24 } );22 details.forEach((detail) => { 23 detail.removeAttribute('open'); 24 }); 25 25 26 26 toggle.innerText = 'Open All'; 27 27 toggle.ariaExpanded = 'false'; 28 28 } 29 } )29 }) 30 30 ); 31 31 } 32 32 }; 33 33 34 document.addEventListener( 'DOMContentLoaded', handleToggleButton);34 document.addEventListener('DOMContentLoaded', handleToggleButton); 35 35 } -
show-hide-section-block/trunk/src/show-hide-section/block.json
r2905297 r3182831 1 1 { 2 2 "$schema": "https://json.schemastore.org/block.json", 3 "apiVersion": 2,3 "apiVersion": 3, 4 4 "name": "happyprime/show-hide-section", 5 5 "title": "Show Hide Section", … … 13 13 "type": "boolean", 14 14 "default": false 15 },16 "summary": {17 "type": "string",18 "source": "html",19 "selector": "summary"20 15 } 21 16 }, -
show-hide-section-block/trunk/src/show-hide-section/index.js
r2905297 r3182831 1 1 import { registerBlockType } from '@wordpress/blocks'; 2 import { InnerBlocks, RichText,useBlockProps } from '@wordpress/block-editor';2 import { InnerBlocks, useBlockProps } from '@wordpress/block-editor'; 3 3 import { __ } from '@wordpress/i18n'; 4 4 5 5 // Internal dependencies. 6 6 import metadata from './block.json'; 7 import deprecated from './deprecated'; 7 8 8 const Edit = ( props) => {9 const Edit = (props) => { 9 10 const { 10 attributes: { isOpen , summary},11 attributes: { isOpen }, 11 12 setAttributes, 13 isSelected, 12 14 } = props; 13 15 14 /** 15 * Insert a space at the current position of the cursor and then adjust 16 * the cursor position, accounting for any selection it has made. 17 * 18 * @param {Node} node 19 */ 20 const insertSpace = ( node ) => { 21 const { ownerDocument } = node; 22 const { defaultView } = ownerDocument; 23 24 const sel = defaultView.getSelection(); 25 const range = sel.getRangeAt( 0 ); 26 const textNode = document.createTextNode( ' ' ); 27 28 range.deleteContents(); 29 range.insertNode( textNode ); 30 range.setStartAfter( textNode ); 31 }; 16 // Create an inner blocks template for the content. 17 const TEMPLATE = [ 18 [ 19 'happyprime/show-hide-summary', 20 { summary: __('Summary', 'show-hide-section-block') }, 21 ], 22 [ 23 'happyprime/show-hide-details', 24 { details: __('Details', 'show-hide-section-block') }, 25 ], 26 ]; 32 27 33 28 return ( 34 <details { ...useBlockProps() } open={ isOpen }> 35 <RichText 36 tagName="summary" 37 label={ __( 'Summary', 'show-hide-section-block' ) } 38 placeholder={ __( 'Summary', 'show-hide-section-block' ) } 39 value={ summary } 40 allowedFormats={ [ 'core/bold', 'core/italic' ] } 41 onChange={ ( value ) => { 42 setAttributes( { summary: value } ); 43 } } 44 onKeyUp={ ( evt ) => { 45 if ( ' ' === evt.key ) { 46 evt.preventDefault(); // Stop the details element from toggling. 47 insertSpace( evt.target ); // But make sure the space character is added. 48 } 49 } } 29 <div {...useBlockProps()}> 30 <InnerBlocks 31 template={TEMPLATE} 32 allowedBlocks={[ 33 'happyprime/show-hide-summary', 34 'happyprime/show-hide-details', 35 ]} 36 templateLock="all" 50 37 /> 51 <InnerBlocks /> 52 </details> 38 </div> 53 39 ); 54 40 }; 55 41 56 const Save = ( props ) => { 57 const { 58 attributes: { summary }, 59 } = props; 60 42 const Save = () => { 61 43 return ( 62 <details { ...useBlockProps.save() }> 63 <summary> 64 <RichText.Content tag={ 'summary' } value={ summary } /> 65 </summary> 44 <details {...useBlockProps.save()}> 66 45 <InnerBlocks.Content /> 67 46 </details> … … 70 49 71 50 // Register the block. 72 registerBlockType( metadata, {51 registerBlockType(metadata, { 73 52 edit: Edit, 74 53 save: Save, 75 } ); 54 deprecated, 55 });
Note: See TracChangeset
for help on using the changeset viewer.