Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/block/column/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* External dependencies
*/
import { ColumnIcon } from '~stackable/icons'
import { i18n } from 'stackable'

/**
* Internal dependencies
Expand All @@ -20,6 +21,7 @@ import metadata from './block.json'
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n'
import { select } from '@wordpress/data'

export const settings = {
...metadata,
Expand All @@ -38,4 +40,26 @@ export const settings = {
deprecated,
edit,
save,

__experimentalLabel: ( attributes, { context } ) => {
const customName = attributes?.metadata?.name
if ( context === 'list-view' && customName ) {
return customName
}

if ( context === 'list-view' && attributes?.uniqueId ) {
const { getEditorDom } = select( 'stackable/editor-dom' )
const editorDom = getEditorDom()
const isCarouselSlide = editorDom?.querySelector( `.stk-block-carousel__slider > * > * > * > * > [data-block-id="${ attributes.uniqueId }"]` )
if ( isCarouselSlide ) {
return __( 'Slide', i18n )
}
const isHorizontalScroller = editorDom?.querySelector( `.stk-block-horizontal-scroller > * > * > * > * > * > [data-block-id="${ attributes.uniqueId }"]` )
if ( isHorizontalScroller ) {
return __( 'Slide', i18n )
}
}

return ''
},
}