Diff: STRATO-apps/wordpress_03/app/wp-content/themes/blocksy/static/js/editor/utils/index.js
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
import { getFirstLevelOptions } from '../../options/helpers/get-value-from-input'
2
+
3
+
export const getAttributesFromOptions = (options) => {
4
+
return Object.entries(getFirstLevelOptions(options)).reduce((acc, item) => {
5
+
const blocksyType = item[1].type
6
+
let type = 'string'
7
+
8
+
if (blocksyType === 'ct-number') {
9
+
type = 'number'
10
+
}
11
+
12
+
if (
13
+
blocksyType === 'ct-visibility' ||
14
+
blocksyType === 'ct-checkboxes' ||
15
+
blocksyType === 'ct-image-uploader'
16
+
) {
17
+
type = 'object'
18
+
}
19
+
20
+
if (blocksyType === 'ct-layers') {
21
+
type = 'array'
22
+
}
23
+
24
+
acc[item[0]] = {
25
+
type,
26
+
default: item[1].value,
27
+
}
28
+
29
+
return acc
30
+
}, {})
31
+
}
32
+
33
+
export const getDefaultsFromOptions = (options) => {
34
+
const attributes = getAttributesFromOptions(options)
35
+
36
+
return Object.entries(attributes).reduce((acc, item) => {
37
+
acc[item[0]] = item[1].default
38
+
39
+
return acc
40
+
}, {})
41
+
}
42
+
43
+
export const getOptionsForBlock = (blockName) => {
44
+
return (
45
+
(window.ct_localizations || window.ct_customizer_localizations)
46
+
?.block_editor_data?.[blockName] || []
47
+
)
48
+
}
49
+