@wordpress/block-library 9.48.1 → 10.0.1-next.v.202606191442.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 +11 -0
- package/build/breadcrumbs/edit.cjs +1 -1
- package/build/breadcrumbs/edit.cjs.map +1 -1
- package/build/button/edit.cjs +1 -1
- package/build/button/edit.cjs.map +2 -2
- package/build/categories/edit.cjs +1 -1
- package/build/categories/edit.cjs.map +1 -1
- package/build/code/edit.cjs +1 -1
- package/build/code/edit.cjs.map +2 -2
- package/build/code/index.cjs +1 -1
- package/build/code/index.cjs.map +1 -1
- package/build/columns/utils.cjs.map +1 -1
- package/build/comments/edit/comments-legacy.cjs +1 -1
- package/build/comments/edit/comments-legacy.cjs.map +1 -1
- package/build/comments/edit/placeholder.cjs +4 -4
- package/build/comments/edit/placeholder.cjs.map +1 -1
- package/build/comments-pagination-next/edit.cjs +2 -2
- package/build/comments-pagination-next/edit.cjs.map +1 -1
- package/build/comments-pagination-previous/edit.cjs +2 -2
- package/build/comments-pagination-previous/edit.cjs.map +1 -1
- package/build/cover/deprecated.cjs +3 -3
- package/build/cover/deprecated.cjs.map +2 -2
- package/build/cover/edit/block-controls.cjs +13 -0
- package/build/cover/edit/block-controls.cjs.map +2 -2
- package/build/cover/edit/index.cjs +61 -2
- package/build/cover/edit/index.cjs.map +3 -3
- package/build/cover/edit/inspector-controls.cjs +93 -35
- package/build/cover/edit/inspector-controls.cjs.map +2 -2
- package/build/details/edit.cjs +1 -1
- package/build/details/edit.cjs.map +2 -2
- package/build/embed/embed-placeholder.cjs +1 -1
- package/build/embed/embed-placeholder.cjs.map +2 -2
- package/build/file/edit.cjs +3 -11
- package/build/file/edit.cjs.map +2 -2
- package/build/file/index.cjs +3 -1
- package/build/file/index.cjs.map +3 -3
- package/build/file/transforms.cjs +11 -32
- package/build/file/transforms.cjs.map +2 -2
- package/build/file/variations.cjs +38 -0
- package/build/file/variations.cjs.map +7 -0
- package/build/footnotes/edit.cjs +1 -1
- package/build/footnotes/edit.cjs.map +2 -2
- package/build/form-input/edit.cjs +1 -1
- package/build/form-input/edit.cjs.map +2 -2
- package/build/freeform/edit.cjs +1 -1
- package/build/freeform/edit.cjs.map +1 -1
- package/build/gallery/edit.cjs +2 -2
- package/build/gallery/edit.cjs.map +2 -2
- package/build/home-link/edit.cjs +1 -1
- package/build/home-link/edit.cjs.map +2 -2
- package/build/html/index.cjs +1 -1
- package/build/html/index.cjs.map +2 -2
- package/build/html/modal.cjs +3 -3
- package/build/html/modal.cjs.map +2 -2
- package/build/icon/block.json +12 -0
- package/build/icon/edit.cjs +90 -39
- package/build/icon/edit.cjs.map +3 -3
- package/build/icon/index.cjs +3 -1
- package/build/icon/index.cjs.map +3 -3
- package/build/{tab/save.cjs → icon/variations.cjs} +14 -15
- package/build/icon/variations.cjs.map +7 -0
- package/build/image/block.json +1 -0
- package/build/image/edit.cjs +4 -3
- package/build/image/edit.cjs.map +2 -2
- package/build/image/image.cjs +91 -27
- 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/image/transforms.cjs +9 -3
- package/build/image/transforms.cjs.map +2 -2
- package/build/index.cjs +1 -3
- package/build/index.cjs.map +2 -2
- package/build/latest-posts/edit.cjs +1 -1
- package/build/latest-posts/edit.cjs.map +1 -1
- package/build/math/edit.cjs +1 -1
- package/build/math/index.cjs +1 -1
- package/build/math/index.cjs.map +1 -1
- package/build/media-text/constants.cjs +1 -1
- package/build/media-text/constants.cjs.map +2 -2
- package/build/media-text/index.cjs +1 -1
- package/build/media-text/index.cjs.map +2 -2
- package/build/missing/edit.cjs +2 -2
- package/build/missing/edit.cjs.map +1 -1
- package/build/navigation/edit/index.cjs +14 -8
- package/build/navigation/edit/index.cjs.map +2 -2
- package/build/navigation/edit/navigation-menu-selector.cjs +1 -1
- package/build/navigation/edit/navigation-menu-selector.cjs.map +2 -2
- package/build/navigation/edit/placeholder/index.cjs +1 -1
- package/build/navigation/edit/placeholder/index.cjs.map +2 -2
- package/build/navigation-link/edit.cjs +1 -1
- package/build/navigation-link/edit.cjs.map +2 -2
- package/build/navigation-submenu/block.json +7 -0
- package/build/navigation-submenu/edit.cjs +1 -1
- package/build/navigation-submenu/edit.cjs.map +2 -2
- package/build/page-list/block.json +2 -5
- package/build/page-list/edit.cjs +1 -11
- package/build/page-list/edit.cjs.map +2 -2
- package/build/post-author/edit.cjs +1 -1
- package/build/post-author/edit.cjs.map +2 -2
- package/build/post-author/utils.cjs +1 -1
- package/build/post-author/utils.cjs.map +2 -2
- package/build/post-date/edit.cjs +2 -2
- package/build/post-date/edit.cjs.map +2 -2
- package/build/post-excerpt/edit.cjs +2 -2
- package/build/post-excerpt/edit.cjs.map +2 -2
- package/build/post-featured-image/block.json +1 -0
- package/build/post-featured-image/dimension-controls.cjs +90 -178
- package/build/post-featured-image/dimension-controls.cjs.map +3 -3
- package/build/post-featured-image/edit.cjs +47 -17
- package/build/post-featured-image/edit.cjs.map +2 -2
- package/build/post-navigation-link/edit.cjs +2 -2
- package/build/post-navigation-link/edit.cjs.map +2 -2
- package/build/post-time-to-read/edit.cjs +1 -1
- package/build/post-time-to-read/edit.cjs.map +1 -1
- package/build/preformatted/edit.cjs +1 -1
- package/build/preformatted/edit.cjs.map +2 -2
- package/build/pullquote/block.json +1 -3
- package/build/pullquote/deprecated.cjs +114 -9
- package/build/pullquote/deprecated.cjs.map +3 -3
- package/build/pullquote/edit.cjs +43 -61
- package/build/pullquote/edit.cjs.map +3 -3
- package/build/pullquote/save.cjs +5 -26
- package/build/pullquote/save.cjs.map +3 -3
- package/build/query/edit/inspector-controls/enhanced-pagination-control.cjs +1 -1
- package/build/query/edit/inspector-controls/enhanced-pagination-control.cjs.map +1 -1
- package/build/query/edit/inspector-controls/order-control.cjs +2 -2
- package/build/query/edit/inspector-controls/order-control.cjs.map +2 -2
- package/build/query/utils.cjs +2 -2
- package/build/query/utils.cjs.map +2 -2
- package/build/query-pagination-next/edit.cjs +2 -2
- package/build/query-pagination-next/edit.cjs.map +1 -1
- package/build/query-pagination-previous/edit.cjs +2 -2
- package/build/query-pagination-previous/edit.cjs.map +1 -1
- package/build/query-title/edit.cjs +1 -1
- package/build/query-title/edit.cjs.map +2 -2
- package/build/query-total/edit.cjs +1 -1
- package/build/query-total/edit.cjs.map +2 -2
- package/build/quote/index.cjs +1 -1
- package/build/quote/index.cjs.map +2 -2
- package/build/read-more/edit.cjs +1 -1
- package/build/read-more/edit.cjs.map +2 -2
- package/build/rss/edit.cjs +1 -1
- package/build/rss/edit.cjs.map +2 -2
- package/build/search/edit.cjs +3 -3
- package/build/search/edit.cjs.map +2 -2
- package/build/shortcode/edit.cjs +1 -1
- package/build/shortcode/edit.cjs.map +2 -2
- package/build/site-tagline/edit.cjs +1 -1
- package/build/site-tagline/edit.cjs.map +2 -2
- package/build/site-title/edit.cjs +1 -1
- package/build/site-title/edit.cjs.map +2 -2
- package/build/tab-list/block.json +34 -21
- package/build/tab-list/edit.cjs +116 -12
- package/build/tab-list/edit.cjs.map +3 -3
- package/build/tab-list/save.cjs +33 -3
- package/build/tab-list/save.cjs.map +3 -3
- package/build/tab-panel/add-tab-toolbar-control.cjs +19 -8
- package/build/tab-panel/add-tab-toolbar-control.cjs.map +2 -2
- package/build/tab-panel/block.json +2 -6
- package/build/tab-panel/remove-tab-toolbar-control.cjs +9 -14
- package/build/tab-panel/remove-tab-toolbar-control.cjs.map +2 -2
- package/build/tab-panels/block.json +2 -27
- package/build/table/index.cjs +1 -1
- package/build/table/index.cjs.map +2 -2
- package/build/tabs/block.json +3 -17
- package/build/tabs/edit.cjs +7 -21
- package/build/tabs/edit.cjs.map +3 -3
- package/build/tabs/index.cjs +6 -10
- package/build/tabs/index.cjs.map +2 -2
- package/build/tabs/use-tab-list-items-sync.cjs +53 -0
- package/build/tabs/use-tab-list-items-sync.cjs.map +7 -0
- package/build/tabs/view.cjs +2 -10
- package/build/tabs/view.cjs.map +2 -2
- package/build/terms-query/edit/inspector-controls/order-control.cjs +2 -2
- package/build/terms-query/edit/inspector-controls/order-control.cjs.map +2 -2
- package/build/utils/style-state.cjs +164 -0
- package/build/utils/style-state.cjs.map +7 -0
- package/build/utils/waveform-player.cjs +1 -1
- package/build/verse/edit.cjs +1 -1
- package/build/verse/edit.cjs.map +2 -2
- package/build-module/breadcrumbs/edit.mjs +1 -1
- package/build-module/breadcrumbs/edit.mjs.map +1 -1
- package/build-module/button/edit.mjs +1 -1
- package/build-module/button/edit.mjs.map +2 -2
- package/build-module/categories/edit.mjs +1 -1
- package/build-module/categories/edit.mjs.map +1 -1
- package/build-module/code/edit.mjs +1 -1
- package/build-module/code/edit.mjs.map +2 -2
- package/build-module/code/index.mjs +1 -1
- package/build-module/code/index.mjs.map +1 -1
- package/build-module/columns/utils.mjs.map +1 -1
- package/build-module/comments/edit/comments-legacy.mjs +1 -1
- package/build-module/comments/edit/comments-legacy.mjs.map +1 -1
- package/build-module/comments/edit/placeholder.mjs +4 -4
- package/build-module/comments/edit/placeholder.mjs.map +1 -1
- package/build-module/comments-pagination-next/edit.mjs +2 -2
- package/build-module/comments-pagination-next/edit.mjs.map +1 -1
- package/build-module/comments-pagination-previous/edit.mjs +2 -2
- package/build-module/comments-pagination-previous/edit.mjs.map +1 -1
- package/build-module/cover/deprecated.mjs +3 -3
- package/build-module/cover/deprecated.mjs.map +2 -2
- package/build-module/cover/edit/block-controls.mjs +15 -2
- package/build-module/cover/edit/block-controls.mjs.map +2 -2
- package/build-module/cover/edit/index.mjs +64 -3
- package/build-module/cover/edit/index.mjs.map +2 -2
- package/build-module/cover/edit/inspector-controls.mjs +98 -35
- package/build-module/cover/edit/inspector-controls.mjs.map +2 -2
- package/build-module/details/edit.mjs +1 -1
- package/build-module/details/edit.mjs.map +2 -2
- package/build-module/embed/embed-placeholder.mjs +1 -1
- package/build-module/embed/embed-placeholder.mjs.map +2 -2
- package/build-module/file/edit.mjs +5 -13
- package/build-module/file/edit.mjs.map +2 -2
- package/build-module/file/index.mjs +3 -1
- package/build-module/file/index.mjs.map +2 -2
- package/build-module/file/transforms.mjs +11 -32
- package/build-module/file/transforms.mjs.map +2 -2
- package/build-module/file/variations.mjs +17 -0
- package/build-module/file/variations.mjs.map +7 -0
- package/build-module/footnotes/edit.mjs +1 -1
- package/build-module/footnotes/edit.mjs.map +2 -2
- package/build-module/form-input/edit.mjs +1 -1
- package/build-module/form-input/edit.mjs.map +2 -2
- package/build-module/freeform/edit.mjs +1 -1
- package/build-module/freeform/edit.mjs.map +1 -1
- package/build-module/gallery/edit.mjs +2 -2
- package/build-module/gallery/edit.mjs.map +2 -2
- package/build-module/home-link/edit.mjs +1 -1
- package/build-module/home-link/edit.mjs.map +2 -2
- package/build-module/html/index.mjs +1 -1
- package/build-module/html/index.mjs.map +2 -2
- package/build-module/html/modal.mjs +3 -3
- package/build-module/html/modal.mjs.map +2 -2
- package/build-module/icon/block.json +12 -0
- package/build-module/icon/edit.mjs +94 -40
- package/build-module/icon/edit.mjs.map +2 -2
- package/build-module/icon/index.mjs +3 -1
- package/build-module/icon/index.mjs.map +2 -2
- package/build-module/icon/variations.mjs +13 -0
- package/build-module/icon/variations.mjs.map +7 -0
- package/build-module/image/block.json +1 -0
- package/build-module/image/edit.mjs +4 -3
- package/build-module/image/edit.mjs.map +2 -2
- package/build-module/image/image.mjs +96 -27
- 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/image/transforms.mjs +9 -3
- package/build-module/image/transforms.mjs.map +2 -2
- package/build-module/index.mjs +1 -3
- package/build-module/index.mjs.map +2 -2
- package/build-module/latest-posts/edit.mjs +1 -1
- package/build-module/latest-posts/edit.mjs.map +1 -1
- package/build-module/math/edit.mjs +1 -1
- package/build-module/math/index.mjs +1 -1
- package/build-module/math/index.mjs.map +1 -1
- package/build-module/media-text/constants.mjs +1 -1
- package/build-module/media-text/constants.mjs.map +2 -2
- package/build-module/media-text/index.mjs +1 -1
- package/build-module/media-text/index.mjs.map +2 -2
- package/build-module/missing/edit.mjs +2 -2
- package/build-module/missing/edit.mjs.map +1 -1
- package/build-module/navigation/edit/index.mjs +14 -8
- package/build-module/navigation/edit/index.mjs.map +2 -2
- package/build-module/navigation/edit/navigation-menu-selector.mjs +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.mjs.map +2 -2
- package/build-module/navigation/edit/placeholder/index.mjs +1 -1
- package/build-module/navigation/edit/placeholder/index.mjs.map +2 -2
- package/build-module/navigation-link/edit.mjs +1 -1
- package/build-module/navigation-link/edit.mjs.map +2 -2
- package/build-module/navigation-submenu/block.json +7 -0
- package/build-module/navigation-submenu/edit.mjs +1 -1
- package/build-module/navigation-submenu/edit.mjs.map +2 -2
- package/build-module/page-list/block.json +2 -5
- package/build-module/page-list/edit.mjs +1 -11
- package/build-module/page-list/edit.mjs.map +2 -2
- package/build-module/post-author/edit.mjs +1 -1
- package/build-module/post-author/edit.mjs.map +2 -2
- package/build-module/post-author/utils.mjs +1 -1
- package/build-module/post-author/utils.mjs.map +2 -2
- package/build-module/post-date/edit.mjs +2 -2
- package/build-module/post-date/edit.mjs.map +2 -2
- package/build-module/post-excerpt/edit.mjs +2 -2
- package/build-module/post-excerpt/edit.mjs.map +2 -2
- package/build-module/post-featured-image/block.json +1 -0
- package/build-module/post-featured-image/dimension-controls.mjs +99 -187
- package/build-module/post-featured-image/dimension-controls.mjs.map +2 -2
- package/build-module/post-featured-image/edit.mjs +47 -17
- package/build-module/post-featured-image/edit.mjs.map +2 -2
- package/build-module/post-navigation-link/edit.mjs +2 -2
- package/build-module/post-navigation-link/edit.mjs.map +2 -2
- package/build-module/post-time-to-read/edit.mjs +1 -1
- package/build-module/post-time-to-read/edit.mjs.map +1 -1
- package/build-module/preformatted/edit.mjs +1 -1
- package/build-module/preformatted/edit.mjs.map +2 -2
- package/build-module/pullquote/block.json +1 -3
- package/build-module/pullquote/deprecated.mjs +114 -9
- package/build-module/pullquote/deprecated.mjs.map +2 -2
- package/build-module/pullquote/edit.mjs +44 -67
- package/build-module/pullquote/edit.mjs.map +2 -2
- package/build-module/pullquote/save.mjs +5 -16
- package/build-module/pullquote/save.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.mjs +1 -1
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.mjs.map +1 -1
- package/build-module/query/edit/inspector-controls/order-control.mjs +2 -2
- package/build-module/query/edit/inspector-controls/order-control.mjs.map +2 -2
- package/build-module/query/utils.mjs +2 -2
- package/build-module/query/utils.mjs.map +2 -2
- package/build-module/query-pagination-next/edit.mjs +2 -2
- package/build-module/query-pagination-next/edit.mjs.map +1 -1
- package/build-module/query-pagination-previous/edit.mjs +2 -2
- package/build-module/query-pagination-previous/edit.mjs.map +1 -1
- package/build-module/query-title/edit.mjs +1 -1
- package/build-module/query-title/edit.mjs.map +2 -2
- package/build-module/query-total/edit.mjs +1 -1
- package/build-module/query-total/edit.mjs.map +2 -2
- package/build-module/quote/index.mjs +1 -1
- package/build-module/quote/index.mjs.map +2 -2
- package/build-module/read-more/edit.mjs +1 -1
- package/build-module/read-more/edit.mjs.map +2 -2
- package/build-module/rss/edit.mjs +1 -1
- package/build-module/rss/edit.mjs.map +2 -2
- package/build-module/search/edit.mjs +3 -3
- package/build-module/search/edit.mjs.map +2 -2
- package/build-module/shortcode/edit.mjs +1 -1
- package/build-module/shortcode/edit.mjs.map +2 -2
- package/build-module/site-tagline/edit.mjs +1 -1
- package/build-module/site-tagline/edit.mjs.map +2 -2
- package/build-module/site-title/edit.mjs +1 -1
- package/build-module/site-title/edit.mjs.map +2 -2
- package/build-module/tab-list/block.json +34 -21
- package/build-module/tab-list/edit.mjs +122 -15
- package/build-module/tab-list/edit.mjs.map +2 -2
- package/build-module/tab-list/save.mjs +29 -4
- package/build-module/tab-list/save.mjs.map +2 -2
- package/build-module/tab-panel/add-tab-toolbar-control.mjs +19 -8
- package/build-module/tab-panel/add-tab-toolbar-control.mjs.map +2 -2
- package/build-module/tab-panel/block.json +2 -6
- package/build-module/tab-panel/remove-tab-toolbar-control.mjs +9 -14
- package/build-module/tab-panel/remove-tab-toolbar-control.mjs.map +2 -2
- package/build-module/tab-panels/block.json +2 -27
- package/build-module/table/index.mjs +1 -1
- package/build-module/table/index.mjs.map +2 -2
- package/build-module/tabs/block.json +3 -17
- package/build-module/tabs/edit.mjs +7 -21
- package/build-module/tabs/edit.mjs.map +2 -2
- package/build-module/tabs/index.mjs +6 -10
- package/build-module/tabs/index.mjs.map +2 -2
- package/build-module/tabs/use-tab-list-items-sync.mjs +32 -0
- package/build-module/tabs/use-tab-list-items-sync.mjs.map +7 -0
- package/build-module/tabs/view.mjs +2 -10
- package/build-module/tabs/view.mjs.map +2 -2
- package/build-module/terms-query/edit/inspector-controls/order-control.mjs +2 -2
- package/build-module/terms-query/edit/inspector-controls/order-control.mjs.map +2 -2
- package/build-module/utils/style-state.mjs +132 -0
- package/build-module/utils/style-state.mjs.map +7 -0
- package/build-module/utils/waveform-player.mjs +1 -1
- package/build-module/verse/edit.mjs +1 -1
- package/build-module/verse/edit.mjs.map +2 -2
- package/build-style/editor-rtl.css +12 -16
- package/build-style/editor.css +12 -16
- package/build-style/icon/style-rtl.css +9 -0
- package/build-style/icon/style.css +9 -0
- package/build-style/style-rtl.css +11 -24
- package/build-style/style.css +11 -24
- package/build-style/tab-list/editor-rtl.css +12 -4
- package/build-style/tab-list/editor.css +12 -4
- package/build-style/{tab → tab-list}/style-rtl.css +2 -2
- package/build-style/{tab → tab-list}/style.css +2 -2
- package/build-style/tab-panel/style-rtl.css +0 -17
- package/build-style/tab-panel/style.css +0 -17
- package/package.json +48 -45
- package/src/avatar/index.php +2 -2
- package/src/block/index.php +2 -26
- package/src/comment-author-avatar/index.php +3 -3
- package/src/comment-author-name/index.php +1 -1
- package/src/comment-date/index.php +1 -1
- package/src/cover/edit/block-controls.js +14 -2
- package/src/cover/edit/index.js +86 -0
- package/src/cover/edit/inspector-controls.js +124 -54
- package/src/editor.scss +0 -1
- package/src/file/edit.js +3 -16
- package/src/file/index.js +2 -0
- package/src/file/transforms.js +12 -31
- package/src/file/variations.js +17 -0
- package/src/gallery/edit.js +13 -13
- package/src/icon/README.md +3 -0
- package/src/icon/block.json +12 -0
- package/src/icon/edit.js +86 -36
- package/src/icon/index.js +3 -1
- package/src/icon/index.php +23 -0
- package/src/icon/style.scss +12 -0
- package/src/icon/variations.js +9 -0
- package/src/image/README.md +1 -0
- package/src/image/block.json +1 -0
- package/src/image/edit.js +8 -3
- package/src/image/image.js +120 -54
- package/src/image/index.php +0 -1
- package/src/image/transforms.js +34 -8
- package/src/index.js +4 -11
- package/src/navigation/edit/index.js +23 -10
- package/src/navigation/index.php +58 -0
- package/src/navigation-submenu/README.md +5 -0
- package/src/navigation-submenu/block.json +7 -0
- package/src/page-list/README.md +1 -1
- package/src/page-list/block.json +2 -5
- package/src/page-list/edit.js +0 -11
- package/src/page-list/index.php +1 -1
- package/src/post-date/edit.js +2 -2
- package/src/post-featured-image/README.md +1 -0
- package/src/post-featured-image/block.json +1 -0
- package/src/post-featured-image/dimension-controls.js +105 -184
- package/src/post-featured-image/edit.js +53 -21
- package/src/post-featured-image/index.php +24 -22
- package/src/pullquote/README.md +1 -1
- package/src/pullquote/block.json +1 -3
- package/src/pullquote/deprecated.js +121 -9
- package/src/pullquote/edit.js +7 -31
- package/src/pullquote/save.js +2 -13
- package/src/search/index.php +1 -1
- package/src/style.scss +1 -2
- package/src/tab-list/README.md +19 -17
- package/src/tab-list/block.json +34 -21
- package/src/tab-list/edit.js +147 -15
- package/src/tab-list/editor.scss +13 -6
- package/src/tab-list/index.php +23 -30
- package/src/tab-list/save.js +39 -4
- package/src/{tab → tab-list}/style.scss +1 -1
- package/src/tab-panel/README.md +0 -3
- package/src/tab-panel/add-tab-toolbar-control.js +24 -11
- package/src/tab-panel/block.json +2 -6
- package/src/tab-panel/remove-tab-toolbar-control.js +10 -14
- package/src/tab-panel/style.scss +0 -17
- package/src/tab-panels/README.md +0 -16
- package/src/tab-panels/block.json +2 -27
- package/src/tabs/README.md +1 -7
- package/src/tabs/block.json +3 -17
- package/src/tabs/edit.js +8 -19
- package/src/tabs/index.js +6 -10
- package/src/tabs/index.php +0 -13
- package/src/tabs/use-tab-list-items-sync.js +49 -0
- package/src/tabs/view.js +2 -10
- package/src/utils/style-state.js +151 -0
- package/src/utils/test/style-state.js +307 -0
- package/babel-plugin.cjs +0 -150
- package/build/tab/block.json +0 -56
- package/build/tab/controls.cjs +0 -46
- package/build/tab/controls.cjs.map +0 -7
- package/build/tab/edit.cjs +0 -135
- package/build/tab/edit.cjs.map +0 -7
- package/build/tab/index.cjs +0 -58
- package/build/tab/index.cjs.map +0 -7
- package/build/tab/save.cjs.map +0 -7
- package/build/tabs/use-tab-list-sync.cjs +0 -190
- package/build/tabs/use-tab-list-sync.cjs.map +0 -7
- package/build-module/tab/block.json +0 -56
- package/build-module/tab/controls.mjs +0 -15
- package/build-module/tab/controls.mjs.map +0 -7
- package/build-module/tab/edit.mjs +0 -108
- package/build-module/tab/edit.mjs.map +0 -7
- package/build-module/tab/index.mjs +0 -20
- package/build-module/tab/index.mjs.map +0 -7
- package/build-module/tab/save.mjs +0 -14
- package/build-module/tab/save.mjs.map +0 -7
- package/build-module/tabs/use-tab-list-sync.mjs +0 -169
- package/build-module/tabs/use-tab-list-sync.mjs.map +0 -7
- package/build-style/tab/editor-rtl.css +0 -11
- package/build-style/tab/editor.css +0 -11
- package/build-style/tab-panels/style-rtl.css +0 -4
- package/build-style/tab-panels/style.css +0 -4
- package/src/tab/README.md +0 -69
- package/src/tab/block.json +0 -56
- package/src/tab/controls.js +0 -19
- package/src/tab/edit.js +0 -141
- package/src/tab/editor.scss +0 -14
- package/src/tab/index.js +0 -24
- package/src/tab/index.php +0 -70
- package/src/tab/save.js +0 -13
- package/src/tab-panels/style.scss +0 -4
- package/src/tabs/use-tab-list-sync.js +0 -237
package/src/tab/edit.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import clsx from 'clsx';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { __ } from '@wordpress/i18n';
|
|
10
|
-
import {
|
|
11
|
-
useBlockProps,
|
|
12
|
-
store as blockEditorStore,
|
|
13
|
-
RichText,
|
|
14
|
-
} from '@wordpress/block-editor';
|
|
15
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
16
|
-
import { useMemo, useCallback } from '@wordpress/element';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Internal dependencies
|
|
20
|
-
*/
|
|
21
|
-
import Controls from './controls';
|
|
22
|
-
|
|
23
|
-
const EMPTY_ARRAY = [];
|
|
24
|
-
|
|
25
|
-
function Edit( { context, clientId } ) {
|
|
26
|
-
const tabsList = context[ 'core/tabs-list' ] || EMPTY_ARRAY;
|
|
27
|
-
const activeTabIndex = context[ 'core/tabs-activeTabIndex' ];
|
|
28
|
-
const editorActiveTabIndex = context[ 'core/tabs-editorActiveTabIndex' ];
|
|
29
|
-
|
|
30
|
-
const effectiveActiveIndex = useMemo( () => {
|
|
31
|
-
return editorActiveTabIndex ?? activeTabIndex;
|
|
32
|
-
}, [ editorActiveTabIndex, activeTabIndex ] );
|
|
33
|
-
|
|
34
|
-
const { tabIndex, tabsClientId, selectedTabClientId } = useSelect(
|
|
35
|
-
( select ) => {
|
|
36
|
-
const {
|
|
37
|
-
getBlockOrder,
|
|
38
|
-
getBlockRootClientId,
|
|
39
|
-
getSelectedBlockClientIds,
|
|
40
|
-
hasSelectedInnerBlock,
|
|
41
|
-
} = select( blockEditorStore );
|
|
42
|
-
|
|
43
|
-
const _tabsListClientId = getBlockRootClientId( clientId );
|
|
44
|
-
const _tabsClientId = _tabsListClientId
|
|
45
|
-
? getBlockRootClientId( _tabsListClientId )
|
|
46
|
-
: null;
|
|
47
|
-
|
|
48
|
-
const siblings = getBlockOrder( _tabsListClientId );
|
|
49
|
-
const _tabIndex = siblings.indexOf( clientId );
|
|
50
|
-
|
|
51
|
-
// Find which tab panel block is currently selected.
|
|
52
|
-
const selectedIds = getSelectedBlockClientIds();
|
|
53
|
-
let _selectedTabClientId = null;
|
|
54
|
-
for ( const tab of tabsList ) {
|
|
55
|
-
if (
|
|
56
|
-
selectedIds.includes( tab.clientId ) ||
|
|
57
|
-
hasSelectedInnerBlock( tab.clientId, true )
|
|
58
|
-
) {
|
|
59
|
-
_selectedTabClientId = tab.clientId;
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
tabIndex: _tabIndex,
|
|
66
|
-
tabsClientId: _tabsClientId,
|
|
67
|
-
selectedTabClientId: _selectedTabClientId,
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
[ clientId, tabsList ]
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
const tab = tabsList[ tabIndex ] || {};
|
|
74
|
-
|
|
75
|
-
// tabListIndex is the tab's position in tabsList, used for active-state
|
|
76
|
-
// checks and click handling.
|
|
77
|
-
const tabListIndex = tab.index ?? tabIndex;
|
|
78
|
-
|
|
79
|
-
const tabClientId = tab.clientId || '';
|
|
80
|
-
const label = tab.label || '';
|
|
81
|
-
|
|
82
|
-
const isActive = tabListIndex === effectiveActiveIndex;
|
|
83
|
-
const isSelected = tabClientId === selectedTabClientId;
|
|
84
|
-
|
|
85
|
-
const { __unstableMarkNextChangeAsNotPersistent, updateBlockAttributes } =
|
|
86
|
-
useDispatch( blockEditorStore );
|
|
87
|
-
|
|
88
|
-
const handleTabClick = useCallback(
|
|
89
|
-
( event ) => {
|
|
90
|
-
event.preventDefault();
|
|
91
|
-
if ( tabsClientId && tabListIndex !== effectiveActiveIndex ) {
|
|
92
|
-
__unstableMarkNextChangeAsNotPersistent();
|
|
93
|
-
updateBlockAttributes( tabsClientId, {
|
|
94
|
-
editorActiveTabIndex: tabListIndex,
|
|
95
|
-
} );
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
[
|
|
99
|
-
tabsClientId,
|
|
100
|
-
tabListIndex,
|
|
101
|
-
effectiveActiveIndex,
|
|
102
|
-
updateBlockAttributes,
|
|
103
|
-
__unstableMarkNextChangeAsNotPersistent,
|
|
104
|
-
]
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
const handleLabelChange = useCallback(
|
|
108
|
-
( newLabel ) => {
|
|
109
|
-
if ( tabClientId ) {
|
|
110
|
-
updateBlockAttributes( tabClientId, { label: newLabel } );
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
[ tabClientId, updateBlockAttributes ]
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
const blockProps = useBlockProps( {
|
|
117
|
-
className: clsx( {
|
|
118
|
-
'is-active': isActive,
|
|
119
|
-
'is-selected': isSelected,
|
|
120
|
-
} ),
|
|
121
|
-
tabIndex: -1,
|
|
122
|
-
onClick: handleTabClick,
|
|
123
|
-
} );
|
|
124
|
-
|
|
125
|
-
return (
|
|
126
|
-
<>
|
|
127
|
-
<Controls tabsClientId={ tabsClientId } />
|
|
128
|
-
<button { ...blockProps } type="button">
|
|
129
|
-
<RichText
|
|
130
|
-
tagName="span"
|
|
131
|
-
withoutInteractiveFormatting
|
|
132
|
-
placeholder={ __( 'Tab title' ) }
|
|
133
|
-
value={ label }
|
|
134
|
-
onChange={ handleLabelChange }
|
|
135
|
-
/>
|
|
136
|
-
</button>
|
|
137
|
-
</>
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export default Edit;
|
package/src/tab/editor.scss
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
.wp-block-tab {
|
|
2
|
-
&.is-selected {
|
|
3
|
-
outline-offset: 2px;
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.block-editor-block-preview__live-content:has(.wp-block-tab) {
|
|
8
|
-
flex-basis: inherit !important;
|
|
9
|
-
flex-grow: inherit !important;
|
|
10
|
-
|
|
11
|
-
.wp-block-tab {
|
|
12
|
-
flex-basis: 100% !important;
|
|
13
|
-
}
|
|
14
|
-
}
|
package/src/tab/index.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { tab as icon } from '@wordpress/icons';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import initBlock from '../utils/init-block';
|
|
10
|
-
import edit from './edit';
|
|
11
|
-
import save from './save';
|
|
12
|
-
import metadata from './block.json';
|
|
13
|
-
|
|
14
|
-
const { name } = metadata;
|
|
15
|
-
|
|
16
|
-
export { metadata, name };
|
|
17
|
-
|
|
18
|
-
export const settings = {
|
|
19
|
-
icon,
|
|
20
|
-
edit,
|
|
21
|
-
save,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const init = () => initBlock( { name, metadata, settings } );
|
package/src/tab/index.php
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
/**
|
|
3
|
-
* Tab Block
|
|
4
|
-
*
|
|
5
|
-
* @package WordPress
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Render callback for core/tab.
|
|
10
|
-
*
|
|
11
|
-
* Injects the tab label and IAPI directives into the saved button HTML.
|
|
12
|
-
* Per-item context (index, id, label) is provided by the parent tab-list
|
|
13
|
-
* render callback before this is called.
|
|
14
|
-
*
|
|
15
|
-
* @since 7.0.0
|
|
16
|
-
*
|
|
17
|
-
* @param array $attributes Block attributes.
|
|
18
|
-
* @param string $content Block content (styled button from save.js).
|
|
19
|
-
* @param \WP_Block $block WP_Block instance.
|
|
20
|
-
*
|
|
21
|
-
* @return string Updated HTML.
|
|
22
|
-
*/
|
|
23
|
-
function block_core_tab_render_callback( array $attributes, string $content, \WP_Block $block ): string {
|
|
24
|
-
$tab_index = $block->context['core/tab-index'] ?? 0;
|
|
25
|
-
$tab_id = $block->context['core/tab-id'] ?? '';
|
|
26
|
-
$tab_label = $block->context['core/tab-label'] ?? '';
|
|
27
|
-
|
|
28
|
-
if ( empty( $tab_id ) ) {
|
|
29
|
-
$tab_id = 'tab-' . $tab_index;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Add Interactivity API directives and tab-specific attributes to the button.
|
|
33
|
-
$tag_processor = new WP_HTML_Tag_Processor( $content );
|
|
34
|
-
|
|
35
|
-
if ( $tag_processor->next_tag() ) {
|
|
36
|
-
$tag_processor->set_attribute( 'id', 'tab__' . $tab_id );
|
|
37
|
-
$tag_processor->set_attribute( 'aria-controls', $tab_id );
|
|
38
|
-
$tag_processor->set_attribute( 'data-wp-on--click', 'actions.handleTabClick' );
|
|
39
|
-
$tag_processor->set_attribute( 'data-wp-on--keydown', 'actions.handleTabKeyDown' );
|
|
40
|
-
$tag_processor->set_attribute( 'data-wp-bind--aria-selected', 'state.isActiveTab' );
|
|
41
|
-
$tag_processor->set_attribute( 'data-wp-bind--tabindex', 'state.tabIndexAttribute' );
|
|
42
|
-
$tag_processor->set_attribute(
|
|
43
|
-
'data-wp-context',
|
|
44
|
-
wp_json_encode( array( 'tabIndex' => $tab_index ) )
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Inject the tab label into the button.
|
|
49
|
-
return preg_replace(
|
|
50
|
-
'/(<button\b[^>]*>).*?(<\/button>)/s',
|
|
51
|
-
'$1<span>' . wp_kses_post( $tab_label ) . '</span>$2',
|
|
52
|
-
$tag_processor->get_updated_html(),
|
|
53
|
-
1
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Registers the `core/tab` block on the server.
|
|
59
|
-
*
|
|
60
|
-
* @since 7.0.0
|
|
61
|
-
*/
|
|
62
|
-
function register_block_core_tab() {
|
|
63
|
-
register_block_type_from_metadata(
|
|
64
|
-
__DIR__ . '/tab',
|
|
65
|
-
array(
|
|
66
|
-
'render_callback' => 'block_core_tab_render_callback',
|
|
67
|
-
)
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
add_action( 'init', 'register_block_core_tab' );
|
package/src/tab/save.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useBlockProps } from '@wordpress/block-editor';
|
|
5
|
-
|
|
6
|
-
export default function save() {
|
|
7
|
-
const blockProps = useBlockProps.save( {
|
|
8
|
-
type: 'button',
|
|
9
|
-
role: 'tab',
|
|
10
|
-
} );
|
|
11
|
-
|
|
12
|
-
return <button { ...blockProps } />;
|
|
13
|
-
}
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { createBlock } from '@wordpress/blocks';
|
|
5
|
-
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
6
|
-
import { useDispatch } from '@wordpress/data';
|
|
7
|
-
import { useEffect, useRef } from '@wordpress/element';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Keep tabs and tab panels in sync when the lists change due to direct
|
|
11
|
-
* user actions (deletion, paste, duplicate, drag-and-drop).
|
|
12
|
-
*
|
|
13
|
-
* Deletion: when one side shrinks, remove the counterpart at the same index.
|
|
14
|
-
* Insertion: when one side grows without the other, insert the missing
|
|
15
|
-
* counterpart at the matching index.
|
|
16
|
-
*
|
|
17
|
-
* When both lists change simultaneously (e.g. the "Add Tab" toolbar button,
|
|
18
|
-
* which inserts both at once), no action is needed and the effect exits early.
|
|
19
|
-
*
|
|
20
|
-
* @param {Object} props
|
|
21
|
-
* @param {Array} props.tabs Raw core/tab block objects.
|
|
22
|
-
* @param {Array} props.tabPanels Raw core/tab-panel block objects.
|
|
23
|
-
* @param {string|null} props.tabPanelsClientId Client ID of the core/tab-panels block.
|
|
24
|
-
* @param {string|null} props.tabsListClientId Client ID of the core/tab-list block.
|
|
25
|
-
*/
|
|
26
|
-
export default function useTabListSync( {
|
|
27
|
-
tabPanels,
|
|
28
|
-
tabs,
|
|
29
|
-
tabPanelsClientId,
|
|
30
|
-
tabsListClientId,
|
|
31
|
-
} ) {
|
|
32
|
-
const {
|
|
33
|
-
removeBlock,
|
|
34
|
-
insertBlocks,
|
|
35
|
-
replaceInnerBlocks,
|
|
36
|
-
__unstableMarkNextChangeAsNotPersistent,
|
|
37
|
-
} = useDispatch( blockEditorStore );
|
|
38
|
-
|
|
39
|
-
const prevSyncStateRef = useRef( null );
|
|
40
|
-
useEffect( () => {
|
|
41
|
-
if ( prevSyncStateRef.current === null ) {
|
|
42
|
-
prevSyncStateRef.current = {
|
|
43
|
-
tabPanels: [ ...tabPanels ],
|
|
44
|
-
tabs: [ ...tabs ],
|
|
45
|
-
};
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const { tabPanels: prevTabPanels, tabs: prevTabs } =
|
|
50
|
-
prevSyncStateRef.current;
|
|
51
|
-
|
|
52
|
-
const tabPanelCountChange = tabPanels.length - prevTabPanels.length;
|
|
53
|
-
const tabCountChange = tabs.length - prevTabs.length;
|
|
54
|
-
|
|
55
|
-
const tabPanelsInserted = tabPanelCountChange > 0;
|
|
56
|
-
const tabsInserted = tabCountChange > 0;
|
|
57
|
-
|
|
58
|
-
// Both sides changed by the same amount.
|
|
59
|
-
// Covers: no-op re-renders, "Add Tab" toolbar, and toolbar-remove.
|
|
60
|
-
// Also handles drag-and-drop reordering of tabs.
|
|
61
|
-
if ( tabPanelCountChange === tabCountChange ) {
|
|
62
|
-
// When lengths are equal but order changed, the user reordered tabs
|
|
63
|
-
// via drag-and-drop. Reorder the tab panel blocks to match.
|
|
64
|
-
if (
|
|
65
|
-
tabPanelCountChange === 0 &&
|
|
66
|
-
tabPanelsClientId &&
|
|
67
|
-
tabs.some( ( m, i ) => m.clientId !== prevTabs[ i ]?.clientId )
|
|
68
|
-
) {
|
|
69
|
-
const reorderedTabPanels = tabs
|
|
70
|
-
.map( ( tab ) => {
|
|
71
|
-
const oldIndex = prevTabs.findIndex(
|
|
72
|
-
( pm ) => pm.clientId === tab.clientId
|
|
73
|
-
);
|
|
74
|
-
return oldIndex !== -1 ? tabPanels[ oldIndex ] : null;
|
|
75
|
-
} )
|
|
76
|
-
.filter( Boolean );
|
|
77
|
-
if ( reorderedTabPanels.length === tabPanels.length ) {
|
|
78
|
-
__unstableMarkNextChangeAsNotPersistent();
|
|
79
|
-
replaceInnerBlocks(
|
|
80
|
-
tabPanelsClientId,
|
|
81
|
-
reorderedTabPanels,
|
|
82
|
-
false
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
prevSyncStateRef.current = {
|
|
87
|
-
tabPanels: [ ...tabPanels ],
|
|
88
|
-
tabs: [ ...tabs ],
|
|
89
|
-
};
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Both sides changed in the same direction but by different amounts.
|
|
94
|
-
// Bail without making a partial fix.
|
|
95
|
-
if (
|
|
96
|
-
( tabPanelCountChange > 0 && tabCountChange > 0 ) ||
|
|
97
|
-
( tabPanelCountChange < 0 && tabCountChange < 0 )
|
|
98
|
-
) {
|
|
99
|
-
prevSyncStateRef.current = {
|
|
100
|
-
tabPanels: [ ...tabPanels ],
|
|
101
|
-
tabs: [ ...tabs ],
|
|
102
|
-
};
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// If the required container block isn't available yet, bail without
|
|
107
|
-
// updating the snapshot so the next render re-evaluates the same count change.
|
|
108
|
-
if ( tabPanelsInserted && ! tabsListClientId ) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
if ( tabsInserted && ! tabPanelsClientId ) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Update snapshot to the current state.
|
|
116
|
-
prevSyncStateRef.current = {
|
|
117
|
-
tabPanels: [ ...tabPanels ],
|
|
118
|
-
tabs: [ ...tabs ],
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
const currentTabPanelIds = new Set(
|
|
122
|
-
tabPanels.map( ( t ) => t.clientId )
|
|
123
|
-
);
|
|
124
|
-
const currentTabIds = new Set( tabs.map( ( m ) => m.clientId ) );
|
|
125
|
-
|
|
126
|
-
if ( tabPanelCountChange < 0 ) {
|
|
127
|
-
// Remove the tab at the same position as each deleted tab panel.
|
|
128
|
-
const removedIndices = prevTabPanels
|
|
129
|
-
.map( ( t, i ) =>
|
|
130
|
-
! currentTabPanelIds.has( t.clientId ) ? i : -1
|
|
131
|
-
)
|
|
132
|
-
.filter( ( i ) => i !== -1 );
|
|
133
|
-
const removedSet = new Set( removedIndices );
|
|
134
|
-
removedIndices.forEach( ( removedIndex ) => {
|
|
135
|
-
if ( tabs[ removedIndex ] ) {
|
|
136
|
-
__unstableMarkNextChangeAsNotPersistent();
|
|
137
|
-
removeBlock( tabs[ removedIndex ].clientId, false );
|
|
138
|
-
}
|
|
139
|
-
} );
|
|
140
|
-
prevSyncStateRef.current.tabs =
|
|
141
|
-
prevSyncStateRef.current.tabs.filter(
|
|
142
|
-
( _, i ) => ! removedSet.has( i )
|
|
143
|
-
);
|
|
144
|
-
} else if ( tabCountChange < 0 ) {
|
|
145
|
-
// Remove the tab panel at the same position as each deleted tab.
|
|
146
|
-
const removedIndices = prevTabs
|
|
147
|
-
.map( ( m, i ) =>
|
|
148
|
-
! currentTabIds.has( m.clientId ) ? i : -1
|
|
149
|
-
)
|
|
150
|
-
.filter( ( i ) => i !== -1 );
|
|
151
|
-
const removedSet = new Set( removedIndices );
|
|
152
|
-
removedIndices.forEach( ( removedIndex ) => {
|
|
153
|
-
if ( tabPanels[ removedIndex ] ) {
|
|
154
|
-
__unstableMarkNextChangeAsNotPersistent();
|
|
155
|
-
removeBlock( tabPanels[ removedIndex ].clientId, false );
|
|
156
|
-
}
|
|
157
|
-
} );
|
|
158
|
-
prevSyncStateRef.current.tabPanels =
|
|
159
|
-
prevSyncStateRef.current.tabPanels.filter(
|
|
160
|
-
( _, i ) => ! removedSet.has( i )
|
|
161
|
-
);
|
|
162
|
-
} else if ( tabPanelsInserted ) {
|
|
163
|
-
// A tab panel was pasted or duplicated — insert a matching tab.
|
|
164
|
-
const prevTabPanelIds = new Set(
|
|
165
|
-
prevTabPanels.map( ( t ) => t.clientId )
|
|
166
|
-
);
|
|
167
|
-
const newTabs = tabPanels
|
|
168
|
-
.map( ( tabPanel, tabPanelIndex ) =>
|
|
169
|
-
! prevTabPanelIds.has( tabPanel.clientId )
|
|
170
|
-
? {
|
|
171
|
-
tabPanelIndex,
|
|
172
|
-
block: createBlock( 'core/tab', {} ),
|
|
173
|
-
}
|
|
174
|
-
: null
|
|
175
|
-
)
|
|
176
|
-
.filter( Boolean );
|
|
177
|
-
|
|
178
|
-
if ( newTabs.length > 0 ) {
|
|
179
|
-
__unstableMarkNextChangeAsNotPersistent();
|
|
180
|
-
insertBlocks(
|
|
181
|
-
newTabs.map( ( { block } ) => block ),
|
|
182
|
-
newTabs[ 0 ].tabPanelIndex,
|
|
183
|
-
tabsListClientId,
|
|
184
|
-
false
|
|
185
|
-
);
|
|
186
|
-
newTabs.forEach( ( { tabPanelIndex, block } ) => {
|
|
187
|
-
prevSyncStateRef.current.tabs.splice( tabPanelIndex, 0, {
|
|
188
|
-
clientId: block.clientId,
|
|
189
|
-
} );
|
|
190
|
-
} );
|
|
191
|
-
}
|
|
192
|
-
} else if ( tabsInserted ) {
|
|
193
|
-
// A tab was pasted or duplicated — insert a matching tab panels,
|
|
194
|
-
// copying the label from the adjacent tab panel.
|
|
195
|
-
const prevTabIds = new Set( prevTabs.map( ( m ) => m.clientId ) );
|
|
196
|
-
const newTabPanels = tabs
|
|
197
|
-
.map( ( tab, tabIndex ) => {
|
|
198
|
-
if ( prevTabIds.has( tab.clientId ) ) {
|
|
199
|
-
return null;
|
|
200
|
-
}
|
|
201
|
-
const label =
|
|
202
|
-
tabPanels[ tabIndex - 1 ]?.attributes?.label ??
|
|
203
|
-
tabPanels[ tabIndex ]?.attributes?.label ??
|
|
204
|
-
'';
|
|
205
|
-
return {
|
|
206
|
-
tabIndex,
|
|
207
|
-
block: createBlock( 'core/tab-panel', { label } ),
|
|
208
|
-
};
|
|
209
|
-
} )
|
|
210
|
-
.filter( Boolean );
|
|
211
|
-
|
|
212
|
-
if ( newTabPanels.length > 0 ) {
|
|
213
|
-
__unstableMarkNextChangeAsNotPersistent();
|
|
214
|
-
insertBlocks(
|
|
215
|
-
newTabPanels.map( ( { block } ) => block ),
|
|
216
|
-
newTabPanels[ 0 ].tabIndex,
|
|
217
|
-
tabPanelsClientId,
|
|
218
|
-
false
|
|
219
|
-
);
|
|
220
|
-
newTabPanels.forEach( ( { tabIndex, block } ) => {
|
|
221
|
-
prevSyncStateRef.current.tabPanels.splice( tabIndex, 0, {
|
|
222
|
-
clientId: block.clientId,
|
|
223
|
-
} );
|
|
224
|
-
} );
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}, [
|
|
228
|
-
tabPanels,
|
|
229
|
-
tabs,
|
|
230
|
-
removeBlock,
|
|
231
|
-
insertBlocks,
|
|
232
|
-
replaceInnerBlocks,
|
|
233
|
-
__unstableMarkNextChangeAsNotPersistent,
|
|
234
|
-
tabsListClientId,
|
|
235
|
-
tabPanelsClientId,
|
|
236
|
-
] );
|
|
237
|
-
}
|