-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathindex.js
More file actions
65 lines (57 loc) · 1.49 KB
/
index.js
File metadata and controls
65 lines (57 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* BLOCK: Card Block.
*/
/**
* External dependencies
*/
import { ColumnIcon } from '~stackable/icons'
import { i18n } from 'stackable'
/**
* Internal dependencies
*/
import edit from './edit'
import save from './save'
import schema from './schema'
import deprecated from './deprecated'
import metadata from './block.json'
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n'
import { select } from '@wordpress/data'
export const settings = {
...metadata,
icon: ColumnIcon,
attributes: schema,
supports: {
anchor: true,
reusable: false,
stkBlockLinking: true,
stkSaveBlockStyle: false,
stkDefaultTab: 'layout',
spacing: true,
},
// styles: blockStyles,
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 ''
},
}