@wordpress/block-library 9.38.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/block/block.json +2 -1
- package/build/breadcrumbs/edit.cjs +15 -5
- package/build/breadcrumbs/edit.cjs.map +2 -2
- package/build/breadcrumbs/index.cjs +1 -0
- package/build/breadcrumbs/index.cjs.map +2 -2
- package/build/button/index.cjs +3 -0
- package/build/button/index.cjs.map +2 -2
- package/build/comment-date/block.json +1 -0
- package/build/comment-edit-link/block.json +1 -3
- package/build/comment-edit-link/deprecated.cjs +91 -0
- package/build/comment-edit-link/deprecated.cjs.map +7 -0
- package/build/comment-edit-link/edit.cjs +6 -18
- package/build/comment-edit-link/edit.cjs.map +3 -3
- package/build/comment-edit-link/index.cjs +2 -0
- package/build/comment-edit-link/index.cjs.map +3 -3
- package/build/comment-reply-link/block.json +1 -5
- package/build/comment-reply-link/deprecated.cjs +84 -0
- package/build/comment-reply-link/deprecated.cjs.map +7 -0
- package/build/comment-reply-link/edit.cjs +10 -23
- package/build/comment-reply-link/edit.cjs.map +3 -3
- package/build/comment-reply-link/index.cjs +2 -0
- package/build/comment-reply-link/index.cjs.map +3 -3
- 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/cover/edit/inspector-controls.cjs +1 -1
- package/build/cover/edit/inspector-controls.cjs.map +2 -2
- package/build/details/index.cjs +3 -0
- package/build/details/index.cjs.map +2 -2
- package/build/embed/util.cjs +9 -0
- package/build/embed/util.cjs.map +2 -2
- package/build/freeform/block.json +2 -1
- package/build/heading/index.cjs +3 -0
- package/build/heading/index.cjs.map +2 -2
- package/build/html/block.json +2 -1
- package/build/image/image.cjs +43 -9
- package/build/image/image.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 +12 -1
- package/build/list-item/index.cjs.map +2 -2
- package/build/missing/block.json +2 -1
- package/build/more/block.json +2 -1
- package/build/more/index.cjs +1 -1
- package/build/more/index.cjs.map +2 -2
- package/build/navigation/block.json +5 -4
- package/build/navigation/deprecated.cjs +133 -5
- package/build/navigation/deprecated.cjs.map +2 -2
- package/build/navigation/edit/deleted-overlay-warning.cjs +70 -0
- package/build/navigation/edit/deleted-overlay-warning.cjs.map +7 -0
- package/build/navigation/edit/index.cjs +143 -65
- package/build/navigation/edit/index.cjs.map +3 -3
- package/build/navigation/edit/overlay-panel.cjs +10 -1
- package/build/navigation/edit/overlay-panel.cjs.map +3 -3
- package/build/navigation/edit/overlay-preview.cjs +120 -0
- package/build/navigation/edit/overlay-preview.cjs.map +7 -0
- package/build/navigation/edit/overlay-template-part-selector.cjs +59 -24
- package/build/navigation/edit/overlay-template-part-selector.cjs.map +3 -3
- package/build/navigation/edit/responsive-wrapper.cjs +12 -1
- package/build/navigation/edit/responsive-wrapper.cjs.map +3 -3
- package/build/navigation/edit/use-create-overlay.cjs +19 -2
- package/build/navigation/edit/use-create-overlay.cjs.map +3 -3
- package/build/navigation/utils/get-submenu-visibility.cjs +37 -0
- package/build/navigation/utils/get-submenu-visibility.cjs.map +7 -0
- package/build/navigation-link/edit.cjs +2 -40
- package/build/navigation-link/edit.cjs.map +2 -2
- package/build/navigation-link/shared/index.cjs +6 -0
- package/build/navigation-link/shared/index.cjs.map +2 -2
- package/build/navigation-link/shared/select-label-text.cjs +40 -0
- package/build/navigation-link/shared/select-label-text.cjs.map +7 -0
- package/build/navigation-link/shared/use-is-dragging-within.cjs +59 -0
- package/build/navigation-link/shared/use-is-dragging-within.cjs.map +7 -0
- package/build/navigation-submenu/block.json +1 -1
- package/build/navigation-submenu/edit.cjs +8 -47
- package/build/navigation-submenu/edit.cjs.map +2 -2
- package/build/navigation-submenu/index.cjs +2 -2
- package/build/navigation-submenu/index.cjs.map +2 -2
- package/build/nextpage/block.json +2 -1
- package/build/paragraph/block.json +1 -0
- 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/shortcode/block.json +2 -1
- 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 +2 -2
- 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/verse/block.json +1 -3
- package/build/verse/deprecated.cjs +74 -5
- package/build/verse/deprecated.cjs.map +3 -3
- package/build/verse/edit.cjs +33 -48
- package/build/verse/edit.cjs.map +3 -3
- package/build/verse/save.cjs +2 -16
- package/build/verse/save.cjs.map +3 -3
- package/build/video/edit.cjs +4 -2
- package/build/video/edit.cjs.map +2 -2
- package/build-module/block/block.json +2 -1
- package/build-module/breadcrumbs/edit.mjs +15 -5
- package/build-module/breadcrumbs/edit.mjs.map +2 -2
- package/build-module/breadcrumbs/index.mjs +1 -0
- package/build-module/breadcrumbs/index.mjs.map +2 -2
- package/build-module/button/index.mjs +3 -0
- package/build-module/button/index.mjs.map +2 -2
- package/build-module/comment-date/block.json +1 -0
- package/build-module/comment-edit-link/block.json +1 -3
- package/build-module/comment-edit-link/deprecated.mjs +60 -0
- package/build-module/comment-edit-link/deprecated.mjs.map +7 -0
- package/build-module/comment-edit-link/edit.mjs +7 -24
- package/build-module/comment-edit-link/edit.mjs.map +2 -2
- package/build-module/comment-edit-link/index.mjs +2 -0
- package/build-module/comment-edit-link/index.mjs.map +2 -2
- package/build-module/comment-reply-link/block.json +1 -5
- package/build-module/comment-reply-link/deprecated.mjs +53 -0
- package/build-module/comment-reply-link/deprecated.mjs.map +7 -0
- package/build-module/comment-reply-link/edit.mjs +12 -29
- package/build-module/comment-reply-link/edit.mjs.map +2 -2
- package/build-module/comment-reply-link/index.mjs +2 -0
- package/build-module/comment-reply-link/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/cover/edit/inspector-controls.mjs +1 -1
- package/build-module/cover/edit/inspector-controls.mjs.map +2 -2
- package/build-module/details/index.mjs +3 -0
- package/build-module/details/index.mjs.map +2 -2
- package/build-module/embed/util.mjs +8 -0
- package/build-module/embed/util.mjs.map +2 -2
- package/build-module/freeform/block.json +2 -1
- package/build-module/heading/index.mjs +3 -0
- package/build-module/heading/index.mjs.map +2 -2
- package/build-module/html/block.json +2 -1
- package/build-module/image/image.mjs +43 -9
- package/build-module/image/image.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 +12 -1
- package/build-module/list-item/index.mjs.map +2 -2
- package/build-module/missing/block.json +2 -1
- package/build-module/more/block.json +2 -1
- package/build-module/more/index.mjs +1 -1
- package/build-module/more/index.mjs.map +2 -2
- package/build-module/navigation/block.json +5 -4
- package/build-module/navigation/deprecated.mjs +133 -5
- package/build-module/navigation/deprecated.mjs.map +2 -2
- package/build-module/navigation/edit/deleted-overlay-warning.mjs +49 -0
- package/build-module/navigation/edit/deleted-overlay-warning.mjs.map +7 -0
- package/build-module/navigation/edit/index.mjs +145 -65
- package/build-module/navigation/edit/index.mjs.map +2 -2
- package/build-module/navigation/edit/overlay-panel.mjs +10 -1
- package/build-module/navigation/edit/overlay-panel.mjs.map +2 -2
- package/build-module/navigation/edit/overlay-preview.mjs +99 -0
- package/build-module/navigation/edit/overlay-preview.mjs.map +7 -0
- package/build-module/navigation/edit/overlay-template-part-selector.mjs +61 -26
- package/build-module/navigation/edit/overlay-template-part-selector.mjs.map +2 -2
- package/build-module/navigation/edit/responsive-wrapper.mjs +12 -1
- package/build-module/navigation/edit/responsive-wrapper.mjs.map +2 -2
- package/build-module/navigation/edit/use-create-overlay.mjs +21 -4
- package/build-module/navigation/edit/use-create-overlay.mjs.map +2 -2
- package/build-module/navigation/utils/get-submenu-visibility.mjs +12 -0
- package/build-module/navigation/utils/get-submenu-visibility.mjs.map +7 -0
- package/build-module/navigation-link/edit.mjs +4 -40
- package/build-module/navigation-link/edit.mjs.map +2 -2
- package/build-module/navigation-link/shared/index.mjs +4 -0
- package/build-module/navigation-link/shared/index.mjs.map +2 -2
- package/build-module/navigation-link/shared/select-label-text.mjs +15 -0
- package/build-module/navigation-link/shared/select-label-text.mjs.map +7 -0
- package/build-module/navigation-link/shared/use-is-dragging-within.mjs +34 -0
- package/build-module/navigation-link/shared/use-is-dragging-within.mjs.map +7 -0
- package/build-module/navigation-submenu/block.json +1 -1
- package/build-module/navigation-submenu/edit.mjs +10 -47
- package/build-module/navigation-submenu/edit.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/nextpage/block.json +2 -1
- package/build-module/paragraph/block.json +1 -0
- 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/shortcode/block.json +2 -1
- 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 +2 -2
- 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/verse/block.json +1 -3
- package/build-module/verse/deprecated.mjs +74 -5
- package/build-module/verse/deprecated.mjs.map +2 -2
- package/build-module/verse/edit.mjs +35 -55
- package/build-module/verse/edit.mjs.map +2 -2
- package/build-module/verse/save.mjs +2 -6
- package/build-module/verse/save.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 +64 -21
- package/build-style/editor.css +64 -21
- package/build-style/gallery/style-rtl.css +1 -1
- package/build-style/gallery/style.css +1 -1
- package/build-style/media-text/style-rtl.css +2 -0
- package/build-style/media-text/style.css +2 -0
- package/build-style/navigation/editor-rtl.css +48 -0
- package/build-style/navigation/editor.css +48 -0
- package/build-style/navigation/style-rtl.css +64 -18
- package/build-style/navigation/style.css +64 -18
- package/build-style/style-rtl.css +109 -171
- package/build-style/style.css +109 -171
- 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/build-style/verse/style-rtl.css +1 -0
- package/build-style/verse/style.css +1 -0
- package/package.json +37 -37
- package/src/block/block.json +2 -1
- package/src/breadcrumbs/edit.js +10 -2
- package/src/breadcrumbs/index.js +1 -0
- package/src/button/index.js +4 -0
- package/src/categories/index.php +5 -1
- package/src/comment-date/block.json +1 -0
- package/src/comment-edit-link/block.json +1 -3
- package/src/comment-edit-link/deprecated.js +63 -0
- package/src/comment-edit-link/edit.js +7 -31
- package/src/comment-edit-link/index.js +2 -0
- package/src/comment-reply-link/block.json +1 -5
- package/src/comment-reply-link/deprecated.js +56 -0
- package/src/comment-reply-link/edit.js +6 -35
- package/src/comment-reply-link/index.js +2 -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/cover/edit/inspector-controls.js +1 -3
- package/src/details/index.js +4 -0
- package/src/editor.scss +2 -1
- package/src/embed/test/index.js +49 -0
- package/src/embed/util.js +21 -0
- package/src/freeform/block.json +2 -1
- package/src/gallery/style.scss +1 -1
- package/src/heading/index.js +4 -0
- package/src/html/block.json +2 -1
- package/src/image/image.js +63 -11
- package/src/image/index.js +4 -1
- package/src/index.js +6 -0
- package/src/list-item/index.js +16 -0
- package/src/media-text/style.scss +2 -0
- package/src/missing/block.json +2 -1
- package/src/more/block.json +2 -1
- package/src/more/index.js +4 -1
- package/src/navigation/block.json +5 -4
- package/src/navigation/deprecated.js +144 -5
- package/src/navigation/edit/deleted-overlay-warning.js +56 -0
- package/src/navigation/edit/index.js +181 -70
- package/src/navigation/edit/overlay-panel.js +10 -0
- package/src/navigation/edit/overlay-preview.js +133 -0
- package/src/navigation/edit/overlay-template-part-selector.js +76 -26
- package/src/navigation/edit/responsive-wrapper.js +14 -1
- package/src/navigation/edit/test/overlay-template-part-selector.js +24 -16
- package/src/navigation/edit/test/responsive-wrapper.js +179 -0
- package/src/navigation/edit/test/use-create-overlay.js +129 -2
- package/src/navigation/edit/use-create-overlay.js +26 -4
- package/src/navigation/editor.scss +51 -0
- package/src/navigation/index.php +59 -11
- package/src/navigation/style.scss +140 -76
- package/src/navigation/utils/get-submenu-visibility.js +27 -0
- package/src/navigation/utils/test/get-submenu-visibility.js +47 -0
- package/src/navigation-link/edit.js +3 -67
- package/src/navigation-link/shared/index.js +2 -0
- package/src/navigation-link/shared/select-label-text.js +16 -0
- package/src/navigation-link/shared/use-is-dragging-within.js +55 -0
- package/src/navigation-submenu/block.json +1 -1
- package/src/navigation-submenu/edit.js +10 -73
- package/src/navigation-submenu/index.js +6 -3
- package/src/navigation-submenu/index.php +36 -5
- package/src/nextpage/block.json +2 -1
- package/src/paragraph/block.json +1 -0
- 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/shortcode/block.json +2 -1
- 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 +2 -4
- package/src/utils/caption.js +1 -7
- package/src/verse/block.json +1 -3
- package/src/verse/deprecated.js +83 -4
- package/src/verse/edit.js +37 -56
- package/src/verse/save.js +2 -11
- package/src/verse/style.scss +1 -0
- 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
|
@@ -1,42 +1,67 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
+
import { sprintf, __ } from '@wordpress/i18n';
|
|
4
5
|
import { createBlock } from '@wordpress/blocks';
|
|
5
6
|
import {
|
|
6
7
|
BlockControls,
|
|
7
8
|
store as blockEditorStore,
|
|
8
9
|
} from '@wordpress/block-editor';
|
|
9
10
|
import { ToolbarGroup, ToolbarButton } from '@wordpress/components';
|
|
10
|
-
import {
|
|
11
|
-
import { useDispatch } from '@wordpress/data';
|
|
11
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* "Add Tab" button in the block toolbar for the tab block.
|
|
15
|
+
* Inserts new tabs into the tab-panels block.
|
|
16
|
+
*
|
|
15
17
|
* @param {Object} props
|
|
16
|
-
* @param {Object} props.attributes The block attributes.
|
|
17
18
|
* @param {string} props.tabsClientId The client ID of the parent tabs block.
|
|
18
19
|
* @return {JSX.Element} The toolbar control element.
|
|
19
20
|
*/
|
|
20
|
-
export default function AddTabToolbarControl( {
|
|
21
|
+
export default function AddTabToolbarControl( { tabsClientId } ) {
|
|
21
22
|
const { insertBlock } = useDispatch( blockEditorStore );
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
// Find the tab-panels block within the tabs block
|
|
25
|
+
const { tabPanelsClientId, nextTabIndex } = useSelect(
|
|
26
|
+
( select ) => {
|
|
27
|
+
if ( ! tabsClientId ) {
|
|
28
|
+
return {
|
|
29
|
+
tabPanelsClientId: null,
|
|
30
|
+
nextTabIndex: 0,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const { getBlocks } = select( blockEditorStore );
|
|
34
|
+
const innerBlocks = getBlocks( tabsClientId );
|
|
35
|
+
const tabPanels = innerBlocks.find(
|
|
36
|
+
( block ) => block.name === 'core/tab-panels'
|
|
37
|
+
);
|
|
38
|
+
return {
|
|
39
|
+
tabPanelsClientId: tabPanels?.clientId || null,
|
|
40
|
+
nextTabIndex: ( tabPanels?.innerBlocks.length || 0 ) + 1,
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
[ tabsClientId ]
|
|
44
|
+
);
|
|
24
45
|
|
|
25
46
|
const addTab = () => {
|
|
47
|
+
if ( ! tabPanelsClientId ) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
26
50
|
const newTabBlock = createBlock( 'core/tab', {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
51
|
+
anchor: 'tab-' + nextTabIndex,
|
|
52
|
+
/* translators: %d: tab number */
|
|
53
|
+
label: sprintf( __( 'Tab %d' ), nextTabIndex ),
|
|
30
54
|
} );
|
|
31
|
-
insertBlock( newTabBlock, undefined,
|
|
55
|
+
insertBlock( newTabBlock, undefined, tabPanelsClientId );
|
|
56
|
+
// @TODO: Possible select and focus the tabs-menu-item active tab RichText editor?
|
|
32
57
|
};
|
|
33
58
|
|
|
34
59
|
return (
|
|
35
|
-
<BlockControls group="
|
|
60
|
+
<BlockControls group="other">
|
|
36
61
|
<ToolbarGroup>
|
|
37
62
|
<ToolbarButton
|
|
38
63
|
className="components-toolbar__control"
|
|
39
|
-
label={ __( 'Add
|
|
64
|
+
label={ __( 'Add a new tab' ) }
|
|
40
65
|
onClick={ addTab }
|
|
41
66
|
showTooltip
|
|
42
67
|
text={ __( 'Add Tab' ) }
|
package/src/tab/block.json
CHANGED
|
@@ -14,11 +14,25 @@
|
|
|
14
14
|
"default": ""
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
-
"parent": [
|
|
17
|
+
"parent": [
|
|
18
|
+
"core/tab-panels"
|
|
19
|
+
],
|
|
20
|
+
"usesContext": [
|
|
21
|
+
"core/tabs-activeTabIndex",
|
|
22
|
+
"core/tabs-editorActiveTabIndex"
|
|
23
|
+
],
|
|
18
24
|
"supports": {
|
|
19
25
|
"anchor": true,
|
|
20
26
|
"html": false,
|
|
21
27
|
"reusable": false,
|
|
28
|
+
"color": {
|
|
29
|
+
"background": true,
|
|
30
|
+
"text": true,
|
|
31
|
+
"__experimentalDefaultControls": {
|
|
32
|
+
"background": true,
|
|
33
|
+
"text": true
|
|
34
|
+
}
|
|
35
|
+
},
|
|
22
36
|
"layout": {
|
|
23
37
|
"allowSwitching": true,
|
|
24
38
|
"allowInheriting": false,
|
|
@@ -38,9 +52,9 @@
|
|
|
38
52
|
"__experimentalDefaultControls": {
|
|
39
53
|
"fontSize": true,
|
|
40
54
|
"__experimentalFontFamily": true
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"renaming": true
|
|
44
58
|
},
|
|
45
59
|
"providesContext": {
|
|
46
60
|
"core/tab-label": "label"
|
package/src/tab/controls.js
CHANGED
|
@@ -14,6 +14,7 @@ import { decodeEntities } from '@wordpress/html-entities';
|
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
import AddTabToolbarControl from './add-tab-toolbar-control';
|
|
17
|
+
import RemoveTabToolbarControl from './remove-tab-toolbar-control';
|
|
17
18
|
import slugFromLabel from './slug-from-label';
|
|
18
19
|
|
|
19
20
|
export default function Controls( {
|
|
@@ -29,12 +30,10 @@ export default function Controls( {
|
|
|
29
30
|
|
|
30
31
|
return (
|
|
31
32
|
<>
|
|
32
|
-
<AddTabToolbarControl
|
|
33
|
-
|
|
34
|
-
attributes={ attributes }
|
|
35
|
-
/>
|
|
33
|
+
<AddTabToolbarControl tabsClientId={ tabsClientId } />
|
|
34
|
+
<RemoveTabToolbarControl tabsClientId={ tabsClientId } />
|
|
36
35
|
<InspectorControls>
|
|
37
|
-
<PanelBody title={ __( '
|
|
36
|
+
<PanelBody title={ __( 'Settings' ) }>
|
|
38
37
|
<TextControl
|
|
39
38
|
label={ __( 'Tab Label' ) }
|
|
40
39
|
value={ decodeEntities( label ) }
|
package/src/tab/edit.js
CHANGED
|
@@ -10,82 +10,44 @@ import { __ } from '@wordpress/i18n';
|
|
|
10
10
|
import {
|
|
11
11
|
useBlockProps,
|
|
12
12
|
useInnerBlocksProps,
|
|
13
|
-
getTypographyClassesAndStyles as useTypographyProps,
|
|
14
|
-
__experimentalUseColorProps as useColorProps,
|
|
15
13
|
store as blockEditorStore,
|
|
16
14
|
} from '@wordpress/block-editor';
|
|
17
15
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
useRef,
|
|
21
|
-
useEffect,
|
|
22
|
-
useCallback,
|
|
23
|
-
useState,
|
|
24
|
-
} from '@wordpress/element';
|
|
16
|
+
import { useMemo, useRef, useEffect } from '@wordpress/element';
|
|
17
|
+
|
|
25
18
|
/**
|
|
26
19
|
* Internal dependencies
|
|
27
20
|
*/
|
|
28
21
|
import Controls from './controls';
|
|
29
22
|
import slugFromLabel from './slug-from-label';
|
|
30
|
-
import TabsList from './tabs-list';
|
|
31
23
|
|
|
32
24
|
const TEMPLATE = [
|
|
33
25
|
[
|
|
34
26
|
'core/paragraph',
|
|
35
27
|
{
|
|
36
|
-
placeholder: __( 'Type / to
|
|
28
|
+
placeholder: __( 'Type / to choose a block' ),
|
|
37
29
|
},
|
|
38
30
|
],
|
|
39
31
|
];
|
|
40
32
|
|
|
41
|
-
const {
|
|
33
|
+
const { cancelAnimationFrame } = window;
|
|
42
34
|
|
|
43
35
|
export default function Edit( {
|
|
44
36
|
attributes,
|
|
45
37
|
clientId,
|
|
38
|
+
context,
|
|
46
39
|
isSelected,
|
|
47
40
|
setAttributes,
|
|
48
41
|
__unstableLayoutClassNames: layoutClassNames,
|
|
49
42
|
} ) {
|
|
50
|
-
const { selectBlock } = useDispatch( blockEditorStore );
|
|
51
|
-
|
|
52
|
-
const innerBlocksRef = useRef( null );
|
|
53
43
|
const focusRef = useRef();
|
|
54
|
-
const [ isInitialMount, setIsInitialMount ] = useState( true );
|
|
55
|
-
const labelElementRef = useRef( null );
|
|
56
44
|
|
|
57
45
|
const { anchor, label } = attributes;
|
|
58
46
|
|
|
59
|
-
//
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if ( node && isInitialMount ) {
|
|
64
|
-
// Focus immediately when ref is set on initial mount.
|
|
65
|
-
const animationId = requestAnimationFrame( () => {
|
|
66
|
-
if ( node ) {
|
|
67
|
-
node.focus();
|
|
68
|
-
}
|
|
69
|
-
} );
|
|
70
|
-
focusRef.current = animationId;
|
|
71
|
-
setIsInitialMount( false );
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
[ isInitialMount ]
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
// Focus the label RichText component when no label exists (after initial mount).
|
|
78
|
-
useEffect( () => {
|
|
79
|
-
if ( ! label && ! isInitialMount && labelElementRef.current ) {
|
|
80
|
-
const animationId = requestAnimationFrame( () => {
|
|
81
|
-
if ( labelElementRef.current ) {
|
|
82
|
-
labelElementRef.current.focus();
|
|
83
|
-
}
|
|
84
|
-
} );
|
|
85
|
-
focusRef.current = animationId;
|
|
86
|
-
return () => cancelAnimationFrame( focusRef.current );
|
|
87
|
-
}
|
|
88
|
-
}, [ label, isInitialMount ] );
|
|
47
|
+
// Consume tab indices from context
|
|
48
|
+
const activeTabIndex = context[ 'core/tabs-activeTabIndex' ] ?? 0;
|
|
49
|
+
const editorActiveTabIndex = context[ 'core/tabs-editorActiveTabIndex' ];
|
|
50
|
+
const effectiveActiveIndex = editorActiveTabIndex ?? activeTabIndex;
|
|
89
51
|
|
|
90
52
|
// Clean up animation frames on unmount.
|
|
91
53
|
useEffect( () => {
|
|
@@ -96,84 +58,85 @@ export default function Edit( {
|
|
|
96
58
|
};
|
|
97
59
|
}, [] );
|
|
98
60
|
|
|
99
|
-
const {
|
|
100
|
-
blockIndex,
|
|
101
|
-
hasInnerBlocksSelected,
|
|
102
|
-
tabsHasSelectedBlock,
|
|
103
|
-
tabsClientId,
|
|
104
|
-
tabsAttributes,
|
|
105
|
-
forceDisplay,
|
|
106
|
-
isTabsClientSelected,
|
|
107
|
-
isDefaultTab,
|
|
108
|
-
siblingTabs,
|
|
109
|
-
} = useSelect(
|
|
61
|
+
const { blockIndex, hasInnerBlocksSelected, tabsClientId } = useSelect(
|
|
110
62
|
( select ) => {
|
|
111
63
|
const {
|
|
112
64
|
getBlockRootClientId,
|
|
113
65
|
getBlockIndex,
|
|
114
|
-
isBlockSelected,
|
|
115
66
|
hasSelectedInnerBlock,
|
|
116
|
-
getBlockAttributes,
|
|
117
|
-
getBlocks,
|
|
118
67
|
} = select( blockEditorStore );
|
|
119
68
|
|
|
120
|
-
// Get
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
const { activeTabIndex } = rootAttributes;
|
|
125
|
-
const _isTabsClientSelected = isBlockSelected( rootClientId );
|
|
69
|
+
// Get the tab-panels parent first
|
|
70
|
+
const tabPanelsClientId = getBlockRootClientId( clientId );
|
|
71
|
+
// Then get the tabs parent
|
|
72
|
+
const _tabsClientId = getBlockRootClientId( tabPanelsClientId );
|
|
126
73
|
|
|
127
74
|
// Get data about this instance of core/tab.
|
|
128
75
|
const _blockIndex = getBlockIndex( clientId );
|
|
129
|
-
const _isDefaultTab = activeTabIndex === _blockIndex;
|
|
130
76
|
const _hasInnerBlocksSelected = hasSelectedInnerBlock(
|
|
131
77
|
clientId,
|
|
132
78
|
true
|
|
133
79
|
);
|
|
134
80
|
|
|
135
|
-
// Get all sibling tabs from parent.
|
|
136
|
-
const _siblingTabs = getBlocks( rootClientId );
|
|
137
|
-
|
|
138
81
|
return {
|
|
139
82
|
blockIndex: _blockIndex,
|
|
140
83
|
hasInnerBlocksSelected: _hasInnerBlocksSelected,
|
|
141
|
-
tabsClientId:
|
|
142
|
-
forceDisplay: _isDefaultTab && _isTabsClientSelected,
|
|
143
|
-
tabsHasSelectedBlock: hasTabSelected,
|
|
144
|
-
isTabsClientSelected: _isTabsClientSelected,
|
|
145
|
-
isDefaultTab: _isDefaultTab,
|
|
146
|
-
tabsAttributes: rootAttributes,
|
|
147
|
-
siblingTabs: _siblingTabs,
|
|
84
|
+
tabsClientId: _tabsClientId,
|
|
148
85
|
};
|
|
149
86
|
},
|
|
150
87
|
[ clientId ]
|
|
151
88
|
);
|
|
152
89
|
|
|
90
|
+
const { updateBlockAttributes, __unstableMarkNextChangeAsNotPersistent } =
|
|
91
|
+
useDispatch( blockEditorStore );
|
|
92
|
+
|
|
93
|
+
// Sync editorActiveTabIndex when this tab is selected directly
|
|
94
|
+
useEffect( () => {
|
|
95
|
+
// Only update if this tab is selected and not already the active index
|
|
96
|
+
const isTabSelected = isSelected || hasInnerBlocksSelected;
|
|
97
|
+
if (
|
|
98
|
+
isTabSelected &&
|
|
99
|
+
tabsClientId &&
|
|
100
|
+
effectiveActiveIndex !== blockIndex
|
|
101
|
+
) {
|
|
102
|
+
// Mark as non-persistent so it doesn't add to undo history
|
|
103
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
104
|
+
updateBlockAttributes( tabsClientId, {
|
|
105
|
+
editorActiveTabIndex: blockIndex,
|
|
106
|
+
} );
|
|
107
|
+
}
|
|
108
|
+
}, [
|
|
109
|
+
isSelected,
|
|
110
|
+
hasInnerBlocksSelected,
|
|
111
|
+
tabsClientId,
|
|
112
|
+
effectiveActiveIndex,
|
|
113
|
+
blockIndex,
|
|
114
|
+
updateBlockAttributes,
|
|
115
|
+
__unstableMarkNextChangeAsNotPersistent,
|
|
116
|
+
] );
|
|
117
|
+
|
|
118
|
+
// Determine if this is the currently active tab (for editor visibility)
|
|
119
|
+
const isActiveTab = effectiveActiveIndex === blockIndex;
|
|
120
|
+
|
|
121
|
+
// Determine if this is the default tab (for the "Default Tab" toggle in controls)
|
|
122
|
+
const isDefaultTab = activeTabIndex === blockIndex;
|
|
123
|
+
|
|
153
124
|
/**
|
|
154
|
-
* This hook determines if the current tab
|
|
125
|
+
* This hook determines if the current tab panel should be visible.
|
|
126
|
+
* This is true if it is the editor active tab, or if it is selected directly.
|
|
155
127
|
*/
|
|
156
128
|
const isSelectedTab = useMemo( () => {
|
|
157
|
-
if
|
|
129
|
+
// Show if this tab is directly selected or has selected inner blocks
|
|
130
|
+
if ( isSelected || hasInnerBlocksSelected ) {
|
|
158
131
|
return true;
|
|
159
132
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
! isSelected &&
|
|
164
|
-
! tabsHasSelectedBlock
|
|
165
|
-
) {
|
|
133
|
+
// Always show the active tab (at effectiveActiveIndex) regardless of other selection state.
|
|
134
|
+
// This ensures the tab panel remains visible when editing labels in tabs-menu.
|
|
135
|
+
if ( isActiveTab ) {
|
|
166
136
|
return true;
|
|
167
137
|
}
|
|
168
138
|
return false;
|
|
169
|
-
}, [
|
|
170
|
-
isSelected,
|
|
171
|
-
hasInnerBlocksSelected,
|
|
172
|
-
forceDisplay,
|
|
173
|
-
isDefaultTab,
|
|
174
|
-
isTabsClientSelected,
|
|
175
|
-
tabsHasSelectedBlock,
|
|
176
|
-
] );
|
|
139
|
+
}, [ isSelected, hasInnerBlocksSelected, isActiveTab ] );
|
|
177
140
|
|
|
178
141
|
// Use a custom anchor, if set. Otherwise fall back to the slug generated from the label text.
|
|
179
142
|
const tabPanelId = useMemo(
|
|
@@ -182,67 +145,29 @@ export default function Edit( {
|
|
|
182
145
|
);
|
|
183
146
|
const tabLabelId = useMemo( () => `${ tabPanelId }--tab`, [ tabPanelId ] );
|
|
184
147
|
|
|
185
|
-
const tabItemColorProps = useColorProps( tabsAttributes );
|
|
186
|
-
const tabContentTypographyProps = useTypographyProps( attributes );
|
|
187
|
-
|
|
188
148
|
const blockProps = useBlockProps( {
|
|
189
149
|
hidden: ! isSelectedTab,
|
|
150
|
+
'aria-labelledby': tabLabelId,
|
|
151
|
+
id: tabPanelId,
|
|
152
|
+
role: 'tabpanel',
|
|
153
|
+
tabIndex: isSelectedTab ? 0 : -1,
|
|
154
|
+
className: clsx( 'wp-block-tab__editor-content', layoutClassNames ),
|
|
190
155
|
} );
|
|
191
156
|
|
|
192
|
-
const innerBlocksProps = useInnerBlocksProps(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
id: tabPanelId,
|
|
196
|
-
role: 'tabpanel',
|
|
197
|
-
ref: innerBlocksRef,
|
|
198
|
-
tabIndex: isSelectedTab ? 0 : -1,
|
|
199
|
-
className: clsx(
|
|
200
|
-
tabContentTypographyProps.className,
|
|
201
|
-
'tabs__tab-editor-content',
|
|
202
|
-
layoutClassNames
|
|
203
|
-
),
|
|
204
|
-
style: {
|
|
205
|
-
...tabContentTypographyProps.style,
|
|
206
|
-
},
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
template: TEMPLATE,
|
|
210
|
-
}
|
|
211
|
-
);
|
|
157
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
158
|
+
template: TEMPLATE,
|
|
159
|
+
} );
|
|
212
160
|
|
|
213
161
|
return (
|
|
214
|
-
|
|
215
|
-
<
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
<>
|
|
225
|
-
<TabsList
|
|
226
|
-
siblingTabs={ siblingTabs }
|
|
227
|
-
currentClientId={ clientId }
|
|
228
|
-
currentBlockIndex={ blockIndex }
|
|
229
|
-
currentLabel={ label }
|
|
230
|
-
tabItemColorProps={ tabItemColorProps }
|
|
231
|
-
onSelectTab={ selectBlock }
|
|
232
|
-
onLabelChange={ ( value ) =>
|
|
233
|
-
setAttributes( {
|
|
234
|
-
label: value,
|
|
235
|
-
anchor: slugFromLabel( value, blockIndex ),
|
|
236
|
-
} )
|
|
237
|
-
}
|
|
238
|
-
labelRef={ labelRef }
|
|
239
|
-
focusRef={ focusRef }
|
|
240
|
-
labelElementRef={ labelElementRef }
|
|
241
|
-
/>
|
|
242
|
-
<section { ...innerBlocksProps } />
|
|
243
|
-
</>
|
|
244
|
-
) }
|
|
245
|
-
</div>
|
|
246
|
-
</>
|
|
162
|
+
<section { ...innerBlocksProps }>
|
|
163
|
+
<Controls
|
|
164
|
+
attributes={ attributes }
|
|
165
|
+
setAttributes={ setAttributes }
|
|
166
|
+
tabsClientId={ tabsClientId }
|
|
167
|
+
blockIndex={ blockIndex }
|
|
168
|
+
isDefaultTab={ isDefaultTab }
|
|
169
|
+
/>
|
|
170
|
+
{ isSelectedTab && innerBlocksProps.children }
|
|
171
|
+
</section>
|
|
247
172
|
);
|
|
248
173
|
}
|
package/src/tab/index.php
CHANGED
|
@@ -5,55 +5,6 @@
|
|
|
5
5
|
* @package WordPress
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* Build typography classnames from named size/family.
|
|
10
|
-
*
|
|
11
|
-
* @param array $attributes Block attributes.
|
|
12
|
-
* @return string Classnames.
|
|
13
|
-
*/
|
|
14
|
-
function block_core_tab_get_typography_classes( array $attributes ): string {
|
|
15
|
-
$typography_classes = array();
|
|
16
|
-
$has_named_font_family = ! empty( $attributes['fontFamily'] );
|
|
17
|
-
$has_named_font_size = ! empty( $attributes['fontSize'] );
|
|
18
|
-
|
|
19
|
-
if ( $has_named_font_size ) {
|
|
20
|
-
$typography_classes[] = sprintf( 'has-%s-font-size', esc_attr( (string) $attributes['fontSize'] ) );
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if ( $has_named_font_family ) {
|
|
24
|
-
$typography_classes[] = sprintf( 'has-%s-font-family', esc_attr( (string) $attributes['fontFamily'] ) );
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return implode( ' ', $typography_classes );
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Build inline typography styles.
|
|
32
|
-
*
|
|
33
|
-
* @param array $attributes Block attributes.
|
|
34
|
-
* @return string Inline CSS.
|
|
35
|
-
*/
|
|
36
|
-
function block_core_tab_get_typography_styles( array $attributes ): string {
|
|
37
|
-
$typography_styles = array();
|
|
38
|
-
|
|
39
|
-
if ( ! empty( $attributes['style']['typography']['fontSize'] ) ) {
|
|
40
|
-
$typography_styles[] = sprintf(
|
|
41
|
-
'font-size: %s;',
|
|
42
|
-
wp_get_typography_font_size_value(
|
|
43
|
-
array(
|
|
44
|
-
'size' => $attributes['style']['typography']['fontSize'],
|
|
45
|
-
)
|
|
46
|
-
)
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if ( ! empty( $attributes['style']['typography']['fontFamily'] ) ) {
|
|
51
|
-
$typography_styles[] = sprintf( 'font-family: %s;', $attributes['style']['typography']['fontFamily'] );
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return implode( '', $typography_styles );
|
|
55
|
-
}
|
|
56
|
-
|
|
57
8
|
/**
|
|
58
9
|
* Render callback for core/tab.
|
|
59
10
|
*
|
|
@@ -66,6 +17,11 @@ function block_core_tab_render( array $attributes, string $content ): string {
|
|
|
66
17
|
$tag_processor = new WP_HTML_Tag_Processor( $content );
|
|
67
18
|
$tag_processor->next_tag( array( 'class_name' => 'wp-block-tab' ) );
|
|
68
19
|
$tab_id = (string) $tag_processor->get_attribute( 'id' );
|
|
20
|
+
// If no id, generate a unique one
|
|
21
|
+
if ( empty( $tab_id ) ) {
|
|
22
|
+
$tab_id = sanitize_title( $attributes['label'] );
|
|
23
|
+
$tag_processor->set_attribute( 'id', $tab_id );
|
|
24
|
+
}
|
|
69
25
|
|
|
70
26
|
/**
|
|
71
27
|
* Add interactivity to the tab element.
|
|
@@ -85,13 +41,6 @@ function block_core_tab_render( array $attributes, string $content ): string {
|
|
|
85
41
|
)
|
|
86
42
|
);
|
|
87
43
|
|
|
88
|
-
/**
|
|
89
|
-
* Process style classnames.
|
|
90
|
-
*/
|
|
91
|
-
$classname = (string) $tag_processor->get_attribute( 'class' );
|
|
92
|
-
$classname .= ' ' . block_core_tab_get_typography_classes( $attributes );
|
|
93
|
-
$tag_processor->set_attribute( 'class', $classname );
|
|
94
|
-
|
|
95
44
|
/**
|
|
96
45
|
* Process accessibility and interactivity attributes.
|
|
97
46
|
*/
|
|
@@ -100,13 +49,6 @@ function block_core_tab_render( array $attributes, string $content ): string {
|
|
|
100
49
|
$tag_processor->set_attribute( 'data-wp-bind--hidden', '!state.isActiveTab' );
|
|
101
50
|
$tag_processor->set_attribute( 'data-wp-bind--tabindex', 'state.tabIndexAttribute' );
|
|
102
51
|
|
|
103
|
-
/**
|
|
104
|
-
* Process style attribute.
|
|
105
|
-
*/
|
|
106
|
-
$style = (string) $tag_processor->get_attribute( 'style' );
|
|
107
|
-
$style .= block_core_tab_get_typography_styles( $attributes );
|
|
108
|
-
$tag_processor->set_attribute( 'style', $style );
|
|
109
|
-
|
|
110
52
|
return (string) $tag_processor->get_updated_html();
|
|
111
53
|
}
|
|
112
54
|
|
|
@@ -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
|
}
|