From aaeb87db8728275161509920c556334e75112152 Mon Sep 17 00:00:00 2001 From: joost de keijzer Date: Mon, 13 Feb 2023 09:21:52 +0100 Subject: [PATCH] add `anchor` option to accordion & toggle blocks (both wrapper and item blocks) --- src/blocks/accordion/accordion-item/edit.js | 2 +- src/blocks/accordion/accordion-item/index.js | 3 ++- src/blocks/accordion/accordion-item/save.js | 6 +++--- src/blocks/accordion/accordion/edit.js | 1 + src/blocks/accordion/accordion/index.js | 1 + src/blocks/accordion/accordion/save.js | 4 +++- src/blocks/toggle/toggle-item/attributes.js | 2 +- src/blocks/toggle/toggle-item/edit.js | 2 +- src/blocks/toggle/toggle-item/index.js | 3 ++- src/blocks/toggle/toggle-item/save.js | 5 +++-- src/blocks/toggle/toggle/attributes.js | 2 +- src/blocks/toggle/toggle/edit.js | 1 + src/blocks/toggle/toggle/index.js | 1 + src/blocks/toggle/toggle/save.js | 4 +++- 14 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/blocks/accordion/accordion-item/edit.js b/src/blocks/accordion/accordion-item/edit.js index 479177916..3ed6c1391 100755 --- a/src/blocks/accordion/accordion-item/edit.js +++ b/src/blocks/accordion/accordion-item/edit.js @@ -76,7 +76,7 @@ class AccordionItem extends Component { ...this.props, } } key={ 'inspector' }/>
-
+
diff --git a/src/blocks/accordion/accordion-item/index.js b/src/blocks/accordion/accordion-item/index.js index be7b7645d..555ec3a05 100755 --- a/src/blocks/accordion/accordion-item/index.js +++ b/src/blocks/accordion/accordion-item/index.js @@ -27,6 +27,7 @@ export default registerBlockType( category: 'getwid-blocks', parent: [ 'getwid/accordion' ], supports: { + anchor: true, multiple: true, reusable: false, html: false @@ -50,4 +51,4 @@ export default registerBlockType( }} /> ) } -); \ No newline at end of file +); diff --git a/src/blocks/accordion/accordion-item/save.js b/src/blocks/accordion/accordion-item/save.js index 1832febd1..fa0a115ef 100755 --- a/src/blocks/accordion/accordion-item/save.js +++ b/src/blocks/accordion/accordion-item/save.js @@ -18,7 +18,7 @@ class Save extends Component { render() { const {className, baseClass} = this.props; - const {outerParent, title} = this.props.attributes; + const {outerParent, title, anchor} = this.props.attributes; const Tag = outerParent ? outerParent.attributes.headerTag : 'span'; const iconOpen = outerParent ? outerParent.attributes.iconOpen : 'fas fa-minus'; @@ -26,7 +26,7 @@ class Save extends Component { return ( -
+
{title && ( @@ -52,4 +52,4 @@ class Save extends Component { } } -export default Save; \ No newline at end of file +export default Save; diff --git a/src/blocks/accordion/accordion/edit.js b/src/blocks/accordion/accordion/edit.js index 4b9270eb3..764f2cc55 100755 --- a/src/blocks/accordion/accordion/edit.js +++ b/src/blocks/accordion/accordion/edit.js @@ -129,6 +129,7 @@ class Accordion extends Component { }, align ? `align${align}` : null )} + id={this.props.attributes.anchor} data-active-element={active != undefined ? active : '0'} > diff --git a/src/blocks/accordion/accordion/index.js b/src/blocks/accordion/accordion/index.js index 04ceb101e..d1c5ebd2c 100755 --- a/src/blocks/accordion/accordion/index.js +++ b/src/blocks/accordion/accordion/index.js @@ -37,6 +37,7 @@ export default registerBlockType( icon: , category: 'getwid-blocks', supports: { + anchor: true, align: [ 'wide', 'full' ], inserter: !Getwid.disabled_blocks.includes(blockName) }, diff --git a/src/blocks/accordion/accordion/save.js b/src/blocks/accordion/accordion/save.js index 97fe8cdf9..719210fbc 100755 --- a/src/blocks/accordion/accordion/save.js +++ b/src/blocks/accordion/accordion/save.js @@ -27,6 +27,7 @@ class Save extends Component { } = this.props; const { className } = this.props; + const { anchor } = this.props.attributes; return (
@@ -42,4 +44,4 @@ class Save extends Component { } } -export default Save; \ No newline at end of file +export default Save; diff --git a/src/blocks/toggle/toggle-item/attributes.js b/src/blocks/toggle/toggle-item/attributes.js index f16a13627..afce0411c 100755 --- a/src/blocks/toggle/toggle-item/attributes.js +++ b/src/blocks/toggle/toggle-item/attributes.js @@ -13,4 +13,4 @@ const attributes = { }, }; -export default attributes; \ No newline at end of file +export default attributes; diff --git a/src/blocks/toggle/toggle-item/edit.js b/src/blocks/toggle/toggle-item/edit.js index a4126cbe8..4096eb681 100755 --- a/src/blocks/toggle/toggle-item/edit.js +++ b/src/blocks/toggle/toggle-item/edit.js @@ -74,7 +74,7 @@ class ToggleItem extends Component { -
+
diff --git a/src/blocks/toggle/toggle-item/index.js b/src/blocks/toggle/toggle-item/index.js index 6ea8d130b..5bf5c76bc 100755 --- a/src/blocks/toggle/toggle-item/index.js +++ b/src/blocks/toggle/toggle-item/index.js @@ -27,6 +27,7 @@ export default registerBlockType( category: 'getwid-blocks', parent: [ 'getwid/toggle' ], supports: { + anchor: true, multiple: true, reusable: false, html: false @@ -57,4 +58,4 @@ export default registerBlockType( }} /> ) } -); \ No newline at end of file +); diff --git a/src/blocks/toggle/toggle-item/save.js b/src/blocks/toggle/toggle-item/save.js index c05955c8f..b28066013 100755 --- a/src/blocks/toggle/toggle-item/save.js +++ b/src/blocks/toggle/toggle-item/save.js @@ -18,7 +18,7 @@ class Save extends Component { render() { const {className, baseClass} = this.props; - const {outerParent, title, active} = this.props.attributes; + const {outerParent, title, active, anchor} = this.props.attributes; const Tag = outerParent ? outerParent.attributes.headerTag : 'span'; const iconOpen = outerParent ? outerParent.attributes.iconOpen : 'fas fa-minus'; @@ -30,6 +30,7 @@ class Save extends Component { 'is-active': active, }, )} + id={anchor} >
, category: 'getwid-blocks', supports: { + anchor: true, align: [ 'wide', 'full' ], inserter: !Getwid.disabled_blocks.includes(blockName) }, diff --git a/src/blocks/toggle/toggle/save.js b/src/blocks/toggle/toggle/save.js index d76737daf..8b484b31e 100755 --- a/src/blocks/toggle/toggle/save.js +++ b/src/blocks/toggle/toggle/save.js @@ -25,11 +25,13 @@ class Save extends Component { } = this.props; const { className } = this.props; + const { anchor } = this.props.attributes; return (
@@ -37,4 +39,4 @@ class Save extends Component { } } -export default Save; \ No newline at end of file +export default Save;