@wordpress/block-editor 15.9.0 → 15.9.1-next.6deb34194.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 (144) hide show
  1. package/README.md +12 -0
  2. package/build/components/block-alignment-matrix-control/index.js +1 -8
  3. package/build/components/block-alignment-matrix-control/index.js.map +2 -2
  4. package/build/components/block-bindings/attribute-control.js +172 -0
  5. package/build/components/block-bindings/attribute-control.js.map +7 -0
  6. package/build/components/block-bindings/index.js +47 -0
  7. package/build/components/block-bindings/index.js.map +7 -0
  8. package/build/components/block-bindings/source-fields-list.js +135 -0
  9. package/build/components/block-bindings/source-fields-list.js.map +7 -0
  10. package/build/components/block-bindings/use-block-bindings-utils.js +66 -0
  11. package/build/components/block-bindings/use-block-bindings-utils.js.map +7 -0
  12. package/build/components/block-edit/edit.js +1 -3
  13. package/build/components/block-edit/edit.js.map +2 -2
  14. package/build/components/block-styles/preview-panel.js +3 -5
  15. package/build/components/block-styles/preview-panel.js.map +2 -2
  16. package/build/components/block-styles/use-styles-for-block.js +2 -2
  17. package/build/components/block-styles/use-styles-for-block.js.map +2 -2
  18. package/build/components/block-toolbar/index.js +1 -8
  19. package/build/components/block-toolbar/index.js.map +3 -3
  20. package/build/components/content-only-controls/index.js +2 -25
  21. package/build/components/content-only-controls/index.js.map +2 -2
  22. package/build/components/content-only-controls/link/index.js +3 -3
  23. package/build/components/content-only-controls/link/index.js.map +2 -2
  24. package/build/components/content-only-controls/media/index.js +3 -3
  25. package/build/components/content-only-controls/media/index.js.map +2 -2
  26. package/build/components/content-only-controls/rich-text/index.js +3 -2
  27. package/build/components/content-only-controls/rich-text/index.js.map +2 -2
  28. package/build/components/dimensions-tool/width-height-tool.js +4 -16
  29. package/build/components/dimensions-tool/width-height-tool.js.map +3 -3
  30. package/build/components/image-editor/cropper.js +3 -34
  31. package/build/components/image-editor/cropper.js.map +3 -3
  32. package/build/components/image-editor/index.js +9 -3
  33. package/build/components/image-editor/index.js.map +2 -2
  34. package/build/components/image-editor/use-transform-image.js +62 -32
  35. package/build/components/image-editor/use-transform-image.js.map +2 -2
  36. package/build/components/image-editor/zoom-dropdown.js +2 -2
  37. package/build/components/image-editor/zoom-dropdown.js.map +2 -2
  38. package/build/components/index.js +10 -3
  39. package/build/components/index.js.map +2 -2
  40. package/build/components/inserter-draggable-blocks/index.js +8 -4
  41. package/build/components/inserter-draggable-blocks/index.js.map +2 -2
  42. package/build/components/inspector-controls-tabs/content-tab.js +3 -2
  43. package/build/components/inspector-controls-tabs/content-tab.js.map +2 -2
  44. package/build/components/tool-selector/index.js +46 -0
  45. package/build/components/tool-selector/index.js.map +7 -0
  46. package/build/hooks/block-bindings.js +22 -260
  47. package/build/hooks/block-bindings.js.map +3 -3
  48. package/build/layouts/grid.js +23 -28
  49. package/build/layouts/grid.js.map +2 -2
  50. package/build/utils/block-bindings.js +2 -44
  51. package/build/utils/block-bindings.js.map +3 -3
  52. package/build/utils/index.js +2 -5
  53. package/build/utils/index.js.map +2 -2
  54. package/build-module/components/block-alignment-matrix-control/index.js +1 -8
  55. package/build-module/components/block-alignment-matrix-control/index.js.map +2 -2
  56. package/build-module/components/block-bindings/attribute-control.js +150 -0
  57. package/build-module/components/block-bindings/attribute-control.js.map +7 -0
  58. package/build-module/components/block-bindings/index.js +10 -0
  59. package/build-module/components/block-bindings/index.js.map +7 -0
  60. package/build-module/components/block-bindings/source-fields-list.js +104 -0
  61. package/build-module/components/block-bindings/source-fields-list.js.map +7 -0
  62. package/build-module/components/block-bindings/use-block-bindings-utils.js +45 -0
  63. package/build-module/components/block-bindings/use-block-bindings-utils.js.map +7 -0
  64. package/build-module/components/block-edit/edit.js +1 -3
  65. package/build-module/components/block-edit/edit.js.map +2 -2
  66. package/build-module/components/block-styles/preview-panel.js +3 -5
  67. package/build-module/components/block-styles/preview-panel.js.map +2 -2
  68. package/build-module/components/block-styles/use-styles-for-block.js +2 -2
  69. package/build-module/components/block-styles/use-styles-for-block.js.map +2 -2
  70. package/build-module/components/block-toolbar/index.js +1 -8
  71. package/build-module/components/block-toolbar/index.js.map +2 -2
  72. package/build-module/components/content-only-controls/index.js +2 -25
  73. package/build-module/components/content-only-controls/index.js.map +2 -2
  74. package/build-module/components/content-only-controls/link/index.js +3 -3
  75. package/build-module/components/content-only-controls/link/index.js.map +2 -2
  76. package/build-module/components/content-only-controls/media/index.js +3 -3
  77. package/build-module/components/content-only-controls/media/index.js.map +2 -2
  78. package/build-module/components/content-only-controls/rich-text/index.js +3 -2
  79. package/build-module/components/content-only-controls/rich-text/index.js.map +2 -2
  80. package/build-module/components/dimensions-tool/width-height-tool.js +4 -6
  81. package/build-module/components/dimensions-tool/width-height-tool.js.map +2 -2
  82. package/build-module/components/image-editor/cropper.js +3 -34
  83. package/build-module/components/image-editor/cropper.js.map +2 -2
  84. package/build-module/components/image-editor/index.js +9 -3
  85. package/build-module/components/image-editor/index.js.map +2 -2
  86. package/build-module/components/image-editor/use-transform-image.js +63 -33
  87. package/build-module/components/image-editor/use-transform-image.js.map +2 -2
  88. package/build-module/components/image-editor/zoom-dropdown.js +2 -2
  89. package/build-module/components/image-editor/zoom-dropdown.js.map +2 -2
  90. package/build-module/components/index.js +74 -66
  91. package/build-module/components/index.js.map +2 -2
  92. package/build-module/components/inserter-draggable-blocks/index.js +8 -4
  93. package/build-module/components/inserter-draggable-blocks/index.js.map +2 -2
  94. package/build-module/components/inspector-controls-tabs/content-tab.js +3 -2
  95. package/build-module/components/inspector-controls-tabs/content-tab.js.map +2 -2
  96. package/build-module/components/tool-selector/index.js +15 -0
  97. package/build-module/components/tool-selector/index.js.map +7 -0
  98. package/build-module/hooks/block-bindings.js +27 -270
  99. package/build-module/hooks/block-bindings.js.map +2 -2
  100. package/build-module/layouts/grid.js +23 -28
  101. package/build-module/layouts/grid.js.map +2 -2
  102. package/build-module/utils/block-bindings.js +1 -42
  103. package/build-module/utils/block-bindings.js.map +2 -2
  104. package/build-module/utils/index.js +1 -3
  105. package/build-module/utils/index.js.map +2 -2
  106. package/build-style/style-rtl.css +6 -6
  107. package/build-style/style.css +6 -6
  108. package/package.json +39 -40
  109. package/src/components/block-alignment-matrix-control/index.js +1 -5
  110. package/src/components/block-bindings/attribute-control.js +174 -0
  111. package/src/components/block-bindings/index.js +6 -0
  112. package/src/components/block-bindings/source-fields-list.js +130 -0
  113. package/src/components/block-bindings/use-block-bindings-utils.js +156 -0
  114. package/src/components/block-edit/edit.js +1 -3
  115. package/src/components/block-styles/preview-panel.js +3 -5
  116. package/src/components/block-styles/use-styles-for-block.js +2 -2
  117. package/src/components/block-toolbar/index.js +1 -6
  118. package/src/components/block-toolbar/style.scss +6 -6
  119. package/src/components/content-only-controls/index.js +2 -27
  120. package/src/components/content-only-controls/link/index.js +3 -3
  121. package/src/components/content-only-controls/media/index.js +3 -3
  122. package/src/components/content-only-controls/rich-text/index.js +3 -2
  123. package/src/components/dimensions-tool/width-height-tool.js +6 -13
  124. package/src/components/image-editor/cropper.js +3 -32
  125. package/src/components/image-editor/index.js +34 -29
  126. package/src/components/image-editor/use-transform-image.js +80 -34
  127. package/src/components/image-editor/zoom-dropdown.js +2 -2
  128. package/src/components/index.js +9 -1
  129. package/src/components/inserter/style.scss +1 -1
  130. package/src/components/inserter-draggable-blocks/index.js +19 -8
  131. package/src/components/inspector-controls-tabs/content-tab.js +6 -2
  132. package/src/components/tool-selector/index.js +19 -0
  133. package/src/hooks/block-bindings.js +27 -347
  134. package/src/layouts/grid.js +40 -72
  135. package/src/layouts/test/grid.js +14 -0
  136. package/src/utils/block-bindings.js +0 -157
  137. package/src/utils/index.js +0 -1
  138. package/tsconfig.json +1 -0
  139. package/build/components/block-toolbar/block-name-context.js +0 -30
  140. package/build/components/block-toolbar/block-name-context.js.map +0 -7
  141. package/build-module/components/block-toolbar/block-name-context.js +0 -9
  142. package/build-module/components/block-toolbar/block-name-context.js.map +0 -7
  143. package/src/components/block-toolbar/block-name-context.js +0 -9
  144. /package/src/{utils → components/block-bindings}/test/use-block-bindings-utils.js +0 -0
@@ -1,28 +1,6 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useDispatch, useRegistry } from '@wordpress/data';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import { store as blockEditorStore } from '../store';
10
- import { useBlockEditContext } from '../components/block-edit';
11
-
12
1
  const DEFAULT_ATTRIBUTE = '__default';
13
2
  const PATTERN_OVERRIDES_SOURCE = 'core/pattern-overrides';
14
3
 
15
- /**
16
- * Checks if the given object is empty.
17
- *
18
- * @param {?Object} object The object to check.
19
- *
20
- * @return {boolean} Whether the object is empty.
21
- */
22
- function isObjectEmpty( object ) {
23
- return ! object || Object.keys( object ).length === 0;
24
- }
25
-
26
4
  /**
27
5
  * Checks if the block has the `__default` binding for pattern overrides.
28
6
  *
@@ -66,138 +44,3 @@ export function replacePatternOverridesDefaultBinding(
66
44
 
67
45
  return bindings;
68
46
  }
69
-
70
- /**
71
- * Contains utils to update the block `bindings` metadata.
72
- *
73
- * @typedef {Object} WPBlockBindingsUtils
74
- *
75
- * @property {Function} updateBlockBindings Updates the value of the bindings connected to block attributes.
76
- * @property {Function} removeAllBlockBindings Removes the bindings property of the `metadata` attribute.
77
- */
78
-
79
- /**
80
- * Retrieves the existing utils needed to update the block `bindings` metadata.
81
- * They can be used to create, modify, or remove connections from the existing block attributes.
82
- *
83
- * It contains the following utils:
84
- * - `updateBlockBindings`: Updates the value of the bindings connected to block attributes. It can be used to remove a specific binding by setting the value to `undefined`.
85
- * - `removeAllBlockBindings`: Removes the bindings property of the `metadata` attribute.
86
- *
87
- * @since 6.7.0 Introduced in WordPress core.
88
- *
89
- * @param {?string} clientId Optional block client ID. If not set, it will use the current block client ID from the context.
90
- *
91
- * @return {?WPBlockBindingsUtils} Object containing the block bindings utils.
92
- *
93
- * @example
94
- * ```js
95
- * import { useBlockBindingsUtils } from '@wordpress/block-editor'
96
- * const { updateBlockBindings, removeAllBlockBindings } = useBlockBindingsUtils();
97
- *
98
- * // Update url and alt attributes.
99
- * updateBlockBindings( {
100
- * url: {
101
- * source: 'core/post-meta',
102
- * args: {
103
- * key: 'url_custom_field',
104
- * },
105
- * },
106
- * alt: {
107
- * source: 'core/post-meta',
108
- * args: {
109
- * key: 'text_custom_field',
110
- * },
111
- * },
112
- * } );
113
- *
114
- * // Remove binding from url attribute.
115
- * updateBlockBindings( { url: undefined } );
116
- *
117
- * // Remove bindings from all attributes.
118
- * removeAllBlockBindings();
119
- * ```
120
- */
121
- export function useBlockBindingsUtils( clientId ) {
122
- const { clientId: contextClientId } = useBlockEditContext();
123
- const blockClientId = clientId || contextClientId;
124
- const { updateBlockAttributes } = useDispatch( blockEditorStore );
125
- const { getBlockAttributes } = useRegistry().select( blockEditorStore );
126
-
127
- /**
128
- * Updates the value of the bindings connected to block attributes.
129
- * It removes the binding when the new value is `undefined`.
130
- *
131
- * @param {Object} bindings Bindings including the attributes to update and the new object.
132
- * @param {string} bindings.source The source name to connect to.
133
- * @param {Object} [bindings.args] Object containing the arguments needed by the source.
134
- *
135
- * @example
136
- * ```js
137
- * import { useBlockBindingsUtils } from '@wordpress/block-editor'
138
- *
139
- * const { updateBlockBindings } = useBlockBindingsUtils();
140
- * updateBlockBindings( {
141
- * url: {
142
- * source: 'core/post-meta',
143
- * args: {
144
- * key: 'url_custom_field',
145
- * },
146
- * },
147
- * alt: {
148
- * source: 'core/post-meta',
149
- * args: {
150
- * key: 'text_custom_field',
151
- * },
152
- * }
153
- * } );
154
- * ```
155
- */
156
- const updateBlockBindings = ( bindings ) => {
157
- const { metadata: { bindings: currentBindings, ...metadata } = {} } =
158
- getBlockAttributes( blockClientId );
159
- const newBindings = { ...currentBindings };
160
-
161
- Object.entries( bindings ).forEach( ( [ attribute, binding ] ) => {
162
- if ( ! binding && newBindings[ attribute ] ) {
163
- delete newBindings[ attribute ];
164
- return;
165
- }
166
- newBindings[ attribute ] = binding;
167
- } );
168
-
169
- const newMetadata = {
170
- ...metadata,
171
- bindings: newBindings,
172
- };
173
-
174
- if ( isObjectEmpty( newMetadata.bindings ) ) {
175
- delete newMetadata.bindings;
176
- }
177
-
178
- updateBlockAttributes( blockClientId, {
179
- metadata: isObjectEmpty( newMetadata ) ? undefined : newMetadata,
180
- } );
181
- };
182
-
183
- /**
184
- * Removes the bindings property of the `metadata` attribute.
185
- *
186
- * @example
187
- * ```js
188
- * import { useBlockBindingsUtils } from '@wordpress/block-editor'
189
- *
190
- * const { removeAllBlockBindings } = useBlockBindingsUtils();
191
- * removeAllBlockBindings();
192
- * ```
193
- */
194
- const removeAllBlockBindings = () => {
195
- const { metadata: { bindings, ...metadata } = {} } =
196
- getBlockAttributes( blockClientId );
197
- updateBlockAttributes( blockClientId, {
198
- metadata: isObjectEmpty( metadata ) ? undefined : metadata,
199
- } );
200
- };
201
-
202
- return { updateBlockBindings, removeAllBlockBindings };
203
- }
@@ -1,3 +1,2 @@
1
1
  export { default as transformStyles } from './transform-styles';
2
2
  export { default as getPxFromCssUnit } from './get-px-from-css-unit';
3
- export { useBlockBindingsUtils } from './block-bindings';
package/tsconfig.json CHANGED
@@ -23,6 +23,7 @@
23
23
  { "path": "../html-entities" },
24
24
  { "path": "../i18n" },
25
25
  { "path": "../icons" },
26
+ { "path": "../image-cropper" },
26
27
  { "path": "../interactivity" },
27
28
  { "path": "../is-shallow-equal" },
28
29
  { "path": "../keycodes" },
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/block-editor/src/components/block-toolbar/block-name-context.js
21
- var block_name_context_exports = {};
22
- __export(block_name_context_exports, {
23
- default: () => block_name_context_default
24
- });
25
- module.exports = __toCommonJS(block_name_context_exports);
26
- var import_element = require("@wordpress/element");
27
- var __unstableBlockNameContext = (0, import_element.createContext)("");
28
- __unstableBlockNameContext.displayName = "__unstableBlockNameContext";
29
- var block_name_context_default = __unstableBlockNameContext;
30
- //# sourceMappingURL=block-name-context.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/block-toolbar/block-name-context.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nconst __unstableBlockNameContext = createContext( '' );\n__unstableBlockNameContext.displayName = '__unstableBlockNameContext';\n\nexport default __unstableBlockNameContext;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA8B;AAE9B,IAAM,iCAA6B,8BAAe,EAAG;AACrD,2BAA2B,cAAc;AAEzC,IAAO,6BAAQ;",
6
- "names": []
7
- }
@@ -1,9 +0,0 @@
1
- // packages/block-editor/src/components/block-toolbar/block-name-context.js
2
- import { createContext } from "@wordpress/element";
3
- var __unstableBlockNameContext = createContext("");
4
- __unstableBlockNameContext.displayName = "__unstableBlockNameContext";
5
- var block_name_context_default = __unstableBlockNameContext;
6
- export {
7
- block_name_context_default as default
8
- };
9
- //# sourceMappingURL=block-name-context.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/block-toolbar/block-name-context.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nconst __unstableBlockNameContext = createContext( '' );\n__unstableBlockNameContext.displayName = '__unstableBlockNameContext';\n\nexport default __unstableBlockNameContext;\n"],
5
- "mappings": ";AAGA,SAAS,qBAAqB;AAE9B,IAAM,6BAA6B,cAAe,EAAG;AACrD,2BAA2B,cAAc;AAEzC,IAAO,6BAAQ;",
6
- "names": []
7
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { createContext } from '@wordpress/element';
5
-
6
- const __unstableBlockNameContext = createContext( '' );
7
- __unstableBlockNameContext.displayName = '__unstableBlockNameContext';
8
-
9
- export default __unstableBlockNameContext;