@wordpress/block-editor 9.5.0 → 9.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/block-lock/modal.js +2 -2
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mover/mover-description.js +95 -32
- package/build/components/block-mover/mover-description.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +1 -1
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-styles/preview.native.js +1 -3
- package/build/components/block-styles/preview.native.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +1 -7
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +4 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-types-list/index.native.js +65 -23
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/colors-gradients/control.js +1 -0
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +5 -2
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/image-editor/cropper.js +4 -3
- package/build/components/image-editor/cropper.js.map +1 -1
- package/build/components/image-editor/index.js +3 -1
- package/build/components/image-editor/index.js.map +1 -1
- package/build/components/inserter/block-types-tab.native.js +30 -16
- package/build/components/inserter/block-types-tab.native.js.map +1 -1
- package/build/components/inserter/preview-panel.js +8 -8
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js +5 -1
- package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build/components/inserter/search-results.native.js +5 -2
- package/build/components/inserter/search-results.native.js.map +1 -1
- package/build/components/inserter/utils.native.js +21 -0
- package/build/components/inserter/utils.native.js.map +1 -1
- package/build/components/inserter-list-item/index.js +5 -1
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/list-view/branch.js +1 -7
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/observe-typing/index.js +22 -8
- package/build/components/observe-typing/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +61 -12
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/index.js +2 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-format-types.js +36 -16
- package/build/components/rich-text/use-format-types.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +1 -1
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/layout.js +14 -2
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/style.js +41 -31
- package/build/hooks/style.js.map +1 -1
- package/build/layouts/flow.js +26 -3
- package/build/layouts/flow.js.map +1 -1
- package/build-module/components/block-lock/modal.js +2 -2
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +2 -2
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-mover/mover-description.js +97 -33
- package/build-module/components/block-mover/mover-description.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +2 -2
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/preview.native.js +2 -3
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +1 -7
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +4 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +67 -25
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +1 -0
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +6 -3
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/image-editor/cropper.js +4 -3
- package/build-module/components/image-editor/cropper.js.map +1 -1
- package/build-module/components/image-editor/index.js +3 -1
- package/build-module/components/image-editor/index.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.native.js +31 -15
- package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +9 -9
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js +6 -2
- package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build-module/components/inserter/search-results.native.js +6 -3
- package/build-module/components/inserter/search-results.native.js.map +1 -1
- package/build-module/components/inserter/utils.native.js +19 -0
- package/build-module/components/inserter/utils.native.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +4 -1
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/list-view/branch.js +1 -6
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/observe-typing/index.js +22 -8
- package/build-module/components/observe-typing/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +58 -12
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/index.js +2 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-format-types.js +37 -18
- package/build-module/components/rich-text/use-format-types.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/layout.js +14 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/style.js +44 -35
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/layouts/flow.js +25 -3
- package/build-module/layouts/flow.js.map +1 -1
- package/build-style/style-rtl.css +2 -2
- package/build-style/style.css +2 -2
- package/package.json +28 -28
- package/src/components/block-lock/modal.js +5 -5
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +3 -3
- package/src/components/block-mover/mover-description.js +131 -48
- package/src/components/block-mover/test/mover-description.js +55 -3
- package/src/components/block-settings-menu-controls/index.js +2 -2
- package/src/components/block-styles/preview.native.js +2 -2
- package/src/components/block-tools/block-selection-button.js +0 -5
- package/src/components/block-tools/index.js +4 -1
- package/src/components/block-types-list/index.native.js +76 -24
- package/src/components/block-types-list/style.native.scss +18 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +0 -4
- package/src/components/colors/test/__snapshots__/with-colors.js.snap +1 -1
- package/src/components/colors/test/with-colors.js +1 -1
- package/src/components/colors-gradients/control.js +1 -0
- package/src/components/colors-gradients/dropdown.js +8 -2
- package/src/components/colors-gradients/style.scss +7 -8
- package/src/components/image-editor/cropper.js +9 -3
- package/src/components/image-editor/index.js +2 -0
- package/src/components/inserter/block-types-tab.native.js +42 -21
- package/src/components/inserter/preview-panel.js +6 -14
- package/src/components/inserter/reusable-blocks-tab.native.js +4 -2
- package/src/components/inserter/search-results.native.js +4 -2
- package/src/components/inserter/test/block-types-tab.native.js +2 -0
- package/src/components/inserter/test/utils.native.js +37 -0
- package/src/components/inserter/utils.native.js +11 -0
- package/src/components/inserter-list-item/index.js +4 -1
- package/src/components/list-view/branch.js +1 -6
- package/src/components/observe-typing/index.js +17 -14
- package/src/components/rich-text/format-toolbar-container.js +63 -14
- package/src/components/rich-text/index.js +1 -0
- package/src/components/rich-text/use-format-types.js +38 -17
- package/src/components/writing-flow/use-tab-nav.js +1 -1
- package/src/hooks/layout.js +14 -3
- package/src/hooks/style.js +46 -39
- package/src/layouts/flow.js +23 -1
|
@@ -4,13 +4,14 @@ import { createElement } from "@wordpress/element";
|
|
|
4
4
|
/**
|
|
5
5
|
* External dependencies
|
|
6
6
|
*/
|
|
7
|
-
import { Dimensions, FlatList, StyleSheet, TouchableWithoutFeedback, View } from 'react-native';
|
|
7
|
+
import { Dimensions, FlatList, SectionList, StyleSheet, Text, TouchableWithoutFeedback, View } from 'react-native';
|
|
8
8
|
/**
|
|
9
9
|
* WordPress dependencies
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { useState, useEffect } from '@wordpress/element';
|
|
13
|
-
import { BottomSheet, InserterButton } from '@wordpress/components';
|
|
13
|
+
import { BottomSheet, Gradient, InserterButton } from '@wordpress/components';
|
|
14
|
+
import { usePreferredColorScheme, usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
14
15
|
/**
|
|
15
16
|
* Internal dependencies
|
|
16
17
|
*/
|
|
@@ -20,7 +21,7 @@ const MIN_COL_NUM = 3;
|
|
|
20
21
|
export default function BlockTypesList(_ref) {
|
|
21
22
|
let {
|
|
22
23
|
name,
|
|
23
|
-
|
|
24
|
+
sections,
|
|
24
25
|
onSelect,
|
|
25
26
|
listProps,
|
|
26
27
|
initialNumToRender = 3
|
|
@@ -65,32 +66,73 @@ export default function BlockTypesList(_ref) {
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
const contentContainerStyle = StyleSheet.flatten(listProps.contentContainerStyle);
|
|
68
|
-
|
|
69
|
+
|
|
70
|
+
const renderSection = _ref2 => {
|
|
71
|
+
let {
|
|
72
|
+
item
|
|
73
|
+
} = _ref2;
|
|
74
|
+
return createElement(TouchableWithoutFeedback, {
|
|
75
|
+
accessible: false
|
|
76
|
+
}, createElement(FlatList, {
|
|
77
|
+
data: item.list,
|
|
78
|
+
key: `InserterUI-${name}-${numberOfColumns}` // Re-render when numberOfColumns changes.
|
|
79
|
+
,
|
|
80
|
+
numColumns: numberOfColumns,
|
|
81
|
+
ItemSeparatorComponent: () => createElement(TouchableWithoutFeedback, {
|
|
82
|
+
accessible: false
|
|
83
|
+
}, createElement(View, {
|
|
84
|
+
style: styles['block-types-list__row-separator']
|
|
85
|
+
})),
|
|
86
|
+
scrollEnabled: false,
|
|
87
|
+
renderItem: renderListItem
|
|
88
|
+
}));
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const renderListItem = _ref3 => {
|
|
92
|
+
let {
|
|
93
|
+
item
|
|
94
|
+
} = _ref3;
|
|
95
|
+
return createElement(InserterButton, {
|
|
96
|
+
item: item,
|
|
97
|
+
itemWidth: itemWidth,
|
|
98
|
+
maxWidth: maxWidth,
|
|
99
|
+
onSelect: onSelect
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const colorScheme = usePreferredColorScheme();
|
|
104
|
+
const sectionHeaderGradientValue = colorScheme === 'light' ? 'linear-gradient(#fff 70%, rgba(255, 255, 255, 0))' : 'linear-gradient(#2e2e2e 70%, rgba(46, 46, 46, 0))';
|
|
105
|
+
const sectionHeaderTitleStyles = usePreferredColorSchemeStyle(styles['block-types-list__section-header-title'], styles['block-types-list__section-header-title--dark']);
|
|
106
|
+
|
|
107
|
+
const renderSectionHeader = _ref4 => {
|
|
108
|
+
let {
|
|
109
|
+
section: {
|
|
110
|
+
metadata
|
|
111
|
+
}
|
|
112
|
+
} = _ref4;
|
|
113
|
+
|
|
114
|
+
if (!(metadata !== null && metadata !== void 0 && metadata.icon) || !(metadata !== null && metadata !== void 0 && metadata.title)) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return createElement(TouchableWithoutFeedback, {
|
|
119
|
+
accessible: false
|
|
120
|
+
}, createElement(Gradient, {
|
|
121
|
+
gradientValue: sectionHeaderGradientValue,
|
|
122
|
+
style: styles['block-types-list__section-header']
|
|
123
|
+
}, metadata === null || metadata === void 0 ? void 0 : metadata.icon, createElement(Text, {
|
|
124
|
+
style: sectionHeaderTitleStyles
|
|
125
|
+
}, metadata === null || metadata === void 0 ? void 0 : metadata.title)));
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
return createElement(SectionList, _extends({
|
|
69
129
|
onLayout: onLayout,
|
|
70
|
-
key: `InserterUI-${name}-${numberOfColumns}` // Re-render when numberOfColumns changes.
|
|
71
|
-
,
|
|
72
130
|
testID: `InserterUI-${name}`,
|
|
73
131
|
keyboardShouldPersistTaps: "always",
|
|
74
|
-
|
|
75
|
-
data: items,
|
|
132
|
+
sections: sections,
|
|
76
133
|
initialNumToRender: initialNumToRender,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}, createElement(View, {
|
|
80
|
-
style: styles['block-types-list__row-separator']
|
|
81
|
-
})),
|
|
82
|
-
keyExtractor: item => item.id,
|
|
83
|
-
renderItem: _ref2 => {
|
|
84
|
-
let {
|
|
85
|
-
item
|
|
86
|
-
} = _ref2;
|
|
87
|
-
return createElement(InserterButton, {
|
|
88
|
-
item,
|
|
89
|
-
itemWidth,
|
|
90
|
-
maxWidth,
|
|
91
|
-
onSelect
|
|
92
|
-
});
|
|
93
|
-
}
|
|
134
|
+
renderItem: renderSection,
|
|
135
|
+
renderSectionHeader: renderSectionHeader
|
|
94
136
|
}, listProps, {
|
|
95
137
|
contentContainerStyle: { ...contentContainerStyle,
|
|
96
138
|
paddingBottom: Math.max(listProps.safeAreaBottomInset, contentContainerStyle.paddingBottom)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-types-list/index.native.js"],"names":["Dimensions","FlatList","StyleSheet","TouchableWithoutFeedback","View","useState","useEffect","BottomSheet","InserterButton","styles","MIN_COL_NUM","BlockTypesList","name","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-types-list/index.native.js"],"names":["Dimensions","FlatList","SectionList","StyleSheet","Text","TouchableWithoutFeedback","View","useState","useEffect","BottomSheet","Gradient","InserterButton","usePreferredColorScheme","usePreferredColorSchemeStyle","styles","MIN_COL_NUM","BlockTypesList","name","sections","onSelect","listProps","initialNumToRender","numberOfColumns","setNumberOfColumns","itemWidth","setItemWidth","maxWidth","setMaxWidth","dimensionsChangeSubscription","addEventListener","onLayout","remove","calculateItemWidth","paddingLeft","itemPaddingLeft","paddingRight","itemPaddingRight","Styles","modalItem","width","modalIconWrapper","columnStyle","sumLeftRightPadding","bottomSheetWidth","getWidth","containerTotalWidth","itemTotalWidth","columnsFitToWidth","Math","floor","numColumns","max","updatedItemWidth","contentContainerStyle","flatten","renderSection","item","list","renderListItem","colorScheme","sectionHeaderGradientValue","sectionHeaderTitleStyles","renderSectionHeader","section","metadata","icon","title","paddingBottom","safeAreaBottomInset"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,UADD,EAECC,QAFD,EAGCC,WAHD,EAICC,UAJD,EAKCC,IALD,EAMCC,wBAND,EAOCC,IAPD,QAQO,cARP;AAUA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SAASC,WAAT,EAAsBC,QAAtB,EAAgCC,cAAhC,QAAsD,uBAAtD;AACA,SACCC,uBADD,EAECC,4BAFD,QAGO,oBAHP;AAKA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AAEA,MAAMC,WAAW,GAAG,CAApB;AAEA,eAAe,SAASC,cAAT,OAMX;AAAA,MANoC;AACvCC,IAAAA,IADuC;AAEvCC,IAAAA,QAFuC;AAGvCC,IAAAA,QAHuC;AAIvCC,IAAAA,SAJuC;AAKvCC,IAAAA,kBAAkB,GAAG;AALkB,GAMpC;AACH,QAAM,CAAEC,eAAF,EAAmBC,kBAAnB,IAA0ChB,QAAQ,CAAEQ,WAAF,CAAxD;AACA,QAAM,CAAES,SAAF,EAAaC,YAAb,IAA8BlB,QAAQ,EAA5C;AACA,QAAM,CAAEmB,QAAF,EAAYC,WAAZ,IAA4BpB,QAAQ,EAA1C;AAEAC,EAAAA,SAAS,CAAE,MAAM;AAChB,UAAMoB,4BAA4B,GAAG5B,UAAU,CAAC6B,gBAAX,CACpC,QADoC,EAEpCC,QAFoC,CAArC;AAIAA,IAAAA,QAAQ;AACR,WAAO,MAAM;AACZF,MAAAA,4BAA4B,CAACG,MAA7B;AACA,KAFD;AAGA,GATQ,EASN,EATM,CAAT;;AAWA,WAASC,kBAAT,GAA8B;AAC7B,UAAM;AAAEC,MAAAA,WAAW,EAAEC,eAAf;AAAgCC,MAAAA,YAAY,EAAEC;AAA9C,QACLzB,cAAc,CAAC0B,MAAf,CAAsBC,SAD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AEC,IAJb,EAKC,cAAC,IAAD;AAAM,MAAA,KAAK,EAAGJ;AAAd,OACGG,QADH,aACGA,QADH,uBACGA,QAAQ,CAAEE,KADb,CALD,CADD,CADD;AAaA,GAlBD;;AAoBA,SACC,cAAC,WAAD;AACC,IAAA,QAAQ,EAAGpC,QADZ;AAEC,IAAA,MAAM,EAAI,cAAcb,IAAM,EAF/B;AAGC,IAAA,yBAAyB,EAAC,QAH3B;AAIC,IAAA,QAAQ,EAAGC,QAJZ;AAKC,IAAA,kBAAkB,EAAGG,kBALtB;AAMC,IAAA,UAAU,EAAGkC,aANd;AAOC,IAAA,mBAAmB,EAAGO;AAPvB,KAQM1C,SARN;AASC,IAAA,qBAAqB,EAAG,EACvB,GAAGiC,qBADoB;AAEvBc,MAAAA,aAAa,EAAEnB,IAAI,CAACG,GAAL,CACd/B,SAAS,CAACgD,mBADI,EAEdf,qBAAqB,CAACc,aAFR;AAFQ;AATzB,KADD;AAmBA","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tDimensions,\n\tFlatList,\n\tSectionList,\n\tStyleSheet,\n\tText,\n\tTouchableWithoutFeedback,\n\tView,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useEffect } from '@wordpress/element';\nimport { BottomSheet, Gradient, InserterButton } from '@wordpress/components';\nimport {\n\tusePreferredColorScheme,\n\tusePreferredColorSchemeStyle,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nconst MIN_COL_NUM = 3;\n\nexport default function BlockTypesList( {\n\tname,\n\tsections,\n\tonSelect,\n\tlistProps,\n\tinitialNumToRender = 3,\n} ) {\n\tconst [ numberOfColumns, setNumberOfColumns ] = useState( MIN_COL_NUM );\n\tconst [ itemWidth, setItemWidth ] = useState();\n\tconst [ maxWidth, setMaxWidth ] = useState();\n\n\tuseEffect( () => {\n\t\tconst dimensionsChangeSubscription = Dimensions.addEventListener(\n\t\t\t'change',\n\t\t\tonLayout\n\t\t);\n\t\tonLayout();\n\t\treturn () => {\n\t\t\tdimensionsChangeSubscription.remove();\n\t\t};\n\t}, [] );\n\n\tfunction calculateItemWidth() {\n\t\tconst { paddingLeft: itemPaddingLeft, paddingRight: itemPaddingRight } =\n\t\t\tInserterButton.Styles.modalItem;\n\t\tconst { width } = InserterButton.Styles.modalIconWrapper;\n\t\treturn width + itemPaddingLeft + itemPaddingRight;\n\t}\n\n\tfunction onLayout() {\n\t\tconst columnStyle = styles[ 'block-types-list__column' ];\n\t\tconst sumLeftRightPadding =\n\t\t\tcolumnStyle.paddingLeft + columnStyle.paddingRight;\n\n\t\tconst bottomSheetWidth = BottomSheet.getWidth();\n\t\tconst containerTotalWidth = bottomSheetWidth - sumLeftRightPadding;\n\t\tconst itemTotalWidth = calculateItemWidth();\n\n\t\tconst columnsFitToWidth = Math.floor(\n\t\t\tcontainerTotalWidth / itemTotalWidth\n\t\t);\n\n\t\tconst numColumns = Math.max( MIN_COL_NUM, columnsFitToWidth );\n\n\t\tsetNumberOfColumns( numColumns );\n\t\tsetMaxWidth( containerTotalWidth / numColumns );\n\n\t\tif ( columnsFitToWidth < MIN_COL_NUM ) {\n\t\t\tconst updatedItemWidth =\n\t\t\t\t( bottomSheetWidth - 2 * sumLeftRightPadding ) / MIN_COL_NUM;\n\t\t\tsetItemWidth( updatedItemWidth );\n\t\t}\n\t}\n\n\tconst contentContainerStyle = StyleSheet.flatten(\n\t\tlistProps.contentContainerStyle\n\t);\n\n\tconst renderSection = ( { item } ) => {\n\t\treturn (\n\t\t\t<TouchableWithoutFeedback accessible={ false }>\n\t\t\t\t<FlatList\n\t\t\t\t\tdata={ item.list }\n\t\t\t\t\tkey={ `InserterUI-${ name }-${ numberOfColumns }` } // Re-render when numberOfColumns changes.\n\t\t\t\t\tnumColumns={ numberOfColumns }\n\t\t\t\t\tItemSeparatorComponent={ () => (\n\t\t\t\t\t\t<TouchableWithoutFeedback accessible={ false }>\n\t\t\t\t\t\t\t<View\n\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\tstyles[ 'block-types-list__row-separator' ]\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</TouchableWithoutFeedback>\n\t\t\t\t\t) }\n\t\t\t\t\tscrollEnabled={ false }\n\t\t\t\t\trenderItem={ renderListItem }\n\t\t\t\t/>\n\t\t\t</TouchableWithoutFeedback>\n\t\t);\n\t};\n\n\tconst renderListItem = ( { item } ) => {\n\t\treturn (\n\t\t\t<InserterButton\n\t\t\t\titem={ item }\n\t\t\t\titemWidth={ itemWidth }\n\t\t\t\tmaxWidth={ maxWidth }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t/>\n\t\t);\n\t};\n\n\tconst colorScheme = usePreferredColorScheme();\n\tconst sectionHeaderGradientValue =\n\t\tcolorScheme === 'light'\n\t\t\t? 'linear-gradient(#fff 70%, rgba(255, 255, 255, 0))'\n\t\t\t: 'linear-gradient(#2e2e2e 70%, rgba(46, 46, 46, 0))';\n\tconst sectionHeaderTitleStyles = usePreferredColorSchemeStyle(\n\t\tstyles[ 'block-types-list__section-header-title' ],\n\t\tstyles[ 'block-types-list__section-header-title--dark' ]\n\t);\n\n\tconst renderSectionHeader = ( { section: { metadata } } ) => {\n\t\tif ( ! metadata?.icon || ! metadata?.title ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<TouchableWithoutFeedback accessible={ false }>\n\t\t\t\t<Gradient\n\t\t\t\t\tgradientValue={ sectionHeaderGradientValue }\n\t\t\t\t\tstyle={ styles[ 'block-types-list__section-header' ] }\n\t\t\t\t>\n\t\t\t\t\t{ metadata?.icon }\n\t\t\t\t\t<Text style={ sectionHeaderTitleStyles }>\n\t\t\t\t\t\t{ metadata?.title }\n\t\t\t\t\t</Text>\n\t\t\t\t</Gradient>\n\t\t\t</TouchableWithoutFeedback>\n\t\t);\n\t};\n\n\treturn (\n\t\t<SectionList\n\t\t\tonLayout={ onLayout }\n\t\t\ttestID={ `InserterUI-${ name }` }\n\t\t\tkeyboardShouldPersistTaps=\"always\"\n\t\t\tsections={ sections }\n\t\t\tinitialNumToRender={ initialNumToRender }\n\t\t\trenderItem={ renderSection }\n\t\t\trenderSectionHeader={ renderSectionHeader }\n\t\t\t{ ...listProps }\n\t\t\tcontentContainerStyle={ {\n\t\t\t\t...contentContainerStyle,\n\t\t\t\tpaddingBottom: Math.max(\n\t\t\t\t\tlistProps.safeAreaBottomInset,\n\t\t\t\t\tcontentContainerStyle.paddingBottom\n\t\t\t\t),\n\t\t\t} }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -82,6 +82,7 @@ function ColorGradientControlInner(_ref) {
|
|
|
82
82
|
})
|
|
83
83
|
};
|
|
84
84
|
return createElement(BaseControl, {
|
|
85
|
+
__nextHasNoMarginBottom: true,
|
|
85
86
|
className: classnames('block-editor-color-gradient-control', className)
|
|
86
87
|
}, createElement("fieldset", {
|
|
87
88
|
className: "block-editor-color-gradient-control__fieldset"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/colors-gradients/control.js"],"names":["classnames","every","isEmpty","BaseControl","__experimentalVStack","VStack","TabPanel","ColorPalette","GradientPicker","useSetting","colorsAndGradientKeys","TAB_COLOR","name","title","value","TAB_GRADIENT","TABS_SETTINGS","ColorGradientControlInner","colors","gradients","disableCustomColors","disableCustomGradients","__experimentalHasMultipleOrigins","__experimentalIsRenderedInSidebar","className","label","onColorChange","onGradientChange","colorValue","gradientValue","clearable","showTitle","enableAlpha","canChooseAColor","canChooseAGradient","tabPanels","newColor","newGradient","tab","ColorGradientControlSelect","props","colorGradientSettings","ColorGradientControl","key","hasOwnProperty"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,KAAT,EAAgBC,OAAhB,QAA+B,QAA/B;AAEA;AACA;AACA;;AACA,SACCC,WADD,EAECC,oBAAoB,IAAIC,MAFzB,EAGCC,QAHD,EAICC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,GACC,cAAC,YAAD;AACC,MAAA,KAAK,EAAGc,UADT;AAEC,MAAA,QAAQ,EACPM,kBAAkB,GACbE,QAAF,IAAgB;AAChBV,QAAAA,aAAa,CAAEU,QAAF,CAAb;AACAT,QAAAA,gBAAgB;AACf,OAJc,GAKfD,aARL;AAUQR,MAAAA,MAVR;AAUgBE,MAAAA,mBAVhB;AAWC,MAAA,gCAAgC,EAC/BE,gCAZF;AAcC,MAAA,iCAAiC,EAChCC,iCAfF;AAiBC,MAAA,SAAS,EAAGO,SAjBb;AAkBC,MAAA,WAAW,EAAGE;AAlBf,MAFgB;AAuBjB,KAAEjB,YAAY,CAACD,KAAf,GACC,cAAC,cAAD;AACC,MAAA,KAAK,EAAGe,aADT;AAEC,MAAA,QAAQ,EACPI,eAAe,GACVI,WAAF,IAAmB;AACnBV,QAAAA,gBAAgB,CAAEU,WAAF,CAAhB;AACAX,QAAAA,aAAa;AACZ,OAJW,GAKZC,gBARL;AAUQR,MAAAA,SAVR;AAUmBE,MAAAA,sBAVnB;AAWC,MAAA,gCAAgC,EAC/BC,gCAZF;AAcC,MAAA,iCAAiC,EAChCC,iCAfF;AAiBC,MAAA,SAAS,EAAGO;AAjBb;AAxBgB,GAAlB;AA8CA,SACC,cAAC,WAAD;AACC,IAAA,SAAS,EAAG9B,UAAU,CACrB,qCADqB,EAErBwB,SAFqB;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/colors-gradients/control.js"],"names":["classnames","every","isEmpty","BaseControl","__experimentalVStack","VStack","TabPanel","ColorPalette","GradientPicker","useSetting","colorsAndGradientKeys","TAB_COLOR","name","title","value","TAB_GRADIENT","TABS_SETTINGS","ColorGradientControlInner","colors","gradients","disableCustomColors","disableCustomGradients","__experimentalHasMultipleOrigins","__experimentalIsRenderedInSidebar","className","label","onColorChange","onGradientChange","colorValue","gradientValue","clearable","showTitle","enableAlpha","canChooseAColor","canChooseAGradient","tabPanels","newColor","newGradient","tab","ColorGradientControlSelect","props","colorGrad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;AAED,eAAeE,oBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { every, isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBaseControl,\n\t__experimentalVStack as VStack,\n\tTabPanel,\n\tColorPalette,\n\tGradientPicker,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../use-setting';\n\nconst colorsAndGradientKeys = [\n\t'colors',\n\t'disableCustomColors',\n\t'gradients',\n\t'disableCustomGradients',\n];\n\nconst TAB_COLOR = {\n\tname: 'color',\n\ttitle: 'Solid color',\n\tvalue: 'color',\n};\nconst TAB_GRADIENT = {\n\tname: 'gradient',\n\ttitle: 'Gradient',\n\tvalue: 'gradient',\n};\n\nconst TABS_SETTINGS = [ TAB_COLOR, TAB_GRADIENT ];\n\nfunction ColorGradientControlInner( {\n\tcolors,\n\tgradients,\n\tdisableCustomColors,\n\tdisableCustomGradients,\n\t__experimentalHasMultipleOrigins,\n\t__experimentalIsRenderedInSidebar,\n\tclassName,\n\tlabel,\n\tonColorChange,\n\tonGradientChange,\n\tcolorValue,\n\tgradientValue,\n\tclearable,\n\tshowTitle = true,\n\tenableAlpha,\n} ) {\n\tconst canChooseAColor =\n\t\tonColorChange && ( ! isEmpty( colors ) || ! disableCustomColors );\n\tconst canChooseAGradient =\n\t\tonGradientChange &&\n\t\t( ! isEmpty( gradients ) || ! disableCustomGradients );\n\n\tif ( ! canChooseAColor && ! canChooseAGradient ) {\n\t\treturn null;\n\t}\n\n\tconst tabPanels = {\n\t\t[ TAB_COLOR.value ]: (\n\t\t\t<ColorPalette\n\t\t\t\tvalue={ colorValue }\n\t\t\t\tonChange={\n\t\t\t\t\tcanChooseAGradient\n\t\t\t\t\t\t? ( newColor ) => {\n\t\t\t\t\t\t\t\tonColorChange( newColor );\n\t\t\t\t\t\t\t\tonGradientChange();\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: onColorChange\n\t\t\t\t}\n\t\t\t\t{ ...{ colors, disableCustomColors } }\n\t\t\t\t__experimentalHasMultipleOrigins={\n\t\t\t\t\t__experimentalHasMultipleOrigins\n\t\t\t\t}\n\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t}\n\t\t\t\tclearable={ clearable }\n\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t/>\n\t\t),\n\t\t[ TAB_GRADIENT.value ]: (\n\t\t\t<GradientPicker\n\t\t\t\tvalue={ gradientValue }\n\t\t\t\tonChange={\n\t\t\t\t\tcanChooseAColor\n\t\t\t\t\t\t? ( newGradient ) => {\n\t\t\t\t\t\t\t\tonGradientChange( newGradient );\n\t\t\t\t\t\t\t\tonColorChange();\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: onGradientChange\n\t\t\t\t}\n\t\t\t\t{ ...{ gradients, disableCustomGradients } }\n\t\t\t\t__experimentalHasMultipleOrigins={\n\t\t\t\t\t__experimentalHasMultipleOrigins\n\t\t\t\t}\n\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t}\n\t\t\t\tclearable={ clearable }\n\t\t\t/>\n\t\t),\n\t};\n\n\treturn (\n\t\t<BaseControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-color-gradient-control',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t>\n\t\t\t<fieldset className=\"block-editor-color-gradient-control__fieldset\">\n\t\t\t\t<VStack spacing={ 1 }>\n\t\t\t\t\t{ showTitle && (\n\t\t\t\t\t\t<legend>\n\t\t\t\t\t\t\t<div className=\"block-editor-color-gradient-control__color-indicator\">\n\t\t\t\t\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</legend>\n\t\t\t\t\t) }\n\t\t\t\t\t{ canChooseAColor && canChooseAGradient && (\n\t\t\t\t\t\t<TabPanel\n\t\t\t\t\t\t\tclassName=\"block-editor-color-gradient-control__tabs\"\n\t\t\t\t\t\t\ttabs={ TABS_SETTINGS }\n\t\t\t\t\t\t\tinitialTabName={\n\t\t\t\t\t\t\t\tgradientValue\n\t\t\t\t\t\t\t\t\t? TAB_GRADIENT.value\n\t\t\t\t\t\t\t\t\t: !! canChooseAColor && TAB_COLOR.value\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ ( tab ) => (\n\t\t\t\t\t\t\t\t<div className=\"block-editor-color-gradient-control__tab-panel\">\n\t\t\t\t\t\t\t\t\t{ tabPanels[ tab.value ] }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TabPanel>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! canChooseAGradient && tabPanels[ TAB_COLOR.value ] }\n\t\t\t\t\t{ ! canChooseAColor && tabPanels[ TAB_GRADIENT.value ] }\n\t\t\t\t</VStack>\n\t\t\t</fieldset>\n\t\t</BaseControl>\n\t);\n}\n\nfunction ColorGradientControlSelect( props ) {\n\tconst colorGradientSettings = {};\n\tcolorGradientSettings.colors = useSetting( 'color.palette' );\n\tcolorGradientSettings.gradients = useSetting( 'color.gradients' );\n\tcolorGradientSettings.disableCustomColors = ! useSetting( 'color.custom' );\n\tcolorGradientSettings.disableCustomGradients = ! useSetting(\n\t\t'color.customGradient'\n\t);\n\n\treturn (\n\t\t<ColorGradientControlInner\n\t\t\t{ ...{ ...colorGradientSettings, ...props } }\n\t\t/>\n\t);\n}\n\nfunction ColorGradientControl( props ) {\n\tif (\n\t\tevery( colorsAndGradientKeys, ( key ) => props.hasOwnProperty( key ) )\n\t) {\n\t\treturn <ColorGradientControlInner { ...props } />;\n\t}\n\treturn <ColorGradientControlSelect { ...props } />;\n}\n\nexport default ColorGradientControl;\n"]}
|
|
@@ -9,7 +9,7 @@ import classnames from 'classnames';
|
|
|
9
9
|
* WordPress dependencies
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { Button, ColorIndicator, Dropdown, FlexItem, __experimentalHStack as HStack, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
|
|
12
|
+
import { Button, ColorIndicator, Dropdown, FlexItem, __experimentalDropdownContentWrapper as DropdownContentWrapper, __experimentalHStack as HStack, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
|
|
13
13
|
/**
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
@@ -148,9 +148,12 @@ export default function ColorGradientSettingsDropdown(_ref4) {
|
|
|
148
148
|
}, props), createElement(Dropdown, {
|
|
149
149
|
popoverProps: popoverProps,
|
|
150
150
|
className: "block-editor-tools-panel-color-gradient-settings__dropdown",
|
|
151
|
-
contentClassName: "block-editor-panel-color-gradient-settings__dropdown-content",
|
|
152
151
|
renderToggle: renderToggle(toggleSettings),
|
|
153
|
-
renderContent: () => createElement(
|
|
152
|
+
renderContent: () => createElement(DropdownContentWrapper, {
|
|
153
|
+
paddingSize: "medium"
|
|
154
|
+
}, createElement("div", {
|
|
155
|
+
className: "block-editor-panel-color-gradient-settings__dropdown-content"
|
|
156
|
+
}, createElement(ColorGradientControl, controlProps)))
|
|
154
157
|
}));
|
|
155
158
|
}));
|
|
156
159
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/colors-gradients/dropdown.js"],"names":["classnames","Button","ColorIndicator","Dropdown","FlexItem","__experimentalHStack","HStack","__experimentalToolsPanelItem","ToolsPanelItem","ColorGradientControl","WithToolsPanelItem","setting","children","panelId","props","clearValue","colorValue","onColorChange","gradientValue","onGradientChange","label","isShownByDefault","undefined","resetAllFilter","LabeledColorIndicator","renderToggle","settings","onToggle","isOpen","toggleProps","onClick","className","ColorGradientSettingsDropdown","colors","disableCustomColors","disableCustomGradients","enableAlpha","gradients","__experimentalHasMultipleOrigins","__experimentalIsRenderedInSidebar","popoverProps","placement","offset","__unstableShift","map","index","controlProps","clearable","showTitle","toggleSettings"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,MADD,EAECC,cAFD,EAGCC,QAHD,EAICC,QAJD,EAKCC,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/colors-gradients/dropdown.js"],"names":["classnames","Button","ColorIndicator","Dropdown","FlexItem","__experimentalDropdownContentWrapper","DropdownContentWrapper","__experimentalHStack","HStack","__experimentalToolsPanelItem","ToolsPanelItem","ColorGradientControl","WithToolsPanelItem","setting","children","panelId","props","clearValue","colorValue","onColorChange","gradientValue","onGradientChange","label","isShownByDefault","undefined","resetAllFilter","LabeledColorIndicator","renderToggle","settings","onToggle","isOpen","toggleProps","onClick","className","ColorGradientSettingsDropdown","colors","disableCustomColors","disableCustomGradients","enableAlpha","gradients","__experimentalHasMultipleOrigins","__experimentalIsRenderedInSidebar","popoverProps","placement","offset","__unstableShift","map","index","controlProps","clearable","showTitle","toggleSettings"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,MADD,EAECC,cAFD,EAGCC,QAHD,EAICC,QAJD,EAKCC,oCAAoC,IAAIC,sBALzC,EAMCC,oBAAoB,IAAIC,MANzB,EAOCC,4BAA4B,IAAIC,cAPjC,QAQO,uBARP;AAUA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,WAAjC,C,CAEA;AACA;;AACA,MAAMC,kBAAkB,GAAG,QAAgD;AAAA,MAA9C;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,QAAX;AAAqBC,IAAAA,OAArB;AAA8B,OAAGC;AAAjC,GAA8C;;AAC1E,QAAMC,UAAU,GAAG,MAAM;AACxB,QAAKJ,OAAO,CAACK,UAAb,EAA0B;AACzBL,MAAAA,OAAO,CAACM,aAAR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KAArB;AAiBA,UAAMsC,cAAc,GAAG;AACtBjC,MAAAA,UAAU,2BAAEL,OAAO,CAACO,aAAV,yEAA2BP,OAAO,CAACK,UADvB;AAEtBI,MAAAA,KAAK,EAAET,OAAO,CAACS;AAFO,KAAvB;AAKA,WACCT,OAAO,IACN;AACA;AACA,kBAAC,kBAAD;AACC,MAAA,GAAG,EAAGkC,KADP;AAEC,MAAA,OAAO,EAAGlC;AAFX,OAGMG,KAHN,GAKC,cAAC,QAAD;AACC,MAAA,YAAY,EAAG0B,YADhB;AAEC,MAAA,SAAS,EAAC,4DAFX;AAGC,MAAA,YAAY,EAAGf,YAAY,CAAEwB,cAAF,CAH5B;AAIC,MAAA,aAAa,EAAG,MACf,cAAC,sBAAD;AAAwB,QAAA,WAAW,EAAC;AAApC,SACC;AAAK,QAAA,SAAS,EAAC;AAAf,SACC,cAAC,oBAAD,EACMH,YADN,CADD,CADD;AALF,MALD,CAJF;AA0BA,GAjDC,CADH,CADD;AAsDA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tColorIndicator,\n\tDropdown,\n\tFlexItem,\n\t__experimentalDropdownContentWrapper as DropdownContentWrapper,\n\t__experimentalHStack as HStack,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport ColorGradientControl from './control';\n\n// When the `ColorGradientSettingsDropdown` controls are being rendered to a\n// `ToolsPanel` they must be wrapped in a `ToolsPanelItem`.\nconst WithToolsPanelItem = ( { setting, children, panelId, ...props } ) => {\n\tconst clearValue = () => {\n\t\tif ( setting.colorValue ) {\n\t\t\tsetting.onColorChange();\n\t\t} else if ( setting.gradientValue ) {\n\t\t\tsetting.onGradientChange();\n\t\t}\n\t};\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\thasValue={ () => {\n\t\t\t\treturn !! setting.colorValue || !! setting.gradientValue;\n\t\t\t} }\n\t\t\tlabel={ setting.label }\n\t\t\tonDeselect={ clearValue }\n\t\t\tisShownByDefault={\n\t\t\t\tsetting.isShownByDefault !== undefined\n\t\t\t\t\t? setting.isShownByDefault\n\t\t\t\t\t: true\n\t\t\t}\n\t\t\t{ ...props }\n\t\t\tclassName=\"block-editor-tools-panel-color-gradient-settings__item\"\n\t\t\tpanelId={ panelId }\n\t\t\t// Pass resetAllFilter if supplied due to rendering via SlotFill\n\t\t\t// into parent ToolsPanel.\n\t\t\tresetAllFilter={ setting.resetAllFilter }\n\t\t>\n\t\t\t{ children }\n\t\t</ToolsPanelItem>\n\t);\n};\n\nconst LabeledColorIndicator = ( { colorValue, label } ) => (\n\t<HStack justify=\"flex-start\">\n\t\t<ColorIndicator\n\t\t\tclassName=\"block-editor-panel-color-gradient-settings__color-indicator\"\n\t\t\tcolorValue={ colorValue }\n\t\t/>\n\t\t<FlexItem>{ label }</FlexItem>\n\t</HStack>\n);\n\n// Renders a color dropdown's toggle as an `Item` if it is within an `ItemGroup`\n// or as a `Button` if it isn't e.g. the controls are being rendered in\n// a `ToolsPanel`.\nconst renderToggle =\n\t( settings ) =>\n\t( { onToggle, isOpen } ) => {\n\t\tconst { colorValue, label } = settings;\n\n\t\tconst toggleProps = {\n\t\t\tonClick: onToggle,\n\t\t\tclassName: classnames(\n\t\t\t\t'block-editor-panel-color-gradient-settings__dropdown',\n\t\t\t\t{ 'is-open': isOpen }\n\t\t\t),\n\t\t\t'aria-expanded': isOpen,\n\t\t};\n\n\t\treturn (\n\t\t\t<Button { ...toggleProps }>\n\t\t\t\t<LabeledColorIndicator\n\t\t\t\t\tcolorValue={ colorValue }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t/>\n\t\t\t</Button>\n\t\t);\n\t};\n\n// Renders a collection of color controls as dropdowns. Depending upon the\n// context in which these dropdowns are being rendered, they may be wrapped\n// in an `ItemGroup` with each dropdown's toggle as an `Item`, or alternatively,\n// the may be individually wrapped in a `ToolsPanelItem` with the toggle as\n// a regular `Button`.\n//\n// For more context see: https://github.com/WordPress/gutenberg/pull/40084\nexport default function ColorGradientSettingsDropdown( {\n\tcolors,\n\tdisableCustomColors,\n\tdisableCustomGradients,\n\tenableAlpha,\n\tgradients,\n\tsettings,\n\t__experimentalHasMultipleOrigins,\n\t__experimentalIsRenderedInSidebar,\n\t...props\n} ) {\n\tlet popoverProps;\n\tif ( __experimentalIsRenderedInSidebar ) {\n\t\tpopoverProps = {\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\t__unstableShift: true,\n\t\t};\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ settings.map( ( setting, index ) => {\n\t\t\t\tconst controlProps = {\n\t\t\t\t\tclearable: false,\n\t\t\t\t\tcolorValue: setting.colorValue,\n\t\t\t\t\tcolors,\n\t\t\t\t\tdisableCustomColors,\n\t\t\t\t\tdisableCustomGradients,\n\t\t\t\t\tenableAlpha,\n\t\t\t\t\tgradientValue: setting.gradientValue,\n\t\t\t\t\tgradients,\n\t\t\t\t\tlabel: setting.label,\n\t\t\t\t\tonColorChange: setting.onColorChange,\n\t\t\t\t\tonGradientChange: setting.onGradientChange,\n\t\t\t\t\tshowTitle: false,\n\t\t\t\t\t__experimentalHasMultipleOrigins,\n\t\t\t\t\t__experimentalIsRenderedInSidebar,\n\t\t\t\t\t...setting,\n\t\t\t\t};\n\t\t\t\tconst toggleSettings = {\n\t\t\t\t\tcolorValue: setting.gradientValue ?? setting.colorValue,\n\t\t\t\t\tlabel: setting.label,\n\t\t\t\t};\n\n\t\t\t\treturn (\n\t\t\t\t\tsetting && (\n\t\t\t\t\t\t// If not in an `ItemGroup` wrap the dropdown in a\n\t\t\t\t\t\t// `ToolsPanelItem`\n\t\t\t\t\t\t<WithToolsPanelItem\n\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\tsetting={ setting }\n\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-tools-panel-color-gradient-settings__dropdown\"\n\t\t\t\t\t\t\t\trenderToggle={ renderToggle( toggleSettings ) }\n\t\t\t\t\t\t\t\trenderContent={ () => (\n\t\t\t\t\t\t\t\t\t<DropdownContentWrapper paddingSize=\"medium\">\n\t\t\t\t\t\t\t\t\t\t<div className=\"block-editor-panel-color-gradient-settings__dropdown-content\">\n\t\t\t\t\t\t\t\t\t\t\t<ColorGradientControl\n\t\t\t\t\t\t\t\t\t\t\t\t{ ...controlProps }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</DropdownContentWrapper>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</WithToolsPanelItem>\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -23,7 +23,8 @@ export default function ImageCropper(_ref) {
|
|
|
23
23
|
height,
|
|
24
24
|
clientWidth,
|
|
25
25
|
naturalHeight,
|
|
26
|
-
naturalWidth
|
|
26
|
+
naturalWidth,
|
|
27
|
+
borderProps
|
|
27
28
|
} = _ref;
|
|
28
29
|
const {
|
|
29
30
|
isInProgress,
|
|
@@ -43,10 +44,10 @@ export default function ImageCropper(_ref) {
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
return createElement("div", {
|
|
46
|
-
className: classnames('wp-block-image__crop-area', {
|
|
47
|
+
className: classnames('wp-block-image__crop-area', borderProps === null || borderProps === void 0 ? void 0 : borderProps.className, {
|
|
47
48
|
'is-applying': isInProgress
|
|
48
49
|
}),
|
|
49
|
-
style: {
|
|
50
|
+
style: { ...(borderProps === null || borderProps === void 0 ? void 0 : borderProps.style),
|
|
50
51
|
width: width || clientWidth,
|
|
51
52
|
height: editedHeight
|
|
52
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/image-editor/cropper.js"],"names":["Cropper","classnames","Spinner","MIN_ZOOM","MAX_ZOOM","useImageEditingContext","ImageCropper","url","width","height","clientWidth","naturalHeight","naturalWidth","isInProgress","editedUrl","position","zoom","aspect","setPosition","setCrop","setZoom","rotation","editedHeight","newCropPercent","newZoom"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,OAAP,MAAoB,iBAApB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,OAAT,QAAwB,uBAAxB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,QAAnB,QAAmC,aAAnC;AAEA,SAASC,sBAAT,QAAuC,WAAvC;AAEA,eAAe,SAASC,YAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/image-editor/cropper.js"],"names":["Cropper","classnames","Spinner","MIN_ZOOM","MAX_ZOOM","useImageEditingContext","ImageCropper","url","width","height","clientWidth","naturalHeight","naturalWidth","borderProps","isInProgress","editedUrl","position","zoom","aspect","setPosition","setCrop","setZoom","rotation","editedHeight","className","style","newCropPercent","newZoom"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,OAAP,MAAoB,iBAApB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,OAAT,QAAwB,uBAAxB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,QAAnB,QAAmC,aAAnC;AAEA,SAASC,sBAAT,QAAuC,WAAvC;AAEA,eAAe,SAASC,YAAT,OAQX;AAAA,MARkC;AACrCC,IAAAA,GADqC;AAErCC,IAAAA,KAFqC;AAGrCC,IAAAA,MAHqC;AAIrCC,IAAAA,WAJqC;AAKrCC,IAAAA,aALqC;AAMrCC,IAAAA,YANqC;AAOrCC,IAAAA;AAPqC,GAQlC;AACH,QAAM;AACLC,IAAAA,YADK;AAELC,IAAAA,SAFK;AAGLC,IAAAA,QAHK;AAILC,IAAA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Content":["/**\n * External dependencies\n */\nimport Cropper from 'react-easy-crop';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Spinner } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { MIN_ZOOM, MAX_ZOOM } from './constants';\n\nimport { useImageEditingContext } from './context';\n\nexport default function ImageCropper( {\n\turl,\n\twidth,\n\theight,\n\tclientWidth,\n\tnaturalHeight,\n\tnaturalWidth,\n\tborderProps,\n} ) {\n\tconst {\n\t\tisInProgress,\n\t\teditedUrl,\n\t\tposition,\n\t\tzoom,\n\t\taspect,\n\t\tsetPosition,\n\t\tsetCrop,\n\t\tsetZoom,\n\t\trotation,\n\t} = useImageEditingContext();\n\n\tlet editedHeight = height || ( clientWidth * naturalHeight ) / naturalWidth;\n\n\tif ( rotation % 180 === 90 ) {\n\t\teditedHeight = ( clientWidth * naturalWidth ) / naturalHeight;\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames(\n\t\t\t\t'wp-block-image__crop-area',\n\t\t\t\tborderProps?.className,\n\t\t\t\t{\n\t\t\t\t\t'is-applying': isInProgress,\n\t\t\t\t}\n\t\t\t) }\n\t\t\tstyle={ {\n\t\t\t\t...borderProps?.style,\n\t\t\t\twidth: width || clientWidth,\n\t\t\t\theight: editedHeight,\n\t\t\t} }\n\t\t>\n\t\t\t<Cropper\n\t\t\t\timage={ editedUrl || url }\n\t\t\t\tdisabled={ isInProgress }\n\t\t\t\tminZoom={ MIN_ZOOM / 100 }\n\t\t\t\tmaxZoom={ MAX_ZOOM / 100 }\n\t\t\t\tcrop={ position }\n\t\t\t\tzoom={ zoom / 100 }\n\t\t\t\taspect={ aspect }\n\t\t\t\tonCropChange={ setPosition }\n\t\t\t\tonCropComplete={ ( newCropPercent ) => {\n\t\t\t\t\tsetCrop( newCropPercent );\n\t\t\t\t} }\n\t\t\t\tonZoomChange={ ( newZoom ) => {\n\t\t\t\t\tsetZoom( newZoom * 100 );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ isInProgress && <Spinner /> }\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -21,9 +21,11 @@ export default function ImageEditor(_ref) {
|
|
|
21
21
|
height,
|
|
22
22
|
clientWidth,
|
|
23
23
|
naturalHeight,
|
|
24
|
-
naturalWidth
|
|
24
|
+
naturalWidth,
|
|
25
|
+
borderProps
|
|
25
26
|
} = _ref;
|
|
26
27
|
return createElement(Fragment, null, createElement(Cropper, {
|
|
28
|
+
borderProps: borderProps,
|
|
27
29
|
url: url,
|
|
28
30
|
width: width,
|
|
29
31
|
height: height,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/image-editor/index.js"],"names":["ToolbarGroup","ToolbarItem","BlockControls","Cropper","ZoomDropdown","AspectRatioDropdown","RotationButton","FormControls","ImageEditor","url","width","height","clientWidth","naturalHeight","naturalWidth","toggleProps","default","ImageEditingProvider"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,YAAT,EAAuBC,WAAvB,QAA0C,uBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,OAAOC,cAAP,MAA2B,mBAA3B;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AAEA,eAAe,SAASC,WAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/image-editor/index.js"],"names":["ToolbarGroup","ToolbarItem","BlockControls","Cropper","ZoomDropdown","AspectRatioDropdown","RotationButton","FormControls","ImageEditor","url","width","height","clientWidth","naturalHeight","naturalWidth","borderProps","toggleProps","default","ImageEditingProvider"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,YAAT,EAAuBC,WAAvB,QAA0C,uBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,OAAOC,cAAP,MAA2B,mBAA3B;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AAEA,eAAe,SAASC,WAAT,OAQX;AAAA,MARiC;AACpCC,IAAAA,GADoC;AAEpCC,IAAAA,KAFoC;AAGpCC,IAAAA,MAHoC;AAIpCC,IAAAA,WAJoC;AAKpCC,IAAAA,aALoC;AAMpCC,IAAAA,YANoC;AAOpCC,IAAAA;AAPoC,GAQjC;AACH,SACC,8BACC,cAAC,OAAD;AACC,IAAA,WAAW,EAAGA,WADf;AAEC,IAAA,GAAG,EAAGN,GAFP;AAGC,IAAA,KAAK,EAAGC,KAHT;AAIC,IAAA,MAAM,EAAGC,MAJV;AAKC,IAAA,WAAW,EAAGC,WALf;AAMC,IAAA,aAAa,EAAGC,aANjB;AAOC,IAAA,YAAY,EAAGC;AAPhB,IADD,EAUC,cAAC,aAAD,QACC,cAAC,YAAD,QACC,cAAC,YAAD,OADD,EAEC,cAAC,WAAD,QACKE,WAAF,IACD,cAAC,mBAAD;AAAqB,IAAA,WAAW,EAAGA;AAAnC,IAFF,CAFD,EAOC,cAAC,cAAD,OAPD,CADD,EAUC,cAAC,YAAD,QACC,cAAC,YAAD,OADD,CAVD,CAVD,CADD;AA2BA;AAED,SAASC,OAAO,IAAIC,oBAApB,QAAgD,WAAhD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ToolbarGroup, ToolbarItem } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockControls from '../block-controls';\nimport Cropper from './cropper';\nimport ZoomDropdown from './zoom-dropdown';\nimport AspectRatioDropdown from './aspect-ratio-dropdown';\nimport RotationButton from './rotation-button';\nimport FormControls from './form-controls';\n\nexport default function ImageEditor( {\n\turl,\n\twidth,\n\theight,\n\tclientWidth,\n\tnaturalHeight,\n\tnaturalWidth,\n\tborderProps,\n} ) {\n\treturn (\n\t\t<>\n\t\t\t<Cropper\n\t\t\t\tborderProps={ borderProps }\n\t\t\t\turl={ url }\n\t\t\t\twidth={ width }\n\t\t\t\theight={ height }\n\t\t\t\tclientWidth={ clientWidth }\n\t\t\t\tnaturalHeight={ naturalHeight }\n\t\t\t\tnaturalWidth={ naturalWidth }\n\t\t\t/>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ZoomDropdown />\n\t\t\t\t\t<ToolbarItem>\n\t\t\t\t\t\t{ ( toggleProps ) => (\n\t\t\t\t\t\t\t<AspectRatioDropdown toggleProps={ toggleProps } />\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToolbarItem>\n\t\t\t\t\t<RotationButton />\n\t\t\t\t</ToolbarGroup>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<FormControls />\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t</>\n\t);\n}\n\nexport { default as ImageEditingProvider } from './context';\n"]}
|
|
@@ -3,16 +3,18 @@ import { createElement } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { useMemo } from '@wordpress/element';
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import BlockTypesList from '../block-types-list';
|
|
12
12
|
import useClipboardBlock from './hooks/use-clipboard-block';
|
|
13
|
-
import { store as blockEditorStore } from '../../store';
|
|
14
13
|
import useBlockTypeImpressions from './hooks/use-block-type-impressions';
|
|
15
|
-
import { filterInserterItems } from './utils';
|
|
14
|
+
import { createInserterSection, filterInserterItems } from './utils';
|
|
15
|
+
import useBlockTypesState from './hooks/use-block-types-state';
|
|
16
|
+
|
|
17
|
+
const getBlockNamespace = item => item.name.split('/')[0];
|
|
16
18
|
|
|
17
19
|
function BlockTypesTab(_ref) {
|
|
18
20
|
let {
|
|
@@ -20,18 +22,10 @@ function BlockTypesTab(_ref) {
|
|
|
20
22
|
rootClientId,
|
|
21
23
|
listProps
|
|
22
24
|
} = _ref;
|
|
25
|
+
const [rawBlockTypes,, collections] = useBlockTypesState(rootClientId, onSelect);
|
|
23
26
|
const clipboardBlock = useClipboardBlock(rootClientId);
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
} = useSelect(select => {
|
|
27
|
-
const {
|
|
28
|
-
getInserterItems
|
|
29
|
-
} = select(blockEditorStore);
|
|
30
|
-
const blockItems = filterInserterItems(getInserterItems(rootClientId));
|
|
31
|
-
return {
|
|
32
|
-
blockTypes: clipboardBlock ? [clipboardBlock, ...blockItems] : blockItems
|
|
33
|
-
};
|
|
34
|
-
}, [rootClientId]);
|
|
27
|
+
const filteredBlockTypes = filterInserterItems(rawBlockTypes);
|
|
28
|
+
const blockTypes = clipboardBlock ? [clipboardBlock, ...filteredBlockTypes] : filteredBlockTypes;
|
|
35
29
|
const {
|
|
36
30
|
items,
|
|
37
31
|
trackBlockTypeSelected
|
|
@@ -42,9 +36,31 @@ function BlockTypesTab(_ref) {
|
|
|
42
36
|
onSelect(...arguments);
|
|
43
37
|
};
|
|
44
38
|
|
|
39
|
+
const collectionSections = useMemo(() => {
|
|
40
|
+
const result = [];
|
|
41
|
+
Object.keys(collections).forEach(namespace => {
|
|
42
|
+
const data = items.filter(item => getBlockNamespace(item) === namespace);
|
|
43
|
+
|
|
44
|
+
if (data.length > 0) {
|
|
45
|
+
result.push(createInserterSection({
|
|
46
|
+
key: `collection-${namespace}`,
|
|
47
|
+
metadata: {
|
|
48
|
+
icon: collections[namespace].icon,
|
|
49
|
+
title: collections[namespace].title
|
|
50
|
+
},
|
|
51
|
+
items: data
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return result;
|
|
56
|
+
}, [items, collections]);
|
|
57
|
+
const sections = [createInserterSection({
|
|
58
|
+
key: 'default',
|
|
59
|
+
items
|
|
60
|
+
}), ...collectionSections];
|
|
45
61
|
return createElement(BlockTypesList, {
|
|
46
62
|
name: "Blocks",
|
|
47
|
-
|
|
63
|
+
sections: sections,
|
|
48
64
|
onSelect: handleSelect,
|
|
49
65
|
listProps: listProps
|
|
50
66
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-types-tab.native.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-types-tab.native.js"],"names":["useMemo","BlockTypesList","useClipboardBlock","useBlockTypeImpressions","createInserterSection","filterInserterItems","useBlockTypesState","getBlockNamespace","item","name","split","BlockTypesTab","onSelect","rootClientId","listProps","rawBlockTypes","collections","clipboardBlock","filteredBlockTypes","blockTypes","items","trackBlockTypeSelected","handleSelect","collectionSections","result","Object","keys","forEach","namespace","data","filter","length","push","key","metadata","icon","title","sections"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,qBAA3B;AACA,OAAOC,iBAAP,MAA8B,6BAA9B;AACA,OAAOC,uBAAP,MAAoC,oCAApC;AACA,SAASC,qBAAT,EAAgCC,mBAAhC,QAA2D,SAA3D;AACA,OAAOC,kBAAP,MAA+B,+BAA/B;;AAEA,MAAMC,iBAAiB,GAAKC,IAAF,IAAYA,IAAI,CAACC,IAAL,CAAUC,KAAV,CAAiB,GAAjB,EAAwB,CAAxB,CAAtC;;AAEA,SAASC,aAAT,OAAgE;AAAA,MAAxC;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,YAAZ;AAA0BC,IAAAA;AAA1B,GAAwC;AAC/D,QAAM,CAAEC,aAAF,GAAmBC,WAAnB,IAAmCV,kBAAkB,CAC1DO,YAD0D,EAE1DD,QAF0D,CAA3D;AAIA,QAAMK,cAAc,GAAGf,iBAAiB,CAAEW,YAAF,CAAxC;AACA,QAAMK,kBAAkB,GAAGb,mBAAmB,CAAEU,aAAF,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,cAAD;AACC,IAAA,IAAI,EAAC,QADN;AAEC,IAAA,QAAQ,EAAGc,QAFZ;AAGC,IAAA,QAAQ,EAAGf,YAHZ;AAIC,IAAA,SAAS,EAAGR;AAJb,IADD;AAQA;;AAED,eAAeH,aAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesList from '../block-types-list';\nimport useClipboardBlock from './hooks/use-clipboard-block';\nimport useBlockTypeImpressions from './hooks/use-block-type-impressions';\nimport { createInserterSection, filterInserterItems } from './utils';\nimport useBlockTypesState from './hooks/use-block-types-state';\n\nconst getBlockNamespace = ( item ) => item.name.split( '/' )[ 0 ];\n\nfunction BlockTypesTab( { onSelect, rootClientId, listProps } ) {\n\tconst [ rawBlockTypes, , collections ] = useBlockTypesState(\n\t\trootClientId,\n\t\tonSelect\n\t);\n\tconst clipboardBlock = useClipboardBlock( rootClientId );\n\tconst filteredBlockTypes = filterInserterItems( rawBlockTypes );\n\tconst blockTypes = clipboardBlock\n\t\t? [ clipboardBlock, ...filteredBlockTypes ]\n\t\t: filteredBlockTypes;\n\tconst { items, trackBlockTypeSelected } =\n\t\tuseBlockTypeImpressions( blockTypes );\n\n\tconst handleSelect = ( ...args ) => {\n\t\ttrackBlockTypeSelected( ...args );\n\t\tonSelect( ...args );\n\t};\n\n\tconst collectionSections = useMemo( () => {\n\t\tconst result = [];\n\t\tObject.keys( collections ).forEach( ( namespace ) => {\n\t\t\tconst data = items.filter(\n\t\t\t\t( item ) => getBlockNamespace( item ) === namespace\n\t\t\t);\n\t\t\tif ( data.length > 0 ) {\n\t\t\t\tresult.push(\n\t\t\t\t\tcreateInserterSection( {\n\t\t\t\t\t\tkey: `collection-${ namespace }`,\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\ticon: collections[ namespace ].icon,\n\t\t\t\t\t\t\ttitle: collections[ namespace ].title,\n\t\t\t\t\t\t},\n\t\t\t\t\t\titems: data,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn result;\n\t}, [ items, collections ] );\n\n\tconst sections = [\n\t\tcreateInserterSection( { key: 'default', items } ),\n\t\t...collectionSections,\n\t];\n\n\treturn (\n\t\t<BlockTypesList\n\t\t\tname=\"Blocks\"\n\t\t\tsections={ sections }\n\t\t\tonSelect={ handleSelect }\n\t\t\tlistProps={ listProps }\n\t\t/>\n\t);\n}\n\nexport default BlockTypesTab;\n"]}
|
|
@@ -3,7 +3,7 @@ import { createElement } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { isReusableBlock, createBlock, getBlockFromExample
|
|
6
|
+
import { isReusableBlock, createBlock, getBlockFromExample } from '@wordpress/blocks';
|
|
7
7
|
import { __ } from '@wordpress/i18n';
|
|
8
8
|
/**
|
|
9
9
|
* Internal dependencies
|
|
@@ -13,7 +13,7 @@ import BlockCard from '../block-card';
|
|
|
13
13
|
import BlockPreview from '../block-preview';
|
|
14
14
|
|
|
15
15
|
function InserterPreviewPanel(_ref) {
|
|
16
|
-
var
|
|
16
|
+
var _example$viewportWidt;
|
|
17
17
|
|
|
18
18
|
let {
|
|
19
19
|
item
|
|
@@ -23,24 +23,24 @@ function InserterPreviewPanel(_ref) {
|
|
|
23
23
|
title,
|
|
24
24
|
icon,
|
|
25
25
|
description,
|
|
26
|
-
initialAttributes
|
|
26
|
+
initialAttributes,
|
|
27
|
+
example
|
|
27
28
|
} = item;
|
|
28
|
-
const hoveredItemBlockType = getBlockType(name);
|
|
29
29
|
const isReusable = isReusableBlock(item);
|
|
30
30
|
return createElement("div", {
|
|
31
31
|
className: "block-editor-inserter__preview-container"
|
|
32
32
|
}, createElement("div", {
|
|
33
33
|
className: "block-editor-inserter__preview"
|
|
34
|
-
}, isReusable ||
|
|
34
|
+
}, isReusable || example ? createElement("div", {
|
|
35
35
|
className: "block-editor-inserter__preview-content"
|
|
36
36
|
}, createElement(BlockPreview, {
|
|
37
37
|
__experimentalPadding: 16,
|
|
38
|
-
viewportWidth: (
|
|
39
|
-
blocks:
|
|
40
|
-
attributes: { ...
|
|
38
|
+
viewportWidth: (_example$viewportWidt = example === null || example === void 0 ? void 0 : example.viewportWidth) !== null && _example$viewportWidt !== void 0 ? _example$viewportWidt : 500,
|
|
39
|
+
blocks: example ? getBlockFromExample(item.name, {
|
|
40
|
+
attributes: { ...example.attributes,
|
|
41
41
|
...initialAttributes
|
|
42
42
|
},
|
|
43
|
-
innerBlocks:
|
|
43
|
+
innerBlocks: example.innerBlocks
|
|
44
44
|
}) : createBlock(name, initialAttributes)
|
|
45
45
|
})) : createElement("div", {
|
|
46
46
|
className: "block-editor-inserter__preview-content-missing"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/preview-panel.js"],"names":["isReusableBlock","createBlock","getBlockFromExample","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/preview-panel.js"],"names":["isReusableBlock","createBlock","getBlockFromExample","__","BlockCard","BlockPreview","InserterPreviewPanel","item","name","title","icon","description","initialAttributes","example","isReusable","viewportWidth","attributes","innerBlocks"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,eADD,EAECC,WAFD,EAGCC,mBAHD,QAIO,mBAJP;AAKA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,eAAtB;AACA,OAAOC,YAAP,MAAyB,kBAAzB;;AAEA,SAASC,oBAAT,OAA0C;AAAA;;AAAA,MAAX;AAAEC,IAAAA;AAAF,GAAW;AACzC,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,KAAR;AAAeC,IAAAA,IAAf;AAAqBC,IAAAA,WAArB;AAAkCC,IAAAA,iBAAlC;AAAqDC,IAAAA;AAArD,MAAiEN,IAAvE;AACA,QAAMO,UAAU,GAAGd,eAAe,CAAEO,IAAF,CAAlC;AACA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGO,UAAU,IAAID,OAAd,GACD;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,YAAD;AACC,IAAA,qBAAqB,EAAG,EADzB;AAEC,IAAA,aAAa,2BAAGA,OAAH,aAAGA,OAAH,uBAAGA,OAAO,CAAEE,aAAZ,yEAA6B,GAF3C;AAGC,IAAA,MAAM,EACLF,OAAO,GACJX,mBAAmB,CAAEK,IAAI,CAACC,IAAP,EAAa;AAChCQ,MAAAA,UAAU,EAAE,EACX,GAAGH,OAAO,CAACG,UADA;AAEX,WAAGJ;AAFQ,OADoB;AAKhCK,MAAAA,WAAW,EAAEJ,OAAO,CAACI;AALW,KAAb,CADf,GAQJhB,WAAW,CAAEO,IAAF,EAAQI,iBAAR;AAZhB,IADD,CADC,GAmBD;AAAK,IAAA,SAAS,EAAC;AAAf,KACGT,EAAE,CAAE,uBAAF,CADL,CApBF,CADD,EA0BG,CAAEW,UAAF,IACD,cAAC,SAAD;AACC,IAAA,KAAK,EAAGL,KADT;AAEC,IAAA,IAAI,EAAGC,IAFR;AAGC,IAAA,WAAW,EAAGC;AAHf,IA3BF,CADD;AAoCA;;AAED,eAAeL,oBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tisReusableBlock,\n\tcreateBlock,\n\tgetBlockFromExample,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockCard from '../block-card';\nimport BlockPreview from '../block-preview';\n\nfunction InserterPreviewPanel( { item } ) {\n\tconst { name, title, icon, description, initialAttributes, example } = item;\n\tconst isReusable = isReusableBlock( item );\n\treturn (\n\t\t<div className=\"block-editor-inserter__preview-container\">\n\t\t\t<div className=\"block-editor-inserter__preview\">\n\t\t\t\t{ isReusable || example ? (\n\t\t\t\t\t<div className=\"block-editor-inserter__preview-content\">\n\t\t\t\t\t\t<BlockPreview\n\t\t\t\t\t\t\t__experimentalPadding={ 16 }\n\t\t\t\t\t\t\tviewportWidth={ example?.viewportWidth ?? 500 }\n\t\t\t\t\t\t\tblocks={\n\t\t\t\t\t\t\t\texample\n\t\t\t\t\t\t\t\t\t? getBlockFromExample( item.name, {\n\t\t\t\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\t\t\t...example.attributes,\n\t\t\t\t\t\t\t\t\t\t\t\t...initialAttributes,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\tinnerBlocks: example.innerBlocks,\n\t\t\t\t\t\t\t\t\t } )\n\t\t\t\t\t\t\t\t\t: createBlock( name, initialAttributes )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t) : (\n\t\t\t\t\t<div className=\"block-editor-inserter__preview-content-missing\">\n\t\t\t\t\t\t{ __( 'No Preview Available.' ) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t{ ! isReusable && (\n\t\t\t\t<BlockCard\n\t\t\t\t\ttitle={ title }\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tdescription={ description }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default InserterPreviewPanel;\n"]}
|
|
@@ -10,7 +10,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
10
10
|
|
|
11
11
|
import BlockTypesList from '../block-types-list';
|
|
12
12
|
import { store as blockEditorStore } from '../../store';
|
|
13
|
-
import { filterInserterItems } from './utils';
|
|
13
|
+
import { createInserterSection, filterInserterItems } from './utils';
|
|
14
14
|
|
|
15
15
|
function ReusableBlocksTab(_ref) {
|
|
16
16
|
let {
|
|
@@ -31,9 +31,13 @@ function ReusableBlocksTab(_ref) {
|
|
|
31
31
|
})
|
|
32
32
|
};
|
|
33
33
|
}, [rootClientId]);
|
|
34
|
+
const sections = [createInserterSection({
|
|
35
|
+
key: 'reuseable',
|
|
36
|
+
items
|
|
37
|
+
})];
|
|
34
38
|
return createElement(BlockTypesList, {
|
|
35
39
|
name: "ReusableBlocks",
|
|
36
|
-
|
|
40
|
+
sections: sections,
|
|
37
41
|
onSelect: onSelect,
|
|
38
42
|
listProps: listProps
|
|
39
43
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/reusable-blocks-tab.native.js"],"names":["useSelect","BlockTypesList","store","blockEditorStore","filterInserterItems","ReusableBlocksTab","onSelect","rootClientId","listProps","items","select","getInserterItems","allItems","onlyReusable"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,qBAA3B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/reusable-blocks-tab.native.js"],"names":["useSelect","BlockTypesList","store","blockEditorStore","createInserterSection","filterInserterItems","ReusableBlocksTab","onSelect","rootClientId","listProps","items","select","getInserterItems","allItems","onlyReusable","sections","key"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,qBAA3B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,qBAAT,EAAgCC,mBAAhC,QAA2D,SAA3D;;AAEA,SAASC,iBAAT,OAAoE;AAAA,MAAxC;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,YAAZ;AAA0BC,IAAAA;AAA1B,GAAwC;AACnE,QAAM;AAAEC,IAAAA;AAAF,MAAYV,SAAS,CACxBW,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAAuBD,MAAM,CAAER,gBAAF,CAAnC;AACA,UAAMU,QAAQ,GAAGD,gBAAgB,CAAEJ,YAAF,CAAjC;AAEA,WAAO;AACNE,MAAAA,KAAK,EAAEL,mBAAmB,CAAEQ,QAAF,EAAY;AAAEC,QAAAA,YAAY,EAAE;AAAhB,OAAZ;AADpB,KAAP;AAGA,GARyB,EAS1B,CAAEN,YAAF,CAT0B,CAA3B;AAYA,QAAMO,QAAQ,GAAG,CAAEX,qBAAqB,CAAE;AAAEY,IAAAA,GAAG,EAAE,WAAP;AAAoBN,IAAAA;AAApB,GAAF,CAAvB,CAAjB;AAEA,SACC,cAAC,cAAD;AACC,IAAA,IAAI,EAAC,gBADN;AAEC,IAAA,QAAQ,EAAGK,QAFZ;AAGC,IAAA,QAAQ,EAAGR,QAHZ;AAIC,IAAA,SAAS,EAAGE;AAJb,IADD;AAQA;;AAED,eAAeH,iBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesList from '../block-types-list';\nimport { store as blockEditorStore } from '../../store';\nimport { createInserterSection, filterInserterItems } from './utils';\n\nfunction ReusableBlocksTab( { onSelect, rootClientId, listProps } ) {\n\tconst { items } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getInserterItems } = select( blockEditorStore );\n\t\t\tconst allItems = getInserterItems( rootClientId );\n\n\t\t\treturn {\n\t\t\t\titems: filterInserterItems( allItems, { onlyReusable: true } ),\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\tconst sections = [ createInserterSection( { key: 'reuseable', items } ) ];\n\n\treturn (\n\t\t<BlockTypesList\n\t\t\tname=\"ReusableBlocks\"\n\t\t\tsections={ sections }\n\t\t\tonSelect={ onSelect }\n\t\t\tlistProps={ listProps }\n\t\t/>\n\t);\n}\n\nexport default ReusableBlocksTab;\n"]}
|