@wordpress/block-library 9.38.1-next.v.0 → 9.39.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 +2 -0
- package/build/button/index.cjs +3 -0
- package/build/button/index.cjs.map +2 -2
- package/build/comments-title/block.json +1 -3
- package/build/comments-title/deprecated.cjs +148 -24
- package/build/comments-title/deprecated.cjs.map +3 -3
- package/build/comments-title/edit.cjs +17 -31
- package/build/comments-title/edit.cjs.map +3 -3
- package/build/cover/edit/block-controls.cjs +10 -2
- package/build/cover/edit/block-controls.cjs.map +2 -2
- package/build/cover/edit/embed-video-url-input.cjs +6 -2
- package/build/cover/edit/embed-video-url-input.cjs.map +2 -2
- package/build/details/index.cjs +3 -0
- package/build/details/index.cjs.map +2 -2
- package/build/heading/index.cjs +3 -0
- package/build/heading/index.cjs.map +2 -2
- package/build/image/index.cjs +1 -1
- package/build/image/index.cjs.map +2 -2
- package/build/index.cjs +6 -0
- package/build/index.cjs.map +2 -2
- package/build/list-item/index.cjs +3 -0
- package/build/list-item/index.cjs.map +2 -2
- package/build/more/index.cjs +1 -1
- package/build/more/index.cjs.map +2 -2
- package/build/navigation/edit/index.cjs +23 -2
- package/build/navigation/edit/index.cjs.map +2 -2
- package/build/navigation-submenu/index.cjs +2 -2
- package/build/navigation-submenu/index.cjs.map +2 -2
- package/build/paragraph/index.cjs +1 -1
- package/build/paragraph/index.cjs.map +2 -2
- package/build/post-excerpt/edit.cjs +1 -1
- package/build/post-excerpt/edit.cjs.map +2 -2
- package/build/tab/add-tab-toolbar-control.cjs +31 -9
- package/build/tab/add-tab-toolbar-control.cjs.map +2 -2
- package/build/tab/block.json +18 -4
- package/build/tab/controls.cjs +4 -8
- package/build/tab/controls.cjs.map +3 -3
- package/build/tab/edit.cjs +46 -118
- package/build/tab/edit.cjs.map +3 -3
- package/build/tab/remove-tab-toolbar-control.cjs +91 -0
- package/build/tab/remove-tab-toolbar-control.cjs.map +7 -0
- package/build/tab/save.cjs +2 -2
- package/build/tab/save.cjs.map +2 -2
- package/build/tab-panels/block.json +70 -0
- package/build/tab-panels/edit.cjs +63 -0
- package/build/tab-panels/edit.cjs.map +7 -0
- package/build/tab-panels/icon.cjs +29 -0
- package/build/tab-panels/icon.cjs.map +7 -0
- package/build/tab-panels/index.cjs +58 -0
- package/build/tab-panels/index.cjs.map +7 -0
- package/build/tab-panels/save.cjs +33 -0
- package/build/tab-panels/save.cjs.map +7 -0
- package/build/tabs/block.json +61 -90
- package/build/tabs/controls.cjs +19 -221
- package/build/tabs/controls.cjs.map +3 -3
- package/build/tabs/deprecated.cjs +179 -0
- package/build/tabs/deprecated.cjs.map +7 -0
- package/build/tabs/edit.cjs +84 -62
- package/build/tabs/edit.cjs.map +3 -3
- package/build/tabs/index.cjs +3 -1
- package/build/tabs/index.cjs.map +3 -3
- package/build/tabs/save.cjs +6 -9
- package/build/tabs/save.cjs.map +2 -2
- package/build/tabs-menu/block.json +77 -0
- package/build/tabs-menu/edit.cjs +204 -0
- package/build/tabs-menu/edit.cjs.map +7 -0
- package/build/tabs-menu/icon.cjs +29 -0
- package/build/tabs-menu/icon.cjs.map +7 -0
- package/build/tabs-menu/index.cjs +58 -0
- package/build/tabs-menu/index.cjs.map +7 -0
- package/build/tabs-menu/save.cjs +35 -0
- package/build/tabs-menu/save.cjs.map +7 -0
- package/build/tabs-menu-item/block.json +98 -0
- package/build/tabs-menu-item/controls.cjs +247 -0
- package/build/tabs-menu-item/controls.cjs.map +7 -0
- package/build/tabs-menu-item/edit.cjs +272 -0
- package/build/tabs-menu-item/edit.cjs.map +7 -0
- package/build/tabs-menu-item/icon.cjs +29 -0
- package/build/tabs-menu-item/icon.cjs.map +7 -0
- package/build/tabs-menu-item/index.cjs +58 -0
- package/build/tabs-menu-item/index.cjs.map +7 -0
- package/build/tabs-menu-item/save.cjs +50 -0
- package/build/tabs-menu-item/save.cjs.map +7 -0
- package/build/template-part/edit/index.cjs +1 -1
- package/build/template-part/edit/index.cjs.map +2 -2
- package/build/utils/caption.cjs +4 -6
- package/build/utils/caption.cjs.map +3 -3
- package/build/video/edit.cjs +4 -2
- package/build/video/edit.cjs.map +2 -2
- package/build-module/button/index.mjs +3 -0
- package/build-module/button/index.mjs.map +2 -2
- package/build-module/comments-title/block.json +1 -3
- package/build-module/comments-title/deprecated.mjs +148 -24
- package/build-module/comments-title/deprecated.mjs.map +2 -2
- package/build-module/comments-title/edit.mjs +17 -32
- package/build-module/comments-title/edit.mjs.map +2 -2
- package/build-module/cover/edit/block-controls.mjs +11 -3
- package/build-module/cover/edit/block-controls.mjs.map +2 -2
- package/build-module/cover/edit/embed-video-url-input.mjs +6 -2
- package/build-module/cover/edit/embed-video-url-input.mjs.map +2 -2
- package/build-module/details/index.mjs +3 -0
- package/build-module/details/index.mjs.map +2 -2
- package/build-module/heading/index.mjs +3 -0
- package/build-module/heading/index.mjs.map +2 -2
- package/build-module/image/index.mjs +1 -1
- package/build-module/image/index.mjs.map +2 -2
- package/build-module/index.mjs +6 -0
- package/build-module/index.mjs.map +2 -2
- package/build-module/list-item/index.mjs +3 -0
- package/build-module/list-item/index.mjs.map +2 -2
- package/build-module/more/index.mjs +1 -1
- package/build-module/more/index.mjs.map +2 -2
- package/build-module/navigation/edit/index.mjs +23 -2
- package/build-module/navigation/edit/index.mjs.map +2 -2
- package/build-module/navigation-submenu/index.mjs +2 -2
- package/build-module/navigation-submenu/index.mjs.map +2 -2
- package/build-module/paragraph/index.mjs +1 -1
- package/build-module/paragraph/index.mjs.map +2 -2
- package/build-module/post-excerpt/edit.mjs +1 -1
- package/build-module/post-excerpt/edit.mjs.map +2 -2
- package/build-module/tab/add-tab-toolbar-control.mjs +32 -10
- package/build-module/tab/add-tab-toolbar-control.mjs.map +2 -2
- package/build-module/tab/block.json +18 -4
- package/build-module/tab/controls.mjs +4 -8
- package/build-module/tab/controls.mjs.map +2 -2
- package/build-module/tab/edit.mjs +48 -128
- package/build-module/tab/edit.mjs.map +2 -2
- package/build-module/tab/remove-tab-toolbar-control.mjs +73 -0
- package/build-module/tab/remove-tab-toolbar-control.mjs.map +7 -0
- package/build-module/tab/save.mjs +2 -2
- package/build-module/tab/save.mjs.map +2 -2
- package/build-module/tab-panels/block.json +70 -0
- package/build-module/tab-panels/edit.mjs +36 -0
- package/build-module/tab-panels/edit.mjs.map +7 -0
- package/build-module/tab-panels/icon.mjs +8 -0
- package/build-module/tab-panels/icon.mjs.map +7 -0
- package/build-module/tab-panels/index.mjs +20 -0
- package/build-module/tab-panels/index.mjs.map +7 -0
- package/build-module/tab-panels/save.mjs +12 -0
- package/build-module/tab-panels/save.mjs.map +7 -0
- package/build-module/tabs/block.json +61 -90
- package/build-module/tabs/controls.mjs +21 -228
- package/build-module/tabs/controls.mjs.map +2 -2
- package/build-module/tabs/deprecated.mjs +158 -0
- package/build-module/tabs/deprecated.mjs.map +7 -0
- package/build-module/tabs/edit.mjs +87 -64
- package/build-module/tabs/edit.mjs.map +2 -2
- package/build-module/tabs/index.mjs +3 -1
- package/build-module/tabs/index.mjs.map +2 -2
- package/build-module/tabs/save.mjs +7 -10
- package/build-module/tabs/save.mjs.map +2 -2
- package/build-module/tabs-menu/block.json +77 -0
- package/build-module/tabs-menu/edit.mjs +186 -0
- package/build-module/tabs-menu/edit.mjs.map +7 -0
- package/build-module/tabs-menu/icon.mjs +8 -0
- package/build-module/tabs-menu/icon.mjs.map +7 -0
- package/build-module/tabs-menu/index.mjs +20 -0
- package/build-module/tabs-menu/index.mjs.map +7 -0
- package/build-module/tabs-menu/save.mjs +14 -0
- package/build-module/tabs-menu/save.mjs.map +7 -0
- package/build-module/tabs-menu-item/block.json +98 -0
- package/build-module/tabs-menu-item/controls.mjs +227 -0
- package/build-module/tabs-menu-item/controls.mjs.map +7 -0
- package/build-module/tabs-menu-item/edit.mjs +253 -0
- package/build-module/tabs-menu-item/edit.mjs.map +7 -0
- package/build-module/tabs-menu-item/icon.mjs +8 -0
- package/build-module/tabs-menu-item/icon.mjs.map +7 -0
- package/build-module/tabs-menu-item/index.mjs +20 -0
- package/build-module/tabs-menu-item/index.mjs.map +7 -0
- package/build-module/tabs-menu-item/save.mjs +29 -0
- package/build-module/tabs-menu-item/save.mjs.map +7 -0
- package/build-module/template-part/edit/index.mjs +1 -1
- package/build-module/template-part/edit/index.mjs.map +2 -2
- package/build-module/utils/caption.mjs +1 -3
- package/build-module/utils/caption.mjs.map +2 -2
- package/build-module/video/edit.mjs +4 -2
- package/build-module/video/edit.mjs.map +2 -2
- package/build-style/editor-rtl.css +16 -21
- package/build-style/editor.css +16 -21
- package/build-style/gallery/style-rtl.css +1 -1
- package/build-style/gallery/style.css +1 -1
- package/build-style/style-rtl.css +42 -153
- package/build-style/style.css +42 -153
- package/build-style/tab/style-rtl.css +7 -1
- package/build-style/tab/style.css +7 -1
- package/build-style/tab-panels/style-rtl.css +4 -0
- package/build-style/tab-panels/style.css +4 -0
- package/build-style/tabs/style-rtl.css +1 -167
- package/build-style/tabs/style.css +1 -167
- package/build-style/tabs-menu/editor-rtl.css +4 -0
- package/build-style/tabs-menu/editor.css +4 -0
- package/build-style/tabs-menu/style-rtl.css +8 -0
- package/build-style/tabs-menu/style.css +8 -0
- package/build-style/tabs-menu-item/editor-rtl.css +16 -0
- package/build-style/tabs-menu-item/editor.css +16 -0
- package/build-style/tabs-menu-item/style-rtl.css +34 -0
- package/build-style/tabs-menu-item/style.css +34 -0
- package/package.json +37 -37
- package/src/button/index.js +4 -0
- package/src/comments-title/block.json +1 -3
- package/src/comments-title/deprecated.js +153 -23
- package/src/comments-title/edit.js +9 -25
- package/src/cover/edit/block-controls.js +14 -3
- package/src/cover/edit/embed-video-url-input.js +6 -2
- package/src/details/index.js +4 -0
- package/src/editor.scss +2 -1
- package/src/gallery/style.scss +1 -1
- package/src/heading/index.js +4 -0
- package/src/image/index.js +4 -1
- package/src/index.js +6 -0
- package/src/list-item/index.js +4 -0
- package/src/more/index.js +4 -1
- package/src/navigation/edit/index.js +28 -4
- package/src/navigation-submenu/index.js +6 -3
- package/src/paragraph/index.js +4 -1
- package/src/post-excerpt/edit.js +1 -1
- package/src/post-excerpt/index.php +39 -16
- package/src/style.scss +3 -0
- package/src/tab/add-tab-toolbar-control.js +36 -11
- package/src/tab/block.json +18 -4
- package/src/tab/controls.js +4 -5
- package/src/tab/edit.js +75 -150
- package/src/tab/index.php +5 -63
- package/src/tab/remove-tab-toolbar-control.js +103 -0
- package/src/tab/save.js +1 -3
- package/src/tab/style.scss +8 -1
- package/src/tab-panels/block.json +70 -0
- package/src/tab-panels/edit.js +44 -0
- package/src/tab-panels/icon.js +10 -0
- package/src/tab-panels/index.js +21 -0
- package/src/tab-panels/save.js +11 -0
- package/src/tab-panels/style.scss +4 -0
- package/src/tabs/block.json +61 -90
- package/src/tabs/controls.js +7 -221
- package/src/tabs/deprecated.js +214 -0
- package/src/tabs/edit.js +108 -68
- package/src/tabs/index.js +2 -0
- package/src/tabs/index.php +86 -191
- package/src/tabs/save.js +6 -13
- package/src/tabs/style.scss +1 -187
- package/src/tabs-menu/block.json +77 -0
- package/src/tabs-menu/edit.js +251 -0
- package/src/tabs-menu/editor.scss +6 -0
- package/src/tabs-menu/icon.js +10 -0
- package/src/tabs-menu/index.js +21 -0
- package/src/tabs-menu/index.php +74 -0
- package/src/tabs-menu/save.js +18 -0
- package/src/tabs-menu/style.scss +8 -0
- package/src/tabs-menu-item/block.json +98 -0
- package/src/tabs-menu-item/controls.js +262 -0
- package/src/tabs-menu-item/edit.js +322 -0
- package/src/tabs-menu-item/editor.scss +20 -0
- package/src/tabs-menu-item/icon.js +10 -0
- package/src/tabs-menu-item/index.js +21 -0
- package/src/tabs-menu-item/index.php +82 -0
- package/src/tabs-menu-item/save.js +44 -0
- package/src/tabs-menu-item/style.scss +42 -0
- package/src/template-part/edit/index.js +1 -3
- package/src/utils/caption.js +1 -7
- package/src/video/edit.js +4 -2
- package/build/tab/tabs-list.cjs +0 -132
- package/build/tab/tabs-list.cjs.map +0 -7
- package/build/tabs/style-engine.cjs +0 -119
- package/build/tabs/style-engine.cjs.map +0 -7
- package/build-module/tab/tabs-list.mjs +0 -101
- package/build-module/tab/tabs-list.mjs.map +0 -7
- package/build-module/tabs/style-engine.mjs +0 -101
- package/build-module/tabs/style-engine.mjs.map +0 -7
- package/build-style/tabs/editor-rtl.css +0 -26
- package/build-style/tabs/editor.css +0 -26
- package/src/tab/tabs-list.js +0 -122
- package/src/tabs/editor.scss +0 -30
- package/src/tabs/style-engine.js +0 -164
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
BlockControls,
|
|
6
|
+
store as blockEditorStore,
|
|
7
|
+
} from '@wordpress/block-editor';
|
|
8
|
+
import { ToolbarGroup, ToolbarButton } from '@wordpress/components';
|
|
9
|
+
import { __ } from '@wordpress/i18n';
|
|
10
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* "Remove Tab" button in the block toolbar for the tab block.
|
|
14
|
+
* Removes the currently active tab from the tab-panels block.
|
|
15
|
+
*
|
|
16
|
+
* @param {Object} props
|
|
17
|
+
* @param {string} props.tabsClientId The client ID of the parent tabs block.
|
|
18
|
+
* @return {JSX.Element} The toolbar control element.
|
|
19
|
+
*/
|
|
20
|
+
export default function RemoveTabToolbarControl( { tabsClientId } ) {
|
|
21
|
+
const {
|
|
22
|
+
removeBlock,
|
|
23
|
+
updateBlockAttributes,
|
|
24
|
+
selectBlock,
|
|
25
|
+
__unstableMarkNextChangeAsNotPersistent,
|
|
26
|
+
} = useDispatch( blockEditorStore );
|
|
27
|
+
|
|
28
|
+
// Find the tab-panels block, active tab, and tab count within the tabs block
|
|
29
|
+
const { activeTabClientId, tabCount, editorActiveTabIndex } = useSelect(
|
|
30
|
+
( select ) => {
|
|
31
|
+
if ( ! tabsClientId ) {
|
|
32
|
+
return {
|
|
33
|
+
activeTabClientId: null,
|
|
34
|
+
tabCount: 0,
|
|
35
|
+
editorActiveTabIndex: 0,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const { getBlocks, getBlockAttributes } =
|
|
39
|
+
select( blockEditorStore );
|
|
40
|
+
const tabsAttributes = getBlockAttributes( tabsClientId );
|
|
41
|
+
const activeIndex =
|
|
42
|
+
tabsAttributes?.editorActiveTabIndex ??
|
|
43
|
+
tabsAttributes?.activeTabIndex ??
|
|
44
|
+
0;
|
|
45
|
+
const innerBlocks = getBlocks( tabsClientId );
|
|
46
|
+
const tabPanels = innerBlocks.find(
|
|
47
|
+
( block ) => block.name === 'core/tab-panels'
|
|
48
|
+
);
|
|
49
|
+
const tabs = tabPanels?.innerBlocks || [];
|
|
50
|
+
const activeTab = tabs[ activeIndex ];
|
|
51
|
+
return {
|
|
52
|
+
activeTabClientId: activeTab?.clientId || null,
|
|
53
|
+
tabCount: tabs.length,
|
|
54
|
+
editorActiveTabIndex: activeIndex,
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
[ tabsClientId ]
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const removeTab = () => {
|
|
61
|
+
if ( ! activeTabClientId || tabCount <= 1 ) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Calculate new active index after removal
|
|
66
|
+
const newActiveIndex =
|
|
67
|
+
editorActiveTabIndex >= tabCount - 1
|
|
68
|
+
? tabCount - 2 // If removing last tab, select the previous one
|
|
69
|
+
: editorActiveTabIndex; // Otherwise keep the same index (next tab shifts into position)
|
|
70
|
+
|
|
71
|
+
// Update the active tab index before removing
|
|
72
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
73
|
+
updateBlockAttributes( tabsClientId, {
|
|
74
|
+
editorActiveTabIndex: newActiveIndex,
|
|
75
|
+
} );
|
|
76
|
+
|
|
77
|
+
// Remove the tab
|
|
78
|
+
removeBlock( activeTabClientId, false );
|
|
79
|
+
|
|
80
|
+
// Select the tabs block after removal
|
|
81
|
+
if ( tabsClientId ) {
|
|
82
|
+
selectBlock( tabsClientId );
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// Don't show the button if there's only one tab or no active tab
|
|
87
|
+
const isDisabled = tabCount <= 1 || ! activeTabClientId;
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<BlockControls group="other">
|
|
91
|
+
<ToolbarGroup>
|
|
92
|
+
<ToolbarButton
|
|
93
|
+
className="components-toolbar__control"
|
|
94
|
+
label={ __( 'Remove the current tab' ) }
|
|
95
|
+
onClick={ removeTab }
|
|
96
|
+
showTooltip
|
|
97
|
+
text={ __( 'Remove Tab' ) }
|
|
98
|
+
disabled={ isDisabled }
|
|
99
|
+
/>
|
|
100
|
+
</ToolbarGroup>
|
|
101
|
+
</BlockControls>
|
|
102
|
+
);
|
|
103
|
+
}
|
package/src/tab/save.js
CHANGED
|
@@ -3,14 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
|
|
5
5
|
|
|
6
|
-
export default function
|
|
6
|
+
export default function save( { attributes } ) {
|
|
7
7
|
const { anchor } = attributes;
|
|
8
8
|
|
|
9
9
|
const tabPanelId = anchor;
|
|
10
10
|
|
|
11
|
-
// eslint-disable-next-line react-compiler/react-compiler
|
|
12
11
|
const blockProps = useBlockProps.save();
|
|
13
|
-
// eslint-disable-next-line react-compiler/react-compiler
|
|
14
12
|
const innerBlocksProps = useInnerBlocksProps.save( blockProps );
|
|
15
13
|
|
|
16
14
|
return <section { ...innerBlocksProps } id={ tabPanelId } />;
|
package/src/tab/style.scss
CHANGED
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
flex-grow: 1;
|
|
5
5
|
box-sizing: border-box;
|
|
6
6
|
|
|
7
|
+
& > *:first-child {
|
|
8
|
+
margin-top: 0;
|
|
9
|
+
}
|
|
10
|
+
& > *:last-child {
|
|
11
|
+
margin-bottom: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
7
14
|
&[hidden],
|
|
8
15
|
&:empty {
|
|
9
16
|
display: none !important;
|
|
@@ -13,7 +20,7 @@
|
|
|
13
20
|
}
|
|
14
21
|
}
|
|
15
22
|
|
|
16
|
-
.wp-block-tab.wp-block
|
|
23
|
+
.wp-block-tab.wp-block.has-background,
|
|
17
24
|
.wp-block-tab:not(.wp-block).has-background {
|
|
18
25
|
padding: var(--wp--preset--spacing--30);
|
|
19
26
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"__experimental": true,
|
|
4
|
+
"apiVersion": 3,
|
|
5
|
+
"name": "core/tab-panels",
|
|
6
|
+
"title": "Tab Panels",
|
|
7
|
+
"description": "Container for tab panel content in a tabbed interface.",
|
|
8
|
+
"version": "1.0.0",
|
|
9
|
+
"category": "design",
|
|
10
|
+
"textdomain": "default",
|
|
11
|
+
"parent": [
|
|
12
|
+
"core/tabs"
|
|
13
|
+
],
|
|
14
|
+
"allowedBlocks": [
|
|
15
|
+
"core/tab"
|
|
16
|
+
],
|
|
17
|
+
"attributes": {},
|
|
18
|
+
"supports": {
|
|
19
|
+
"anchor": false,
|
|
20
|
+
"html": false,
|
|
21
|
+
"reusable": false,
|
|
22
|
+
"lock": false,
|
|
23
|
+
"dimensions": {
|
|
24
|
+
"aspectRatio": false,
|
|
25
|
+
"height": false,
|
|
26
|
+
"minHeight": false,
|
|
27
|
+
"width": false
|
|
28
|
+
},
|
|
29
|
+
"color": {
|
|
30
|
+
"background": true,
|
|
31
|
+
"text": true,
|
|
32
|
+
"heading": true,
|
|
33
|
+
"link": true,
|
|
34
|
+
"__experimentalDefaultControls": {
|
|
35
|
+
"background": true,
|
|
36
|
+
"text": true
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"spacing": {
|
|
40
|
+
"blockGap": false,
|
|
41
|
+
"padding": true,
|
|
42
|
+
"margin": true
|
|
43
|
+
},
|
|
44
|
+
"typography": {
|
|
45
|
+
"fontSize": true,
|
|
46
|
+
"__experimentalFontFamily": true
|
|
47
|
+
},
|
|
48
|
+
"layout": {
|
|
49
|
+
"default": {
|
|
50
|
+
"type": "flex",
|
|
51
|
+
"flexWrap": "nowrap",
|
|
52
|
+
"justifyContent": "stretch",
|
|
53
|
+
"orientation": "vertical"
|
|
54
|
+
},
|
|
55
|
+
"allowSwitching": false,
|
|
56
|
+
"allowVerticalAlignment": false,
|
|
57
|
+
"allowOrientation": false,
|
|
58
|
+
"allowJustification": true,
|
|
59
|
+
"allowSizingOnChildren": false
|
|
60
|
+
},
|
|
61
|
+
"__experimentalBorder": {
|
|
62
|
+
"radius": true,
|
|
63
|
+
"color": true,
|
|
64
|
+
"width": true,
|
|
65
|
+
"style": true
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"editorScript": "file:./index.js",
|
|
69
|
+
"style": "file:./style-index.css"
|
|
70
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
useBlockProps,
|
|
6
|
+
useInnerBlocksProps,
|
|
7
|
+
store as blockEditorStore,
|
|
8
|
+
} from '@wordpress/block-editor';
|
|
9
|
+
import { useSelect } from '@wordpress/data';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import AddTabToolbarControl from '../tab/add-tab-toolbar-control';
|
|
15
|
+
import RemoveTabToolbarControl from '../tab/remove-tab-toolbar-control';
|
|
16
|
+
|
|
17
|
+
const TAB_PANELS_TEMPLATE = [ [ 'core/tab', {} ] ];
|
|
18
|
+
|
|
19
|
+
export default function Edit( { clientId } ) {
|
|
20
|
+
const blockProps = useBlockProps();
|
|
21
|
+
|
|
22
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
23
|
+
template: TAB_PANELS_TEMPLATE,
|
|
24
|
+
templateLock: false,
|
|
25
|
+
renderAppender: false, // Appender handled by individual tab blocks
|
|
26
|
+
} );
|
|
27
|
+
|
|
28
|
+
// Get the parent tabs block clientId
|
|
29
|
+
const tabsClientId = useSelect(
|
|
30
|
+
( select ) => {
|
|
31
|
+
const { getBlockRootClientId } = select( blockEditorStore );
|
|
32
|
+
return getBlockRootClientId( clientId );
|
|
33
|
+
},
|
|
34
|
+
[ clientId ]
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
<AddTabToolbarControl tabsClientId={ tabsClientId } />
|
|
40
|
+
<RemoveTabToolbarControl tabsClientId={ tabsClientId } />
|
|
41
|
+
<div { ...innerBlocksProps } />
|
|
42
|
+
</>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import initBlock from '../utils/init-block';
|
|
5
|
+
import edit from './edit';
|
|
6
|
+
import save from './save';
|
|
7
|
+
import icon from './icon';
|
|
8
|
+
|
|
9
|
+
import metadata from './block.json';
|
|
10
|
+
|
|
11
|
+
const { name } = metadata;
|
|
12
|
+
|
|
13
|
+
export { metadata, name };
|
|
14
|
+
|
|
15
|
+
export const settings = {
|
|
16
|
+
icon,
|
|
17
|
+
edit,
|
|
18
|
+
save,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const init = () => initBlock( { name, metadata, settings } );
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
|
|
5
|
+
|
|
6
|
+
export default function save() {
|
|
7
|
+
const blockProps = useBlockProps.save();
|
|
8
|
+
const innerBlocksProps = useInnerBlocksProps.save( blockProps );
|
|
9
|
+
|
|
10
|
+
return <div { ...innerBlocksProps } />;
|
|
11
|
+
}
|
package/src/tabs/block.json
CHANGED
|
@@ -8,97 +8,53 @@
|
|
|
8
8
|
"version": "1.0.0",
|
|
9
9
|
"category": "design",
|
|
10
10
|
"textdomain": "default",
|
|
11
|
-
"allowedBlocks": [
|
|
11
|
+
"allowedBlocks": [
|
|
12
|
+
"core/tabs-menu",
|
|
13
|
+
"core/tab-panels"
|
|
14
|
+
],
|
|
12
15
|
"attributes": {
|
|
13
|
-
"tabsId": {
|
|
14
|
-
"type": "string",
|
|
15
|
-
"default": ""
|
|
16
|
-
},
|
|
17
|
-
"orientation": {
|
|
18
|
-
"type": "string",
|
|
19
|
-
"default": "horizontal",
|
|
20
|
-
"enum": [ "horizontal", "vertical" ]
|
|
21
|
-
},
|
|
22
16
|
"activeTabIndex": {
|
|
23
17
|
"type": "number",
|
|
24
18
|
"default": 0
|
|
25
19
|
},
|
|
26
|
-
"
|
|
27
|
-
"type": "
|
|
28
|
-
|
|
29
|
-
"customTabInactiveColor": {
|
|
30
|
-
"type": "string"
|
|
31
|
-
},
|
|
32
|
-
"tabHoverColor": {
|
|
33
|
-
"type": "string"
|
|
34
|
-
},
|
|
35
|
-
"customTabHoverColor": {
|
|
36
|
-
"type": "string"
|
|
37
|
-
},
|
|
38
|
-
"tabActiveColor": {
|
|
39
|
-
"type": "string"
|
|
40
|
-
},
|
|
41
|
-
"customTabActiveColor": {
|
|
42
|
-
"type": "string"
|
|
43
|
-
},
|
|
44
|
-
"tabTextColor": {
|
|
45
|
-
"type": "string"
|
|
46
|
-
},
|
|
47
|
-
"customTabTextColor": {
|
|
48
|
-
"type": "string"
|
|
49
|
-
},
|
|
50
|
-
"tabActiveTextColor": {
|
|
51
|
-
"type": "string"
|
|
52
|
-
},
|
|
53
|
-
"customTabActiveTextColor": {
|
|
54
|
-
"type": "string"
|
|
55
|
-
},
|
|
56
|
-
"tabHoverTextColor": {
|
|
57
|
-
"type": "string"
|
|
58
|
-
},
|
|
59
|
-
"customTabHoverTextColor": {
|
|
60
|
-
"type": "string"
|
|
20
|
+
"editorActiveTabIndex": {
|
|
21
|
+
"type": "number",
|
|
22
|
+
"role": "local"
|
|
61
23
|
}
|
|
62
24
|
},
|
|
63
|
-
"styles": [
|
|
64
|
-
{
|
|
65
|
-
"name": "tab",
|
|
66
|
-
"label": "Tabs",
|
|
67
|
-
"isDefault": true
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
"name": "links",
|
|
71
|
-
"label": "Links"
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
"name": "button",
|
|
75
|
-
"label": "Button"
|
|
76
|
-
}
|
|
77
|
-
],
|
|
78
25
|
"supports": {
|
|
79
26
|
"align": true,
|
|
27
|
+
"anchor": true,
|
|
80
28
|
"color": {
|
|
81
29
|
"text": false,
|
|
82
30
|
"background": false
|
|
83
31
|
},
|
|
32
|
+
"layout": {
|
|
33
|
+
"default": {
|
|
34
|
+
"type": "flex",
|
|
35
|
+
"flexWrap": "nowrap",
|
|
36
|
+
"justifyContent": "stretch",
|
|
37
|
+
"verticalAlignment": "stretch",
|
|
38
|
+
"orientation": "vertical"
|
|
39
|
+
},
|
|
40
|
+
"allowSwitching": false,
|
|
41
|
+
"allowVerticalAlignment": true,
|
|
42
|
+
"allowJustification": true,
|
|
43
|
+
"allowOrientation": true,
|
|
44
|
+
"allowSizingOnChildren": true
|
|
45
|
+
},
|
|
84
46
|
"html": false,
|
|
85
47
|
"interactivity": true,
|
|
86
48
|
"spacing": {
|
|
87
|
-
"blockGap":
|
|
49
|
+
"blockGap": true,
|
|
88
50
|
"margin": true,
|
|
89
|
-
"padding":
|
|
51
|
+
"padding": true
|
|
90
52
|
},
|
|
91
53
|
"typography": {
|
|
92
54
|
"fontSize": true,
|
|
93
55
|
"__experimentalFontFamily": true
|
|
94
56
|
},
|
|
95
|
-
"
|
|
96
|
-
"radius": true,
|
|
97
|
-
"__experimentalSkipSerialization": true,
|
|
98
|
-
"__experimentalDefaultControls": {
|
|
99
|
-
"radius": true
|
|
100
|
-
}
|
|
101
|
-
}
|
|
57
|
+
"renaming": true
|
|
102
58
|
},
|
|
103
59
|
"example": {
|
|
104
60
|
"attributes": {
|
|
@@ -106,42 +62,57 @@
|
|
|
106
62
|
},
|
|
107
63
|
"innerBlocks": [
|
|
108
64
|
{
|
|
109
|
-
"name": "core/
|
|
110
|
-
"attributes": {
|
|
111
|
-
|
|
112
|
-
|
|
65
|
+
"name": "core/tabs-menu",
|
|
66
|
+
"attributes": {},
|
|
67
|
+
"innerBlocks": [
|
|
68
|
+
{
|
|
69
|
+
"name": "core/tabs-menu-item",
|
|
70
|
+
"attributes": {}
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"name": "core/tab-panels",
|
|
76
|
+
"attributes": {},
|
|
113
77
|
"innerBlocks": [
|
|
114
78
|
{
|
|
115
|
-
"name": "core/
|
|
79
|
+
"name": "core/tab",
|
|
116
80
|
"attributes": {
|
|
117
|
-
"
|
|
81
|
+
"label": "Tab 1"
|
|
82
|
+
},
|
|
83
|
+
"innerBlocks": [
|
|
84
|
+
{
|
|
85
|
+
"name": "core/paragraph",
|
|
86
|
+
"attributes": {
|
|
87
|
+
"content": "Pariatur commodo sint mollit. Veniam Lorem labore voluptate fugiat. Ad nulla est labore cillum cillum qui nostrud do incididunt eiusmod."
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"name": "core/tab",
|
|
94
|
+
"attributes": {
|
|
95
|
+
"label": "Tab 2"
|
|
118
96
|
}
|
|
119
97
|
},
|
|
120
98
|
{
|
|
121
|
-
"name": "core/
|
|
99
|
+
"name": "core/tab",
|
|
122
100
|
"attributes": {
|
|
123
|
-
"
|
|
101
|
+
"label": "Tab 3"
|
|
124
102
|
}
|
|
125
103
|
}
|
|
126
104
|
]
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
"name": "core/tab",
|
|
130
|
-
"attributes": {
|
|
131
|
-
"label": "Tab 2"
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
"name": "core/tab",
|
|
136
|
-
"attributes": {
|
|
137
|
-
"label": "Tab 3"
|
|
138
|
-
}
|
|
139
105
|
}
|
|
140
106
|
]
|
|
141
107
|
},
|
|
142
108
|
"providesContext": {
|
|
143
|
-
"core/tabs-
|
|
109
|
+
"core/tabs-activeTabIndex": "activeTabIndex",
|
|
110
|
+
"core/tabs-editorActiveTabIndex": "editorActiveTabIndex"
|
|
144
111
|
},
|
|
112
|
+
"usesContext": [
|
|
113
|
+
"core/tabs-list",
|
|
114
|
+
"core/tabs-id"
|
|
115
|
+
],
|
|
145
116
|
"editorScript": "file:./index.js",
|
|
146
117
|
"editorStyle": "file:./index.css",
|
|
147
118
|
"style": "file:./style-index.css",
|