@wordpress/block-editor 15.13.2-next.v.202602271551.0 → 15.14.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.
Files changed (66) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +1 -0
  3. package/build/components/block-settings-menu-controls/index.cjs +1 -0
  4. package/build/components/block-settings-menu-controls/index.cjs.map +2 -2
  5. package/build/components/block-styles/index.cjs +68 -57
  6. package/build/components/block-styles/index.cjs.map +3 -3
  7. package/build/components/block-switcher/preview-block-popover.cjs +10 -8
  8. package/build/components/block-switcher/preview-block-popover.cjs.map +2 -2
  9. package/build/components/block-toolbar/block-toolbar-icon.cjs +1 -1
  10. package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
  11. package/build/components/block-toolbar/index.cjs +8 -4
  12. package/build/components/block-toolbar/index.cjs.map +2 -2
  13. package/build/components/block-visibility/modal.cjs +2 -2
  14. package/build/components/block-visibility/modal.cjs.map +1 -1
  15. package/build/components/dimension-control/index.cjs +4 -2
  16. package/build/components/dimension-control/index.cjs.map +2 -2
  17. package/build/components/global-styles/dimensions-panel.cjs +6 -3
  18. package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
  19. package/build/hooks/auto-inspector-controls.cjs +26 -2
  20. package/build/hooks/auto-inspector-controls.cjs.map +3 -3
  21. package/build/index.cjs +2 -0
  22. package/build/index.cjs.map +2 -2
  23. package/build-module/components/block-settings-menu-controls/index.mjs +1 -0
  24. package/build-module/components/block-settings-menu-controls/index.mjs.map +2 -2
  25. package/build-module/components/block-styles/index.mjs +71 -61
  26. package/build-module/components/block-styles/index.mjs.map +2 -2
  27. package/build-module/components/block-switcher/preview-block-popover.mjs +11 -9
  28. package/build-module/components/block-switcher/preview-block-popover.mjs.map +2 -2
  29. package/build-module/components/block-toolbar/block-toolbar-icon.mjs +1 -1
  30. package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
  31. package/build-module/components/block-toolbar/index.mjs +8 -4
  32. package/build-module/components/block-toolbar/index.mjs.map +2 -2
  33. package/build-module/components/block-visibility/modal.mjs +2 -2
  34. package/build-module/components/block-visibility/modal.mjs.map +1 -1
  35. package/build-module/components/dimension-control/index.mjs +4 -2
  36. package/build-module/components/dimension-control/index.mjs.map +2 -2
  37. package/build-module/components/global-styles/dimensions-panel.mjs +6 -3
  38. package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
  39. package/build-module/hooks/auto-inspector-controls.mjs +28 -4
  40. package/build-module/hooks/auto-inspector-controls.mjs.map +2 -2
  41. package/build-module/index.mjs +2 -0
  42. package/build-module/index.mjs.map +3 -3
  43. package/build-style/content-rtl.css +11 -7
  44. package/build-style/content.css +11 -7
  45. package/build-style/style-rtl.css +0 -13
  46. package/build-style/style.css +0 -13
  47. package/package.json +39 -39
  48. package/src/components/block-settings-menu-controls/index.js +1 -0
  49. package/src/components/block-styles/index.js +35 -24
  50. package/src/components/block-styles/style.scss +0 -7
  51. package/src/components/block-switcher/preview-block-popover.js +9 -7
  52. package/src/components/block-switcher/style.scss +0 -8
  53. package/src/components/block-toolbar/block-toolbar-icon.js +6 -1
  54. package/src/components/block-toolbar/index.js +7 -2
  55. package/src/components/block-tools/style.scss +1 -14
  56. package/src/components/default-block-appender/content.scss +3 -25
  57. package/src/components/dimension-control/index.js +7 -4
  58. package/src/components/global-styles/dimensions-panel.js +3 -0
  59. package/src/hooks/auto-inspector-controls.js +31 -4
  60. package/src/hooks/test/dimensions.js +16 -0
  61. package/src/index.js +1 -0
  62. package/build/components/block-styles/preview-panel.cjs +0 -61
  63. package/build/components/block-styles/preview-panel.cjs.map +0 -7
  64. package/build-module/components/block-styles/preview-panel.mjs +0 -30
  65. package/build-module/components/block-styles/preview-panel.mjs.map +0 -7
  66. package/src/components/block-styles/preview-panel.js +0 -35
@@ -6,12 +6,11 @@ import clsx from 'clsx';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { useState } from '@wordpress/element';
10
- import { debounce, useViewportMatch } from '@wordpress/compose';
9
+ import { useState, useMemo } from '@wordpress/element';
10
+ import { debounce } from '@wordpress/compose';
11
11
  import {
12
12
  Button,
13
13
  __experimentalTruncate as Truncate,
14
- Popover,
15
14
  __experimentalToolsPanel as ToolsPanel,
16
15
  __experimentalToolsPanelItem as ToolsPanelItem,
17
16
  } from '@wordpress/components';
@@ -20,10 +19,10 @@ import { __ } from '@wordpress/i18n';
20
19
  /**
21
20
  * Internal dependencies
22
21
  */
23
- import BlockStylesPreviewPanel from './preview-panel';
22
+ import PreviewBlockPopover from '../block-switcher/preview-block-popover';
24
23
  import useStylesForBlocks from './use-styles-for-block';
25
24
  import { useToolsPanelDropdownMenuProps } from '../global-styles/utils';
26
- import { getDefaultStyle } from './utils';
25
+ import { getDefaultStyle, replaceActiveStyle } from './utils';
27
26
 
28
27
  const noop = () => {};
29
28
 
@@ -34,15 +33,35 @@ function BlockStyles( { clientId, onSwitch = noop, onHoverClassName = noop } ) {
34
33
  stylesToRender,
35
34
  activeStyle,
36
35
  genericPreviewBlock,
37
- className: previewClassName,
36
+ className,
38
37
  } = useStylesForBlocks( {
39
38
  clientId,
40
39
  onSwitch,
41
40
  } );
42
41
  const [ hoveredStyle, setHoveredStyle ] = useState( null );
43
- const isMobileViewport = useViewportMatch( 'medium', '<' );
42
+ const [ blockStylesAnchor, setBlockStylesAnchor ] = useState( null );
44
43
  const dropdownMenuProps = useToolsPanelDropdownMenuProps();
45
44
 
45
+ const previewBlocks = useMemo( () => {
46
+ if ( ! hoveredStyle || ! genericPreviewBlock ) {
47
+ return null;
48
+ }
49
+ const previewClassName = replaceActiveStyle(
50
+ className,
51
+ activeStyle,
52
+ hoveredStyle
53
+ );
54
+ return [
55
+ {
56
+ ...genericPreviewBlock,
57
+ attributes: {
58
+ ...( genericPreviewBlock.attributes || {} ),
59
+ className: previewClassName,
60
+ },
61
+ },
62
+ ];
63
+ }, [ hoveredStyle, genericPreviewBlock, className, activeStyle ] );
64
+
46
65
  if ( ! stylesToRender || stylesToRender.length === 0 ) {
47
66
  return null;
48
67
  }
@@ -90,7 +109,10 @@ function BlockStyles( { clientId, onSwitch = noop, onHoverClassName = noop } ) {
90
109
  isShownByDefault
91
110
  panelId={ clientId }
92
111
  >
93
- <div className="block-editor-block-styles">
112
+ <div
113
+ ref={ setBlockStylesAnchor }
114
+ className="block-editor-block-styles"
115
+ >
94
116
  <div className="block-editor-block-styles__variants">
95
117
  { stylesToRender.map( ( style ) => {
96
118
  const buttonText = style.label || style.name;
@@ -133,24 +155,13 @@ function BlockStyles( { clientId, onSwitch = noop, onHoverClassName = noop } ) {
133
155
  );
134
156
  } ) }
135
157
  </div>
136
- { hoveredStyle && ! isMobileViewport && (
137
- <Popover
158
+ { previewBlocks && (
159
+ <PreviewBlockPopover
160
+ blocks={ previewBlocks }
138
161
  placement="left-start"
139
162
  offset={ 34 }
140
- focusOnMount={ false }
141
- >
142
- <div
143
- className="block-editor-block-styles__preview-panel"
144
- onMouseLeave={ () => styleItemHandler( null ) }
145
- >
146
- <BlockStylesPreviewPanel
147
- activeStyle={ activeStyle }
148
- className={ previewClassName }
149
- genericPreviewBlock={ genericPreviewBlock }
150
- style={ hoveredStyle }
151
- />
152
- </div>
153
- </Popover>
163
+ anchor={ blockStylesAnchor }
164
+ />
154
165
  ) }
155
166
  </div>
156
167
  </ToolsPanelItem>
@@ -67,10 +67,3 @@
67
67
  }
68
68
  }
69
69
 
70
- // To prevent overflow in the preview container,
71
- // ensure that block contents' margin and padding
72
- // do not add to the block container's width.
73
- .block-editor-block-styles__block-preview-container,
74
- .block-editor-block-styles__block-preview-container * {
75
- box-sizing: border-box !important;
76
- }
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { __ } from '@wordpress/i18n';
5
4
  import { Popover } from '@wordpress/components';
6
5
  import { useViewportMatch } from '@wordpress/compose';
7
6
 
@@ -10,7 +9,12 @@ import { useViewportMatch } from '@wordpress/compose';
10
9
  */
11
10
  import BlockPreview from '../block-preview';
12
11
 
13
- export default function PreviewBlockPopover( { blocks } ) {
12
+ export default function PreviewBlockPopover( {
13
+ blocks,
14
+ placement = 'right-start',
15
+ offset = 16,
16
+ anchor,
17
+ } ) {
14
18
  const isMobile = useViewportMatch( 'medium', '<' );
15
19
 
16
20
  if ( isMobile ) {
@@ -21,14 +25,12 @@ export default function PreviewBlockPopover( { blocks } ) {
21
25
  <div className="block-editor-block-switcher__popover-preview-container">
22
26
  <Popover
23
27
  className="block-editor-block-switcher__popover-preview"
24
- placement="right-start"
28
+ placement={ placement }
25
29
  focusOnMount={ false }
26
- offset={ 16 }
30
+ offset={ offset }
31
+ anchor={ anchor }
27
32
  >
28
33
  <div className="block-editor-block-switcher__preview">
29
- <div className="block-editor-block-switcher__preview-title">
30
- { __( 'Preview' ) }
31
- </div>
32
34
  { /* 600px is the value of $break-small in base-styles/_breakpoints.scss.
33
35
  We set the viewport width to 601px to make sure that the media-text
34
36
  block which uses this breakpoint has the correct padding. */ }
@@ -41,14 +41,6 @@
41
41
  }
42
42
  }
43
43
 
44
- .block-editor-block-switcher__preview-title {
45
- margin-bottom: $grid-unit-15;
46
- color: $gray-700;
47
- text-transform: uppercase;
48
- font-size: 11px;
49
- font-weight: $font-weight-medium;
50
- }
51
-
52
44
  .block-editor-block-switcher__preview-patterns-container {
53
45
  padding-bottom: $grid-unit-20;
54
46
 
@@ -71,7 +71,12 @@ function getBlockIconVariant( { select, clientIds } ) {
71
71
 
72
72
  if ( _showBlockSwitcher ) {
73
73
  return 'switcher';
74
- } else if ( isContentOnlyMode && hasBlockStyles && ! hasPatternOverrides ) {
74
+ } else if (
75
+ isContentOnlyMode &&
76
+ hasBlockStyles &&
77
+ ! hasPatternOverrides &&
78
+ canEdit
79
+ ) {
75
80
  return 'styles-only';
76
81
  } else if ( _showPatternOverrides ) {
77
82
  return 'pattern-overrides';
@@ -78,7 +78,9 @@ export function PrivateBlockToolbar( {
78
78
  showBlockVisibilityButton,
79
79
  showSwitchSectionStyleButton,
80
80
  areSelectedBlocksHiddenOnViewport,
81
+ canEdit,
81
82
  } = useSelect( ( select ) => {
83
+ const { canEditBlock } = select( blockEditorStore );
82
84
  const {
83
85
  getBlockName,
84
86
  getBlockMode,
@@ -122,7 +124,9 @@ export function PrivateBlockToolbar( {
122
124
 
123
125
  const _isZoomOut = isZoomOut();
124
126
  const _isSectionBlock = isSectionBlock( selectedBlockClientId );
125
- const _showSwitchSectionStyleButton = _isZoomOut || _isSectionBlock;
127
+ const _canEditBlock = canEditBlock( selectedBlockClientId );
128
+ const _showSwitchSectionStyleButton =
129
+ _canEditBlock && ( _isZoomOut || _isSectionBlock );
126
130
 
127
131
  const _currentDeviceType =
128
132
  getSettings()?.[ deviceTypeKey ]?.toLowerCase() || 'desktop';
@@ -161,6 +165,7 @@ export function PrivateBlockToolbar( {
161
165
  showSwitchSectionStyleButton: _showSwitchSectionStyleButton,
162
166
  areSelectedBlocksHiddenOnViewport:
163
167
  _areSelectedBlocksHiddenOnViewport,
168
+ canEdit: _canEditBlock,
164
169
  };
165
170
  }, [] );
166
171
 
@@ -245,7 +250,7 @@ export function PrivateBlockToolbar( {
245
250
  shouldShowVisualToolbar &&
246
251
  isMultiToolbar &&
247
252
  showGroupButtons && <BlockGroupToolbar /> }
248
- { ! isMultiToolbar && (
253
+ { ! isMultiToolbar && canEdit && (
249
254
  <EditSectionButton clientId={ blockClientIds[ 0 ] } />
250
255
  ) }
251
256
  { ! areSelectedBlocksHiddenOnViewport && showShuffleButton && (
@@ -76,20 +76,7 @@
76
76
  .block-editor-block-list__empty-block-inserter,
77
77
  .block-editor-block-list__insertion-point-inserter {
78
78
  .block-editor-inserter__toggle.components-button.has-icon {
79
- // Basic look
80
- background: $gray-900;
81
- color: $white;
82
- padding: 0;
83
-
84
- // TODO: Consider passing size="small" to the Inserter toggle instead.
85
- // Special dimensions for this button.
86
- min-width: $button-size-small;
87
- height: $button-size-small;
88
-
89
- &:hover {
90
- color: $white;
91
- background: var(--wp-admin-theme-color);
92
- }
79
+ @include inserter-toggle;
93
80
  }
94
81
  }
95
82
 
@@ -1,4 +1,5 @@
1
1
  @use "@wordpress/base-styles/colors" as *;
2
+ @use "@wordpress/base-styles/mixins" as *;
2
3
  @use "@wordpress/base-styles/variables" as *;
3
4
  @use "@wordpress/base-styles/z-index" as *;
4
5
 
@@ -41,20 +42,7 @@
41
42
  }
42
43
 
43
44
  .block-editor-inserter__toggle.components-button.has-icon {
44
- // Basic look
45
- background: $gray-900;
46
- color: $white;
47
- padding: 0;
48
-
49
- // TODO: Consider passing size="small" to the Inserter toggle instead.
50
- // Special dimensions for this button.
51
- min-width: $button-size-small;
52
- height: $button-size-small;
53
-
54
- &:hover {
55
- color: $white;
56
- background: var(--wp-admin-theme-color);
57
- }
45
+ @include inserter-toggle;
58
46
  }
59
47
  }
60
48
 
@@ -103,26 +91,16 @@
103
91
  // treating them the same, one or both can be retired.
104
92
  .block-editor-inserter__toggle.components-button.has-icon,
105
93
  .block-list-appender__toggle {
94
+ @include inserter-toggle;
106
95
  flex-direction: row;
107
96
  box-shadow: none;
108
- height: $button-size-small;
109
97
  width: $button-size-small;
110
- min-width: $button-size-small;
111
98
 
112
99
  // Hide by default, then we unhide it when the selected block is a direct ancestor.
113
100
  display: none;
114
101
 
115
102
  // Important to override styles form Button component.
116
103
  padding: 0 !important;
117
-
118
- // Basic look
119
- background: $gray-900;
120
- color: $white;
121
-
122
- &:hover {
123
- color: $white;
124
- background: var(--wp-admin-theme-color);
125
- }
126
104
  }
127
105
 
128
106
  // This content only shows up inside the empty appender.
@@ -55,9 +55,10 @@ function useDimensionSizes( presets ) {
55
55
  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/dimension-control/README.md
56
56
  *
57
57
  * @param {Object} props
58
- * @param {?string} props.label A label for the control.
59
- * @param {( value: string ) => void } props.onChange Called when the dimension value changes.
60
- * @param {string} props.value The current dimension value.
58
+ * @param {?string} props.label A label for the control.
59
+ * @param {( value: string ) => void } props.onChange Called when the dimension value changes.
60
+ * @param {string} props.value The current dimension value.
61
+ * @param {?Object} props.dimensionSizes Optional dimension size presets. Falls back to settings from the store.
61
62
  *
62
63
  * @return {Component} The component to be rendered.
63
64
  */
@@ -65,11 +66,13 @@ export default function DimensionControl( {
65
66
  label = __( 'Dimension' ),
66
67
  onChange,
67
68
  value,
69
+ dimensionSizes: dimensionSizesProp,
68
70
  } ) {
69
- const [ dimensionSizes, availableUnits ] = useSettings(
71
+ const [ dimensionSizesFromSettings, availableUnits ] = useSettings(
70
72
  'dimensions.dimensionSizes',
71
73
  'spacing.units'
72
74
  );
75
+ const dimensionSizes = dimensionSizesProp ?? dimensionSizesFromSettings;
73
76
 
74
77
  const units = useCustomUnits( {
75
78
  availableUnits: availableUnits || [
@@ -735,6 +735,7 @@ export default function DimensionsPanel( {
735
735
  label={ __( 'Minimum height' ) }
736
736
  value={ minHeightValue }
737
737
  onChange={ setMinHeightValue }
738
+ dimensionSizes={ dimensions?.dimensionSizes }
738
739
  />
739
740
  </ToolsPanelItem>
740
741
  ) }
@@ -752,6 +753,7 @@ export default function DimensionsPanel( {
752
753
  label={ __( 'Height' ) }
753
754
  value={ heightValue }
754
755
  onChange={ setHeightValue }
756
+ dimensionSizes={ dimensions?.dimensionSizes }
755
757
  />
756
758
  </ToolsPanelItem>
757
759
  ) }
@@ -769,6 +771,7 @@ export default function DimensionsPanel( {
769
771
  label={ __( 'Width' ) }
770
772
  value={ widthValue }
771
773
  onChange={ setWidthValue }
774
+ dimensionSizes={ dimensions?.dimensionSizes }
772
775
  />
773
776
  </ToolsPanelItem>
774
777
  ) }
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { getBlockType } from '@wordpress/blocks';
4
+ import { getBlockType, store as blocksStore } from '@wordpress/blocks';
5
5
  import { PanelBody } from '@wordpress/components';
6
6
  import { useSelect } from '@wordpress/data';
7
7
  import { DataForm } from '@wordpress/dataviews';
8
- import { useMemo } from '@wordpress/element';
8
+ import { useContext, useMemo } from '@wordpress/element';
9
9
  import { __ } from '@wordpress/i18n';
10
10
 
11
11
  /**
@@ -14,6 +14,8 @@ import { __ } from '@wordpress/i18n';
14
14
  import InspectorControls from '../components/inspector-controls';
15
15
  import { useBlockEditingMode } from '../components/block-editing-mode';
16
16
  import { store as blockEditorStore } from '../store';
17
+ import { unlock } from '../lock-unlock';
18
+ import BlockContext from '../components/block-context';
17
19
  import { generateFieldsFromAttributes } from './generate-fields-from-attributes';
18
20
 
19
21
  /**
@@ -45,9 +47,34 @@ function hasAutoGenerateControl( blockTypeAttributes ) {
45
47
  function AutoRegisterControls( { name, clientId, setAttributes } ) {
46
48
  const blockEditingMode = useBlockEditingMode();
47
49
 
50
+ const blockContext = useContext( BlockContext );
51
+
48
52
  const attributes = useSelect(
49
- ( select ) => select( blockEditorStore ).getBlockAttributes( clientId ),
50
- [ clientId ]
53
+ ( select ) => {
54
+ const _attributes =
55
+ select( blockEditorStore ).getBlockAttributes( clientId );
56
+ if ( ! _attributes?.metadata?.bindings ) {
57
+ return _attributes;
58
+ }
59
+
60
+ const { getBlockBindingsSource } = unlock( select( blocksStore ) );
61
+ return Object.entries( _attributes.metadata.bindings ).reduce(
62
+ ( acc, [ attribute, binding ] ) => {
63
+ const source = getBlockBindingsSource( binding.source );
64
+ if ( ! source ) {
65
+ return acc;
66
+ }
67
+ const values = source.getValues( {
68
+ select,
69
+ context: blockContext,
70
+ bindings: { [ attribute ]: binding },
71
+ } );
72
+ return { ...acc, ...values };
73
+ },
74
+ _attributes
75
+ );
76
+ },
77
+ [ blockContext, clientId ]
51
78
  );
52
79
 
53
80
  const blockType = getBlockType( name );
@@ -93,4 +93,20 @@ describe( 'getDimensionsClassesAndStyles', () => {
93
93
  },
94
94
  } );
95
95
  } );
96
+
97
+ it( 'should convert preset width value to CSS var', () => {
98
+ const attributes = {
99
+ style: {
100
+ dimensions: {
101
+ width: 'var:preset|dimension|custom-width',
102
+ },
103
+ },
104
+ };
105
+ expect( getDimensionsClassesAndStyles( attributes ) ).toEqual( {
106
+ className: undefined,
107
+ style: {
108
+ width: 'var(--wp--preset--dimension--custom-width)',
109
+ },
110
+ } );
111
+ } );
96
112
  } );
package/src/index.js CHANGED
@@ -11,6 +11,7 @@ export {
11
11
  useColorProps as __experimentalUseColorProps,
12
12
  useCustomSides as __experimentalUseCustomSides,
13
13
  getSpacingClassesAndStyles as __experimentalGetSpacingClassesAndStyles,
14
+ getDimensionsClassesAndStyles as __experimentalGetDimensionsClassesAndStyles,
14
15
  getGapCSSValue as __experimentalGetGapCSSValue,
15
16
  getShadowClassesAndStyles as __experimentalGetShadowClassesAndStyles,
16
17
  useCachedTruthy,
@@ -1,61 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // packages/block-editor/src/components/block-styles/preview-panel.js
31
- var preview_panel_exports = {};
32
- __export(preview_panel_exports, {
33
- default: () => BlockStylesPreviewPanel
34
- });
35
- module.exports = __toCommonJS(preview_panel_exports);
36
- var import_element = require("@wordpress/element");
37
- var import_preview_panel = __toESM(require("../inserter/preview-panel.cjs"));
38
- var import_utils = require("./utils.cjs");
39
- var import_jsx_runtime = require("react/jsx-runtime");
40
- function BlockStylesPreviewPanel({
41
- genericPreviewBlock,
42
- style,
43
- className,
44
- activeStyle
45
- }) {
46
- const styleClassName = (0, import_utils.replaceActiveStyle)(className, activeStyle, style);
47
- const previewBlocks = (0, import_element.useMemo)(() => {
48
- return {
49
- name: genericPreviewBlock.name,
50
- title: style.label || style.name,
51
- description: style.description,
52
- initialAttributes: {
53
- ...genericPreviewBlock.attributes,
54
- className: styleClassName + " block-editor-block-styles__block-preview-container"
55
- },
56
- example: genericPreviewBlock
57
- };
58
- }, [genericPreviewBlock, style, styleClassName]);
59
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_preview_panel.default, { item: previewBlocks });
60
- }
61
- //# sourceMappingURL=preview-panel.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/block-styles/preview-panel.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport InserterPreviewPanel from '../inserter/preview-panel';\nimport { replaceActiveStyle } from './utils';\n\nexport default function BlockStylesPreviewPanel( {\n\tgenericPreviewBlock,\n\tstyle,\n\tclassName,\n\tactiveStyle,\n} ) {\n\tconst styleClassName = replaceActiveStyle( className, activeStyle, style );\n\tconst previewBlocks = useMemo( () => {\n\t\treturn {\n\t\t\tname: genericPreviewBlock.name,\n\t\t\ttitle: style.label || style.name,\n\t\t\tdescription: style.description,\n\t\t\tinitialAttributes: {\n\t\t\t\t...genericPreviewBlock.attributes,\n\t\t\t\tclassName:\n\t\t\t\t\tstyleClassName +\n\t\t\t\t\t' block-editor-block-styles__block-preview-container',\n\t\t\t},\n\t\t\texample: genericPreviewBlock,\n\t\t};\n\t}, [ genericPreviewBlock, style, styleClassName ] );\n\n\treturn <InserterPreviewPanel item={ previewBlocks } />;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAwB;AAKxB,2BAAiC;AACjC,mBAAmC;AAwB3B;AAtBO,SAAR,wBAA0C;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,qBAAiB,iCAAoB,WAAW,aAAa,KAAM;AACzE,QAAM,oBAAgB,wBAAS,MAAM;AACpC,WAAO;AAAA,MACN,MAAM,oBAAoB;AAAA,MAC1B,OAAO,MAAM,SAAS,MAAM;AAAA,MAC5B,aAAa,MAAM;AAAA,MACnB,mBAAmB;AAAA,QAClB,GAAG,oBAAoB;AAAA,QACvB,WACC,iBACA;AAAA,MACF;AAAA,MACA,SAAS;AAAA,IACV;AAAA,EACD,GAAG,CAAE,qBAAqB,OAAO,cAAe,CAAE;AAElD,SAAO,4CAAC,qBAAAA,SAAA,EAAqB,MAAO,eAAgB;AACrD;",
6
- "names": ["InserterPreviewPanel"]
7
- }
@@ -1,30 +0,0 @@
1
- // packages/block-editor/src/components/block-styles/preview-panel.js
2
- import { useMemo } from "@wordpress/element";
3
- import InserterPreviewPanel from "../inserter/preview-panel.mjs";
4
- import { replaceActiveStyle } from "./utils.mjs";
5
- import { jsx } from "react/jsx-runtime";
6
- function BlockStylesPreviewPanel({
7
- genericPreviewBlock,
8
- style,
9
- className,
10
- activeStyle
11
- }) {
12
- const styleClassName = replaceActiveStyle(className, activeStyle, style);
13
- const previewBlocks = useMemo(() => {
14
- return {
15
- name: genericPreviewBlock.name,
16
- title: style.label || style.name,
17
- description: style.description,
18
- initialAttributes: {
19
- ...genericPreviewBlock.attributes,
20
- className: styleClassName + " block-editor-block-styles__block-preview-container"
21
- },
22
- example: genericPreviewBlock
23
- };
24
- }, [genericPreviewBlock, style, styleClassName]);
25
- return /* @__PURE__ */ jsx(InserterPreviewPanel, { item: previewBlocks });
26
- }
27
- export {
28
- BlockStylesPreviewPanel as default
29
- };
30
- //# sourceMappingURL=preview-panel.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/block-styles/preview-panel.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport InserterPreviewPanel from '../inserter/preview-panel';\nimport { replaceActiveStyle } from './utils';\n\nexport default function BlockStylesPreviewPanel( {\n\tgenericPreviewBlock,\n\tstyle,\n\tclassName,\n\tactiveStyle,\n} ) {\n\tconst styleClassName = replaceActiveStyle( className, activeStyle, style );\n\tconst previewBlocks = useMemo( () => {\n\t\treturn {\n\t\t\tname: genericPreviewBlock.name,\n\t\t\ttitle: style.label || style.name,\n\t\t\tdescription: style.description,\n\t\t\tinitialAttributes: {\n\t\t\t\t...genericPreviewBlock.attributes,\n\t\t\t\tclassName:\n\t\t\t\t\tstyleClassName +\n\t\t\t\t\t' block-editor-block-styles__block-preview-container',\n\t\t\t},\n\t\t\texample: genericPreviewBlock,\n\t\t};\n\t}, [ genericPreviewBlock, style, styleClassName ] );\n\n\treturn <InserterPreviewPanel item={ previewBlocks } />;\n}\n"],
5
- "mappings": ";AAGA,SAAS,eAAe;AAKxB,OAAO,0BAA0B;AACjC,SAAS,0BAA0B;AAwB3B;AAtBO,SAAR,wBAA0C;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,iBAAiB,mBAAoB,WAAW,aAAa,KAAM;AACzE,QAAM,gBAAgB,QAAS,MAAM;AACpC,WAAO;AAAA,MACN,MAAM,oBAAoB;AAAA,MAC1B,OAAO,MAAM,SAAS,MAAM;AAAA,MAC5B,aAAa,MAAM;AAAA,MACnB,mBAAmB;AAAA,QAClB,GAAG,oBAAoB;AAAA,QACvB,WACC,iBACA;AAAA,MACF;AAAA,MACA,SAAS;AAAA,IACV;AAAA,EACD,GAAG,CAAE,qBAAqB,OAAO,cAAe,CAAE;AAElD,SAAO,oBAAC,wBAAqB,MAAO,eAAgB;AACrD;",
6
- "names": []
7
- }
@@ -1,35 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useMemo } from '@wordpress/element';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import InserterPreviewPanel from '../inserter/preview-panel';
10
- import { replaceActiveStyle } from './utils';
11
-
12
- export default function BlockStylesPreviewPanel( {
13
- genericPreviewBlock,
14
- style,
15
- className,
16
- activeStyle,
17
- } ) {
18
- const styleClassName = replaceActiveStyle( className, activeStyle, style );
19
- const previewBlocks = useMemo( () => {
20
- return {
21
- name: genericPreviewBlock.name,
22
- title: style.label || style.name,
23
- description: style.description,
24
- initialAttributes: {
25
- ...genericPreviewBlock.attributes,
26
- className:
27
- styleClassName +
28
- ' block-editor-block-styles__block-preview-container',
29
- },
30
- example: genericPreviewBlock,
31
- };
32
- }, [ genericPreviewBlock, style, styleClassName ] );
33
-
34
- return <InserterPreviewPanel item={ previewBlocks } />;
35
- }