@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.
- package/README.md +12 -0
- package/build/components/block-alignment-matrix-control/index.js +1 -8
- package/build/components/block-alignment-matrix-control/index.js.map +2 -2
- package/build/components/block-bindings/attribute-control.js +172 -0
- package/build/components/block-bindings/attribute-control.js.map +7 -0
- package/build/components/block-bindings/index.js +47 -0
- package/build/components/block-bindings/index.js.map +7 -0
- package/build/components/block-bindings/source-fields-list.js +135 -0
- package/build/components/block-bindings/source-fields-list.js.map +7 -0
- package/build/components/block-bindings/use-block-bindings-utils.js +66 -0
- package/build/components/block-bindings/use-block-bindings-utils.js.map +7 -0
- package/build/components/block-edit/edit.js +1 -3
- package/build/components/block-edit/edit.js.map +2 -2
- package/build/components/block-styles/preview-panel.js +3 -5
- package/build/components/block-styles/preview-panel.js.map +2 -2
- package/build/components/block-styles/use-styles-for-block.js +2 -2
- package/build/components/block-styles/use-styles-for-block.js.map +2 -2
- package/build/components/block-toolbar/index.js +1 -8
- package/build/components/block-toolbar/index.js.map +3 -3
- package/build/components/content-only-controls/index.js +2 -25
- package/build/components/content-only-controls/index.js.map +2 -2
- package/build/components/content-only-controls/link/index.js +3 -3
- package/build/components/content-only-controls/link/index.js.map +2 -2
- package/build/components/content-only-controls/media/index.js +3 -3
- package/build/components/content-only-controls/media/index.js.map +2 -2
- package/build/components/content-only-controls/rich-text/index.js +3 -2
- package/build/components/content-only-controls/rich-text/index.js.map +2 -2
- package/build/components/dimensions-tool/width-height-tool.js +4 -16
- package/build/components/dimensions-tool/width-height-tool.js.map +3 -3
- package/build/components/image-editor/cropper.js +3 -34
- package/build/components/image-editor/cropper.js.map +3 -3
- package/build/components/image-editor/index.js +9 -3
- package/build/components/image-editor/index.js.map +2 -2
- package/build/components/image-editor/use-transform-image.js +62 -32
- package/build/components/image-editor/use-transform-image.js.map +2 -2
- package/build/components/image-editor/zoom-dropdown.js +2 -2
- package/build/components/image-editor/zoom-dropdown.js.map +2 -2
- package/build/components/index.js +10 -3
- package/build/components/index.js.map +2 -2
- package/build/components/inserter-draggable-blocks/index.js +8 -4
- package/build/components/inserter-draggable-blocks/index.js.map +2 -2
- package/build/components/inspector-controls-tabs/content-tab.js +3 -2
- package/build/components/inspector-controls-tabs/content-tab.js.map +2 -2
- package/build/components/tool-selector/index.js +46 -0
- package/build/components/tool-selector/index.js.map +7 -0
- package/build/hooks/block-bindings.js +22 -260
- package/build/hooks/block-bindings.js.map +3 -3
- package/build/layouts/grid.js +23 -28
- package/build/layouts/grid.js.map +2 -2
- package/build/utils/block-bindings.js +2 -44
- package/build/utils/block-bindings.js.map +3 -3
- package/build/utils/index.js +2 -5
- package/build/utils/index.js.map +2 -2
- package/build-module/components/block-alignment-matrix-control/index.js +1 -8
- package/build-module/components/block-alignment-matrix-control/index.js.map +2 -2
- package/build-module/components/block-bindings/attribute-control.js +150 -0
- package/build-module/components/block-bindings/attribute-control.js.map +7 -0
- package/build-module/components/block-bindings/index.js +10 -0
- package/build-module/components/block-bindings/index.js.map +7 -0
- package/build-module/components/block-bindings/source-fields-list.js +104 -0
- package/build-module/components/block-bindings/source-fields-list.js.map +7 -0
- package/build-module/components/block-bindings/use-block-bindings-utils.js +45 -0
- package/build-module/components/block-bindings/use-block-bindings-utils.js.map +7 -0
- package/build-module/components/block-edit/edit.js +1 -3
- package/build-module/components/block-edit/edit.js.map +2 -2
- package/build-module/components/block-styles/preview-panel.js +3 -5
- package/build-module/components/block-styles/preview-panel.js.map +2 -2
- package/build-module/components/block-styles/use-styles-for-block.js +2 -2
- package/build-module/components/block-styles/use-styles-for-block.js.map +2 -2
- package/build-module/components/block-toolbar/index.js +1 -8
- package/build-module/components/block-toolbar/index.js.map +2 -2
- package/build-module/components/content-only-controls/index.js +2 -25
- package/build-module/components/content-only-controls/index.js.map +2 -2
- package/build-module/components/content-only-controls/link/index.js +3 -3
- package/build-module/components/content-only-controls/link/index.js.map +2 -2
- package/build-module/components/content-only-controls/media/index.js +3 -3
- package/build-module/components/content-only-controls/media/index.js.map +2 -2
- package/build-module/components/content-only-controls/rich-text/index.js +3 -2
- package/build-module/components/content-only-controls/rich-text/index.js.map +2 -2
- package/build-module/components/dimensions-tool/width-height-tool.js +4 -6
- package/build-module/components/dimensions-tool/width-height-tool.js.map +2 -2
- package/build-module/components/image-editor/cropper.js +3 -34
- package/build-module/components/image-editor/cropper.js.map +2 -2
- package/build-module/components/image-editor/index.js +9 -3
- package/build-module/components/image-editor/index.js.map +2 -2
- package/build-module/components/image-editor/use-transform-image.js +63 -33
- package/build-module/components/image-editor/use-transform-image.js.map +2 -2
- package/build-module/components/image-editor/zoom-dropdown.js +2 -2
- package/build-module/components/image-editor/zoom-dropdown.js.map +2 -2
- package/build-module/components/index.js +74 -66
- package/build-module/components/index.js.map +2 -2
- package/build-module/components/inserter-draggable-blocks/index.js +8 -4
- package/build-module/components/inserter-draggable-blocks/index.js.map +2 -2
- package/build-module/components/inspector-controls-tabs/content-tab.js +3 -2
- package/build-module/components/inspector-controls-tabs/content-tab.js.map +2 -2
- package/build-module/components/tool-selector/index.js +15 -0
- package/build-module/components/tool-selector/index.js.map +7 -0
- package/build-module/hooks/block-bindings.js +27 -270
- package/build-module/hooks/block-bindings.js.map +2 -2
- package/build-module/layouts/grid.js +23 -28
- package/build-module/layouts/grid.js.map +2 -2
- package/build-module/utils/block-bindings.js +1 -42
- package/build-module/utils/block-bindings.js.map +2 -2
- package/build-module/utils/index.js +1 -3
- package/build-module/utils/index.js.map +2 -2
- package/build-style/style-rtl.css +6 -6
- package/build-style/style.css +6 -6
- package/package.json +39 -40
- package/src/components/block-alignment-matrix-control/index.js +1 -5
- package/src/components/block-bindings/attribute-control.js +174 -0
- package/src/components/block-bindings/index.js +6 -0
- package/src/components/block-bindings/source-fields-list.js +130 -0
- package/src/components/block-bindings/use-block-bindings-utils.js +156 -0
- package/src/components/block-edit/edit.js +1 -3
- package/src/components/block-styles/preview-panel.js +3 -5
- package/src/components/block-styles/use-styles-for-block.js +2 -2
- package/src/components/block-toolbar/index.js +1 -6
- package/src/components/block-toolbar/style.scss +6 -6
- package/src/components/content-only-controls/index.js +2 -27
- package/src/components/content-only-controls/link/index.js +3 -3
- package/src/components/content-only-controls/media/index.js +3 -3
- package/src/components/content-only-controls/rich-text/index.js +3 -2
- package/src/components/dimensions-tool/width-height-tool.js +6 -13
- package/src/components/image-editor/cropper.js +3 -32
- package/src/components/image-editor/index.js +34 -29
- package/src/components/image-editor/use-transform-image.js +80 -34
- package/src/components/image-editor/zoom-dropdown.js +2 -2
- package/src/components/index.js +9 -1
- package/src/components/inserter/style.scss +1 -1
- package/src/components/inserter-draggable-blocks/index.js +19 -8
- package/src/components/inspector-controls-tabs/content-tab.js +6 -2
- package/src/components/tool-selector/index.js +19 -0
- package/src/hooks/block-bindings.js +27 -347
- package/src/layouts/grid.js +40 -72
- package/src/layouts/test/grid.js +14 -0
- package/src/utils/block-bindings.js +0 -157
- package/src/utils/index.js +0 -1
- package/tsconfig.json +1 -0
- package/build/components/block-toolbar/block-name-context.js +0 -30
- package/build/components/block-toolbar/block-name-context.js.map +0 -7
- package/build-module/components/block-toolbar/block-name-context.js +0 -9
- package/build-module/components/block-toolbar/block-name-context.js.map +0 -7
- package/src/components/block-toolbar/block-name-context.js +0 -9
- /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
|
-
}
|
package/src/utils/index.js
CHANGED
package/tsconfig.json
CHANGED
|
@@ -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;
|
|
File without changes
|