@wordpress/block-editor 11.4.0 → 11.5.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 +6 -0
- package/build/components/block-inspector/index.js +11 -10
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-inspector/useBlockInspectorAnimationSettings.js +46 -0
- package/build/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
- package/build/components/block-lock/modal.js +1 -0
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/index.js +2 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/child-layout-control/index.js +107 -0
- package/build/components/child-layout-control/index.js.map +1 -0
- package/build/components/date-format-picker/index.js +3 -3
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +594 -0
- package/build/components/global-styles/dimensions-panel.js.map +1 -0
- package/build/components/global-styles/hooks.js +72 -36
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +20 -6
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +25 -12
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +1 -1
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -0
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/index.native.js +23 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +10 -11
- package/build/components/inserter/media-tab/hooks.js.map +1 -1
- package/build/components/inserter/media-tab/media-list.js +5 -108
- package/build/components/inserter/media-tab/media-list.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +242 -0
- package/build/components/inserter/media-tab/media-preview.js.map +1 -0
- package/build/components/inspector-controls/block-support-tools-panel.js +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls/fill.js +38 -9
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/link-control/settings-drawer.js +1 -1
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/link-control/settings.js +1 -0
- package/build/components/link-control/settings.js.map +1 -1
- package/build/components/list-view/block.js +17 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +2 -2
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/expander.js +2 -1
- package/build/components/list-view/expander.js.map +1 -1
- package/build/components/list-view/leaf.js +10 -6
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-list-view-scroll-into-view.js +51 -0
- package/build/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
- package/build/components/off-canvas-editor/appender.js +5 -10
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +1 -0
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +7 -3
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/leaf-more-menu.js +34 -4
- package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build/components/off-canvas-editor/link-ui.js +1 -0
- package/build/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build/components/responsive-block-control/index.js +1 -0
- package/build/components/responsive-block-control/index.js.map +1 -1
- package/build/components/rich-text/index.js +9 -43
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-delete.js +73 -0
- package/build/components/rich-text/use-delete.js.map +1 -0
- package/build/components/rich-text/use-input-rules.js +14 -6
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +4 -1
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/hooks/align.js +3 -1
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/dimensions.js +72 -190
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +94 -25
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/gap.js +0 -202
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/layout.js +14 -5
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +7 -163
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +7 -163
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/typography.js +50 -65
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +75 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/flex.js +1 -0
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +24 -12
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +28 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +53 -47
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +5 -1
- package/build/store/selectors.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +36 -3
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/components/block-inspector/index.js +9 -9
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js +37 -0
- package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
- package/build-module/components/block-lock/modal.js +1 -0
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/index.js +2 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +98 -0
- package/build-module/components/child-layout-control/index.js.map +1 -0
- package/build-module/components/date-format-picker/index.js +4 -4
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +574 -0
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +71 -33
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +2 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +26 -11
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/index.native.js +2 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +10 -11
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-list.js +6 -105
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +222 -0
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -0
- package/build-module/components/inspector-controls/block-support-tools-panel.js +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +39 -9
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +1 -1
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/link-control/settings.js +1 -0
- package/build-module/components/link-control/settings.js.map +1 -1
- package/build-module/components/list-view/block.js +16 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +2 -2
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/expander.js +2 -1
- package/build-module/components/list-view/expander.js.map +1 -1
- package/build-module/components/list-view/leaf.js +8 -4
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-list-view-scroll-into-view.js +42 -0
- package/build-module/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
- package/build-module/components/off-canvas-editor/appender.js +5 -10
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +1 -0
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +7 -3
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/leaf-more-menu.js +36 -7
- package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build-module/components/off-canvas-editor/link-ui.js +1 -0
- package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build-module/components/responsive-block-control/index.js +1 -0
- package/build-module/components/responsive-block-control/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +9 -43
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-delete.js +62 -0
- package/build-module/components/rich-text/use-delete.js.map +1 -0
- package/build-module/components/rich-text/use-input-rules.js +14 -6
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +4 -1
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/hooks/align.js +3 -1
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/dimensions.js +75 -187
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +86 -24
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/gap.js +0 -183
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/layout.js +14 -5
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +4 -143
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +4 -143
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/typography.js +52 -65
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +70 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/flex.js +1 -0
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +24 -12
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +28 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +53 -45
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +5 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +36 -3
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-style/style-rtl.css +33 -21
- package/build-style/style.css +33 -21
- package/package.json +31 -31
- package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +24 -24
- package/src/components/block-inspector/index.js +11 -14
- package/src/components/block-inspector/useBlockInspectorAnimationSettings.js +53 -0
- package/src/components/block-lock/modal.js +1 -0
- package/src/components/block-lock/style.scss +0 -9
- package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +20 -20
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +15 -15
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/src/components/block-styles/index.js +5 -1
- package/src/components/child-layout-control/index.js +106 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/date-format-picker/index.js +6 -8
- package/src/components/date-format-picker/style.scss +0 -5
- package/src/components/global-styles/dimensions-panel.js +627 -0
- package/src/components/global-styles/hooks.js +88 -45
- package/src/components/global-styles/index.js +5 -1
- package/src/components/global-styles/typography-panel.js +33 -8
- package/src/components/global-styles/use-global-styles-output.js +4 -3
- package/src/components/global-styles/utils.js +2 -0
- package/src/components/index.native.js +5 -0
- package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
- package/src/components/inserter/media-tab/hooks.js +9 -8
- package/src/components/inserter/media-tab/media-list.js +3 -122
- package/src/components/inserter/media-tab/media-preview.js +268 -0
- package/src/components/inserter/style.scss +22 -0
- package/src/components/inserter/test/__snapshots__/index.native.js.snap +15 -15
- package/src/components/inspector-controls/block-support-tools-panel.js +0 -1
- package/src/components/inspector-controls/fill.js +32 -8
- package/src/components/link-control/settings-drawer.js +2 -1
- package/src/components/link-control/settings.js +1 -0
- package/src/components/link-control/style.scss +18 -8
- package/src/components/link-control/test/index.js +3 -3
- package/src/components/list-view/block.js +19 -1
- package/src/components/list-view/branch.js +1 -2
- package/src/components/list-view/expander.js +1 -0
- package/src/components/list-view/leaf.js +43 -29
- package/src/components/list-view/use-list-view-scroll-into-view.js +48 -0
- package/src/components/media-replace-flow/style.scss +7 -9
- package/src/components/off-canvas-editor/appender.js +13 -16
- package/src/components/off-canvas-editor/branch.js +1 -0
- package/src/components/off-canvas-editor/index.js +8 -2
- package/src/components/off-canvas-editor/leaf-more-menu.js +57 -15
- package/src/components/off-canvas-editor/link-ui.js +1 -0
- package/src/components/responsive-block-control/index.js +1 -0
- package/src/components/rich-text/index.js +8 -44
- package/src/components/rich-text/use-delete.js +59 -0
- package/src/components/rich-text/use-input-rules.js +13 -5
- package/src/components/spacing-sizes-control/style.scss +1 -1
- package/src/components/url-popover/stories/index.js +1 -0
- package/src/components/writing-flow/use-selection-observer.js +5 -1
- package/src/hooks/align.js +1 -1
- package/src/hooks/dimensions.js +85 -269
- package/src/hooks/duotone.js +100 -30
- package/src/hooks/gap.js +0 -208
- package/src/hooks/layout.js +19 -6
- package/src/hooks/margin.js +1 -164
- package/src/hooks/padding.js +1 -163
- package/src/hooks/test/__snapshots__/align.native.js.snap +24 -24
- package/src/hooks/test/duotone.js +102 -0
- package/src/hooks/typography.js +66 -88
- package/src/hooks/utils.js +90 -0
- package/src/layouts/flex.js +1 -0
- package/src/store/actions.js +12 -4
- package/src/store/defaults.js +14 -1
- package/src/store/reducer.js +68 -43
- package/src/store/selectors.js +8 -1
- package/src/store/test/actions.js +4 -2
- package/src/utils/parse-css-unit-to-px.js +35 -5
- package/src/utils/test/parse-css-unit-to-px.js +12 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/hooks/child-layout.js +0 -213
- package/build/hooks/child-layout.js.map +0 -1
- package/build/hooks/min-height.js +0 -139
- package/build/hooks/min-height.js.map +0 -1
- package/build-module/hooks/child-layout.js +0 -193
- package/build-module/hooks/child-layout.js.map +0 -1
- package/build-module/hooks/min-height.js +0 -116
- package/build-module/hooks/min-height.js.map +0 -1
- package/src/hooks/child-layout.js +0 -195
- package/src/hooks/min-height.js +0 -104
|
@@ -55,7 +55,7 @@ const VALID_SETTINGS = [
|
|
|
55
55
|
'spacing.margin',
|
|
56
56
|
'spacing.padding',
|
|
57
57
|
'spacing.units',
|
|
58
|
-
'typography.
|
|
58
|
+
'typography.fluid',
|
|
59
59
|
'typography.customFontSize',
|
|
60
60
|
'typography.dropCap',
|
|
61
61
|
'typography.fontFamilies',
|
|
@@ -204,62 +204,105 @@ export function useGlobalStyle(
|
|
|
204
204
|
return [ result, setStyle ];
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
/**
|
|
208
|
+
* React hook that overrides a global settings object with block and element specific settings.
|
|
209
|
+
*
|
|
210
|
+
* @param {Object} parentSettings Settings object.
|
|
211
|
+
* @param {blockName?} blockName Block name.
|
|
212
|
+
* @param {element?} element Element name.
|
|
213
|
+
*
|
|
214
|
+
* @return {Object} Merge of settings and supports.
|
|
215
|
+
*/
|
|
216
|
+
export function useSettingsForBlockElement(
|
|
217
|
+
parentSettings,
|
|
218
|
+
blockName,
|
|
219
|
+
element
|
|
220
|
+
) {
|
|
221
|
+
const { supportedStyles, supports } = useSelect(
|
|
209
222
|
( select ) => {
|
|
210
223
|
return {
|
|
211
|
-
|
|
224
|
+
supportedStyles: unlock(
|
|
212
225
|
select( blocksStore )
|
|
213
|
-
).getSupportedStyles(
|
|
226
|
+
).getSupportedStyles( blockName, element ),
|
|
227
|
+
supports:
|
|
228
|
+
select( blocksStore ).getBlockType( blockName )?.supports,
|
|
214
229
|
};
|
|
215
230
|
},
|
|
216
|
-
[
|
|
231
|
+
[ blockName, element ]
|
|
217
232
|
);
|
|
218
233
|
|
|
219
|
-
return
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Given a settings object and a list of supported panels,
|
|
224
|
-
* returns a new settings object with the unsupported panels removed.
|
|
225
|
-
*
|
|
226
|
-
* @param {Object} settings Settings object.
|
|
227
|
-
* @param {string[]} supports Supported style panels.
|
|
228
|
-
*
|
|
229
|
-
* @return {Object} Merge of settings and supports.
|
|
230
|
-
*/
|
|
231
|
-
export function overrideSettingsWithSupports( settings, supports ) {
|
|
232
|
-
const updatedSettings = { ...settings };
|
|
234
|
+
return useMemo( () => {
|
|
235
|
+
const updatedSettings = { ...parentSettings };
|
|
233
236
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
if ( ! supports.includes( 'fontFamily' ) ) {
|
|
243
|
-
updatedSettings.typography = {
|
|
244
|
-
...updatedSettings.typography,
|
|
245
|
-
fontFamilies: {},
|
|
246
|
-
};
|
|
247
|
-
}
|
|
237
|
+
if ( ! supportedStyles.includes( 'fontSize' ) ) {
|
|
238
|
+
updatedSettings.typography = {
|
|
239
|
+
...updatedSettings.typography,
|
|
240
|
+
fontSizes: {},
|
|
241
|
+
customFontSize: false,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
248
244
|
|
|
249
|
-
|
|
250
|
-
'lineHeight',
|
|
251
|
-
'fontStyle',
|
|
252
|
-
'fontWeight',
|
|
253
|
-
'letterSpacing',
|
|
254
|
-
'textTransform',
|
|
255
|
-
].forEach( ( key ) => {
|
|
256
|
-
if ( ! supports.includes( key ) ) {
|
|
245
|
+
if ( ! supportedStyles.includes( 'fontFamily' ) ) {
|
|
257
246
|
updatedSettings.typography = {
|
|
258
247
|
...updatedSettings.typography,
|
|
259
|
-
|
|
248
|
+
fontFamilies: {},
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
[
|
|
253
|
+
'lineHeight',
|
|
254
|
+
'fontStyle',
|
|
255
|
+
'fontWeight',
|
|
256
|
+
'letterSpacing',
|
|
257
|
+
'textTransform',
|
|
258
|
+
'textDecoration',
|
|
259
|
+
].forEach( ( key ) => {
|
|
260
|
+
if ( ! supportedStyles.includes( key ) ) {
|
|
261
|
+
updatedSettings.typography = {
|
|
262
|
+
...updatedSettings.typography,
|
|
263
|
+
[ key ]: false,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
} );
|
|
267
|
+
|
|
268
|
+
[ 'contentSize', 'wideSize' ].forEach( ( key ) => {
|
|
269
|
+
if ( ! supportedStyles.includes( key ) ) {
|
|
270
|
+
updatedSettings.layout = {
|
|
271
|
+
...updatedSettings.layout,
|
|
272
|
+
[ key ]: false,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
} );
|
|
276
|
+
|
|
277
|
+
[ 'padding', 'margin', 'blockGap' ].forEach( ( key ) => {
|
|
278
|
+
if ( ! supportedStyles.includes( key ) ) {
|
|
279
|
+
updatedSettings.spacing = {
|
|
280
|
+
...updatedSettings.spacing,
|
|
281
|
+
[ key ]: false,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const sides = Array.isArray( supports?.spacing?.[ key ] )
|
|
286
|
+
? supports?.spacing?.[ key ]
|
|
287
|
+
: supports?.spacing?.[ key ]?.sides;
|
|
288
|
+
if ( sides?.length ) {
|
|
289
|
+
updatedSettings.spacing = {
|
|
290
|
+
...updatedSettings.spacing,
|
|
291
|
+
[ key ]: {
|
|
292
|
+
...updatedSettings.spacing?.[ key ],
|
|
293
|
+
sides,
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
} );
|
|
298
|
+
|
|
299
|
+
if ( ! supportedStyles.includes( 'minHeight' ) ) {
|
|
300
|
+
updatedSettings.dimensions = {
|
|
301
|
+
...updatedSettings.dimensions,
|
|
302
|
+
minHeight: false,
|
|
260
303
|
};
|
|
261
304
|
}
|
|
262
|
-
} );
|
|
263
305
|
|
|
264
|
-
|
|
306
|
+
return updatedSettings;
|
|
307
|
+
}, [ parentSettings, supportedStyles, supports ] );
|
|
265
308
|
}
|
|
@@ -2,7 +2,7 @@ export {
|
|
|
2
2
|
useGlobalStylesReset,
|
|
3
3
|
useGlobalSetting,
|
|
4
4
|
useGlobalStyle,
|
|
5
|
-
|
|
5
|
+
useSettingsForBlockElement,
|
|
6
6
|
} from './hooks';
|
|
7
7
|
export { useGlobalStylesOutput } from './use-global-styles-output';
|
|
8
8
|
export { GlobalStylesContext } from './context';
|
|
@@ -10,3 +10,7 @@ export {
|
|
|
10
10
|
default as TypographyPanel,
|
|
11
11
|
useHasTypographyPanel,
|
|
12
12
|
} from './typography-panel';
|
|
13
|
+
export {
|
|
14
|
+
default as DimensionsPanel,
|
|
15
|
+
useHasDimensionsPanel,
|
|
16
|
+
} from './dimensions-panel';
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
8
8
|
} from '@wordpress/components';
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
|
+
import { useCallback } from '@wordpress/element';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Internal dependencies
|
|
@@ -92,8 +93,27 @@ function useHasTextDecorationControl( settings ) {
|
|
|
92
93
|
return settings?.typography?.textDecoration;
|
|
93
94
|
}
|
|
94
95
|
|
|
95
|
-
function TypographyToolsPanel( {
|
|
96
|
-
|
|
96
|
+
function TypographyToolsPanel( {
|
|
97
|
+
resetAllFilter,
|
|
98
|
+
onChange,
|
|
99
|
+
value,
|
|
100
|
+
panelId,
|
|
101
|
+
children,
|
|
102
|
+
} ) {
|
|
103
|
+
const resetAll = () => {
|
|
104
|
+
const updatedValue = resetAllFilter( value );
|
|
105
|
+
onChange( updatedValue );
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<ToolsPanel
|
|
110
|
+
label={ __( 'Typography' ) }
|
|
111
|
+
resetAll={ resetAll }
|
|
112
|
+
panelId={ panelId }
|
|
113
|
+
>
|
|
114
|
+
{ children }
|
|
115
|
+
</ToolsPanel>
|
|
116
|
+
);
|
|
97
117
|
}
|
|
98
118
|
|
|
99
119
|
const DEFAULT_CONTROLS = {
|
|
@@ -260,15 +280,20 @@ export default function TypographyPanel( {
|
|
|
260
280
|
const hasTextDecoration = () => !! value?.typography?.textDecoration;
|
|
261
281
|
const resetTextDecoration = () => setTextDecoration( undefined );
|
|
262
282
|
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
...
|
|
283
|
+
const resetAllFilter = useCallback( ( previousValue ) => {
|
|
284
|
+
return {
|
|
285
|
+
...previousValue,
|
|
266
286
|
typography: {},
|
|
267
|
-
}
|
|
268
|
-
};
|
|
287
|
+
};
|
|
288
|
+
}, [] );
|
|
269
289
|
|
|
270
290
|
return (
|
|
271
|
-
<Wrapper
|
|
291
|
+
<Wrapper
|
|
292
|
+
resetAllFilter={ resetAllFilter }
|
|
293
|
+
value={ value }
|
|
294
|
+
onChange={ onChange }
|
|
295
|
+
panelId={ panelId }
|
|
296
|
+
>
|
|
272
297
|
{ hasFontFamilyEnabled && (
|
|
273
298
|
<ToolsPanelItem
|
|
274
299
|
label={ __( 'Font family' ) }
|
|
@@ -790,9 +790,10 @@ export const toStyles = (
|
|
|
790
790
|
if ( duotoneDeclarations.length > 0 ) {
|
|
791
791
|
ruleset =
|
|
792
792
|
ruleset +
|
|
793
|
-
`${
|
|
794
|
-
|
|
795
|
-
|
|
793
|
+
`${ scopeSelector(
|
|
794
|
+
selector,
|
|
795
|
+
duotoneSelector
|
|
796
|
+
) }{${ duotoneDeclarations.join( ';' ) };}`;
|
|
796
797
|
}
|
|
797
798
|
}
|
|
798
799
|
|
|
@@ -57,6 +57,7 @@ export const PRESET_METADATA = [
|
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
path: [ 'color', 'duotone' ],
|
|
60
|
+
valueKey: 'colors',
|
|
60
61
|
cssVarInfix: 'duotone',
|
|
61
62
|
valueFunc: ( { slug } ) => `url( '#wp-duotone-${ slug }' )`,
|
|
62
63
|
classes: [],
|
|
@@ -95,6 +96,7 @@ export const PRESET_METADATA = [
|
|
|
95
96
|
export const STYLE_PATH_TO_CSS_VAR_INFIX = {
|
|
96
97
|
'color.background': 'color',
|
|
97
98
|
'color.text': 'color',
|
|
99
|
+
'filter.duotone': 'duotone',
|
|
98
100
|
'elements.link.color.text': 'color',
|
|
99
101
|
'elements.link.:hover.color.text': 'color',
|
|
100
102
|
'elements.link.typography.fontFamily': 'font-family',
|
|
@@ -74,6 +74,11 @@ export {
|
|
|
74
74
|
} from './block-settings';
|
|
75
75
|
export { default as VideoPlayer, VIDEO_ASPECT_RATIO } from './video-player';
|
|
76
76
|
|
|
77
|
+
export {
|
|
78
|
+
getSpacingPresetCssVar,
|
|
79
|
+
getCustomValueFromPreset,
|
|
80
|
+
isValueSpacingPreset,
|
|
81
|
+
} from './spacing-sizes-control/utils';
|
|
77
82
|
// Content Related Components.
|
|
78
83
|
export { default as BlockList } from './block-list';
|
|
79
84
|
export { default as BlockMover } from './block-mover';
|
|
@@ -9,7 +9,7 @@ exports[`InnerBlocks should force serialize for invalid block with inner blocks
|
|
|
9
9
|
`;
|
|
10
10
|
|
|
11
11
|
exports[`InnerBlocks should return element as string, with inner blocks 1`] = `
|
|
12
|
-
"<div>Bananas<!-- wp:fruit {
|
|
12
|
+
"<div>Bananas<!-- wp:fruit {"fruit":"Apples"} -->
|
|
13
13
|
<div>Apples</div>
|
|
14
14
|
<!-- /wp:fruit --></div>"
|
|
15
15
|
`;
|
|
@@ -98,13 +98,6 @@ function useInserterMediaCategories() {
|
|
|
98
98
|
) {
|
|
99
99
|
return false;
|
|
100
100
|
}
|
|
101
|
-
// When a category has set `isExternalResource` to `true`, we
|
|
102
|
-
// don't need to check for allowed mime types, as they are used
|
|
103
|
-
// for restricting uploads for this media type and not for
|
|
104
|
-
// inserting media from external sources.
|
|
105
|
-
if ( category.isExternalResource ) {
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
101
|
return Object.values( allowedMimeTypes ).some( ( mimeType ) =>
|
|
109
102
|
mimeType.startsWith( `${ category.mediaType }/` )
|
|
110
103
|
);
|
|
@@ -156,7 +149,15 @@ export function useMediaCategories( rootClientId ) {
|
|
|
156
149
|
if ( category.isExternalResource ) {
|
|
157
150
|
return [ category.name, true ];
|
|
158
151
|
}
|
|
159
|
-
|
|
152
|
+
let results = [];
|
|
153
|
+
try {
|
|
154
|
+
results = await category.fetch( {
|
|
155
|
+
per_page: 1,
|
|
156
|
+
} );
|
|
157
|
+
} catch ( e ) {
|
|
158
|
+
// If the request fails, we shallow the error and just don't show
|
|
159
|
+
// the category, in order to not break the media tab.
|
|
160
|
+
}
|
|
160
161
|
return [ category.name, !! results.length ];
|
|
161
162
|
} )
|
|
162
163
|
)
|
|
@@ -1,129 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import classnames from 'classnames';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
9
4
|
import {
|
|
10
5
|
__unstableComposite as Composite,
|
|
11
6
|
__unstableUseCompositeState as useCompositeState,
|
|
12
|
-
__unstableCompositeItem as CompositeItem,
|
|
13
|
-
Tooltip,
|
|
14
|
-
DropdownMenu,
|
|
15
|
-
MenuGroup,
|
|
16
|
-
MenuItem,
|
|
17
7
|
} from '@wordpress/components';
|
|
18
|
-
import { __
|
|
19
|
-
import { useMemo, useCallback, useState } from '@wordpress/element';
|
|
20
|
-
import { cloneBlock } from '@wordpress/blocks';
|
|
21
|
-
import { moreVertical, external } from '@wordpress/icons';
|
|
8
|
+
import { __ } from '@wordpress/i18n';
|
|
22
9
|
|
|
23
10
|
/**
|
|
24
11
|
* Internal dependencies
|
|
25
12
|
*/
|
|
26
|
-
import
|
|
27
|
-
import { getBlockAndPreviewFromMedia } from './utils';
|
|
28
|
-
|
|
29
|
-
const MAXIMUM_TITLE_LENGTH = 25;
|
|
30
|
-
const MEDIA_OPTIONS_POPOVER_PROPS = {
|
|
31
|
-
position: 'bottom left',
|
|
32
|
-
className:
|
|
33
|
-
'block-editor-inserter__media-list__item-preview-options__popover',
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
function MediaPreviewOptions( { category, media } ) {
|
|
37
|
-
if ( ! category.getReportUrl ) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
const reportUrl = category.getReportUrl( media );
|
|
41
|
-
return (
|
|
42
|
-
<DropdownMenu
|
|
43
|
-
className="block-editor-inserter__media-list__item-preview-options"
|
|
44
|
-
label={ __( 'Options' ) }
|
|
45
|
-
popoverProps={ MEDIA_OPTIONS_POPOVER_PROPS }
|
|
46
|
-
icon={ moreVertical }
|
|
47
|
-
>
|
|
48
|
-
{ () => (
|
|
49
|
-
<MenuGroup>
|
|
50
|
-
<MenuItem
|
|
51
|
-
onClick={ () =>
|
|
52
|
-
window.open( reportUrl, '_blank' ).focus()
|
|
53
|
-
}
|
|
54
|
-
icon={ external }
|
|
55
|
-
>
|
|
56
|
-
{ sprintf(
|
|
57
|
-
/* translators: %s: The media type to report e.g: "image", "video", "audio" */
|
|
58
|
-
__( 'Report %s' ),
|
|
59
|
-
category.mediaType
|
|
60
|
-
) }
|
|
61
|
-
</MenuItem>
|
|
62
|
-
</MenuGroup>
|
|
63
|
-
) }
|
|
64
|
-
</DropdownMenu>
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function MediaPreview( { media, onClick, composite, category } ) {
|
|
69
|
-
const [ isHovered, setIsHovered ] = useState( false );
|
|
70
|
-
const [ block, preview ] = useMemo(
|
|
71
|
-
() => getBlockAndPreviewFromMedia( media, category.mediaType ),
|
|
72
|
-
[ media, category.mediaType ]
|
|
73
|
-
);
|
|
74
|
-
const title = media.title?.rendered || media.title;
|
|
75
|
-
let truncatedTitle;
|
|
76
|
-
if ( title.length > MAXIMUM_TITLE_LENGTH ) {
|
|
77
|
-
const omission = '...';
|
|
78
|
-
truncatedTitle =
|
|
79
|
-
title.slice( 0, MAXIMUM_TITLE_LENGTH - omission.length ) + omission;
|
|
80
|
-
}
|
|
81
|
-
const onMouseEnter = useCallback( () => setIsHovered( true ), [] );
|
|
82
|
-
const onMouseLeave = useCallback( () => setIsHovered( false ), [] );
|
|
83
|
-
return (
|
|
84
|
-
<InserterDraggableBlocks isEnabled={ true } blocks={ [ block ] }>
|
|
85
|
-
{ ( { draggable, onDragStart, onDragEnd } ) => (
|
|
86
|
-
<div
|
|
87
|
-
className={ classnames(
|
|
88
|
-
'block-editor-inserter__media-list__list-item',
|
|
89
|
-
{
|
|
90
|
-
'is-hovered': isHovered,
|
|
91
|
-
}
|
|
92
|
-
) }
|
|
93
|
-
draggable={ draggable }
|
|
94
|
-
onDragStart={ onDragStart }
|
|
95
|
-
onDragEnd={ onDragEnd }
|
|
96
|
-
>
|
|
97
|
-
<Tooltip text={ truncatedTitle || title }>
|
|
98
|
-
{ /* Adding `is-hovered` class to the wrapper element is needed
|
|
99
|
-
because the options Popover is rendered outside of this node. */ }
|
|
100
|
-
<div
|
|
101
|
-
onMouseEnter={ onMouseEnter }
|
|
102
|
-
onMouseLeave={ onMouseLeave }
|
|
103
|
-
>
|
|
104
|
-
<CompositeItem
|
|
105
|
-
role="option"
|
|
106
|
-
as="div"
|
|
107
|
-
{ ...composite }
|
|
108
|
-
className="block-editor-inserter__media-list__item"
|
|
109
|
-
onClick={ () => onClick( block ) }
|
|
110
|
-
aria-label={ title }
|
|
111
|
-
>
|
|
112
|
-
<div className="block-editor-inserter__media-list__item-preview">
|
|
113
|
-
{ preview }
|
|
114
|
-
</div>
|
|
115
|
-
</CompositeItem>
|
|
116
|
-
<MediaPreviewOptions
|
|
117
|
-
category={ category }
|
|
118
|
-
media={ media }
|
|
119
|
-
/>
|
|
120
|
-
</div>
|
|
121
|
-
</Tooltip>
|
|
122
|
-
</div>
|
|
123
|
-
) }
|
|
124
|
-
</InserterDraggableBlocks>
|
|
125
|
-
);
|
|
126
|
-
}
|
|
13
|
+
import { MediaPreview } from './media-preview';
|
|
127
14
|
|
|
128
15
|
function MediaList( {
|
|
129
16
|
mediaList,
|
|
@@ -132,12 +19,6 @@ function MediaList( {
|
|
|
132
19
|
label = __( 'Media List' ),
|
|
133
20
|
} ) {
|
|
134
21
|
const composite = useCompositeState();
|
|
135
|
-
const onPreviewClick = useCallback(
|
|
136
|
-
( block ) => {
|
|
137
|
-
onClick( cloneBlock( block ) );
|
|
138
|
-
},
|
|
139
|
-
[ onClick ]
|
|
140
|
-
);
|
|
141
22
|
return (
|
|
142
23
|
<Composite
|
|
143
24
|
{ ...composite }
|
|
@@ -150,7 +31,7 @@ function MediaList( {
|
|
|
150
31
|
key={ media.id || media.sourceId || index }
|
|
151
32
|
media={ media }
|
|
152
33
|
category={ category }
|
|
153
|
-
onClick={
|
|
34
|
+
onClick={ onClick }
|
|
154
35
|
composite={ composite }
|
|
155
36
|
/>
|
|
156
37
|
) ) }
|