@secretstache/wordpress-gutenberg 0.3.14 → 0.3.16
Sign up to get free protection for your applications and to get access to all the features.
- package/build/index.js +3 -3
- package/build/index.js.map +1 -1
- package/build/styles.css +3 -0
- package/package.json +1 -1
- package/src/components/ColorPaletteControl.js +1 -1
- package/src/components/PreviewControl.js +23 -0
- package/src/components/index.js +1 -0
- package/src/hooks/usePreviewControl.js +10 -17
- package/src/styles/_root-block-appender.scss +7 -0
- package/src/utils/rootBlock/setRootBlock.js +7 -4
package/build/styles.css
CHANGED
@@ -146,6 +146,9 @@
|
|
146
146
|
box-shadow: inset 0 0 0 1px #1e1e1e;
|
147
147
|
color: #1e1e1e; }
|
148
148
|
|
149
|
+
.block-editor__container .editor-visual-editor.is-resizable .root-block-appender {
|
150
|
+
display: none; }
|
151
|
+
|
149
152
|
.block-editor__container .root-block-appender {
|
150
153
|
position: absolute;
|
151
154
|
bottom: 30px;
|
package/package.json
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
import { ToggleControl } from '@wordpress/components';
|
2
|
+
|
3
|
+
const defaultLabel = 'Enable Preview';
|
4
|
+
const defaultHelp = 'Please check this option to see how the block will actually look and behave on the frontend.';
|
5
|
+
|
6
|
+
export const PreviewControl = (props) => {
|
7
|
+
const {
|
8
|
+
checked,
|
9
|
+
onChange,
|
10
|
+
help = defaultHelp,
|
11
|
+
label = defaultLabel,
|
12
|
+
} = props;
|
13
|
+
|
14
|
+
return (
|
15
|
+
<ToggleControl
|
16
|
+
checked={checked}
|
17
|
+
onChange={onChange}
|
18
|
+
label={label}
|
19
|
+
help={help}
|
20
|
+
{...props}
|
21
|
+
/>
|
22
|
+
);
|
23
|
+
};
|
package/src/components/index.js
CHANGED
@@ -11,3 +11,4 @@ export { ResourcesWrapper } from './ResourcesWrapper.js'
|
|
11
11
|
export { DividersControl } from './DividersControl.js'
|
12
12
|
export { MediaTypeControl } from './MediaTypeControl.js'
|
13
13
|
export { InsertBlockToolbar } from './InsertBlockToolbar.js'
|
14
|
+
export { PreviewControl } from './PreviewControl.js'
|
@@ -1,8 +1,5 @@
|
|
1
|
-
import { useCallback,
|
2
|
-
import {
|
3
|
-
|
4
|
-
const defaultLabel = 'Enable Preview';
|
5
|
-
const defaultHelpText = 'Please check this option to see how the block will actually look and behave on the frontend.';
|
1
|
+
import { useCallback, useState } from '@wordpress/element';
|
2
|
+
import { PreviewControl } from '../components/PreviewControl.js';
|
6
3
|
|
7
4
|
export const usePreviewControl = () => {
|
8
5
|
const [ isPreview, setIsPreview ] = useState(false);
|
@@ -11,21 +8,17 @@ export const usePreviewControl = () => {
|
|
11
8
|
setIsPreview(prev => !prev);
|
12
9
|
}, []);
|
13
10
|
|
14
|
-
const
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
{...props}
|
22
|
-
/>
|
23
|
-
);
|
24
|
-
});
|
11
|
+
const control = (props) => (
|
12
|
+
<PreviewControl
|
13
|
+
checked={isPreview}
|
14
|
+
onChange={onChange}
|
15
|
+
{...props}
|
16
|
+
/>
|
17
|
+
);
|
25
18
|
|
26
19
|
return {
|
27
20
|
isPreview,
|
28
21
|
setIsPreview,
|
29
|
-
PreviewControl,
|
22
|
+
PreviewControl: control,
|
30
23
|
};
|
31
24
|
};
|
@@ -17,16 +17,19 @@ export const setRootBlock = (rootBlockName, initAppender = true, appenderTooltip
|
|
17
17
|
'blocks.registerBlockType',
|
18
18
|
'ssm/with-root-block',
|
19
19
|
(settings, name) => {
|
20
|
-
|
21
|
-
|
20
|
+
const isRootBlock = name === rootBlockName;
|
21
|
+
const isBaseBlock = name === 'core/block';
|
22
|
+
const hasAncestor = !!settings?.ancestor;
|
23
|
+
|
24
|
+
if (!isRootBlock && !isBaseBlock && !hasAncestor) {
|
22
25
|
settings.ancestor = [rootBlockName];
|
23
26
|
}
|
24
27
|
|
25
28
|
return settings;
|
26
|
-
}
|
29
|
+
},
|
27
30
|
);
|
28
31
|
|
29
32
|
if (initAppender) {
|
30
33
|
initRootBlockAppender(rootBlockName, appenderTooltipText);
|
31
34
|
}
|
32
|
-
}
|
35
|
+
};
|