@wordpress/block-editor 14.2.1-next.1f6eadc42.0 → 14.3.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 (124) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/background-image-control/index.js +566 -0
  3. package/build/components/background-image-control/index.js.map +1 -0
  4. package/build/components/block-card/index.js +5 -2
  5. package/build/components/block-card/index.js.map +1 -1
  6. package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js +4 -2
  7. package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -1
  8. package/build/components/global-styles/background-panel.js +20 -545
  9. package/build/components/global-styles/background-panel.js.map +1 -1
  10. package/build/components/global-styles/dimensions-panel.js +3 -0
  11. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  12. package/build/components/iframe/index.js +1 -0
  13. package/build/components/iframe/index.js.map +1 -1
  14. package/build/components/image-editor/use-save-image.js +6 -0
  15. package/build/components/image-editor/use-save-image.js.map +1 -1
  16. package/build/components/image-editor/use-transform-image.js +1 -0
  17. package/build/components/image-editor/use-transform-image.js.map +1 -1
  18. package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +2 -4
  19. package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -1
  20. package/build/components/inserter/block-patterns-tab/index.js +2 -4
  21. package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
  22. package/build/components/inserter/media-tab/media-preview.js +4 -8
  23. package/build/components/inserter/media-tab/media-preview.js.map +1 -1
  24. package/build/components/inserter/media-tab/media-tab.js +2 -4
  25. package/build/components/inserter/media-tab/media-tab.js.map +1 -1
  26. package/build/components/inserter/quick-inserter.js +2 -4
  27. package/build/components/inserter/quick-inserter.js.map +1 -1
  28. package/build/components/inserter-listbox/item.js +2 -4
  29. package/build/components/inserter-listbox/item.js.map +1 -1
  30. package/build/components/link-control/index.js +14 -14
  31. package/build/components/link-control/index.js.map +1 -1
  32. package/build/components/link-control/search-input.js +4 -2
  33. package/build/components/link-control/search-input.js.map +1 -1
  34. package/build/components/rich-text/index.js +10 -4
  35. package/build/components/rich-text/index.js.map +1 -1
  36. package/build/components/spacing-sizes-control/utils.js +16 -4
  37. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  38. package/build/components/url-input/index.js +7 -6
  39. package/build/components/url-input/index.js.map +1 -1
  40. package/build/hooks/block-bindings.js +64 -53
  41. package/build/hooks/block-bindings.js.map +1 -1
  42. package/build/hooks/block-hooks.js +1 -8
  43. package/build/hooks/block-hooks.js.map +1 -1
  44. package/build/store/private-selectors.js +10 -0
  45. package/build/store/private-selectors.js.map +1 -1
  46. package/build-module/components/background-image-control/index.js +556 -0
  47. package/build-module/components/background-image-control/index.js.map +1 -0
  48. package/build-module/components/block-card/index.js +6 -3
  49. package/build-module/components/block-card/index.js.map +1 -1
  50. package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js +4 -2
  51. package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -1
  52. package/build-module/components/global-styles/background-panel.js +22 -546
  53. package/build-module/components/global-styles/background-panel.js.map +1 -1
  54. package/build-module/components/global-styles/dimensions-panel.js +3 -0
  55. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  56. package/build-module/components/iframe/index.js +1 -0
  57. package/build-module/components/iframe/index.js.map +1 -1
  58. package/build-module/components/image-editor/use-save-image.js +6 -0
  59. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  60. package/build-module/components/image-editor/use-transform-image.js +1 -0
  61. package/build-module/components/image-editor/use-transform-image.js.map +1 -1
  62. package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +2 -4
  63. package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -1
  64. package/build-module/components/inserter/block-patterns-tab/index.js +2 -4
  65. package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
  66. package/build-module/components/inserter/media-tab/media-preview.js +4 -8
  67. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
  68. package/build-module/components/inserter/media-tab/media-tab.js +2 -4
  69. package/build-module/components/inserter/media-tab/media-tab.js.map +1 -1
  70. package/build-module/components/inserter/quick-inserter.js +2 -4
  71. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  72. package/build-module/components/inserter-listbox/item.js +2 -4
  73. package/build-module/components/inserter-listbox/item.js.map +1 -1
  74. package/build-module/components/link-control/index.js +15 -15
  75. package/build-module/components/link-control/index.js.map +1 -1
  76. package/build-module/components/link-control/search-input.js +4 -2
  77. package/build-module/components/link-control/search-input.js.map +1 -1
  78. package/build-module/components/rich-text/index.js +10 -4
  79. package/build-module/components/rich-text/index.js.map +1 -1
  80. package/build-module/components/spacing-sizes-control/utils.js +16 -4
  81. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  82. package/build-module/components/url-input/index.js +8 -7
  83. package/build-module/components/url-input/index.js.map +1 -1
  84. package/build-module/hooks/block-bindings.js +64 -53
  85. package/build-module/hooks/block-bindings.js.map +1 -1
  86. package/build-module/hooks/block-hooks.js +3 -10
  87. package/build-module/hooks/block-hooks.js.map +1 -1
  88. package/build-module/store/private-selectors.js +10 -0
  89. package/build-module/store/private-selectors.js.map +1 -1
  90. package/build-style/style-rtl.css +152 -276
  91. package/build-style/style.css +152 -276
  92. package/package.json +32 -32
  93. package/src/components/background-image-control/index.js +741 -0
  94. package/src/components/background-image-control/style.scss +170 -0
  95. package/src/components/background-image-control/test/index.js +47 -0
  96. package/src/components/block-card/index.js +12 -3
  97. package/src/components/block-list/use-block-props/use-zoom-out-mode-exit.js +2 -5
  98. package/src/components/global-styles/background-panel.js +19 -730
  99. package/src/components/global-styles/dimensions-panel.js +3 -0
  100. package/src/components/global-styles/style.scss +0 -168
  101. package/src/components/global-styles/test/background-panel.js +1 -47
  102. package/src/components/image-editor/use-save-image.js +7 -0
  103. package/src/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +1 -2
  104. package/src/components/inserter/block-patterns-tab/index.js +1 -2
  105. package/src/components/inserter/media-tab/media-preview.js +2 -4
  106. package/src/components/inserter/media-tab/media-tab.js +1 -2
  107. package/src/components/inserter/quick-inserter.js +1 -2
  108. package/src/components/inserter/style.scss +0 -1
  109. package/src/components/inserter-listbox/item.js +1 -5
  110. package/src/components/link-control/index.js +19 -14
  111. package/src/components/link-control/search-input.js +2 -0
  112. package/src/components/link-control/style.scss +0 -22
  113. package/src/components/list-view/style.scss +1 -1
  114. package/src/components/rich-text/index.js +20 -5
  115. package/src/components/spacing-sizes-control/test/utils.js +18 -25
  116. package/src/components/spacing-sizes-control/utils.js +22 -5
  117. package/src/components/url-input/index.js +5 -4
  118. package/src/components/url-input/style.scss +3 -26
  119. package/src/hooks/block-bindings.js +63 -49
  120. package/src/hooks/block-hooks.js +3 -14
  121. package/src/hooks/block-hooks.scss +0 -9
  122. package/src/store/private-selectors.js +9 -0
  123. package/src/style.scss +1 -0
  124. package/src/utils/test/transform-styles.js +1 -1
@@ -0,0 +1,170 @@
1
+ .block-editor-global-styles-background-panel__inspector-media-replace-container {
2
+ border: $border-width solid $gray-300;
3
+ border-radius: $radius-small;
4
+ // Full width. ToolsPanel lays out children in a grid.
5
+ grid-column: 1 / -1;
6
+
7
+ &.is-open {
8
+ background-color: $gray-100;
9
+ }
10
+
11
+ .block-editor-global-styles-background-panel__image-tools-panel-item {
12
+ flex-grow: 1;
13
+ border: 0;
14
+
15
+ .components-dropdown {
16
+ display: block;
17
+ }
18
+ }
19
+
20
+ .block-editor-global-styles-background-panel__inspector-preview-inner {
21
+ height: 100%;
22
+ }
23
+
24
+ .components-dropdown {
25
+ display: block;
26
+ height: 36px;
27
+ }
28
+ }
29
+
30
+ .block-editor-global-styles-background-panel__image-tools-panel-item {
31
+ border: $border-width solid $gray-300;
32
+
33
+ // Full width. ToolsPanel lays out children in a grid.
34
+ grid-column: 1 / -1;
35
+
36
+ // Ensure the dropzone is positioned to the size of the item.
37
+ position: relative;
38
+
39
+ // Since there is no option to skip rendering the drag'n'drop icon in drop
40
+ // zone, we hide it for now.
41
+ .components-drop-zone__content-icon {
42
+ display: none;
43
+ }
44
+
45
+ .components-dropdown {
46
+ display: block;
47
+ height: 36px;
48
+ }
49
+
50
+ button.components-button {
51
+ color: $gray-900;
52
+ width: 100%;
53
+ display: block;
54
+
55
+ &:hover {
56
+ color: var(--wp-admin-theme-color);
57
+ }
58
+
59
+ &:focus {
60
+ box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
61
+ }
62
+ }
63
+
64
+ .block-editor-global-styles-background-panel__loading {
65
+ height: 100%;
66
+ position: absolute;
67
+ z-index: 1;
68
+ width: 100%;
69
+ padding: 10px 0 0 0;
70
+
71
+ svg {
72
+ margin: 0;
73
+ }
74
+ }
75
+ }
76
+
77
+ .block-editor-global-styles-background-panel__image-preview-content,
78
+ .block-editor-global-styles-background-panel__dropdown-toggle {
79
+ height: 100%;
80
+ width: 100%;
81
+ padding-left: $grid-unit-15;
82
+ }
83
+
84
+ .block-editor-global-styles-background-panel__dropdown-toggle {
85
+ cursor: pointer;
86
+ background: transparent;
87
+ border: none;
88
+ }
89
+
90
+ .block-editor-global-styles-background-panel__inspector-media-replace-title {
91
+ word-break: break-all;
92
+ // The Button component is white-space: nowrap, and that won't work with line-clamp.
93
+ white-space: normal;
94
+
95
+ // Without this, the ellipsis can sometimes be partially hidden by the Button padding.
96
+ text-align: start;
97
+ text-align-last: center;
98
+ }
99
+
100
+ .block-editor-global-styles-background-panel__inspector-preview-inner {
101
+ .block-editor-global-styles-background-panel__inspector-image-indicator-wrapper {
102
+ width: 20px;
103
+ height: 20px;
104
+ min-width: auto;
105
+ }
106
+ }
107
+
108
+ .block-editor-global-styles-background-panel__inspector-image-indicator {
109
+ background-size: cover;
110
+ border-radius: $radius-round;
111
+ width: 20px;
112
+ height: 20px;
113
+ display: block;
114
+ position: relative;
115
+ }
116
+
117
+ .block-editor-global-styles-background-panel__inspector-image-indicator::after {
118
+ content: "";
119
+ position: absolute;
120
+ top: -1px;
121
+ left: -1px;
122
+ bottom: -1px;
123
+ right: -1px;
124
+ border-radius: $radius-round;
125
+ box-shadow: inset 0 0 0 $border-width rgba(0, 0, 0, 0.2);
126
+ // Show a thin outline in Windows high contrast mode, otherwise the button is invisible.
127
+ border: 1px solid transparent;
128
+ box-sizing: inherit;
129
+ }
130
+
131
+ .block-editor-global-styles-background-panel__dropdown-content-wrapper {
132
+ min-width: 260px;
133
+ overflow-x: hidden;
134
+
135
+ .components-focal-point-picker-wrapper {
136
+ background-color: $gray-100;
137
+ width: 100%;
138
+ border-radius: $radius-small;
139
+ border: $border-width solid $gray-300;
140
+ }
141
+
142
+ .components-focal-point-picker__media--image {
143
+ max-height: 180px;
144
+ }
145
+
146
+ // Override focal picker to avoid a double border.
147
+ .components-focal-point-picker::after {
148
+ content: none;
149
+ }
150
+ }
151
+
152
+ // Push control panel into the background when the media modal is open.
153
+ .modal-open .block-editor-global-styles-background-panel__popover {
154
+ z-index: z-index(".block-editor-global-styles-background-panel__popover");
155
+ }
156
+
157
+ .block-editor-global-styles-background-panel__media-replace-popover {
158
+ .components-popover__content {
159
+ // width of block-editor-global-styles-background-panel__dropdown-content-wrapper minus padding.
160
+ width: 226px;
161
+ }
162
+
163
+ .components-button {
164
+ padding: 0 $grid-unit-10;
165
+ }
166
+
167
+ .components-button .components-menu-items__item-icon.has-icon-right {
168
+ margin-left: $grid-unit-30 - $grid-unit-10;
169
+ }
170
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+
5
+ import { backgroundPositionToCoords, coordsToBackgroundPosition } from '../';
6
+
7
+ describe( 'backgroundPositionToCoords', () => {
8
+ it( 'should return the correct coordinates for a percentage value using 2-value syntax', () => {
9
+ expect( backgroundPositionToCoords( '25% 75%' ) ).toEqual( {
10
+ x: 0.25,
11
+ y: 0.75,
12
+ } );
13
+ } );
14
+
15
+ it( 'should return the correct coordinates for a percentage using 1-value syntax', () => {
16
+ expect( backgroundPositionToCoords( '50%' ) ).toEqual( {
17
+ x: 0.5,
18
+ y: 0.5,
19
+ } );
20
+ } );
21
+
22
+ it( 'should return undefined coords in given an empty value', () => {
23
+ expect( backgroundPositionToCoords( '' ) ).toEqual( {
24
+ x: undefined,
25
+ y: undefined,
26
+ } );
27
+ } );
28
+
29
+ it( 'should return undefined coords in given a string that cannot be converted', () => {
30
+ expect( backgroundPositionToCoords( 'apples' ) ).toEqual( {
31
+ x: undefined,
32
+ y: undefined,
33
+ } );
34
+ } );
35
+ } );
36
+
37
+ describe( 'coordsToBackgroundPosition', () => {
38
+ it( 'should return the correct background position for a set of coordinates', () => {
39
+ expect( coordsToBackgroundPosition( { x: 0.25, y: 0.75 } ) ).toBe(
40
+ '25% 75%'
41
+ );
42
+ } );
43
+
44
+ it( 'should return undefined if no coordinates are provided', () => {
45
+ expect( coordsToBackgroundPosition( {} ) ).toBeUndefined();
46
+ } );
47
+ } );
@@ -13,7 +13,7 @@ import {
13
13
  __experimentalVStack as VStack,
14
14
  } from '@wordpress/components';
15
15
  import { chevronLeft, chevronRight } from '@wordpress/icons';
16
- import { __, isRTL } from '@wordpress/i18n';
16
+ import { __, isRTL, sprintf } from '@wordpress/i18n';
17
17
  import { useSelect, useDispatch } from '@wordpress/data';
18
18
 
19
19
  /**
@@ -22,7 +22,7 @@ import { useSelect, useDispatch } from '@wordpress/data';
22
22
  import BlockIcon from '../block-icon';
23
23
  import { store as blockEditorStore } from '../../store';
24
24
 
25
- function BlockCard( { title, icon, description, blockType, className } ) {
25
+ function BlockCard( { title, icon, description, blockType, className, name } ) {
26
26
  if ( blockType ) {
27
27
  deprecated( '`blockType` property in `BlockCard component`', {
28
28
  since: '5.7',
@@ -65,7 +65,16 @@ function BlockCard( { title, icon, description, blockType, className } ) {
65
65
  ) }
66
66
  <BlockIcon icon={ icon } showColors />
67
67
  <VStack spacing={ 1 }>
68
- <h2 className="block-editor-block-card__title">{ title }</h2>
68
+ <h2 className="block-editor-block-card__title">
69
+ { name?.length
70
+ ? sprintf(
71
+ // translators: %1$s: Custom block name. %2$s: Block title.
72
+ __( '%1$s (%2$s)' ),
73
+ name,
74
+ title
75
+ )
76
+ : title }
77
+ </h2>
69
78
  { description && (
70
79
  <Text className="block-editor-block-card__description">
71
80
  { description }
@@ -16,10 +16,7 @@ import { unlock } from '../../../lock-unlock';
16
16
  * @param {string} clientId Block client ID.
17
17
  */
18
18
  export function useZoomOutModeExit( { editorMode } ) {
19
- const getSettings = useSelect(
20
- ( select ) => select( blockEditorStore ).getSettings
21
- );
22
-
19
+ const { getSettings } = useSelect( blockEditorStore );
23
20
  const { __unstableSetEditorMode } = unlock(
24
21
  useDispatch( blockEditorStore )
25
22
  );
@@ -51,6 +48,6 @@ export function useZoomOutModeExit( { editorMode } ) {
51
48
  node.removeEventListener( 'dblclick', onDoubleClick );
52
49
  };
53
50
  },
54
- [ editorMode, __unstableSetEditorMode ]
51
+ [ editorMode, getSettings, __unstableSetEditorMode ]
55
52
  );
56
53
  }