@secretstache/wordpress-gutenberg 0.7.0 → 0.7.2
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/build/index.js +335 -313
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/MediaControl.jsx +11 -12
- package/src/components/MediaWithFocalPointControl.jsx +10 -11
- package/src/components/index.js +0 -1
- package/src/filters/index.js +1 -0
- package/src/filters/root-block-default.js +44 -0
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@ export const ImageRenderer = ({
|
|
|
27
27
|
<Button
|
|
28
28
|
className="bc-remove-btn"
|
|
29
29
|
onClick={onRemoveClick}
|
|
30
|
-
|
|
30
|
+
variant="secondary"
|
|
31
31
|
isDestructive
|
|
32
32
|
>
|
|
33
33
|
{removeButtonLabel}
|
|
@@ -61,7 +61,7 @@ export const VideoRenderer = ({
|
|
|
61
61
|
<Button
|
|
62
62
|
className="bc-remove-btn"
|
|
63
63
|
onClick={onRemoveClick}
|
|
64
|
-
|
|
64
|
+
variant="secondary"
|
|
65
65
|
isDestructive
|
|
66
66
|
>
|
|
67
67
|
{removeButtonLabel}
|
|
@@ -158,16 +158,15 @@ export const MediaControl = ({
|
|
|
158
158
|
|
|
159
159
|
{
|
|
160
160
|
hasFocalPoint && mediaId && mediaUrl && (
|
|
161
|
-
<
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
</BaseControl>
|
|
161
|
+
<FocalPointPicker
|
|
162
|
+
__nextHasNoMarginBottom
|
|
163
|
+
label={focalPointLabel}
|
|
164
|
+
url={mediaUrl}
|
|
165
|
+
value={focalPoint}
|
|
166
|
+
onDragStart={onFocalPointChange}
|
|
167
|
+
onDrag={onFocalPointChange}
|
|
168
|
+
onChange={onFocalPointChange}
|
|
169
|
+
/>
|
|
171
170
|
)
|
|
172
171
|
}
|
|
173
172
|
</>
|
|
@@ -36,7 +36,7 @@ export const MediaWithFocalPointControl = memo(({
|
|
|
36
36
|
|
|
37
37
|
[focalPointAttributeName]: { x: 0.5, y: 0.5 }
|
|
38
38
|
});
|
|
39
|
-
}, [ mediaAttributeName ]);
|
|
39
|
+
}, [ mediaAttributeName, focalPointAttributeName ]);
|
|
40
40
|
|
|
41
41
|
const onMediaRemove = useCallback(() => {
|
|
42
42
|
setAttributes({
|
|
@@ -62,16 +62,15 @@ export const MediaWithFocalPointControl = memo(({
|
|
|
62
62
|
</BaseControl>
|
|
63
63
|
|
|
64
64
|
{media?.url && (
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
</BaseControl>
|
|
65
|
+
<FocalPointPicker
|
|
66
|
+
__nextHasNoMarginBottom
|
|
67
|
+
label={focalPointLabel}
|
|
68
|
+
url={media.url}
|
|
69
|
+
value={focalPoint}
|
|
70
|
+
onDragStart={onFocalPointChange}
|
|
71
|
+
onDrag={onFocalPointChange}
|
|
72
|
+
onChange={onFocalPointChange}
|
|
73
|
+
/>
|
|
75
74
|
)}
|
|
76
75
|
</>
|
|
77
76
|
);
|
package/src/components/index.js
CHANGED
|
@@ -13,7 +13,6 @@ export * from './MediaTypeControl.jsx';
|
|
|
13
13
|
export * from './InsertBlockToolbar.jsx';
|
|
14
14
|
export * from './PreviewControl.jsx';
|
|
15
15
|
export * from './MediaWithFocalPointControl.jsx';
|
|
16
|
-
export * from './MediaWithFocalPointControl.jsx';
|
|
17
16
|
export * from './EmptyBlockPlaceholder.jsx';
|
|
18
17
|
export * from './PatternAppender.jsx';
|
|
19
18
|
export * from './PatternsModal.jsx';
|
package/src/filters/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { dispatch } from '@wordpress/data';
|
|
|
3
3
|
export * from './hide-root-block-for-other.js';
|
|
4
4
|
export * from './inner-blocks-cleanup.jsx';
|
|
5
5
|
export * from './root-block.js';
|
|
6
|
+
export * from './root-block-default.js';
|
|
6
7
|
export * from './block-categories.js';
|
|
7
8
|
|
|
8
9
|
export const setPostTypeFilters = (filters, currentPostType, onSet) => {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { subscribe, select, dispatch } from '@wordpress/data';
|
|
2
|
+
import { createBlock } from '@wordpress/blocks';
|
|
3
|
+
|
|
4
|
+
/* WordPress's own empty-canvas fallback (clicking/focusing the "Type / to
|
|
5
|
+
choose a block" prompt) inserts core/paragraph with no ancestor check,
|
|
6
|
+
bypassing RootBlockFilter's "everything lives inside the root block" rule.
|
|
7
|
+
getBlockCount() with no rootClientId only ever reflects the top-level
|
|
8
|
+
canvas, so this never fires for an emptied-out Column/Group — those still
|
|
9
|
+
fall back to the normal default block. */
|
|
10
|
+
export class RootBlockDefaultFilter {
|
|
11
|
+
name = 'ssm/root-block-default';
|
|
12
|
+
isAdded = false;
|
|
13
|
+
unsubscribe = null;
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
rootBlockName = 'ssm/section-wrapper',
|
|
17
|
+
postTypes = ['page', 'post', 'ssm_design_system'],
|
|
18
|
+
) {
|
|
19
|
+
this.rootBlockName = rootBlockName;
|
|
20
|
+
this.postTypes = postTypes;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
add() {
|
|
24
|
+
let previousCount = select('core/block-editor').getBlockCount();
|
|
25
|
+
|
|
26
|
+
this.unsubscribe = subscribe(() => {
|
|
27
|
+
const currentCount = select('core/block-editor').getBlockCount();
|
|
28
|
+
|
|
29
|
+
if (previousCount > 0 && currentCount === 0) {
|
|
30
|
+
dispatch('core/block-editor').insertBlock(createBlock(this.rootBlockName));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
previousCount = currentCount;
|
|
34
|
+
}, 'core/block-editor');
|
|
35
|
+
|
|
36
|
+
this.isAdded = true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
remove() {
|
|
40
|
+
this.unsubscribe?.();
|
|
41
|
+
this.unsubscribe = null;
|
|
42
|
+
this.isAdded = false;
|
|
43
|
+
}
|
|
44
|
+
}
|