From 6f27d802e774de2c3258fc3533e5c1002fadf667 Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Wed, 29 Nov 2023 10:22:30 +0800 Subject: [PATCH 01/14] text block now uses repeaterValue context --- src/block/text/block.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/block/text/block.json b/src/block/text/block.json index 3d4e31502c..51a5f2834a 100644 --- a/src/block/text/block.json +++ b/src/block/text/block.json @@ -4,7 +4,7 @@ "title": "Text", "description": "Start with the building block of all page layouts.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId", "stackable/innerBlockOrientation" ], + "usesContext": [ "postId", "postType", "queryId", "stackable/innerBlockOrientation", "repeaterValue" ], "keywords": [ "Paragraph" ], From ed1778025366e2d68cec5783a951ac7427141523 Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Thu, 13 Jun 2024 10:14:17 +0800 Subject: [PATCH 02/14] added repeater value context --- src/block/heading/block.json | 2 +- src/block/text/block.json | 2 +- src/stk-block-types.php | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/block/heading/block.json b/src/block/heading/block.json index 5a72bd0a6b..25f2cf350d 100644 --- a/src/block/heading/block.json +++ b/src/block/heading/block.json @@ -4,7 +4,7 @@ "title": "Heading", "description": "Introduce new sections of your content in style.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation", "stackable/repeaterValue" ], "keywords": [ "Title" ], diff --git a/src/block/text/block.json b/src/block/text/block.json index 51a5f2834a..24eb32b4d2 100644 --- a/src/block/text/block.json +++ b/src/block/text/block.json @@ -4,7 +4,7 @@ "title": "Text", "description": "Start with the building block of all page layouts.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId", "stackable/innerBlockOrientation", "repeaterValue" ], + "usesContext": [ "postId", "postType", "queryId", "stackable/innerBlockOrientation", "stackable/repeaterValue" ], "keywords": [ "Paragraph" ], diff --git a/src/stk-block-types.php b/src/stk-block-types.php index 70e3371741..31c1c4f715 100644 --- a/src/stk-block-types.php +++ b/src/stk-block-types.php @@ -367,7 +367,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'Title', STACKABLE_I18N ) @@ -947,7 +948,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'Paragraph', STACKABLE_I18N ) From 4d1b60eb02e88dd56026708eaf1117043f5c1f35 Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Wed, 7 Aug 2024 13:06:39 +0800 Subject: [PATCH 03/14] added support for updating object properties inside attributes --- src/components/base-control2/hooks.js | 38 ++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/components/base-control2/hooks.js b/src/components/base-control2/hooks.js index 120b51a599..7fbb41027a 100644 --- a/src/components/base-control2/hooks.js +++ b/src/components/base-control2/hooks.js @@ -4,21 +4,51 @@ import { useAttributeName, useBlockAttributesContext, useBlockSetAttributesContext, } from '~stackable/hooks' +import { + get, set, cloneDeep, +} from 'lodash' + +export const useControlHandlers = ( _attribute, responsive = false, hover = false, valueCallback = null, changeCallback = null ) => { + // If there's a '.' it means the attribute value is an object, and we want + // to change a single property inside that object. + const willUpdateObjectProperty = _attribute.includes( '.' ) + const attribute = willUpdateObjectProperty ? _attribute.split( '.' )[ 0 ] : _attribute -export const useControlHandlers = ( attribute, responsive = false, hover = false, valueCallback = null, changeCallback = null ) => { const setAttributes = useBlockSetAttributesContext() const attrName = useAttributeName( attribute, responsive, hover ) const _value = useBlockAttributesContext( attributes => attributes[ attrName ] ) - const originalValue = _value !== undefined ? _value : '' - let value = _value !== undefined ? _value : '' + // We're just updating the attribute directly. + if ( ! willUpdateObjectProperty ) { + const originalValue = _value !== undefined ? _value : '' + let value = originalValue + if ( valueCallback ) { + value = valueCallback( value ) + } + + const onChange = _value => { + const value = changeCallback ? changeCallback( _value, originalValue ) : _value + setAttributes( { [ attrName ]: value } ) + } + + return [ value, onChange ] + } + + // If we reach here, then the attribute's value is an object and we're + // updating one property in it. _attribute is the path in the format of + // 'attribute.property' or 'attribute.property1.property2' + const path = _attribute.substring( _attribute.indexOf( '.' ) + 1 ) + const originalObjectValue = _value !== undefined ? _value : {} + const originalValue = _value !== undefined ? get( _value, path, '' ) : '' + let value = originalValue if ( valueCallback ) { value = valueCallback( value ) } const onChange = _value => { const value = changeCallback ? changeCallback( _value, originalValue ) : _value - setAttributes( { [ attrName ]: value } ) + const newObjectValue = set( cloneDeep( originalObjectValue ), path, value ) + setAttributes( { [ attrName ]: newObjectValue } ) } return [ value, onChange ] From 94c61d670de847301e0f76c449e9cd752a0a30db Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Sat, 10 Aug 2024 16:36:43 +0800 Subject: [PATCH 04/14] Pass query loop context --- src/components/dynamic-content-control/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/dynamic-content-control/index.js b/src/components/dynamic-content-control/index.js index 69980da426..0930a98697 100644 --- a/src/components/dynamic-content-control/index.js +++ b/src/components/dynamic-content-control/index.js @@ -235,6 +235,7 @@ export const useDynamicContent = ( value = '' ) => { const { clientId } = useBlockEditContext() const blockDetails = select( 'core/block-editor' ).getBlock( clientId ) const queryLoopContext = useContext( QueryLoopContext ) + blockDetails.context = queryLoopContext return useSelect( select => { if ( ! value || ! isString( value ) ) { From 658972a0e7ab5485b00822f505a95666754583f4 Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Thu, 5 Sep 2024 18:34:19 +0800 Subject: [PATCH 05/14] added repeater block icons --- src/icons/images/repeater-icon.svg | 3 +++ src/icons/images/repeater-template-icon.svg | 3 +++ src/icons/index.js | 10 ++++++++++ 3 files changed, 16 insertions(+) create mode 100644 src/icons/images/repeater-icon.svg create mode 100644 src/icons/images/repeater-template-icon.svg diff --git a/src/icons/images/repeater-icon.svg b/src/icons/images/repeater-icon.svg new file mode 100644 index 0000000000..c2fa541469 --- /dev/null +++ b/src/icons/images/repeater-icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/icons/images/repeater-template-icon.svg b/src/icons/images/repeater-template-icon.svg new file mode 100644 index 0000000000..d38fda7e55 --- /dev/null +++ b/src/icons/images/repeater-template-icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/icons/index.js b/src/icons/index.js index 7209a22f07..6ed9706ffc 100644 --- a/src/icons/index.js +++ b/src/icons/index.js @@ -39,6 +39,8 @@ import SVGPaginationIcon from './images/pagination.svg' import SVGPricingBoxIcon from './images/pricing-box-icon.svg' import SVGProgressCircleIcon from './images/progress-circle-icon.svg' import SVGProgressBarIcon from './images/progress-bar-icon.svg' +import SVGRepeaterIcon from './images/repeater-icon.svg' +import SVGRepeaterTemplateIcon from './images/repeater-template-icon.svg' import SVGSeparatorIcon from './images/separator-icon.svg' import SVGSocialButtonsIcon from './images/social-buttons.svg' import SVGSpacerIcon from './images/spacer-icon.svg' @@ -262,6 +264,14 @@ export function ProgressBarIcon() { return colorizeIcon( ) } +export function RepeaterIcon() { + return colorizeIcon( ) +} + +export function RepeaterTemplateIcon() { + return colorizeIcon( ) +} + export function SeparatorIcon() { return colorizeIcon( ) } From 4f79131b64fc7e13227c19c6dfb6cb40c84e593c Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Thu, 5 Sep 2024 19:36:54 +0800 Subject: [PATCH 06/14] do not run through sprintf anymore if it's just the default attr name template --- src/util/attributes/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/util/attributes/index.js b/src/util/attributes/index.js index 453bb7bb06..53cac2408d 100644 --- a/src/util/attributes/index.js +++ b/src/util/attributes/index.js @@ -17,10 +17,16 @@ import { import { sprintf } from '@wordpress/i18n' export const getAttrName = ( attrNameTemplate = '%s', param1 = '', param2 = '' ) => { + if ( attrNameTemplate === '%s' ) { + return param1 + } return camelCase( sprintf( attrNameTemplate, upperFirst( param1 ), upperFirst( param2 ) ) ) } export const getAttrNameFunction = attrNameTemplate => ( param1 = '', param2 = '' ) => { + if ( attrNameTemplate === '%s' ) { + return param1 + } return getAttrName( attrNameTemplate, param1, param2 ) } From 85d43fdd1fd518a383384530acdb60d8a9058474 Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Sat, 7 Sep 2024 00:38:30 +0800 Subject: [PATCH 07/14] optimized use dynamic content --- src/block/image/block.json | 3 +- .../dynamic-content-control/index.js | 49 ++++++++++++++++--- src/components/index.js | 4 +- src/stk-block-types.php | 3 +- 4 files changed, 48 insertions(+), 11 deletions(-) diff --git a/src/block/image/block.json b/src/block/image/block.json index f47e4426c2..6db39559ac 100644 --- a/src/block/image/block.json +++ b/src/block/image/block.json @@ -8,7 +8,8 @@ "postId", "postType", "queryId", - "stackable/innerBlockOrientation" + "stackable/innerBlockOrientation", + "stackable/repeaterValue" ], "textdomain": "stackable-ultimate-gutenberg-blocks", "stk-type": "essential", diff --git a/src/components/dynamic-content-control/index.js b/src/components/dynamic-content-control/index.js index 0930a98697..1b38a35c5c 100644 --- a/src/components/dynamic-content-control/index.js +++ b/src/components/dynamic-content-control/index.js @@ -165,7 +165,9 @@ export const hasDynamicContent = ( value = '' ) => { return value.includes( '!#stk_dynamic' ) || value.includes( 'data-stk-dynamic' ) } -export const getDynamicContent = ( value = '', queryLoopContext = null ) => { +/* +// Unused +export const ____getDynamicContent = ( value = '', queryLoopContext = null ) => { if ( ! select( 'stackable/dynamic-content' ) ) { return value } @@ -215,6 +217,7 @@ export const getDynamicContent = ( value = '', queryLoopContext = null ) => { return select( 'stackable/dynamic-content' ).parseDynamicContents( tempValue ) } +*/ export const useQueryLoopContext = () => { return useContext( QueryLoopContext ) @@ -229,14 +232,43 @@ export const useQueryLoopContext = () => { * const value = useDynamicContent( 'Post Title: !#stk_dynamic/current-page/post-title!#' ) * // returns `Post Title: The actual post title` * ``` + * @param context * @param {string} value */ export const useDynamicContent = ( value = '' ) => { const { clientId } = useBlockEditContext() - const blockDetails = select( 'core/block-editor' ).getBlock( clientId ) - const queryLoopContext = useContext( QueryLoopContext ) - blockDetails.context = queryLoopContext + // We need to create a new object here. + const blockDetails = { + ...select( 'core/block-editor' ).getBlock( clientId ), + context: useContext( QueryLoopContext ), + } + // const queryLoopContext = + // blockDetails.context = { ...context } + + return useSelect( select => { + if ( ! value || ! isString( value ) ) { + return value + } + + if ( ! value.includes( '!#stk_dynamic' ) && ! value.includes( 'data-stk-dynamic' ) ) { + return value + } + if ( ! select( 'stackable/dynamic-content' ) ) { + return value + } + + const parsedContent = select( 'stackable/dynamic-content' ).parseDynamicContents( value, blockDetails ) + return parsedContent + }, [ value, blockDetails.context?.postId, blockDetails.context?.[ 'stackable/repeaterValue' ] ] ) + + return value + '-' + blockDetails.context?.postId + + // TODO: Below is the old method, there was a lot going on here. Instead of + // passing the context, we tried inserting the current post id and then + // parsing that. but now we're passing the context, so no need for this. But + // keep this for now because we need to know if our new method works for any + // currently saved blocks that use dynamic data. return useSelect( select => { if ( ! value || ! isString( value ) ) { return value @@ -301,7 +333,6 @@ export const useDynamicContent = ( value = '' ) => { return '!#stk_dynamic/' + splitFieldString.join( '/' ) + '!#' } ) } - // Get the correct value for the dynamic content. let parsedContent = select( 'stackable/dynamic-content' ).parseDynamicContents( tempValue, blockDetails ) @@ -333,7 +364,7 @@ export const useDynamicContent = ( value = '' ) => { } return parsedContent - }, [ value, queryLoopContext?.postId ] ) + }, [ value, queryLoopContext?.postId, queryLoopContext?.[ 'stackable/repeaterValue' ] ] ) } /** @@ -399,6 +430,11 @@ export const useValueWithFieldsTitle = ( value = '' ) => { const dynamicContent = export const DynamicContentButton = memo( props => { + const { clientId } = useBlockEditContext() + const queryLoopContext = useContext( QueryLoopContext ) + const block = select( 'core/block-editor' ).getBlock( clientId ) + block.context = queryLoopContext + if ( ! isPro && ! showProNotice ) { return null } @@ -430,6 +466,7 @@ export const DynamicContentButton = memo( props => { onChange={ props.onChange } activeAttribute={ props.activeAttribute } type={ props.type } + blockDetails={ block } /> ) } diff --git a/src/components/index.js b/src/components/index.js index 6207dbbb61..000ff020ca 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -98,9 +98,7 @@ export { } from './inspector-tabs' export { default as Div } from './div' export { default as ControlIconToggle } from './control-icon-toggle' -export { - default as DynamicContentControl, useDynamicContent, getDynamicContent, -} from './dynamic-content-control' +export { default as DynamicContentControl, useDynamicContent } from './dynamic-content-control' export { default as Separator2 } from './separator2' export { default as ColumnInnerBlocks } from './column-inner-blocks' export { default as VariationPicker } from './variation-picker' diff --git a/src/stk-block-types.php b/src/stk-block-types.php index 31c1c4f715..d0dec45e0c 100644 --- a/src/stk-block-types.php +++ b/src/stk-block-types.php @@ -557,7 +557,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'textdomain' => 'stackable-ultimate-gutenberg-blocks', 'stk-type' => 'essential', From 4dbfbfdedd9b9f38efb4cf6f2d72d8f2f3a83378 Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Tue, 10 Sep 2024 16:29:09 +0800 Subject: [PATCH 08/14] show spinner while still loading dynamic content in editor --- src/block-components/typography/index.js | 4 ++++ src/components/dynamic-content-control/index.js | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/block-components/typography/index.js b/src/block-components/typography/index.js index ec61981132..cbe5eb91c6 100644 --- a/src/block-components/typography/index.js +++ b/src/block-components/typography/index.js @@ -20,6 +20,7 @@ import { useDynamicContent } from '~stackable/components/dynamic-content-control /** * WordPress dependencies */ +import { Spinner } from '@wordpress/components' import { RichText } from '@wordpress/block-editor' import { useEffect, @@ -92,6 +93,9 @@ export const Typography = memo( forwardRef( ( props, ref ) => { }, [ debouncedText, onChange ] ) // Don't include `value` in the dependency list because it will cause a double triggering of the `onChange`. const dynamicContentText = useDynamicContent( debouncedText ) + if ( dynamicContentText.includes( 'data-stk-dynamic=' ) && dynamicContentText.includes( '>' ) ) { + return + } if ( ! editable ) { return { dynamicContentText } diff --git a/src/components/dynamic-content-control/index.js b/src/components/dynamic-content-control/index.js index 1b38a35c5c..62beaa7cb3 100644 --- a/src/components/dynamic-content-control/index.js +++ b/src/components/dynamic-content-control/index.js @@ -242,8 +242,6 @@ export const useDynamicContent = ( value = '' ) => { ...select( 'core/block-editor' ).getBlock( clientId ), context: useContext( QueryLoopContext ), } - // const queryLoopContext = - // blockDetails.context = { ...context } return useSelect( select => { if ( ! value || ! isString( value ) ) { From 5acc42151c7d45313b58392a47edb923a4333da5 Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Wed, 11 Sep 2024 23:33:51 +0800 Subject: [PATCH 09/14] added format to the dynamic content popup --- src/components/base-control2/hooks.js | 2 +- src/components/dynamic-content-control/index.js | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/base-control2/hooks.js b/src/components/base-control2/hooks.js index 7fbb41027a..ac1b13007e 100644 --- a/src/components/base-control2/hooks.js +++ b/src/components/base-control2/hooks.js @@ -8,7 +8,7 @@ import { get, set, cloneDeep, } from 'lodash' -export const useControlHandlers = ( _attribute, responsive = false, hover = false, valueCallback = null, changeCallback = null ) => { +export const useControlHandlers = ( _attribute = '', responsive = false, hover = false, valueCallback = null, changeCallback = null ) => { // If there's a '.' it means the attribute value is an object, and we want // to change a single property inside that object. const willUpdateObjectProperty = _attribute.includes( '.' ) diff --git a/src/components/dynamic-content-control/index.js b/src/components/dynamic-content-control/index.js index 62beaa7cb3..ba96f77977 100644 --- a/src/components/dynamic-content-control/index.js +++ b/src/components/dynamic-content-control/index.js @@ -13,7 +13,7 @@ import { QueryLoopContext } from '~stackable/higher-order/with-query-loop-contex /** * WordPress dependencies */ -import { __ } from '@wordpress/i18n' +import { __, sprintf } from '@wordpress/i18n' import { useBlockEditContext } from '@wordpress/block-editor' import { Button, @@ -120,12 +120,17 @@ export const useDynamicContentControlProps = props => { const isPressed = isPopoverOpen || activeAttributes.length const activeAttribute = first( activeAttributes ) || '' - const onChange = ( newValue, editorQueryString, frontendQueryString ) => { + const onChange = ( newValue, editorQueryString, frontendQueryString, format = '' ) => { // If `isFormatType` is true, the onChange function will generate a `stackable/dynamic-content` format type. - const willChangeValue = props.isFormatType + let willChangeValue = props.isFormatType ? `${ newValue }` : `!#stk_dynamic/${ frontendQueryString }!#` + // If `format` is set, then we will use it to format the value. + if ( format ) { + willChangeValue = sprintf( format, willChangeValue ) + } + props.onChange( willChangeValue ) setDebouncedValue( willChangeValue ) @@ -465,6 +470,8 @@ export const DynamicContentButton = memo( props => { activeAttribute={ props.activeAttribute } type={ props.type } blockDetails={ block } + value={ props.value } + hasFormat={ !! props.value?.includes( 'class="stk-dynamic-content"' ) } /> ) } From 5231a840117a7079aca4154803fcb4a864841431 Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Wed, 11 Sep 2024 23:34:12 +0800 Subject: [PATCH 10/14] added repeater value in button block --- src/block/button-group/block.json | 2 +- src/block/button/block.json | 2 +- src/stk-block-types.php | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/block/button-group/block.json b/src/block/button-group/block.json index 838f9adf2c..2dd2c84fdc 100644 --- a/src/block/button-group/block.json +++ b/src/block/button-group/block.json @@ -4,7 +4,7 @@ "title": "Button Group", "description": "Add a customizable button.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation", "stackable/repeaterValue" ], "keywords": [ "Link" ], diff --git a/src/block/button/block.json b/src/block/button/block.json index 9f79e69747..8a2e751fff 100644 --- a/src/block/button/block.json +++ b/src/block/button/block.json @@ -4,7 +4,7 @@ "title": "Button", "description": "Add a customizable button.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation", "stackable/repeaterValue" ], "parent": [ "stackable/button-group" ], diff --git a/src/stk-block-types.php b/src/stk-block-types.php index d0dec45e0c..462a7998b0 100644 --- a/src/stk-block-types.php +++ b/src/stk-block-types.php @@ -55,7 +55,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'parent' => [ 'stackable/button-group' @@ -77,7 +78,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'Link', STACKABLE_I18N ) From 64e0201b980e4adf3e63143409e05430a67770a5 Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Wed, 25 Sep 2024 18:51:24 +0800 Subject: [PATCH 11/14] allow custom attributes, links and image attributes to be dynamically formatted --- src/components/advanced-text-control/index.js | 3 +++ src/components/custom-attributes-control/index.js | 3 +++ src/components/dynamic-content-control/index.js | 3 ++- src/components/image-control2/index.js | 2 ++ src/components/link-control/index.js | 7 ++++--- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/components/advanced-text-control/index.js b/src/components/advanced-text-control/index.js index b679de26d4..4aea1cb430 100644 --- a/src/components/advanced-text-control/index.js +++ b/src/components/advanced-text-control/index.js @@ -50,6 +50,8 @@ const AdvancedTextControl = memo( props => { { { hasError && { __( 'There is an error in your custom attribute', i18n ) } } ) } + isDynamic={ true } + isFormatType={ false } + rawValue={ customAttributes } /> ) } diff --git a/src/components/dynamic-content-control/index.js b/src/components/dynamic-content-control/index.js index 40b1fd5c8b..ac7388bf9a 100644 --- a/src/components/dynamic-content-control/index.js +++ b/src/components/dynamic-content-control/index.js @@ -572,7 +572,8 @@ export const DynamicContentButton = memo( props => { type={ props.type } blockDetails={ block } value={ props.value } - hasFormat={ !! props.value?.includes( 'class="stk-dynamic-content"' ) } + hasFormat={ props.hasFormat || !! props.value?.includes( 'class="stk-dynamic-content"' ) } + rawValue={ props.rawValue } /> ) } diff --git a/src/components/image-control2/index.js b/src/components/image-control2/index.js index 1203522c3a..83d28f2e3e 100644 --- a/src/components/image-control2/index.js +++ b/src/components/image-control2/index.js @@ -136,6 +136,8 @@ const ImageControl = memo( props => { enable={ props.isDynamic } hasPanelModifiedIndicator={ props.hasPanelModifiedIndicator } type="image-url" + hasFormat={ true } + rawValue={ attributes[ attrNameUrl ] } { ...dynamicContentProps } > {
From ebb1dba41814a65c057f4eb9cc0d3fec33ceb374 Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Fri, 4 Oct 2024 14:49:05 +0800 Subject: [PATCH 12/14] added repeaterValue in all block.json --- src/__block-container-template/block.json | 8 +- src/__block-template/block.json | 8 +- src/block/accordion/block.json | 8 +- src/block/blockquote/block.json | 8 +- src/block/button-group/block.json | 8 +- src/block/button/block.json | 8 +- src/block/call-to-action/block.json | 8 +- src/block/card/block.json | 8 +- src/block/carousel/block.json | 8 +- src/block/column/block.json | 9 +- src/block/columns/block.json | 3 +- src/block/count-up/block.json | 8 +- src/block/countdown/block.json | 8 +- src/block/design-library/block.json | 3 +- src/block/divider/block.json | 8 +- src/block/expand/block.json | 8 +- src/block/feature-grid/block.json | 8 +- src/block/feature/block.json | 8 +- src/block/heading/block.json | 8 +- src/block/hero/block.json | 3 +- src/block/horizontal-scroller/block.json | 8 +- src/block/icon-box/block.json | 3 +- src/block/icon-button/block.json | 8 +- src/block/icon-label/block.json | 3 +- src/block/icon-list-item/block.json | 10 +- src/block/icon-list/block.json | 8 +- src/block/icon/block.json | 8 +- src/block/image-box/block.json | 8 +- src/block/map/block.json | 8 +- src/block/notification/block.json | 8 +- src/block/number-box/block.json | 8 +- src/block/posts/block.json | 8 +- src/block/price/block.json | 3 +- src/block/pricing-box/block.json | 8 +- src/block/progress-bar/block.json | 8 +- src/block/progress-circle/block.json | 8 +- src/block/separator/block.json | 8 +- src/block/spacer/block.json | 8 +- src/block/subtitle/block.json | 3 +- src/block/tab-content/block.json | 10 +- src/block/tab-labels/block.json | 10 +- src/block/table-of-contents/block.json | 3 +- src/block/tabs/block.json | 8 +- src/block/team-member/block.json | 8 +- src/block/testimonial/block.json | 8 +- src/block/text/block.json | 8 +- src/block/timeline/block.json | 8 +- src/block/video-popup/block.json | 8 +- src/stk-block-types.php | 126 ++++++++++++++-------- 49 files changed, 386 insertions(+), 91 deletions(-) diff --git a/src/__block-container-template/block.json b/src/__block-container-template/block.json index 40f8a30e69..f66ba01f3c 100644 --- a/src/__block-container-template/block.json +++ b/src/__block-container-template/block.json @@ -4,7 +4,13 @@ "title": "New Block", "description": "A new block.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "Keywords that are not in the title" ], diff --git a/src/__block-template/block.json b/src/__block-template/block.json index 40f8a30e69..f66ba01f3c 100644 --- a/src/__block-template/block.json +++ b/src/__block-template/block.json @@ -4,7 +4,13 @@ "title": "New Block", "description": "A new block.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "Keywords that are not in the title" ], diff --git a/src/block/accordion/block.json b/src/block/accordion/block.json index 4582c7ea38..c3e8c6e93a 100644 --- a/src/block/accordion/block.json +++ b/src/block/accordion/block.json @@ -4,7 +4,13 @@ "title": "Accordion", "description": "A title that your visitors can toggle to view more text. Use as FAQs or multiple ones for an Accordion.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "Toggle", "Faq" diff --git a/src/block/blockquote/block.json b/src/block/blockquote/block.json index 5f10563d53..61043e4002 100644 --- a/src/block/blockquote/block.json +++ b/src/block/blockquote/block.json @@ -4,7 +4,13 @@ "title": "Blockquote", "description": "Display a quote in style", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "textdomain": "stackable-ultimate-gutenberg-blocks", "stk-type": "section", "stk-demo": "https://wpstackable.com/blockquote-block/?utm_source=welcome&utm_medium=settings&utm_campaign=view_demo&utm_content=demolink" diff --git a/src/block/button-group/block.json b/src/block/button-group/block.json index 2dd2c84fdc..50ee2b09ec 100644 --- a/src/block/button-group/block.json +++ b/src/block/button-group/block.json @@ -4,7 +4,13 @@ "title": "Button Group", "description": "Add a customizable button.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation", "stackable/repeaterValue" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "Link" ], diff --git a/src/block/button/block.json b/src/block/button/block.json index 8a2e751fff..bc98a31c47 100644 --- a/src/block/button/block.json +++ b/src/block/button/block.json @@ -4,7 +4,13 @@ "title": "Button", "description": "Add a customizable button.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation", "stackable/repeaterValue" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "parent": [ "stackable/button-group" ], diff --git a/src/block/call-to-action/block.json b/src/block/call-to-action/block.json index 1b38094be3..03de1987b5 100644 --- a/src/block/call-to-action/block.json +++ b/src/block/call-to-action/block.json @@ -4,7 +4,13 @@ "title": "Call to Action", "description": "A small section you can use to call the attention of your visitors. Great for calling attention to your products or deals.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "providesContext": { "stackable/innerBlockOrientation": "innerBlockOrientation" }, diff --git a/src/block/card/block.json b/src/block/card/block.json index 2025e1f7dd..86a7e66587 100644 --- a/src/block/card/block.json +++ b/src/block/card/block.json @@ -4,7 +4,13 @@ "title": "Card", "description": "Describe a single subject in a small card. You can use this to describe your product, service or a person.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "providesContext": { "stackable/innerBlockOrientation": "innerBlockOrientation" }, diff --git a/src/block/carousel/block.json b/src/block/carousel/block.json index d712313c0a..d68e44b691 100644 --- a/src/block/carousel/block.json +++ b/src/block/carousel/block.json @@ -4,7 +4,13 @@ "title": "Carousel", "description": "A carousel slider.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "Slider" ], diff --git a/src/block/column/block.json b/src/block/column/block.json index fce9089cc5..e593ceb086 100644 --- a/src/block/column/block.json +++ b/src/block/column/block.json @@ -4,7 +4,14 @@ "title": "Inner Column", "description": "A single column with advanced layout options.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId", "stackable/innerBlockOrientation", "stackable/columnWrapDesktop" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/columnWrapDesktop", + "stackable/repeaterValue" + ], "providesContext": { "stackable/innerBlockOrientation": "innerBlockOrientation" }, diff --git a/src/block/columns/block.json b/src/block/columns/block.json index 93ff48c38a..4801cb30cd 100644 --- a/src/block/columns/block.json +++ b/src/block/columns/block.json @@ -7,7 +7,8 @@ "usesContext": [ "postId", "postType", - "queryId" + "queryId", + "stackable/repeaterValue" ], "keywords": [ "Section rows", diff --git a/src/block/count-up/block.json b/src/block/count-up/block.json index fba299396f..8f2ed08dad 100644 --- a/src/block/count-up/block.json +++ b/src/block/count-up/block.json @@ -4,7 +4,13 @@ "title": "Count Up", "description": "Showcase your stats. Display how many customers you have or the number of downloads of your app.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "Number" ], diff --git a/src/block/countdown/block.json b/src/block/countdown/block.json index a6b6817c73..ac7e05cc8b 100644 --- a/src/block/countdown/block.json +++ b/src/block/countdown/block.json @@ -4,7 +4,13 @@ "title": "Countdown", "description": "Display a countdown timer on your website.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "Timer" ], diff --git a/src/block/design-library/block.json b/src/block/design-library/block.json index cf56eaba99..f9bb7aaa37 100644 --- a/src/block/design-library/block.json +++ b/src/block/design-library/block.json @@ -8,7 +8,8 @@ "postId", "postType", "queryId", - "stackable/innerBlockOrientation" + "stackable/innerBlockOrientation", + "stackable/repeaterValue" ], "keywords": [ "Template" diff --git a/src/block/divider/block.json b/src/block/divider/block.json index 3b28da93d0..6b05888785 100644 --- a/src/block/divider/block.json +++ b/src/block/divider/block.json @@ -4,7 +4,13 @@ "title": "Divider", "description": "Add a pause between your content.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "Horizontal Rule", "HR" diff --git a/src/block/expand/block.json b/src/block/expand/block.json index ed0bcba11a..61c7cf9ab6 100644 --- a/src/block/expand/block.json +++ b/src/block/expand/block.json @@ -4,7 +4,13 @@ "title": "Expand / Show More", "description": "Display a small snippet of text. Your readers can toggle it to show more information.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "Hide", "Less" diff --git a/src/block/feature-grid/block.json b/src/block/feature-grid/block.json index bb62bda42d..faeb6039f7 100644 --- a/src/block/feature-grid/block.json +++ b/src/block/feature-grid/block.json @@ -4,7 +4,13 @@ "title": "Feature Grid", "description": "Display multiple product features or services. You can use Feature Grids one after another.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "providesContext": { "stackable/columnWrapDesktop": "columnWrapDesktop" }, diff --git a/src/block/feature/block.json b/src/block/feature/block.json index 422623c381..fa923cf6d5 100644 --- a/src/block/feature/block.json +++ b/src/block/feature/block.json @@ -4,7 +4,13 @@ "title": "Feature", "description": "Display a product feature or a service in a large area.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "providesContext": { "stackable/columnWrapDesktop": "columnWrapDesktop" }, diff --git a/src/block/heading/block.json b/src/block/heading/block.json index 25f2cf350d..14cc2f6c06 100644 --- a/src/block/heading/block.json +++ b/src/block/heading/block.json @@ -4,7 +4,13 @@ "title": "Heading", "description": "Introduce new sections of your content in style.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation", "stackable/repeaterValue" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "Title" ], diff --git a/src/block/hero/block.json b/src/block/hero/block.json index e7946996bc..c1ac4b79a0 100644 --- a/src/block/hero/block.json +++ b/src/block/hero/block.json @@ -8,7 +8,8 @@ "postId", "postType", "queryId", - "stackable/innerBlockOrientation" + "stackable/innerBlockOrientation", + "stackable/repeaterValue" ], "providesContext": { "stackable/innerBlockOrientation": "innerBlockOrientation" diff --git a/src/block/horizontal-scroller/block.json b/src/block/horizontal-scroller/block.json index e306971d5d..5cd501bd20 100644 --- a/src/block/horizontal-scroller/block.json +++ b/src/block/horizontal-scroller/block.json @@ -4,7 +4,13 @@ "title": "Horizontal Scroller", "description": "A slider that scrolls horizontally.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId", "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "Slider", "Carousel" diff --git a/src/block/icon-box/block.json b/src/block/icon-box/block.json index bca7d3200a..ddd4558a54 100644 --- a/src/block/icon-box/block.json +++ b/src/block/icon-box/block.json @@ -8,7 +8,8 @@ "postId", "postType", "queryId", - "stackable/innerBlockOrientation" + "stackable/innerBlockOrientation", + "stackable/repeaterValue" ], "textdomain": "stackable-ultimate-gutenberg-blocks", "stk-type": "section", diff --git a/src/block/icon-button/block.json b/src/block/icon-button/block.json index 10ccb4bf68..3a6c4d937e 100644 --- a/src/block/icon-button/block.json +++ b/src/block/icon-button/block.json @@ -4,7 +4,13 @@ "title": "Icon Button", "description": "Add a customizable button.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "parent": [ "stackable/button-group" ], diff --git a/src/block/icon-label/block.json b/src/block/icon-label/block.json index 8d0df07d5e..fa3222880e 100644 --- a/src/block/icon-label/block.json +++ b/src/block/icon-label/block.json @@ -8,7 +8,8 @@ "postId", "postType", "queryId", - "stackable/innerBlockOrientation" + "stackable/innerBlockOrientation", + "stackable/repeaterValue" ], "keywords": [ "SVG" diff --git a/src/block/icon-list-item/block.json b/src/block/icon-list-item/block.json index 5e82ef662b..16b8b3d89d 100644 --- a/src/block/icon-list-item/block.json +++ b/src/block/icon-list-item/block.json @@ -4,7 +4,15 @@ "title": "Icon List Item", "description": "A single list entry in the Icon List block", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation", "stackable/ordered", "stackable/uniqueId" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/ordered", + "stackable/uniqueId", + "stackable/repeaterValue" + ], "keywords": [], "parent": [ "stackable/icon-list" diff --git a/src/block/icon-list/block.json b/src/block/icon-list/block.json index 7f07d74145..87b5759141 100644 --- a/src/block/icon-list/block.json +++ b/src/block/icon-list/block.json @@ -4,7 +4,13 @@ "title": "Icon List", "description": "An unordered list with icons. You can use this as a list of features or benefits.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "Checklist", "Bullets", diff --git a/src/block/icon/block.json b/src/block/icon/block.json index 7bd36d9fd0..679ae03046 100644 --- a/src/block/icon/block.json +++ b/src/block/icon/block.json @@ -4,7 +4,13 @@ "title": "Icon", "description": "Pick an icon or upload your own SVG icon to decorate your content.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "SVG" ], diff --git a/src/block/image-box/block.json b/src/block/image-box/block.json index 4cc47bd030..3d12d7fcb6 100644 --- a/src/block/image-box/block.json +++ b/src/block/image-box/block.json @@ -4,7 +4,13 @@ "title": "Image Box", "description": "Display an image that shows more information when hovered on. Can be used as a fancy link to other pages.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "textdomain": "stackable-ultimate-gutenberg-blocks", "stk-type": "special", "stk-demo": "https://wpstackable.com/image-box-block/?utm_source=welcome&utm_medium=settings&utm_campaign=view_demo&utm_content=demolink" diff --git a/src/block/map/block.json b/src/block/map/block.json index 301f43bf4c..871fa9700b 100644 --- a/src/block/map/block.json +++ b/src/block/map/block.json @@ -8,10 +8,14 @@ "postId", "postType", "queryId", - "stackable/innerBlockOrientation" + "stackable/innerBlockOrientation", + "stackable/repeaterValue" ], "textdomain": "stackable-ultimate-gutenberg-blocks", - "keywords": [ "location", "address" ], + "keywords": [ + "location", + "address" + ], "stk-type": "special", "stk-demo": "https://wpstackable.com/map-block/?utm_source=welcome&utm_medium=settings&utm_campaign=view_demo&utm_content=demolink" } diff --git a/src/block/notification/block.json b/src/block/notification/block.json index a7bf51c75a..14bcc87b59 100644 --- a/src/block/notification/block.json +++ b/src/block/notification/block.json @@ -4,7 +4,13 @@ "title": "Notification", "description": "Show a notice to your readers. People can dismiss the notice to permanently hide it.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "providesContext": { "stackable/innerBlockOrientation": "innerBlockOrientation" }, diff --git a/src/block/number-box/block.json b/src/block/number-box/block.json index 6b4d227724..f46527d2dd 100644 --- a/src/block/number-box/block.json +++ b/src/block/number-box/block.json @@ -4,7 +4,13 @@ "title": "Number Box", "description": "Display steps or methods that your users will do in your service.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "Steps" ], diff --git a/src/block/posts/block.json b/src/block/posts/block.json index 1444a8b651..99a249a2b4 100644 --- a/src/block/posts/block.json +++ b/src/block/posts/block.json @@ -4,7 +4,13 @@ "title": "Posts", "description": "Your latest blog posts. Use this to showcase a few of your posts in your landing pages.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "Blog Posts", "Lastest Posts", diff --git a/src/block/price/block.json b/src/block/price/block.json index c907c9bbb5..ec6b84e2ca 100644 --- a/src/block/price/block.json +++ b/src/block/price/block.json @@ -8,7 +8,8 @@ "postId", "postType", "queryId", - "stackable/innerBlockOrientation" + "stackable/innerBlockOrientation", + "stackable/repeaterValue" ], "keywords": [ "Currency", diff --git a/src/block/pricing-box/block.json b/src/block/pricing-box/block.json index 4e4deb83d9..1a0d6aa723 100644 --- a/src/block/pricing-box/block.json +++ b/src/block/pricing-box/block.json @@ -4,7 +4,13 @@ "title": "Pricing Box", "description": "Display the different pricing tiers of your business.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "providesContext": { "stackable/innerBlockOrientation": "innerBlockOrientation" }, diff --git a/src/block/progress-bar/block.json b/src/block/progress-bar/block.json index 13df6f1d89..550ed62459 100644 --- a/src/block/progress-bar/block.json +++ b/src/block/progress-bar/block.json @@ -4,7 +4,13 @@ "title": "Progress Bar", "description": "Visualize a progress value or percentage in a bar.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "percentage status" ], diff --git a/src/block/progress-circle/block.json b/src/block/progress-circle/block.json index a4e7e9abfe..79595c3cce 100644 --- a/src/block/progress-circle/block.json +++ b/src/block/progress-circle/block.json @@ -4,7 +4,13 @@ "title": "Progress Circle", "description": "Visualize a progress value or percentage in a circle.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "percentage status" ], diff --git a/src/block/separator/block.json b/src/block/separator/block.json index 6d6ea171ad..ab6b63c3a3 100644 --- a/src/block/separator/block.json +++ b/src/block/separator/block.json @@ -4,7 +4,13 @@ "title": "Separator", "description": "A fancy separator to be placed between content.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "Svg Divider" ], diff --git a/src/block/spacer/block.json b/src/block/spacer/block.json index 5bfe52cea5..4d26d6dd96 100644 --- a/src/block/spacer/block.json +++ b/src/block/spacer/block.json @@ -4,7 +4,13 @@ "title": "Spacer", "description": "Sometimes you just need some space.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "textdomain": "stackable-ultimate-gutenberg-blocks", "stk-type": "special" } diff --git a/src/block/subtitle/block.json b/src/block/subtitle/block.json index 0a66cd8c3b..1302875f11 100644 --- a/src/block/subtitle/block.json +++ b/src/block/subtitle/block.json @@ -8,7 +8,8 @@ "postId", "postType", "queryId", - "stackable/innerBlockOrientation" + "stackable/innerBlockOrientation", + "stackable/repeaterValue" ], "textdomain": "stackable-ultimate-gutenberg-blocks", "stk-type": "special", diff --git a/src/block/tab-content/block.json b/src/block/tab-content/block.json index c6952dce57..05b16f0507 100644 --- a/src/block/tab-content/block.json +++ b/src/block/tab-content/block.json @@ -4,7 +4,15 @@ "title": "Tab Content", "description": "A wrapper for tab panels.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation", "stackable/tabPanelEffect", "stackable/equalTabHeight" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/tabPanelEffect", + "stackable/equalTabHeight", + "stackable/repeaterValue" + ], "keywords": [], "parent": [ "stackable/tabs" diff --git a/src/block/tab-labels/block.json b/src/block/tab-labels/block.json index b6623b6c59..f578ece009 100644 --- a/src/block/tab-labels/block.json +++ b/src/block/tab-labels/block.json @@ -4,7 +4,15 @@ "title": "Tab Labels", "description": "Create interactive navigation within tabs.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation", "stackable/initialTabOpen", "stackable/tabOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/initialTabOpen", + "stackable/tabOrientation", + "stackable/repeaterValue" + ], "keywords": [], "parent": [ "stackable/tabs" diff --git a/src/block/table-of-contents/block.json b/src/block/table-of-contents/block.json index 3b7263eed4..9004725729 100644 --- a/src/block/table-of-contents/block.json +++ b/src/block/table-of-contents/block.json @@ -8,7 +8,8 @@ "postId", "postType", "queryId", - "stackable/innerBlockOrientation" + "stackable/innerBlockOrientation", + "stackable/repeaterValue" ], "keywords": [ "ToC", diff --git a/src/block/tabs/block.json b/src/block/tabs/block.json index 191e922803..5ce93fc874 100644 --- a/src/block/tabs/block.json +++ b/src/block/tabs/block.json @@ -4,7 +4,13 @@ "title": "Tabs", "description": "Organize and display content in multiple tabs.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "toggle" ], diff --git a/src/block/team-member/block.json b/src/block/team-member/block.json index 6c108fd96b..bd83ac1f44 100644 --- a/src/block/team-member/block.json +++ b/src/block/team-member/block.json @@ -4,7 +4,13 @@ "title": "Team Member", "description": "Display members of your team or your office. Use multiple Team Member blocks if you have a large team.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "providesContext": { "stackable/innerBlockOrientation": "innerBlockOrientation" }, diff --git a/src/block/testimonial/block.json b/src/block/testimonial/block.json index 5ff892c680..028855a9b8 100644 --- a/src/block/testimonial/block.json +++ b/src/block/testimonial/block.json @@ -4,7 +4,13 @@ "title": "Testimonial", "description": "Showcase what your users say about your product or service.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "providesContext": { "stackable/innerBlockOrientation": "innerBlockOrientation" }, diff --git a/src/block/text/block.json b/src/block/text/block.json index 24eb32b4d2..b82de216f3 100644 --- a/src/block/text/block.json +++ b/src/block/text/block.json @@ -4,7 +4,13 @@ "title": "Text", "description": "Start with the building block of all page layouts.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId", "stackable/innerBlockOrientation", "stackable/repeaterValue" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "Paragraph" ], diff --git a/src/block/timeline/block.json b/src/block/timeline/block.json index 80c3927889..bf969abd50 100644 --- a/src/block/timeline/block.json +++ b/src/block/timeline/block.json @@ -4,7 +4,13 @@ "title": "Timeline", "description": "Show events in chronological order", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "history", "milestone" diff --git a/src/block/video-popup/block.json b/src/block/video-popup/block.json index 958aa67679..fa828d2291 100644 --- a/src/block/video-popup/block.json +++ b/src/block/video-popup/block.json @@ -4,7 +4,13 @@ "title": "Video Popup", "description": "Display a large thumbnail that your users can click to play a video full-screen. Great for introductory or tutorial videos.", "category": "stackable", - "usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ], + "usesContext": [ + "postId", + "postType", + "queryId", + "stackable/innerBlockOrientation", + "stackable/repeaterValue" + ], "keywords": [ "YouTube", "Vimeo", diff --git a/src/stk-block-types.php b/src/stk-block-types.php index 462a7998b0..25e35584ee 100644 --- a/src/stk-block-types.php +++ b/src/stk-block-types.php @@ -19,7 +19,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'Toggle', STACKABLE_I18N ), @@ -39,7 +40,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'textdomain' => 'stackable-ultimate-gutenberg-blocks', 'stk-type' => 'section', @@ -123,7 +125,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'provides_context' => [ 'stackable/innerBlockOrientation' => 'innerBlockOrientation' @@ -145,7 +148,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'provides_context' => [ 'stackable/innerBlockOrientation' => 'innerBlockOrientation' @@ -164,7 +168,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'Slider', STACKABLE_I18N ) @@ -184,7 +189,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postType', 'queryId', 'stackable/innerBlockOrientation', - 'stackable/columnWrapDesktop' + 'stackable/columnWrapDesktop', + 'stackable/repeaterValue' ], 'provides_context' => [ 'stackable/innerBlockOrientation' => 'innerBlockOrientation' @@ -211,7 +217,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'uses_context' => [ 'postId', 'postType', - 'queryId' + 'queryId', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'Section rows', STACKABLE_I18N ), @@ -235,7 +242,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'Number', STACKABLE_I18N ) @@ -254,7 +262,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'Timer', STACKABLE_I18N ) @@ -273,7 +282,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'Template', STACKABLE_I18N ) @@ -292,7 +302,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'Horizontal Rule', STACKABLE_I18N ), @@ -311,7 +322,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'Hide', STACKABLE_I18N ), @@ -331,7 +343,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'provides_context' => [ 'stackable/columnWrapDesktop' => 'columnWrapDesktop' @@ -350,7 +363,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'provides_context' => [ 'stackable/columnWrapDesktop' => 'columnWrapDesktop' @@ -389,7 +403,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'provides_context' => [ 'stackable/innerBlockOrientation' => 'innerBlockOrientation' @@ -411,7 +426,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'Slider', STACKABLE_I18N ), @@ -434,7 +450,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'SVG', STACKABLE_I18N ) @@ -453,7 +470,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'textdomain' => 'stackable-ultimate-gutenberg-blocks', 'stk-type' => 'section', @@ -469,7 +487,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'parent' => [ 'stackable/button-group' @@ -491,7 +510,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'SVG', STACKABLE_I18N ) @@ -510,7 +530,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'Checklist', STACKABLE_I18N ), @@ -537,7 +558,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'queryId', 'stackable/innerBlockOrientation', 'stackable/ordered', - 'stackable/uniqueId' + 'stackable/uniqueId', + 'stackable/repeaterValue' ], 'keywords' => [ @@ -576,7 +598,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'textdomain' => 'stackable-ultimate-gutenberg-blocks', 'stk-type' => 'special', @@ -592,7 +615,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'textdomain' => 'stackable-ultimate-gutenberg-blocks', 'keywords' => [ @@ -612,7 +636,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'provides_context' => [ 'stackable/innerBlockOrientation' => 'innerBlockOrientation' @@ -635,7 +660,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'Steps', STACKABLE_I18N ) @@ -654,7 +680,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'Blog Posts', STACKABLE_I18N ), @@ -688,7 +715,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'Currency', STACKABLE_I18N ), @@ -709,7 +737,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'provides_context' => [ 'stackable/innerBlockOrientation' => 'innerBlockOrientation' @@ -733,7 +762,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'percentage status', STACKABLE_I18N ) @@ -752,7 +782,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'percentage status', STACKABLE_I18N ) @@ -771,7 +802,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'Svg Divider', STACKABLE_I18N ) @@ -790,7 +822,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'textdomain' => 'stackable-ultimate-gutenberg-blocks', 'stk-type' => 'special' @@ -805,7 +838,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'textdomain' => 'stackable-ultimate-gutenberg-blocks', 'stk-type' => 'special', @@ -823,7 +857,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'queryId', 'stackable/innerBlockOrientation', 'stackable/tabPanelEffect', - 'stackable/equalTabHeight' + 'stackable/equalTabHeight', + 'stackable/repeaterValue' ], 'keywords' => [ @@ -846,7 +881,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'queryId', 'stackable/innerBlockOrientation', 'stackable/initialTabOpen', - 'stackable/tabOrientation' + 'stackable/tabOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ @@ -867,7 +903,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'ToC', STACKABLE_I18N ), @@ -888,7 +925,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'toggle', STACKABLE_I18N ) @@ -913,7 +951,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'provides_context' => [ 'stackable/innerBlockOrientation' => 'innerBlockOrientation' @@ -932,7 +971,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'provides_context' => [ 'stackable/innerBlockOrientation' => 'innerBlockOrientation' @@ -971,7 +1011,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'history', STACKABLE_I18N ), @@ -991,7 +1032,8 @@ function stackable_get_blocks_array( $blocks = array() ) { 'postId', 'postType', 'queryId', - 'stackable/innerBlockOrientation' + 'stackable/innerBlockOrientation', + 'stackable/repeaterValue' ], 'keywords' => [ __( 'YouTube', STACKABLE_I18N ), From ad03d99aaa54a908ab1e793348c173a720edf084 Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Thu, 17 Oct 2024 16:38:06 +0800 Subject: [PATCH 13/14] added tabOverrides prop --- src/components/inspector-tabs/index.js | 18 ++++++++++-------- src/components/panel-tabs/index.js | 17 ++++++++++++++--- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/components/inspector-tabs/index.js b/src/components/inspector-tabs/index.js index 5d9f925268..029a713e52 100644 --- a/src/components/inspector-tabs/index.js +++ b/src/components/inspector-tabs/index.js @@ -63,15 +63,22 @@ export { } const InspectorTabs = props => { + const { + tabs = [ 'layout', 'style', 'advanced' ], + tabOverrides = {}, + hasLayoutPanel = true, + } = props + const { name } = useBlockEditContext() const defaultTab = getBlockSupport( name, 'stkDefaultTab' ) || 'style' - const [ activeTab, setActiveTab ] = useGlobalState( `tabCache-${ name }`, props.tabs.includes( defaultTab ) ? defaultTab : 'style' ) + const [ activeTab, setActiveTab ] = useGlobalState( `tabCache-${ name }`, tabs.includes( defaultTab ) ? defaultTab : 'style' ) return ( <> @@ -79,7 +86,7 @@ const InspectorTabs = props => { { /* Make sure the layout panel is the very first one */ } - { props.hasLayoutPanel && ( + { hasLayoutPanel && ( { ) } -InspectorTabs.defaultProps = { - tabs: [ 'layout', 'style', 'advanced' ], - hasLayoutPanel: true, -} - export default memo( InspectorTabs ) diff --git a/src/components/panel-tabs/index.js b/src/components/panel-tabs/index.js index 8724b60856..15e78d8aac 100644 --- a/src/components/panel-tabs/index.js +++ b/src/components/panel-tabs/index.js @@ -153,12 +153,23 @@ class PanelTabs extends Component { ref={ this.containerDiv } >
- { applyFilters( 'stackable.inspector.tabs', TABS ).map( ( { - value, title, label, icon, - }, i ) => { + { applyFilters( 'stackable.inspector.tabs', TABS ).map( ( tabProps, i ) => { + let { + value, title, label, icon, + } = tabProps + if ( ! this.tabsToUse.includes( value ) ) { return null } + + // Allow the different display attributes of the tab to be overridden. + if ( this.props.tabOverrides && this.props.tabOverrides[ value ] ) { + const override = this.props.tabOverrides[ value ] + title = override.title ? override.title : title + label = override.label ? override.label : label + icon = override.icon ? override.icon : icon + } + return (