@plaudit/gutenberg-api-extensions 2.80.0 → 2.81.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 +158 -0
- package/README.md +10 -2
- package/dist/blocks/basic-custom-block-bindings-support.js +10 -10
- package/dist/blocks/basic-custom-block-bindings-support.js.map +1 -1
- package/dist/blocks/utilities.d.ts +1 -1
- package/dist/controls/ExtendedFormTokenField.d.ts +1 -1
- package/dist/controls/ExtendedFormTokenField.js.map +1 -1
- package/dist/controls/hooks/useImprovedTokenManager.d.ts +1 -1
- package/dist/controls/hooks/useImprovedTokenManager.js.map +1 -1
- package/dist/editor/simple-gutenberg-endpoints-impl.d.ts +1 -0
- package/dist/editor/simple-gutenberg-endpoints-impl.js +6 -0
- package/dist/editor/simple-gutenberg-endpoints-impl.js.map +1 -1
- package/dist/lib/gutenberg-api-extensions-state.d.ts +1 -1
- package/dist/lib/helpers.d.ts +1 -2
- package/dist/lib/helpers.js.map +1 -1
- package/package.json +20 -16
- package/simple-native-properties.md +1100 -0
- package/src/blocks/basic-custom-block-bindings-support.tsx +12 -12
- package/src/blocks/utilities.ts +1 -1
- package/src/controls/ExtendedFormTokenField.tsx +1 -2
- package/src/controls/hooks/useImprovedTokenManager.ts +1 -2
- package/src/editor/simple-gutenberg-endpoints-impl.ts +8 -1
- package/src/lib/helpers.ts +1 -2
- package/src/schemas/README.md +1 -0
- package/src/schemas/plaudit-block-schema.json +818 -0
|
@@ -93,7 +93,7 @@ export function installCustomBlockBindingsSupport() {
|
|
|
93
93
|
);
|
|
94
94
|
|
|
95
95
|
type BlockBindingToolProps = {
|
|
96
|
-
value: { source: string, args
|
|
96
|
+
value: { source: string, args: { [key: string]: any } } | undefined,
|
|
97
97
|
currentPost: any,
|
|
98
98
|
label: string,
|
|
99
99
|
binding: string
|
|
@@ -119,7 +119,7 @@ export function installCustomBlockBindingsSupport() {
|
|
|
119
119
|
key="source"
|
|
120
120
|
label="Source"
|
|
121
121
|
__nextHasNoMarginBottom={true}
|
|
122
|
-
onChange={source => updateBlockBindings({[binding]: {source}})}
|
|
122
|
+
onChange={source => updateBlockBindings({[binding]: {source, args: {}}})}
|
|
123
123
|
options={[
|
|
124
124
|
{
|
|
125
125
|
disabled: true,
|
|
@@ -158,11 +158,11 @@ export function installCustomBlockBindingsSupport() {
|
|
|
158
158
|
|
|
159
159
|
const subfieldKeys = useMemo<SelectableOptions[number]['subfields']>(() => {
|
|
160
160
|
if (Array.isArray(selectableOptions)) {
|
|
161
|
-
const key = value?.args
|
|
161
|
+
const key = value?.args['key'];
|
|
162
162
|
return key ? selectableOptions.find(option => option.value === key)?.subfields ?? [] : [];
|
|
163
163
|
}
|
|
164
164
|
return [];
|
|
165
|
-
}, [selectableOptions, value?.args
|
|
165
|
+
}, [selectableOptions, value?.args['key']]);
|
|
166
166
|
|
|
167
167
|
const controls: ReactElement[] = [];
|
|
168
168
|
if (selectableOptions.length) {
|
|
@@ -180,7 +180,7 @@ export function installCustomBlockBindingsSupport() {
|
|
|
180
180
|
},
|
|
181
181
|
...selectableOptions
|
|
182
182
|
]}
|
|
183
|
-
value={value?.args
|
|
183
|
+
value={value?.args['key'] ?? ''}
|
|
184
184
|
/>);
|
|
185
185
|
|
|
186
186
|
if (subfieldKeys.length) {
|
|
@@ -190,7 +190,7 @@ export function installCustomBlockBindingsSupport() {
|
|
|
190
190
|
label="Subfield"
|
|
191
191
|
__nextHasNoMarginBottom={true}
|
|
192
192
|
onChange={subfield => updateBlockBindings({[binding]: (value ? {...value, args: {...value.args, subfield}} : undefined)})}
|
|
193
|
-
value={value?.args
|
|
193
|
+
value={value?.args['subfield'] ?? ''}
|
|
194
194
|
help="Please enter the name of a subfield. You may need to inspect the raw data from this binding to determine the subfield."
|
|
195
195
|
/>);
|
|
196
196
|
} else {
|
|
@@ -207,28 +207,28 @@ export function installCustomBlockBindingsSupport() {
|
|
|
207
207
|
},
|
|
208
208
|
...subfieldKeys
|
|
209
209
|
]}
|
|
210
|
-
value={value?.args
|
|
210
|
+
value={value?.args['subfield'] ?? ''}
|
|
211
211
|
/>);
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
if (value?.args
|
|
215
|
+
if (value?.args['key'] && dbSources?.length) {
|
|
216
216
|
controls.push(<SelectControl
|
|
217
217
|
key="db-source"
|
|
218
218
|
label="DB Source"
|
|
219
219
|
__nextHasNoMarginBottom={true}
|
|
220
220
|
onChange={db_source => updateBlockBindings({[binding]: (value ? {...value, args: {...value.args, db_source}} : undefined)})}
|
|
221
221
|
options={dbSources}
|
|
222
|
-
value={value?.args
|
|
223
|
-
help={dbSources.find(dbs => dbs.value === value?.args
|
|
222
|
+
value={value?.args['db_source'] ?? dbSources[0]!.value}
|
|
223
|
+
help={dbSources.find(dbs => dbs.value === value?.args['db_source'])?.help}
|
|
224
224
|
/>);
|
|
225
|
-
} else if (value?.args
|
|
225
|
+
} else if (value?.args['db_source']) {
|
|
226
226
|
const {db_source, ...updatedArgs} = value.args;
|
|
227
227
|
updateBlockBindings({[binding]: {...value, args: updatedArgs}});
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
if (controls.length === 0) {
|
|
231
|
-
controls.push(<p>No Options Found</p>);
|
|
231
|
+
controls.push(<p key="no-options-found-text">No Options Found</p>);
|
|
232
232
|
}
|
|
233
233
|
return controls;
|
|
234
234
|
});
|
package/src/blocks/utilities.ts
CHANGED
|
@@ -2,7 +2,7 @@ import {type BlockStyle, type BlockVariation, registerBlockStyle, registerBlockV
|
|
|
2
2
|
import {store as realBlockEditorStore} from "@wordpress/block-editor";
|
|
3
3
|
import type * as BlockEditorActions from "@wordpress/block-editor/store/actions";
|
|
4
4
|
import type * as BlockEditorSelectors from "@wordpress/block-editor/store/selectors";
|
|
5
|
-
import type {ReduxStoreConfig, StoreDescriptor} from "@wordpress/data
|
|
5
|
+
import type {ReduxStoreConfig, StoreDescriptor} from "@wordpress/data";
|
|
6
6
|
import domReady from "@wordpress/dom-ready";
|
|
7
7
|
|
|
8
8
|
import type {PairNormalizedPickableOptions} from "../controls";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {Spinner, FormTokenField} from '@wordpress/components';
|
|
2
2
|
import {useDebounce} from "@wordpress/compose";
|
|
3
|
-
import {useSelect} from "@wordpress/data";
|
|
4
|
-
import type {MapSelect} from "@wordpress/data/types";
|
|
3
|
+
import {type MapSelect, useSelect} from "@wordpress/data";
|
|
5
4
|
import {useCallback, useEffect, useMemo, useRef, useState} from "@wordpress/element";
|
|
6
5
|
import {__} from "@wordpress/i18n";
|
|
7
6
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {useSelect} from "@wordpress/data";
|
|
2
|
-
import type {MapSelect} from "@wordpress/data/types";
|
|
1
|
+
import {type MapSelect, useSelect} from "@wordpress/data";
|
|
3
2
|
import {useEffect, useMemo, useRef, useState} from "@wordpress/element";
|
|
4
3
|
|
|
5
4
|
import type {TokenItem} from "../../lib/useful-types";
|
|
@@ -31,7 +31,8 @@ export namespace installSimpleGutenbergApisSupport {
|
|
|
31
31
|
|
|
32
32
|
type Selectors = {
|
|
33
33
|
get(name: string, args?: ApiCallArgs): unknown,
|
|
34
|
-
resolve(name: string, args?: ApiCallArgs): Promise<unknown
|
|
34
|
+
resolve(name: string, args?: ApiCallArgs): Promise<unknown>,
|
|
35
|
+
registeredEndpoints(): string[]
|
|
35
36
|
};
|
|
36
37
|
type Actions = {
|
|
37
38
|
registerEndpoint(
|
|
@@ -94,6 +95,9 @@ export const store: ReturnType<typeof createReduxStore<{}, Actions, AddBSStateAr
|
|
|
94
95
|
},
|
|
95
96
|
resolve(name, args?) {
|
|
96
97
|
return handleCacheMiss(name, args);
|
|
98
|
+
},
|
|
99
|
+
registeredEndpoints(): string[] {
|
|
100
|
+
return Object.keys(endpoints);
|
|
97
101
|
}
|
|
98
102
|
};
|
|
99
103
|
const suspendSelectors: Selectors = {
|
|
@@ -102,6 +106,9 @@ export const store: ReturnType<typeof createReduxStore<{}, Actions, AddBSStateAr
|
|
|
102
106
|
},
|
|
103
107
|
resolve(name, args?) {
|
|
104
108
|
return useToPromise(handleCacheMiss(name, args));
|
|
109
|
+
},
|
|
110
|
+
registeredEndpoints(): string[] {
|
|
111
|
+
return Object.keys(endpoints);
|
|
105
112
|
}
|
|
106
113
|
};
|
|
107
114
|
|
package/src/lib/helpers.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {resolveSelect, type select} from "@wordpress/data";
|
|
2
|
-
import type {ActionCreator, ReduxStoreConfig} from "@wordpress/data/types";
|
|
1
|
+
import {type ActionCreator, type ReduxStoreConfig, resolveSelect, type select} from "@wordpress/data";
|
|
3
2
|
import type * as MetaActions from "@wordpress/data/redux-store/metadata/actions";
|
|
4
3
|
import type * as MetaSelectors from "@wordpress/data/redux-store/metadata/selectors";
|
|
5
4
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
See `Deploy Schema` section of ../README.md
|