@wordpress/block-library 10.0.1 → 10.1.1-next.v.202607070741.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/accordion/edit.cjs +0 -1
- package/build/accordion/edit.cjs.map +2 -2
- package/build/accordion/view.cjs +23 -0
- package/build/accordion/view.cjs.map +2 -2
- package/build/accordion-heading/deprecated.cjs +121 -1
- package/build/accordion-heading/deprecated.cjs.map +2 -2
- package/build/accordion-heading/edit.cjs +18 -1
- package/build/accordion-heading/edit.cjs.map +3 -3
- package/build/accordion-heading/save.cjs +18 -1
- package/build/accordion-heading/save.cjs.map +3 -3
- package/build/accordion-panel/edit.cjs +1 -1
- package/build/accordion-panel/edit.cjs.map +2 -2
- package/build/archives/edit.cjs +0 -1
- package/build/archives/edit.cjs.map +2 -2
- package/build/audio/edit.cjs +0 -1
- package/build/audio/edit.cjs.map +2 -2
- package/build/avatar/edit.cjs +0 -1
- package/build/avatar/edit.cjs.map +2 -2
- package/build/avatar/user-control.cjs +0 -1
- package/build/avatar/user-control.cjs.map +2 -2
- package/build/categories/edit.cjs +0 -1
- package/build/categories/edit.cjs.map +2 -2
- package/build/code/transforms.cjs +5 -3
- package/build/code/transforms.cjs.map +2 -2
- package/build/column/edit.cjs +0 -1
- package/build/column/edit.cjs.map +2 -2
- package/build/columns/edit.cjs +0 -1
- package/build/columns/edit.cjs.map +2 -2
- package/build/columns/transforms.cjs +9 -2
- package/build/columns/transforms.cjs.map +2 -2
- package/build/comment-author-avatar/edit.cjs +0 -1
- package/build/comment-author-avatar/edit.cjs.map +2 -2
- package/build/comments-pagination/comments-pagination-arrow-controls.cjs +0 -1
- package/build/comments-pagination/comments-pagination-arrow-controls.cjs.map +2 -2
- package/build/cover/edit/inspector-controls.cjs +1 -3
- package/build/cover/edit/inspector-controls.cjs.map +2 -2
- package/build/details/transforms.cjs +3 -1
- package/build/details/transforms.cjs.map +2 -2
- package/build/embed/edit.cjs +2 -3
- package/build/embed/edit.cjs.map +2 -2
- package/build/embed/embed-placeholder.cjs +20 -20
- package/build/embed/embed-placeholder.cjs.map +3 -3
- package/build/file/inspector.cjs +0 -2
- package/build/file/inspector.cjs.map +2 -2
- package/build/form/edit.cjs +0 -2
- package/build/form/edit.cjs.map +2 -2
- package/build/freeform/convert-to-blocks-button.cjs +52 -0
- package/build/freeform/convert-to-blocks-button.cjs.map +7 -0
- package/build/freeform/edit.cjs +14 -33
- package/build/freeform/edit.cjs.map +3 -3
- package/build/freeform/index.cjs +1 -7
- package/build/freeform/index.cjs.map +3 -3
- package/build/gallery/block.json +4 -1
- package/build/gallery/dynamic-gallery.cjs +263 -0
- package/build/gallery/dynamic-gallery.cjs.map +7 -0
- package/build/gallery/dynamic-source.cjs +85 -0
- package/build/gallery/dynamic-source.cjs.map +7 -0
- package/build/gallery/edit.cjs +285 -205
- package/build/gallery/edit.cjs.map +3 -3
- package/build/gallery/gallery.cjs +0 -3
- package/build/gallery/gallery.cjs.map +2 -2
- package/build/gallery/index.cjs +2 -0
- package/build/gallery/index.cjs.map +3 -3
- package/build/gallery/save.cjs +16 -12
- package/build/gallery/save.cjs.map +2 -2
- package/build/gallery/use-dynamic-gallery.cjs +181 -0
- package/build/gallery/use-dynamic-gallery.cjs.map +7 -0
- package/build/gallery/variations.cjs +54 -0
- package/build/gallery/variations.cjs.map +7 -0
- package/build/group/edit.cjs +1 -2
- package/build/group/edit.cjs.map +2 -2
- package/build/group/transforms.cjs +3 -7
- package/build/group/transforms.cjs.map +2 -2
- package/build/heading/edit.cjs +10 -3
- package/build/heading/edit.cjs.map +2 -2
- package/build/html/block.json +2 -2
- package/build/html/edit.cjs +65 -23
- package/build/html/edit.cjs.map +3 -3
- package/build/html/index.cjs +3 -3
- package/build/html/index.cjs.map +2 -2
- package/build/html/modal.cjs +4 -8
- package/build/html/modal.cjs.map +2 -2
- package/build/html/save.cjs +2 -4
- package/build/html/save.cjs.map +2 -2
- package/build/html/transforms.cjs +7 -5
- package/build/html/transforms.cjs.map +2 -2
- package/build/image/animated-gif-convert-control.cjs +105 -0
- package/build/image/animated-gif-convert-control.cjs.map +7 -0
- package/build/image/edit.cjs +34 -0
- package/build/image/edit.cjs.map +2 -2
- package/build/image/image.cjs +38 -66
- package/build/image/image.cjs.map +3 -3
- package/build/index.cjs.map +2 -2
- package/build/latest-comments/edit.cjs +0 -2
- package/build/latest-comments/edit.cjs.map +2 -2
- package/build/latest-posts/block.json +8 -9
- package/build/latest-posts/constants.cjs +0 -3
- package/build/latest-posts/constants.cjs.map +2 -2
- package/build/latest-posts/deprecated.cjs +100 -8
- package/build/latest-posts/deprecated.cjs.map +2 -2
- package/build/latest-posts/edit.cjs +62 -76
- package/build/latest-posts/edit.cjs.map +2 -2
- package/build/list/ordered-list-settings.cjs +0 -1
- package/build/list/ordered-list-settings.cjs.map +2 -2
- package/build/media-text/edit.cjs +0 -1
- package/build/media-text/edit.cjs.map +2 -2
- package/build/missing/edit.cjs +1 -3
- package/build/missing/edit.cjs.map +2 -2
- package/build/navigation/edit/index.cjs +0 -1
- package/build/navigation/edit/index.cjs.map +2 -2
- package/build/navigation/edit/overlay-menu-preview-controls.cjs +0 -1
- package/build/navigation/edit/overlay-menu-preview-controls.cjs.map +2 -2
- package/build/navigation/edit/overlay-menu-preview.cjs +0 -1
- package/build/navigation/edit/overlay-menu-preview.cjs.map +2 -2
- package/build/navigation/edit/overlay-template-part-selector.cjs +0 -1
- package/build/navigation/edit/overlay-template-part-selector.cjs.map +2 -2
- package/build/navigation/edit/overlay-visibility-control.cjs +0 -1
- package/build/navigation/edit/overlay-visibility-control.cjs.map +2 -2
- package/build/navigation-link/shared/use-link-preview.cjs +11 -1
- package/build/navigation-link/shared/use-link-preview.cjs.map +2 -2
- package/build/navigation-overlay-close/edit.cjs +0 -1
- package/build/navigation-overlay-close/edit.cjs.map +2 -2
- package/build/page-list/edit.cjs +0 -1
- package/build/page-list/edit.cjs.map +2 -2
- package/build/playlist/block.json +1 -7
- package/build/playlist/context.cjs +36 -0
- package/build/playlist/context.cjs.map +7 -0
- package/build/playlist/edit.cjs +43 -69
- package/build/playlist/edit.cjs.map +3 -3
- package/build/playlist/utils.cjs +0 -3
- package/build/playlist/utils.cjs.map +3 -3
- package/build/playlist/view.cjs +4 -4
- package/build/playlist/view.cjs.map +2 -2
- package/build/playlist-track/block.json +1 -4
- package/build/playlist-track/edit.cjs +22 -8
- package/build/playlist-track/edit.cjs.map +3 -3
- package/build/post-author/edit.cjs +0 -2
- package/build/post-author/edit.cjs.map +2 -2
- package/build/post-excerpt/edit.cjs +0 -1
- package/build/post-excerpt/edit.cjs.map +2 -2
- package/build/post-featured-image/overlay-controls.cjs +1 -2
- package/build/post-featured-image/overlay-controls.cjs.map +2 -2
- package/build/post-navigation-link/edit.cjs +0 -2
- package/build/post-navigation-link/edit.cjs.map +2 -2
- package/build/query/edit/inspector-controls/author-control.cjs +1 -2
- package/build/query/edit/inspector-controls/author-control.cjs.map +2 -2
- package/build/query/edit/inspector-controls/format-controls.cjs +1 -2
- package/build/query/edit/inspector-controls/format-controls.cjs.map +2 -2
- package/build/query/edit/inspector-controls/index.cjs +0 -3
- package/build/query/edit/inspector-controls/index.cjs.map +2 -2
- package/build/query/edit/inspector-controls/order-control.cjs +0 -1
- package/build/query/edit/inspector-controls/order-control.cjs.map +2 -2
- package/build/query/edit/inspector-controls/parent-control.cjs +0 -1
- package/build/query/edit/inspector-controls/parent-control.cjs.map +2 -2
- package/build/query/edit/inspector-controls/per-page-control.cjs +0 -1
- package/build/query/edit/inspector-controls/per-page-control.cjs.map +2 -2
- package/build/query/edit/inspector-controls/sticky-control.cjs +0 -1
- package/build/query/edit/inspector-controls/sticky-control.cjs.map +2 -2
- package/build/query/edit/inspector-controls/taxonomy-controls.cjs +1 -2
- package/build/query/edit/inspector-controls/taxonomy-controls.cjs.map +2 -2
- package/build/query-pagination/query-pagination-arrow-controls.cjs +0 -1
- package/build/query-pagination/query-pagination-arrow-controls.cjs.map +2 -2
- package/build/query-pagination-numbers/edit.cjs +0 -1
- package/build/query-pagination-numbers/edit.cjs.map +2 -2
- package/build/quote/transforms.cjs +1 -5
- package/build/quote/transforms.cjs.map +2 -2
- package/build/rss/edit.cjs +0 -3
- package/build/rss/edit.cjs.map +2 -2
- package/build/search/edit.cjs +0 -4
- package/build/search/edit.cjs.map +2 -2
- package/build/separator/edit.cjs +1 -2
- package/build/separator/edit.cjs.map +2 -2
- package/build/site-logo/edit.cjs +34 -63
- package/build/site-logo/edit.cjs.map +3 -3
- package/build/social-links/edit.cjs +0 -1
- package/build/social-links/edit.cjs.map +2 -2
- package/build/spacer/controls.cjs +2 -4
- package/build/spacer/controls.cjs.map +2 -2
- package/build/spacer/edit.cjs +1 -2
- package/build/spacer/edit.cjs.map +2 -2
- package/build/tab-list/block.json +3 -2
- package/build/tab-list/edit.cjs +38 -51
- package/build/tab-list/edit.cjs.map +3 -3
- package/build/tab-list/save.cjs +4 -3
- package/build/tab-list/save.cjs.map +2 -2
- package/build/tab-panel/controls.cjs +2 -4
- package/build/tab-panel/controls.cjs.map +3 -3
- package/build/tab-panels/edit.cjs +2 -4
- package/build/tab-panels/edit.cjs.map +3 -3
- package/build/table-of-contents/edit.cjs +0 -1
- package/build/table-of-contents/edit.cjs.map +2 -2
- package/build/tabs/edit.cjs +2 -2
- package/build/tabs/edit.cjs.map +3 -3
- package/build/tabs/tab-toolbar-controls.cjs +74 -0
- package/build/tabs/tab-toolbar-controls.cjs.map +7 -0
- package/build/tabs/use-tab-actions.cjs +87 -0
- package/build/tabs/use-tab-actions.cjs.map +7 -0
- package/build/tabs/use-tab-list-items-sync.cjs +4 -4
- package/build/tabs/use-tab-list-items-sync.cjs.map +2 -2
- package/build/tag-cloud/edit.cjs +2 -6
- package/build/tag-cloud/edit.cjs.map +2 -2
- package/build/template-part/edit/advanced-controls.cjs +0 -1
- package/build/template-part/edit/advanced-controls.cjs.map +2 -2
- package/build/template-part/edit/import-controls.cjs +1 -2
- package/build/template-part/edit/import-controls.cjs.map +2 -2
- package/build/terms-query/edit/inspector-controls/include-control.cjs +0 -1
- package/build/terms-query/edit/inspector-controls/include-control.cjs.map +2 -2
- package/build/terms-query/edit/inspector-controls/inherit-control.cjs +0 -1
- package/build/terms-query/edit/inspector-controls/inherit-control.cjs.map +2 -2
- package/build/terms-query/edit/inspector-controls/max-terms-control.cjs +0 -1
- package/build/terms-query/edit/inspector-controls/max-terms-control.cjs.map +2 -2
- package/build/terms-query/edit/inspector-controls/order-control.cjs +0 -1
- package/build/terms-query/edit/inspector-controls/order-control.cjs.map +2 -2
- package/build/terms-query/edit/inspector-controls/taxonomy-control.cjs +0 -1
- package/build/terms-query/edit/inspector-controls/taxonomy-control.cjs.map +2 -2
- package/build/text-columns/edit.cjs +0 -1
- package/build/text-columns/edit.cjs.map +2 -2
- package/build/utils/gif-conversion-attributes.cjs +40 -0
- package/build/utils/gif-conversion-attributes.cjs.map +7 -0
- package/build/verse/block.json +3 -1
- package/build/video/block.json +6 -0
- package/build/video/edit-common-settings.cjs +0 -1
- package/build/video/edit-common-settings.cjs.map +2 -2
- package/build/video/edit.cjs +28 -3
- package/build/video/edit.cjs.map +3 -3
- package/build/video/gif-restore-control.cjs +73 -0
- package/build/video/gif-restore-control.cjs.map +7 -0
- package/build/video/index.cjs +2 -0
- package/build/video/index.cjs.map +3 -3
- package/build/video/save.cjs +7 -1
- package/build/video/save.cjs.map +2 -2
- package/build/video/tracks-editor.cjs +0 -1
- package/build/video/tracks-editor.cjs.map +2 -2
- package/build/video/variations.cjs +75 -0
- package/build/video/variations.cjs.map +7 -0
- package/build-module/accordion/edit.mjs +0 -1
- package/build-module/accordion/edit.mjs.map +2 -2
- package/build-module/accordion/view.mjs +23 -0
- package/build-module/accordion/view.mjs.map +2 -2
- package/build-module/accordion-heading/deprecated.mjs +121 -1
- package/build-module/accordion-heading/deprecated.mjs.map +2 -2
- package/build-module/accordion-heading/edit.mjs +8 -1
- package/build-module/accordion-heading/edit.mjs.map +2 -2
- package/build-module/accordion-heading/save.mjs +8 -1
- package/build-module/accordion-heading/save.mjs.map +2 -2
- package/build-module/accordion-panel/edit.mjs +1 -1
- package/build-module/accordion-panel/edit.mjs.map +2 -2
- package/build-module/archives/edit.mjs +0 -1
- package/build-module/archives/edit.mjs.map +2 -2
- package/build-module/audio/edit.mjs +0 -1
- package/build-module/audio/edit.mjs.map +2 -2
- package/build-module/avatar/edit.mjs +0 -1
- package/build-module/avatar/edit.mjs.map +2 -2
- package/build-module/avatar/user-control.mjs +0 -1
- package/build-module/avatar/user-control.mjs.map +2 -2
- package/build-module/categories/edit.mjs +0 -1
- package/build-module/categories/edit.mjs.map +2 -2
- package/build-module/code/transforms.mjs +6 -4
- package/build-module/code/transforms.mjs.map +2 -2
- package/build-module/column/edit.mjs +0 -1
- package/build-module/column/edit.mjs.map +2 -2
- package/build-module/columns/edit.mjs +0 -1
- package/build-module/columns/edit.mjs.map +2 -2
- package/build-module/columns/transforms.mjs +9 -2
- package/build-module/columns/transforms.mjs.map +2 -2
- package/build-module/comment-author-avatar/edit.mjs +0 -1
- package/build-module/comment-author-avatar/edit.mjs.map +2 -2
- package/build-module/comments-pagination/comments-pagination-arrow-controls.mjs +0 -1
- package/build-module/comments-pagination/comments-pagination-arrow-controls.mjs.map +2 -2
- package/build-module/cover/edit/inspector-controls.mjs +1 -3
- package/build-module/cover/edit/inspector-controls.mjs.map +2 -2
- package/build-module/details/transforms.mjs +7 -2
- package/build-module/details/transforms.mjs.map +2 -2
- package/build-module/embed/edit.mjs +2 -3
- package/build-module/embed/edit.mjs.map +2 -2
- package/build-module/embed/embed-placeholder.mjs +20 -23
- package/build-module/embed/embed-placeholder.mjs.map +2 -2
- package/build-module/file/inspector.mjs +0 -2
- package/build-module/file/inspector.mjs.map +2 -2
- package/build-module/form/edit.mjs +0 -2
- package/build-module/form/edit.mjs.map +2 -2
- package/build-module/freeform/convert-to-blocks-button.mjs +31 -0
- package/build-module/freeform/convert-to-blocks-button.mjs.map +7 -0
- package/build-module/freeform/edit.mjs +15 -34
- package/build-module/freeform/edit.mjs.map +2 -2
- package/build-module/freeform/index.mjs +1 -7
- package/build-module/freeform/index.mjs.map +2 -2
- package/build-module/gallery/block.json +4 -1
- package/build-module/gallery/dynamic-gallery.mjs +253 -0
- package/build-module/gallery/dynamic-gallery.mjs.map +7 -0
- package/build-module/gallery/dynamic-source.mjs +55 -0
- package/build-module/gallery/dynamic-source.mjs.map +7 -0
- package/build-module/gallery/edit.mjs +288 -206
- package/build-module/gallery/edit.mjs.map +2 -2
- package/build-module/gallery/gallery.mjs +0 -3
- package/build-module/gallery/gallery.mjs.map +2 -2
- package/build-module/gallery/index.mjs +2 -0
- package/build-module/gallery/index.mjs.map +2 -2
- package/build-module/gallery/save.mjs +16 -12
- package/build-module/gallery/save.mjs.map +2 -2
- package/build-module/gallery/use-dynamic-gallery.mjs +167 -0
- package/build-module/gallery/use-dynamic-gallery.mjs.map +7 -0
- package/build-module/gallery/variations.mjs +33 -0
- package/build-module/gallery/variations.mjs.map +7 -0
- package/build-module/group/edit.mjs +1 -2
- package/build-module/group/edit.mjs.map +2 -2
- package/build-module/group/transforms.mjs +7 -8
- package/build-module/group/transforms.mjs.map +2 -2
- package/build-module/heading/edit.mjs +11 -4
- package/build-module/heading/edit.mjs.map +2 -2
- package/build-module/html/block.json +2 -2
- package/build-module/html/edit.mjs +69 -25
- package/build-module/html/edit.mjs.map +2 -2
- package/build-module/html/index.mjs +3 -3
- package/build-module/html/index.mjs.map +2 -2
- package/build-module/html/modal.mjs +4 -8
- package/build-module/html/modal.mjs.map +2 -2
- package/build-module/html/save.mjs +2 -4
- package/build-module/html/save.mjs.map +2 -2
- package/build-module/html/transforms.mjs +8 -6
- package/build-module/html/transforms.mjs.map +2 -2
- package/build-module/image/animated-gif-convert-control.mjs +87 -0
- package/build-module/image/animated-gif-convert-control.mjs.map +7 -0
- package/build-module/image/edit.mjs +34 -0
- package/build-module/image/edit.mjs.map +2 -2
- package/build-module/image/image.mjs +28 -67
- package/build-module/image/image.mjs.map +2 -2
- package/build-module/index.mjs.map +2 -2
- package/build-module/latest-comments/edit.mjs +0 -2
- package/build-module/latest-comments/edit.mjs.map +2 -2
- package/build-module/latest-posts/block.json +8 -9
- package/build-module/latest-posts/constants.mjs +0 -2
- package/build-module/latest-posts/constants.mjs.map +2 -2
- package/build-module/latest-posts/deprecated.mjs +100 -8
- package/build-module/latest-posts/deprecated.mjs.map +2 -2
- package/build-module/latest-posts/edit.mjs +62 -77
- package/build-module/latest-posts/edit.mjs.map +2 -2
- package/build-module/list/ordered-list-settings.mjs +0 -1
- package/build-module/list/ordered-list-settings.mjs.map +2 -2
- package/build-module/media-text/edit.mjs +0 -1
- package/build-module/media-text/edit.mjs.map +2 -2
- package/build-module/missing/edit.mjs +1 -3
- package/build-module/missing/edit.mjs.map +2 -2
- package/build-module/navigation/edit/index.mjs +0 -1
- package/build-module/navigation/edit/index.mjs.map +2 -2
- package/build-module/navigation/edit/overlay-menu-preview-controls.mjs +0 -1
- package/build-module/navigation/edit/overlay-menu-preview-controls.mjs.map +2 -2
- package/build-module/navigation/edit/overlay-menu-preview.mjs +0 -1
- package/build-module/navigation/edit/overlay-menu-preview.mjs.map +2 -2
- package/build-module/navigation/edit/overlay-template-part-selector.mjs +0 -1
- package/build-module/navigation/edit/overlay-template-part-selector.mjs.map +2 -2
- package/build-module/navigation/edit/overlay-visibility-control.mjs +0 -1
- package/build-module/navigation/edit/overlay-visibility-control.mjs.map +2 -2
- package/build-module/navigation-link/shared/use-link-preview.mjs +11 -1
- package/build-module/navigation-link/shared/use-link-preview.mjs.map +2 -2
- package/build-module/navigation-overlay-close/edit.mjs +0 -1
- package/build-module/navigation-overlay-close/edit.mjs.map +2 -2
- package/build-module/page-list/edit.mjs +0 -1
- package/build-module/page-list/edit.mjs.map +2 -2
- package/build-module/playlist/block.json +1 -7
- package/build-module/playlist/context.mjs +11 -0
- package/build-module/playlist/context.mjs.map +7 -0
- package/build-module/playlist/edit.mjs +44 -70
- package/build-module/playlist/edit.mjs.map +2 -2
- package/build-module/playlist/utils.mjs +0 -3
- package/build-module/playlist/utils.mjs.map +2 -2
- package/build-module/playlist/view.mjs +4 -4
- package/build-module/playlist/view.mjs.map +2 -2
- package/build-module/playlist-track/block.json +1 -4
- package/build-module/playlist-track/edit.mjs +23 -9
- package/build-module/playlist-track/edit.mjs.map +2 -2
- package/build-module/post-author/edit.mjs +0 -2
- package/build-module/post-author/edit.mjs.map +2 -2
- package/build-module/post-excerpt/edit.mjs +0 -1
- package/build-module/post-excerpt/edit.mjs.map +2 -2
- package/build-module/post-featured-image/overlay-controls.mjs +1 -2
- package/build-module/post-featured-image/overlay-controls.mjs.map +2 -2
- package/build-module/post-navigation-link/edit.mjs +0 -2
- package/build-module/post-navigation-link/edit.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/author-control.mjs +1 -2
- package/build-module/query/edit/inspector-controls/author-control.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/format-controls.mjs +1 -2
- package/build-module/query/edit/inspector-controls/format-controls.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/index.mjs +0 -3
- package/build-module/query/edit/inspector-controls/index.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/order-control.mjs +0 -1
- package/build-module/query/edit/inspector-controls/order-control.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/parent-control.mjs +0 -1
- package/build-module/query/edit/inspector-controls/parent-control.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/per-page-control.mjs +0 -1
- package/build-module/query/edit/inspector-controls/per-page-control.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/sticky-control.mjs +0 -1
- package/build-module/query/edit/inspector-controls/sticky-control.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/taxonomy-controls.mjs +1 -2
- package/build-module/query/edit/inspector-controls/taxonomy-controls.mjs.map +2 -2
- package/build-module/query-pagination/query-pagination-arrow-controls.mjs +0 -1
- package/build-module/query-pagination/query-pagination-arrow-controls.mjs.map +2 -2
- package/build-module/query-pagination-numbers/edit.mjs +0 -1
- package/build-module/query-pagination-numbers/edit.mjs.map +2 -2
- package/build-module/quote/transforms.mjs +6 -6
- package/build-module/quote/transforms.mjs.map +2 -2
- package/build-module/rss/edit.mjs +0 -3
- package/build-module/rss/edit.mjs.map +2 -2
- package/build-module/search/edit.mjs +0 -4
- package/build-module/search/edit.mjs.map +2 -2
- package/build-module/separator/edit.mjs +1 -2
- package/build-module/separator/edit.mjs.map +2 -2
- package/build-module/site-logo/edit.mjs +34 -64
- package/build-module/site-logo/edit.mjs.map +2 -2
- package/build-module/social-links/edit.mjs +0 -1
- package/build-module/social-links/edit.mjs.map +2 -2
- package/build-module/spacer/controls.mjs +2 -4
- package/build-module/spacer/controls.mjs.map +2 -2
- package/build-module/spacer/edit.mjs +1 -2
- package/build-module/spacer/edit.mjs.map +2 -2
- package/build-module/tab-list/block.json +3 -2
- package/build-module/tab-list/edit.mjs +39 -52
- package/build-module/tab-list/edit.mjs.map +2 -2
- package/build-module/tab-list/save.mjs +5 -3
- package/build-module/tab-list/save.mjs.map +2 -2
- package/build-module/tab-panel/controls.mjs +2 -4
- package/build-module/tab-panel/controls.mjs.map +2 -2
- package/build-module/tab-panels/edit.mjs +2 -4
- package/build-module/tab-panels/edit.mjs.map +2 -2
- package/build-module/table-of-contents/edit.mjs +0 -1
- package/build-module/table-of-contents/edit.mjs.map +2 -2
- package/build-module/tabs/edit.mjs +2 -2
- package/build-module/tabs/edit.mjs.map +2 -2
- package/build-module/tabs/tab-toolbar-controls.mjs +46 -0
- package/build-module/tabs/tab-toolbar-controls.mjs.map +7 -0
- package/build-module/tabs/use-tab-actions.mjs +66 -0
- package/build-module/tabs/use-tab-actions.mjs.map +7 -0
- package/build-module/tabs/use-tab-list-items-sync.mjs +6 -6
- package/build-module/tabs/use-tab-list-items-sync.mjs.map +2 -2
- package/build-module/tag-cloud/edit.mjs +2 -6
- package/build-module/tag-cloud/edit.mjs.map +2 -2
- package/build-module/template-part/edit/advanced-controls.mjs +0 -1
- package/build-module/template-part/edit/advanced-controls.mjs.map +2 -2
- package/build-module/template-part/edit/import-controls.mjs +1 -2
- package/build-module/template-part/edit/import-controls.mjs.map +2 -2
- package/build-module/terms-query/edit/inspector-controls/include-control.mjs +0 -1
- package/build-module/terms-query/edit/inspector-controls/include-control.mjs.map +2 -2
- package/build-module/terms-query/edit/inspector-controls/inherit-control.mjs +0 -1
- package/build-module/terms-query/edit/inspector-controls/inherit-control.mjs.map +2 -2
- package/build-module/terms-query/edit/inspector-controls/max-terms-control.mjs +0 -1
- package/build-module/terms-query/edit/inspector-controls/max-terms-control.mjs.map +2 -2
- package/build-module/terms-query/edit/inspector-controls/order-control.mjs +0 -1
- package/build-module/terms-query/edit/inspector-controls/order-control.mjs.map +2 -2
- package/build-module/terms-query/edit/inspector-controls/taxonomy-control.mjs +0 -1
- package/build-module/terms-query/edit/inspector-controls/taxonomy-control.mjs.map +2 -2
- package/build-module/text-columns/edit.mjs +0 -1
- package/build-module/text-columns/edit.mjs.map +2 -2
- package/build-module/utils/gif-conversion-attributes.mjs +15 -0
- package/build-module/utils/gif-conversion-attributes.mjs.map +7 -0
- package/build-module/verse/block.json +3 -1
- package/build-module/video/block.json +6 -0
- package/build-module/video/edit-common-settings.mjs +0 -1
- package/build-module/video/edit-common-settings.mjs.map +2 -2
- package/build-module/video/edit.mjs +28 -3
- package/build-module/video/edit.mjs.map +2 -2
- package/build-module/video/gif-restore-control.mjs +55 -0
- package/build-module/video/gif-restore-control.mjs.map +7 -0
- package/build-module/video/index.mjs +2 -0
- package/build-module/video/index.mjs.map +2 -2
- package/build-module/video/save.mjs +7 -1
- package/build-module/video/save.mjs.map +2 -2
- package/build-module/video/tracks-editor.mjs +0 -1
- package/build-module/video/tracks-editor.mjs.map +2 -2
- package/build-module/video/variations.mjs +50 -0
- package/build-module/video/variations.mjs.map +7 -0
- package/build-style/accordion-panel/style-rtl.css +1 -2
- package/build-style/accordion-panel/style.css +1 -2
- package/build-style/audio/style-rtl.css +6 -0
- package/build-style/audio/style.css +6 -0
- package/build-style/audio/theme-rtl.css +6 -0
- package/build-style/audio/theme.css +6 -0
- package/build-style/columns/style-rtl.css +6 -0
- package/build-style/columns/style.css +6 -0
- package/build-style/common-rtl.css +6 -4
- package/build-style/common.css +6 -4
- package/build-style/editor-rtl.css +38 -3
- package/build-style/editor.css +38 -3
- package/build-style/embed/style-rtl.css +6 -0
- package/build-style/embed/style.css +6 -0
- package/build-style/embed/theme-rtl.css +6 -0
- package/build-style/embed/theme.css +6 -0
- package/build-style/freeform/editor-rtl.css +6 -0
- package/build-style/freeform/editor.css +6 -0
- package/build-style/gallery/editor-rtl.css +27 -3
- package/build-style/gallery/editor.css +27 -3
- package/build-style/gallery/style-rtl.css +6 -0
- package/build-style/gallery/style.css +6 -0
- package/build-style/gallery/theme-rtl.css +6 -0
- package/build-style/gallery/theme.css +6 -0
- package/build-style/html/editor-rtl.css +13 -0
- package/build-style/html/editor.css +13 -0
- package/build-style/image/editor-rtl.css +10 -0
- package/build-style/image/editor.css +10 -0
- package/build-style/image/style-rtl.css +6 -1
- package/build-style/image/style.css +6 -1
- package/build-style/image/theme-rtl.css +6 -0
- package/build-style/image/theme.css +6 -0
- package/build-style/latest-posts/style-rtl.css +26 -15
- package/build-style/latest-posts/style.css +26 -15
- package/build-style/navigation/editor-rtl.css +6 -0
- package/build-style/navigation/editor.css +6 -0
- package/build-style/navigation/style-rtl.css +6 -0
- package/build-style/navigation/style.css +6 -0
- package/build-style/navigation-submenu/editor-rtl.css +6 -0
- package/build-style/navigation-submenu/editor.css +6 -0
- package/build-style/page-list/editor-rtl.css +6 -0
- package/build-style/page-list/editor.css +6 -0
- package/build-style/playlist/style-rtl.css +121 -19
- package/build-style/playlist/style.css +121 -19
- package/build-style/post-template/style-rtl.css +6 -0
- package/build-style/post-template/style.css +6 -0
- package/build-style/query/editor-rtl.css +6 -0
- package/build-style/query/editor.css +6 -0
- package/build-style/rss/style-rtl.css +6 -0
- package/build-style/rss/style.css +6 -0
- package/build-style/shortcode/editor-rtl.css +6 -0
- package/build-style/shortcode/editor.css +6 -0
- package/build-style/style-rtl.css +145 -38
- package/build-style/style.css +145 -38
- package/build-style/table/editor-rtl.css +6 -0
- package/build-style/table/editor.css +6 -0
- package/build-style/table/theme-rtl.css +6 -0
- package/build-style/table/theme.css +6 -0
- package/build-style/template-part/editor-rtl.css +6 -0
- package/build-style/template-part/editor.css +6 -0
- package/build-style/theme-rtl.css +6 -0
- package/build-style/theme.css +6 -0
- package/build-style/video/style-rtl.css +6 -0
- package/build-style/video/style.css +6 -0
- package/build-style/video/theme-rtl.css +6 -0
- package/build-style/video/theme.css +6 -0
- package/package.json +43 -41
- package/src/accordion/README.md +1 -1
- package/src/accordion/edit.js +0 -1
- package/src/accordion/view.js +24 -0
- package/src/accordion-heading/README.md +1 -1
- package/src/accordion-heading/deprecated.js +122 -1
- package/src/accordion-heading/edit.js +12 -1
- package/src/accordion-heading/save.js +12 -1
- package/src/accordion-item/README.md +1 -1
- package/src/accordion-item/index.php +2 -1
- package/src/accordion-panel/edit.js +1 -1
- package/src/accordion-panel/style.scss +1 -4
- package/src/archives/edit.js +0 -1
- package/src/audio/edit.js +0 -1
- package/src/avatar/edit.js +0 -1
- package/src/avatar/user-control.js +0 -1
- package/src/categories/edit.js +0 -1
- package/src/code/transforms.js +6 -4
- package/src/column/edit.js +0 -1
- package/src/columns/edit.js +0 -1
- package/src/columns/transforms.js +9 -2
- package/src/comment-author-avatar/edit.js +0 -1
- package/src/comments-pagination/comments-pagination-arrow-controls.js +0 -1
- package/src/common.scss +0 -4
- package/src/cover/edit/inspector-controls.js +0 -2
- package/src/cover/test/edit.js +4 -42
- package/src/details/transforms.js +7 -2
- package/src/embed/edit.js +4 -5
- package/src/embed/embed-placeholder.js +16 -19
- package/src/file/inspector.js +0 -2
- package/src/form/edit.js +0 -2
- package/src/freeform/convert-to-blocks-button.js +33 -0
- package/src/freeform/edit.js +11 -21
- package/src/freeform/index.js +1 -9
- package/src/gallery/README.md +3 -0
- package/src/gallery/block.json +4 -1
- package/src/gallery/dynamic-gallery.js +384 -0
- package/src/gallery/dynamic-source.js +117 -0
- package/src/gallery/edit.js +152 -46
- package/src/gallery/editor.scss +32 -4
- package/src/gallery/gallery.js +0 -7
- package/src/gallery/index.js +2 -0
- package/src/gallery/index.php +277 -0
- package/src/gallery/save.js +22 -11
- package/src/gallery/test/dynamic-source.js +90 -0
- package/src/gallery/use-dynamic-gallery.js +275 -0
- package/src/gallery/variations.js +37 -0
- package/src/group/edit.js +2 -3
- package/src/group/transforms.js +7 -8
- package/src/heading/edit.js +19 -14
- package/src/home-link/index.php +1 -1
- package/src/html/README.md +2 -1
- package/src/html/block.json +2 -2
- package/src/html/edit.js +86 -14
- package/src/html/editor.scss +10 -0
- package/src/html/index.js +3 -4
- package/src/html/modal.js +5 -9
- package/src/html/save.js +4 -7
- package/src/html/test/index.js +143 -0
- package/src/html/transforms.js +11 -6
- package/src/icon/index.php +38 -45
- package/src/image/animated-gif-convert-control.js +135 -0
- package/src/image/edit.js +52 -0
- package/src/image/editor.scss +9 -0
- package/src/image/image.js +121 -180
- package/src/image/style.scss +0 -1
- package/src/image/test/animated-gif-convert-control.js +276 -0
- package/src/image/test/use-open-image-media-editor-modal.js +19 -4
- package/src/index.js +0 -2
- package/src/latest-comments/edit.js +0 -2
- package/src/latest-posts/README.md +2 -2
- package/src/latest-posts/block.json +8 -9
- package/src/latest-posts/constants.js +0 -1
- package/src/latest-posts/deprecated.js +112 -9
- package/src/latest-posts/edit.js +33 -45
- package/src/latest-posts/index.php +14 -3
- package/src/latest-posts/style.scss +12 -2
- package/src/latest-posts/test/deprecated.js +153 -0
- package/src/list/ordered-list-settings.js +0 -1
- package/src/media-text/edit.js +0 -1
- package/src/missing/edit.js +1 -3
- package/src/navigation/edit/index.js +0 -1
- package/src/navigation/edit/overlay-menu-preview-controls.js +0 -1
- package/src/navigation/edit/overlay-menu-preview.js +0 -1
- package/src/navigation/edit/overlay-template-part-selector.js +0 -1
- package/src/navigation/edit/overlay-visibility-control.js +0 -1
- package/src/navigation-link/shared/test/controls.js +0 -4
- package/src/navigation-link/shared/test/use-entity-binding.js +8 -12
- package/src/navigation-link/shared/test/use-handle-link-change.test.js +0 -4
- package/src/navigation-link/shared/test/use-link-preview.test.js +17 -4
- package/src/navigation-link/shared/use-link-preview.js +24 -4
- package/src/navigation-overlay-close/edit.js +0 -1
- package/src/page-list/edit.js +0 -1
- package/src/page-list/index.php +1 -1
- package/src/playlist/README.md +0 -2
- package/src/playlist/block.json +1 -7
- package/src/playlist/context.js +9 -0
- package/src/playlist/edit.js +51 -82
- package/src/playlist/index.php +37 -26
- package/src/playlist/style.scss +0 -5
- package/src/playlist/test/edit.js +0 -10
- package/src/playlist/utils.js +0 -6
- package/src/playlist/view.js +4 -4
- package/src/playlist-track/README.md +0 -2
- package/src/playlist-track/block.json +1 -4
- package/src/playlist-track/edit.js +25 -16
- package/src/playlist-track/index.php +4 -11
- package/src/post-author/edit.js +0 -2
- package/src/post-excerpt/edit.js +0 -1
- package/src/post-featured-image/overlay-controls.js +0 -1
- package/src/post-navigation-link/edit.js +0 -2
- package/src/query/edit/inspector-controls/author-control.js +0 -1
- package/src/query/edit/inspector-controls/format-controls.js +0 -1
- package/src/query/edit/inspector-controls/index.js +0 -3
- package/src/query/edit/inspector-controls/order-control.js +0 -1
- package/src/query/edit/inspector-controls/parent-control.js +0 -1
- package/src/query/edit/inspector-controls/per-page-control.js +0 -1
- package/src/query/edit/inspector-controls/sticky-control.js +0 -1
- package/src/query/edit/inspector-controls/taxonomy-controls.js +0 -1
- package/src/query-pagination/query-pagination-arrow-controls.js +0 -1
- package/src/query-pagination-numbers/edit.js +0 -1
- package/src/quote/transforms.js +6 -6
- package/src/rss/edit.js +0 -3
- package/src/search/edit.js +0 -4
- package/src/separator/edit.js +0 -1
- package/src/site-logo/edit.js +38 -78
- package/src/social-links/edit.js +0 -1
- package/src/spacer/controls.js +2 -4
- package/src/spacer/edit.js +2 -3
- package/src/tab-list/block.json +3 -2
- package/src/tab-list/edit.js +53 -55
- package/src/tab-list/save.js +5 -4
- package/src/tab-panel/controls.js +2 -4
- package/src/tab-panels/edit.js +2 -4
- package/src/table-of-contents/edit.js +0 -1
- package/src/tabs/edit.js +2 -2
- package/src/tabs/tab-toolbar-controls.js +58 -0
- package/src/tabs/use-tab-actions.js +102 -0
- package/src/tabs/use-tab-list-items-sync.js +7 -8
- package/src/tag-cloud/edit.js +0 -4
- package/src/tag-cloud/index.php +1 -1
- package/src/template-part/edit/advanced-controls.js +0 -1
- package/src/template-part/edit/import-controls.js +0 -1
- package/src/terms-query/edit/inspector-controls/include-control.js +0 -1
- package/src/terms-query/edit/inspector-controls/inherit-control.js +0 -1
- package/src/terms-query/edit/inspector-controls/max-terms-control.js +0 -1
- package/src/terms-query/edit/inspector-controls/order-control.js +0 -1
- package/src/terms-query/edit/inspector-controls/taxonomy-control.js +0 -1
- package/src/text-columns/edit.js +0 -1
- package/src/utils/gif-conversion-attributes.js +30 -0
- package/src/utils/test/gif-conversion-attributes.js +60 -0
- package/src/utils/test/waveform-player.js +0 -4
- package/src/utils/test/waveform-utils.js +0 -4
- package/src/verse/README.md +1 -0
- package/src/verse/block.json +3 -1
- package/src/video/README.md +2 -0
- package/src/video/block.json +6 -0
- package/src/video/edit-common-settings.js +0 -1
- package/src/video/edit.js +38 -1
- package/src/video/gif-restore-control.js +92 -0
- package/src/video/index.js +2 -0
- package/src/video/save.js +12 -0
- package/src/video/test/variations.js +65 -0
- package/src/video/tracks-editor.js +0 -1
- package/src/video/variations.js +65 -0
- package/build/freeform/migration-notice.cjs +0 -58
- package/build/freeform/migration-notice.cjs.map +0 -7
- package/build/tab-panel/add-tab-toolbar-control.cjs +0 -90
- package/build/tab-panel/add-tab-toolbar-control.cjs.map +0 -7
- package/build/tab-panel/remove-tab-toolbar-control.cjs +0 -99
- package/build/tab-panel/remove-tab-toolbar-control.cjs.map +0 -7
- package/build/tabs/controls.cjs +0 -45
- package/build/tabs/controls.cjs.map +0 -7
- package/build-module/freeform/migration-notice.mjs +0 -37
- package/build-module/freeform/migration-notice.mjs.map +0 -7
- package/build-module/tab-panel/add-tab-toolbar-control.mjs +0 -72
- package/build-module/tab-panel/add-tab-toolbar-control.mjs.map +0 -7
- package/build-module/tab-panel/remove-tab-toolbar-control.mjs +0 -81
- package/build-module/tab-panel/remove-tab-toolbar-control.mjs.map +0 -7
- package/build-module/tabs/controls.mjs +0 -14
- package/build-module/tabs/controls.mjs.map +0 -7
- package/src/freeform/migration-notice.js +0 -49
- package/src/tab-panel/add-tab-toolbar-control.js +0 -90
- package/src/tab-panel/remove-tab-toolbar-control.js +0 -110
- package/src/tabs/controls.js +0 -14
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/tab-list/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tRichText,\n\t__experimentalUseBorderProps as useBorderProps,\n\t__experimentalUseColorProps as useColorProps,\n\t__experimentalGetSpacingClassesAndStyles as getSpacingClassesAndStyles,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA,gCAAgC;AAAA,EAChC,+BAA+B;AAAA,EAC/B,4CAA4C;AAAA,OACtC;AACP,SAAS,WAAW,mBAAmB;AACvC,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tRichText,\n\t__experimentalUseBorderProps as useBorderProps,\n\t__experimentalUseColorProps as useColorProps,\n\t__experimentalGetSpacingClassesAndStyles as getSpacingClassesAndStyles,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport TabToolbarControls from '../tabs/tab-toolbar-controls';\nimport useTabActions from '../tabs/use-tab-actions';\n\nconst EMPTY_ARRAY = [];\n\nfunction Edit( {\n\tattributes,\n\tclientId,\n\tcontext,\n\t__unstableLayoutClassNames: layoutClassNames,\n} ) {\n\tconst tabsList = context[ 'core/tabs-list' ] || EMPTY_ARRAY;\n\n\tconst colorProps = useColorProps( attributes );\n\tconst borderProps = useBorderProps( attributes );\n\tconst spacingProps = getSpacingClassesAndStyles( attributes );\n\n\tconst { tabsClientId, editorActiveTabIndex, activeTabIndex } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\tconst _tabsClientId = getBlockRootClientId( clientId );\n\t\t\tconst tabsAttributes = _tabsClientId\n\t\t\t\t? getBlockAttributes( _tabsClientId )\n\t\t\t\t: {};\n\n\t\t\treturn {\n\t\t\t\ttabsClientId: _tabsClientId,\n\t\t\t\teditorActiveTabIndex: tabsAttributes?.editorActiveTabIndex,\n\t\t\t\tactiveTabIndex: tabsAttributes?.activeTabIndex ?? 0,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { isBlockSelected, hasSelectedInnerBlock } =\n\t\tuseSelect( blockEditorStore );\n\tconst { updateBlockAttributes, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { insertTab, removeTab } = useTabActions( tabsClientId );\n\n\tconst effectiveActiveIndex = editorActiveTabIndex ?? activeTabIndex;\n\n\tfunction selectTabPanel( tabIndex ) {\n\t\tif ( tabsClientId && tabIndex !== effectiveActiveIndex ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateBlockAttributes( tabsClientId, {\n\t\t\t\teditorActiveTabIndex: tabIndex,\n\t\t\t} );\n\t\t}\n\t}\n\n\tfunction handleLabelChange( tabIndex, newLabel ) {\n\t\tconst tab = tabsList[ tabIndex ];\n\t\tif ( tab?.clientId ) {\n\t\t\tupdateBlockAttributes( tab.clientId, { label: newLabel } );\n\t\t}\n\t}\n\n\tconst menuRef = useRef();\n\tconst prevTabCountRef = useRef( tabsList.length );\n\n\t// When tabs are added or removed, focus the appropriate button.\n\tuseEffect( () => {\n\t\tconst prevCount = prevTabCountRef.current;\n\t\tprevTabCountRef.current = tabsList.length;\n\n\t\tif ( ! menuRef.current || tabsList.length === prevCount ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Only move focus during active editing, not external data changes.\n\t\tif (\n\t\t\t! isBlockSelected( tabsClientId ) &&\n\t\t\t! hasSelectedInnerBlock( tabsClientId, true )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst focusButtonAt = ( index ) => {\n\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\tconst button =\n\t\t\t\t\tmenuRef.current?.querySelectorAll( 'button' )?.[ index ];\n\t\t\t\t(\n\t\t\t\t\tbutton?.querySelector( '[contenteditable]' ) ?? button\n\t\t\t\t)?.focus();\n\t\t\t} );\n\t\t};\n\n\t\tfocusButtonAt( effectiveActiveIndex );\n\t}, [\n\t\teffectiveActiveIndex,\n\t\thasSelectedInnerBlock,\n\t\tisBlockSelected,\n\t\ttabsClientId,\n\t\ttabsList.length,\n\t] );\n\n\tconst blockProps = useBlockProps( {\n\t\trole: 'tablist',\n\t\tref: menuRef,\n\t\t// Applied manually since this block has no inner blocks for the layout\n\t\t// support to add its container classes to.\n\t\tclassName: layoutClassNames,\n\t} );\n\n\tconst buttonClassName = clsx( colorProps.className, borderProps.className );\n\n\tconst buttonStyle = {\n\t\t...colorProps.style,\n\t\t...borderProps.style,\n\t\t...spacingProps.style,\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<TabToolbarControls tabsClientId={ tabsClientId } />\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ tabsList.map( ( tab, index ) => {\n\t\t\t\t\tconst isActive = index === effectiveActiveIndex;\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\tkey={ tab.clientId || index }\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\trole=\"tab\"\n\t\t\t\t\t\t\taria-selected={ isActive }\n\t\t\t\t\t\t\tclassName={ buttonClassName || undefined }\n\t\t\t\t\t\t\tstyle={ buttonStyle }\n\t\t\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\t\t\t// Activate the matching panel whenever this tab\n\t\t\t\t\t\t\t// receives focus — whether from a click or the caret\n\t\t\t\t\t\t\t// moving into the label via the keyboard.\n\t\t\t\t\t\t\tonFocus={ () => {\n\t\t\t\t\t\t\t\tselectTabPanel( index );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\ttagName=\"span\"\n\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\tplaceholder={ __( 'Tab title' ) }\n\t\t\t\t\t\t\t\tvalue={ tab.label }\n\t\t\t\t\t\t\t\tonChange={ ( newLabel ) =>\n\t\t\t\t\t\t\t\t\thandleLabelChange( index, newLabel )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\t\t\tinsertTab( index + 1 )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonRemove={ () => removeTab( index ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default Edit;\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,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UAChB,WAAY,mBAAmB;AAAA,UAC/B,OAAQ;AAAA,UACR,UAAW;AAAA,UAIX,SAAU,MAAM;AACf,2BAAgB,KAAM;AAAA,UACvB;AAAA,UAEA;AAAA,YAAC;AAAA;AAAA,cACA,SAAQ;AAAA,cACR,8BAA4B;AAAA,cAC5B,aAAc,GAAI,WAAY;AAAA,cAC9B,OAAQ,IAAI;AAAA,cACZ,UAAW,CAAE,aACZ,kBAAmB,OAAO,QAAS;AAAA,cAEpC,wBAAyB,MACxB,UAAW,QAAQ,CAAE;AAAA,cAEtB,UAAW,MAAM,UAAW,KAAM;AAAA;AAAA,UACnC;AAAA;AAAA,QA1BM,IAAI,YAAY;AAAA,MA2BvB;AAAA,IAEF,CAAE,GACH;AAAA,KACD;AAEF;AAEA,IAAO,eAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// packages/block-library/src/tab-list/save.js
|
|
2
2
|
import clsx from "clsx";
|
|
3
3
|
import {
|
|
4
|
+
RichText,
|
|
4
5
|
useBlockProps,
|
|
5
6
|
__experimentalGetBorderClassesAndStyles as getBorderClassesAndStyles,
|
|
6
7
|
__experimentalGetColorClassesAndStyles as getColorClassesAndStyles,
|
|
@@ -22,13 +23,14 @@ function save({ attributes }) {
|
|
|
22
23
|
...spacingProps.style
|
|
23
24
|
};
|
|
24
25
|
return /* @__PURE__ */ jsx("div", { ...blockProps, children: tabs.map((tab, index) => /* @__PURE__ */ jsx(
|
|
25
|
-
|
|
26
|
+
RichText.Content,
|
|
26
27
|
{
|
|
27
28
|
className: buttonClassName || void 0,
|
|
28
29
|
style: buttonStyle,
|
|
30
|
+
tagName: "button",
|
|
31
|
+
value: tab.label,
|
|
29
32
|
type: "button",
|
|
30
|
-
role: "tab"
|
|
31
|
-
children: tab.label
|
|
33
|
+
role: "tab"
|
|
32
34
|
},
|
|
33
35
|
index
|
|
34
36
|
)) });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/tab-list/save.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\t__experimentalGetBorderClassesAndStyles as getBorderClassesAndStyles,\n\t__experimentalGetColorClassesAndStyles as getColorClassesAndStyles,\n\t__experimentalGetSpacingClassesAndStyles as getSpacingClassesAndStyles,\n} from '@wordpress/block-editor';\n\nexport default function save( { attributes } ) {\n\tconst { tabs } = attributes;\n\tconst blockProps = useBlockProps.save( {\n\t\trole: 'tablist',\n\t} );\n\n\tconst colorProps = getColorClassesAndStyles( attributes );\n\tconst borderProps = getBorderClassesAndStyles( attributes );\n\tconst spacingProps = getSpacingClassesAndStyles( attributes );\n\n\tconst buttonClassName = clsx( colorProps.className, borderProps.className );\n\n\tconst buttonStyle = {\n\t\t...colorProps.style,\n\t\t...borderProps.style,\n\t\t...spacingProps.style,\n\t};\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t{ tabs.map( ( tab, index ) => (\n\t\t\t\t<
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB;AAAA,EACC;AAAA,EACA,2CAA2C;AAAA,EAC3C,0CAA0C;AAAA,EAC1C,4CAA4C;AAAA,OACtC;AAuBH;AArBW,SAAR,KAAuB,EAAE,WAAW,GAAI;AAC9C,QAAM,EAAE,KAAK,IAAI;AACjB,QAAM,aAAa,cAAc,KAAM;AAAA,IACtC,MAAM;AAAA,EACP,CAAE;AAEF,QAAM,aAAa,yBAA0B,UAAW;AACxD,QAAM,cAAc,0BAA2B,UAAW;AAC1D,QAAM,eAAe,2BAA4B,UAAW;AAE5D,QAAM,kBAAkB,KAAM,WAAW,WAAW,YAAY,SAAU;AAE1E,QAAM,cAAc;AAAA,IACnB,GAAG,WAAW;AAAA,IACd,GAAG,YAAY;AAAA,IACf,GAAG,aAAa;AAAA,EACjB;AAEA,SACC,oBAAC,SAAM,GAAG,YACP,eAAK,IAAK,CAAE,KAAK,UAClB;AAAA,IAAC;AAAA;AAAA,MAEA,WAAY,mBAAmB;AAAA,MAC/B,OAAQ;AAAA,MACR,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tRichText,\n\tuseBlockProps,\n\t__experimentalGetBorderClassesAndStyles as getBorderClassesAndStyles,\n\t__experimentalGetColorClassesAndStyles as getColorClassesAndStyles,\n\t__experimentalGetSpacingClassesAndStyles as getSpacingClassesAndStyles,\n} from '@wordpress/block-editor';\n\nexport default function save( { attributes } ) {\n\tconst { tabs } = attributes;\n\tconst blockProps = useBlockProps.save( {\n\t\trole: 'tablist',\n\t} );\n\n\tconst colorProps = getColorClassesAndStyles( attributes );\n\tconst borderProps = getBorderClassesAndStyles( attributes );\n\tconst spacingProps = getSpacingClassesAndStyles( attributes );\n\n\tconst buttonClassName = clsx( colorProps.className, borderProps.className );\n\n\tconst buttonStyle = {\n\t\t...colorProps.style,\n\t\t...borderProps.style,\n\t\t...spacingProps.style,\n\t};\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t{ tabs.map( ( tab, index ) => (\n\t\t\t\t<RichText.Content\n\t\t\t\t\tkey={ index }\n\t\t\t\t\tclassName={ buttonClassName || undefined }\n\t\t\t\t\tstyle={ buttonStyle }\n\t\t\t\t\ttagName=\"button\"\n\t\t\t\t\tvalue={ tab.label }\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\trole=\"tab\"\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB;AAAA,EACC;AAAA,EACA;AAAA,EACA,2CAA2C;AAAA,EAC3C,0CAA0C;AAAA,EAC1C,4CAA4C;AAAA,OACtC;AAuBH;AArBW,SAAR,KAAuB,EAAE,WAAW,GAAI;AAC9C,QAAM,EAAE,KAAK,IAAI;AACjB,QAAM,aAAa,cAAc,KAAM;AAAA,IACtC,MAAM;AAAA,EACP,CAAE;AAEF,QAAM,aAAa,yBAA0B,UAAW;AACxD,QAAM,cAAc,0BAA2B,UAAW;AAC1D,QAAM,eAAe,2BAA4B,UAAW;AAE5D,QAAM,kBAAkB,KAAM,WAAW,WAAW,YAAY,SAAU;AAE1E,QAAM,cAAc;AAAA,IACnB,GAAG,WAAW;AAAA,IACd,GAAG,YAAY;AAAA,IACf,GAAG,aAAa;AAAA,EACjB;AAEA,SACC,oBAAC,SAAM,GAAG,YACP,eAAK,IAAK,CAAE,KAAK,UAClB;AAAA,IAAC,SAAS;AAAA,IAAT;AAAA,MAEA,WAAY,mBAAmB;AAAA,MAC/B,OAAQ;AAAA,MACR,SAAQ;AAAA,MACR,OAAQ,IAAI;AAAA,MACZ,MAAK;AAAA,MACL,MAAK;AAAA;AAAA,IANC;AAAA,EAOP,CACC,GACH;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -10,16 +10,14 @@ import {
|
|
|
10
10
|
} from "@wordpress/components";
|
|
11
11
|
import { __ } from "@wordpress/i18n";
|
|
12
12
|
import { useDispatch } from "@wordpress/data";
|
|
13
|
-
import
|
|
14
|
-
import RemoveTabToolbarControl from "./remove-tab-toolbar-control.mjs";
|
|
13
|
+
import TabToolbarControls from "../tabs/tab-toolbar-controls.mjs";
|
|
15
14
|
import { useToolsPanelDropdownMenuProps } from "../utils/hooks.mjs";
|
|
16
15
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
17
16
|
function Controls({ tabsClientId, blockIndex, isDefaultTab }) {
|
|
18
17
|
const { updateBlockAttributes } = useDispatch(blockEditorStore);
|
|
19
18
|
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
20
19
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
21
|
-
/* @__PURE__ */ jsx(
|
|
22
|
-
/* @__PURE__ */ jsx(RemoveTabToolbarControl, { tabsClientId }),
|
|
20
|
+
/* @__PURE__ */ jsx(TabToolbarControls, { tabsClientId }),
|
|
23
21
|
/* @__PURE__ */ jsx(InspectorControls, { children: /* @__PURE__ */ jsx(
|
|
24
22
|
ToolsPanel,
|
|
25
23
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/tab-panel/controls.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tInspectorControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tCheckboxControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport
|
|
5
|
-
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP;AAAA,EACC;AAAA,EACA,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,OAC1B;AACP,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAK5B,OAAO,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tInspectorControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tCheckboxControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport TabToolbarControls from '../tabs/tab-toolbar-controls';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nexport default function Controls( { tabsClientId, blockIndex, isDefaultTab } ) {\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\treturn (\n\t\t<>\n\t\t\t<TabToolbarControls tabsClientId={ tabsClientId } />\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tupdateBlockAttributes( tabsClientId, {\n\t\t\t\t\t\t\tactiveTabIndex: 0,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Default tab' ) }\n\t\t\t\t\t\thasValue={ () => isDefaultTab && blockIndex !== 0 }\n\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\tupdateBlockAttributes( tabsClientId, {\n\t\t\t\t\t\t\t\tactiveTabIndex: 0,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\tlabel={ __( 'Default tab' ) }\n\t\t\t\t\t\t\tchecked={ isDefaultTab }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tupdateBlockAttributes( tabsClientId, {\n\t\t\t\t\t\t\t\t\tactiveTabIndex: value ? blockIndex : 0,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP;AAAA,EACC;AAAA,EACA,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,OAC1B;AACP,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAK5B,OAAO,wBAAwB;AAC/B,SAAS,sCAAsC;AAO7C,mBACC,KADD;AALa,SAAR,SAA2B,EAAE,cAAc,YAAY,aAAa,GAAI;AAC9E,QAAM,EAAE,sBAAsB,IAAI,YAAa,gBAAiB;AAChE,QAAM,oBAAoB,+BAA+B;AAEzD,SACC,iCACC;AAAA,wBAAC,sBAAmB,cAA8B;AAAA,IAClD,oBAAC,qBACA;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ,GAAI,UAAW;AAAA,QACvB,UAAW,MAAM;AAChB,gCAAuB,cAAc;AAAA,YACpC,gBAAgB;AAAA,UACjB,CAAE;AAAA,QACH;AAAA,QACA;AAAA,QAEA;AAAA,UAAC;AAAA;AAAA,YACA,OAAQ,GAAI,aAAc;AAAA,YAC1B,UAAW,MAAM,gBAAgB,eAAe;AAAA,YAChD,YAAa,MAAM;AAClB,oCAAuB,cAAc;AAAA,gBACpC,gBAAgB;AAAA,cACjB,CAAE;AAAA,YACH;AAAA,YACA,kBAAgB;AAAA,YAEhB;AAAA,cAAC;AAAA;AAAA,gBACA,OAAQ,GAAI,aAAc;AAAA,gBAC1B,SAAU;AAAA,gBACV,UAAW,CAAE,UAAW;AACvB,wCAAuB,cAAc;AAAA,oBACpC,gBAAgB,QAAQ,aAAa;AAAA,kBACtC,CAAE;AAAA,gBACH;AAAA;AAAA,YACD;AAAA;AAAA,QACD;AAAA;AAAA,IACD,GACD;AAAA,KACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -6,8 +6,7 @@ import {
|
|
|
6
6
|
} from "@wordpress/block-editor";
|
|
7
7
|
import { useSelect } from "@wordpress/data";
|
|
8
8
|
import { __ } from "@wordpress/i18n";
|
|
9
|
-
import
|
|
10
|
-
import RemoveTabToolbarControl from "../tab-panel/remove-tab-toolbar-control.mjs";
|
|
9
|
+
import TabToolbarControls from "../tabs/tab-toolbar-controls.mjs";
|
|
11
10
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
11
|
var TAB_PANELS_TEMPLATE = [
|
|
13
12
|
["core/tab-panel", { label: __("Tab") }],
|
|
@@ -26,8 +25,7 @@ function Edit({ clientId }) {
|
|
|
26
25
|
[clientId]
|
|
27
26
|
);
|
|
28
27
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
29
|
-
/* @__PURE__ */ jsx(
|
|
30
|
-
/* @__PURE__ */ jsx(RemoveTabToolbarControl, { tabsClientId }),
|
|
28
|
+
/* @__PURE__ */ jsx(TabToolbarControls, { tabsClientId }),
|
|
31
29
|
/* @__PURE__ */ jsx("div", { ...innerBlocksProps })
|
|
32
30
|
] });
|
|
33
31
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/tab-panels/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport
|
|
5
|
-
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AAKnB,OAAO,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport TabToolbarControls from '../tabs/tab-toolbar-controls';\n\n/**\n * Initial template applied only when the block is first inserted (i.e. when\n * inner blocks are empty). templateLock is false, so this is never applied to\n * existing blocks that already have tab panels saved.\n */\nconst TAB_PANELS_TEMPLATE = [\n\t[ 'core/tab-panel', { label: __( 'Tab' ) } ],\n\t[ 'core/tab-panel', { label: __( 'Tab' ) } ],\n];\n\nexport default function Edit( { clientId } ) {\n\tconst blockProps = useBlockProps();\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TAB_PANELS_TEMPLATE,\n\t\ttemplateLock: false,\n\t\trenderAppender: false, // Appender handled by individual tab blocks\n\t} );\n\n\t// Get the parent tabs block clientId\n\tconst tabsClientId = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlockRootClientId( clientId ),\n\t\t[ clientId ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<TabToolbarControls tabsClientId={ tabsClientId } />\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AAKnB,OAAO,wBAAwB;AA6B7B,mBACC,KADD;AAtBF,IAAM,sBAAsB;AAAA,EAC3B,CAAE,kBAAkB,EAAE,OAAO,GAAI,KAAM,EAAE,CAAE;AAAA,EAC3C,CAAE,kBAAkB,EAAE,OAAO,GAAI,KAAM,EAAE,CAAE;AAC5C;AAEe,SAAR,KAAuB,EAAE,SAAS,GAAI;AAC5C,QAAM,aAAa,cAAc;AAEjC,QAAM,mBAAmB,oBAAqB,YAAY;AAAA,IACzD,UAAU;AAAA,IACV,cAAc;AAAA,IACd,gBAAgB;AAAA;AAAA,EACjB,CAAE;AAGF,QAAM,eAAe;AAAA,IACpB,CAAE,WACD,OAAQ,gBAAiB,EAAE,qBAAsB,QAAS;AAAA,IAC3D,CAAE,QAAS;AAAA,EACZ;AAEA,SACC,iCACC;AAAA,wBAAC,sBAAmB,cAA8B;AAAA,IAClD,oBAAC,SAAM,GAAG,kBAAmB;AAAA,KAC9B;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/table-of-contents/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { createBlock } from '@wordpress/blocks';\nimport {\n\tPlaceholder,\n\tToggleControl,\n\tSelectControl,\n\tToolbarButton,\n\tToolbarGroup,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { renderToString } from '@wordpress/element';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as noticeStore } from '@wordpress/notices';\nimport {\n\ttableOfContents as icon,\n\tformatListBullets,\n\tformatListBulletsRTL,\n\tformatListNumbered,\n\tformatListNumberedRTL,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport TableOfContentsList from './list';\nimport { linearToNestedHeadingList } from './utils';\nimport { useObserveHeadings } from './hooks';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\n/** @typedef {import('./utils').HeadingData} HeadingData */\n\n/**\n * Table of Contents block edit component.\n *\n * @param {Object} props The props.\n * @param {Object} props.attributes The block attributes.\n * @param {HeadingData[]} props.attributes.headings The list of data for each heading in the post.\n * @param {boolean} props.attributes.onlyIncludeCurrentPage Whether to only include headings from the current page (if the post is paginated).\n * @param {number|undefined} props.attributes.maxLevel The maximum heading level to include, or null to include all levels.\n * @param {boolean} props.attributes.ordered Whether to display as an ordered list (true) or unordered list (false).\n * @param {string} props.clientId The client id.\n * @param {(attributes: Object) => void} props.setAttributes The set attributes function.\n *\n * @return {Component} The component.\n */\nexport default function TableOfContentsEdit( {\n\tattributes: {\n\t\theadings = [],\n\t\tonlyIncludeCurrentPage,\n\t\tmaxLevel,\n\t\tordered = true,\n\t},\n\tclientId,\n\tsetAttributes,\n} ) {\n\tuseObserveHeadings( clientId );\n\n\tconst blockProps = useBlockProps();\n\tconst instanceId = useInstanceId(\n\t\tTableOfContentsEdit,\n\t\t'table-of-contents'\n\t);\n\n\t// If a user clicks to a link prevent redirection and show a warning.\n\tconst { createWarningNotice } = useDispatch( noticeStore );\n\tconst showRedirectionPreventedNotice = ( event ) => {\n\t\tevent.preventDefault();\n\t\tcreateWarningNotice( __( 'Links are disabled in the editor.' ), {\n\t\t\tid: `block-library/core/table-of-contents/redirection-prevented/${ instanceId }`,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t};\n\n\tconst canInsertList = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, canInsertBlockType } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\treturn canInsertBlockType( 'core/list', rootClientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst headingTree = linearToNestedHeadingList( headings );\n\n\tconst toolbarControls = (\n\t\t<BlockControls>\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\ticon={ isRTL() ? formatListBulletsRTL : formatListBullets }\n\t\t\t\t\ttitle={ __( 'Unordered' ) }\n\t\t\t\t\tdescription={ __( 'Convert to unordered list' ) }\n\t\t\t\t\tonClick={ () => setAttributes( { ordered: false } ) }\n\t\t\t\t\tisActive={ ordered === false }\n\t\t\t\t/>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\ticon={\n\t\t\t\t\t\tisRTL() ? formatListNumberedRTL : formatListNumbered\n\t\t\t\t\t}\n\t\t\t\t\ttitle={ __( 'Ordered' ) }\n\t\t\t\t\tdescription={ __( 'Convert to ordered list' ) }\n\t\t\t\t\tonClick={ () => setAttributes( { ordered: true } ) }\n\t\t\t\t\tisActive={ ordered === true }\n\t\t\t\t/>\n\t\t\t</ToolbarGroup>\n\t\t\t{ canInsertList && (\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\tcreateBlock( 'core/list', {\n\t\t\t\t\t\t\t\t\tordered,\n\t\t\t\t\t\t\t\t\tvalues: renderToString(\n\t\t\t\t\t\t\t\t\t\t<TableOfContentsList\n\t\t\t\t\t\t\t\t\t\t\tnestedHeadingList={ headingTree }\n\t\t\t\t\t\t\t\t\t\t\tordered={ ordered }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Convert to static list' ) }\n\t\t\t\t\t</ToolbarButton>\n\t\t\t\t</ToolbarGroup>\n\t\t\t) }\n\t\t</BlockControls>\n\t);\n\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<ToolsPanel\n\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\tresetAll={ () => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tonlyIncludeCurrentPage: false,\n\t\t\t\t\t\tmaxLevel: undefined,\n\t\t\t\t\t\tordered: true,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => !! onlyIncludeCurrentPage }\n\t\t\t\t\tlabel={ __( 'Only include current page' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { onlyIncludeCurrentPage: false } )\n\t\t\t\t\t}\n\t\t\t\t\tisShownByDefault\n\t\t\t\t>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Only include current page' ) }\n\t\t\t\t\t\tchecked={ onlyIncludeCurrentPage }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { onlyIncludeCurrentPage: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\tonlyIncludeCurrentPage\n\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t'Only including headings from the current page (if the post is paginated).'\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t'Include headings from all pages (if the post is paginated).'\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => !! maxLevel }\n\t\t\t\t\tlabel={ __( 'Limit heading levels' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { maxLevel: undefined } )\n\t\t\t\t\t}\n\t\t\t\t\tisShownByDefault\n\t\t\t\t>\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\
|
|
5
|
-
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,OACM;AACP,SAAS,mBAAmB;AAC5B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,OAC1B;AACP,SAAS,aAAa,iBAAiB;AACvC,SAAS,sBAAsB;AAC/B,SAAS,IAAI,aAAa;AAC1B,SAAS,qBAAqB;AAC9B,SAAS,SAAS,mBAAmB;AACrC;AAAA,EACC,mBAAmB;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAKP,OAAO,yBAAyB;AAChC,SAAS,iCAAiC;AAC1C,SAAS,0BAA0B;AACnC,SAAS,sCAAsC;AA+D5C,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { createBlock } from '@wordpress/blocks';\nimport {\n\tPlaceholder,\n\tToggleControl,\n\tSelectControl,\n\tToolbarButton,\n\tToolbarGroup,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { renderToString } from '@wordpress/element';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as noticeStore } from '@wordpress/notices';\nimport {\n\ttableOfContents as icon,\n\tformatListBullets,\n\tformatListBulletsRTL,\n\tformatListNumbered,\n\tformatListNumberedRTL,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport TableOfContentsList from './list';\nimport { linearToNestedHeadingList } from './utils';\nimport { useObserveHeadings } from './hooks';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\n/** @typedef {import('./utils').HeadingData} HeadingData */\n\n/**\n * Table of Contents block edit component.\n *\n * @param {Object} props The props.\n * @param {Object} props.attributes The block attributes.\n * @param {HeadingData[]} props.attributes.headings The list of data for each heading in the post.\n * @param {boolean} props.attributes.onlyIncludeCurrentPage Whether to only include headings from the current page (if the post is paginated).\n * @param {number|undefined} props.attributes.maxLevel The maximum heading level to include, or null to include all levels.\n * @param {boolean} props.attributes.ordered Whether to display as an ordered list (true) or unordered list (false).\n * @param {string} props.clientId The client id.\n * @param {(attributes: Object) => void} props.setAttributes The set attributes function.\n *\n * @return {Component} The component.\n */\nexport default function TableOfContentsEdit( {\n\tattributes: {\n\t\theadings = [],\n\t\tonlyIncludeCurrentPage,\n\t\tmaxLevel,\n\t\tordered = true,\n\t},\n\tclientId,\n\tsetAttributes,\n} ) {\n\tuseObserveHeadings( clientId );\n\n\tconst blockProps = useBlockProps();\n\tconst instanceId = useInstanceId(\n\t\tTableOfContentsEdit,\n\t\t'table-of-contents'\n\t);\n\n\t// If a user clicks to a link prevent redirection and show a warning.\n\tconst { createWarningNotice } = useDispatch( noticeStore );\n\tconst showRedirectionPreventedNotice = ( event ) => {\n\t\tevent.preventDefault();\n\t\tcreateWarningNotice( __( 'Links are disabled in the editor.' ), {\n\t\t\tid: `block-library/core/table-of-contents/redirection-prevented/${ instanceId }`,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t};\n\n\tconst canInsertList = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, canInsertBlockType } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\treturn canInsertBlockType( 'core/list', rootClientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst headingTree = linearToNestedHeadingList( headings );\n\n\tconst toolbarControls = (\n\t\t<BlockControls>\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\ticon={ isRTL() ? formatListBulletsRTL : formatListBullets }\n\t\t\t\t\ttitle={ __( 'Unordered' ) }\n\t\t\t\t\tdescription={ __( 'Convert to unordered list' ) }\n\t\t\t\t\tonClick={ () => setAttributes( { ordered: false } ) }\n\t\t\t\t\tisActive={ ordered === false }\n\t\t\t\t/>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\ticon={\n\t\t\t\t\t\tisRTL() ? formatListNumberedRTL : formatListNumbered\n\t\t\t\t\t}\n\t\t\t\t\ttitle={ __( 'Ordered' ) }\n\t\t\t\t\tdescription={ __( 'Convert to ordered list' ) }\n\t\t\t\t\tonClick={ () => setAttributes( { ordered: true } ) }\n\t\t\t\t\tisActive={ ordered === true }\n\t\t\t\t/>\n\t\t\t</ToolbarGroup>\n\t\t\t{ canInsertList && (\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\tcreateBlock( 'core/list', {\n\t\t\t\t\t\t\t\t\tordered,\n\t\t\t\t\t\t\t\t\tvalues: renderToString(\n\t\t\t\t\t\t\t\t\t\t<TableOfContentsList\n\t\t\t\t\t\t\t\t\t\t\tnestedHeadingList={ headingTree }\n\t\t\t\t\t\t\t\t\t\t\tordered={ ordered }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Convert to static list' ) }\n\t\t\t\t\t</ToolbarButton>\n\t\t\t\t</ToolbarGroup>\n\t\t\t) }\n\t\t</BlockControls>\n\t);\n\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<ToolsPanel\n\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\tresetAll={ () => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tonlyIncludeCurrentPage: false,\n\t\t\t\t\t\tmaxLevel: undefined,\n\t\t\t\t\t\tordered: true,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => !! onlyIncludeCurrentPage }\n\t\t\t\t\tlabel={ __( 'Only include current page' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { onlyIncludeCurrentPage: false } )\n\t\t\t\t\t}\n\t\t\t\t\tisShownByDefault\n\t\t\t\t>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Only include current page' ) }\n\t\t\t\t\t\tchecked={ onlyIncludeCurrentPage }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { onlyIncludeCurrentPage: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\tonlyIncludeCurrentPage\n\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t'Only including headings from the current page (if the post is paginated).'\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t'Include headings from all pages (if the post is paginated).'\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => !! maxLevel }\n\t\t\t\t\tlabel={ __( 'Limit heading levels' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { maxLevel: undefined } )\n\t\t\t\t\t}\n\t\t\t\t\tisShownByDefault\n\t\t\t\t>\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\tlabel={ __( 'Include headings down to level' ) }\n\t\t\t\t\t\tvalue={ maxLevel || '' }\n\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t{ value: '', label: __( 'All levels' ) },\n\t\t\t\t\t\t\t{ value: '1', label: __( 'Heading 1' ) },\n\t\t\t\t\t\t\t{ value: '2', label: __( 'Heading 2' ) },\n\t\t\t\t\t\t\t{ value: '3', label: __( 'Heading 3' ) },\n\t\t\t\t\t\t\t{ value: '4', label: __( 'Heading 4' ) },\n\t\t\t\t\t\t\t{ value: '5', label: __( 'Heading 5' ) },\n\t\t\t\t\t\t\t{ value: '6', label: __( 'Heading 6' ) },\n\t\t\t\t\t\t] }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tmaxLevel: value ? parseInt( value ) : undefined,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t! maxLevel\n\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t'Including all heading levels in the table of contents.'\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t'Only include headings up to and including this level.'\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t</ToolsPanel>\n\t\t</InspectorControls>\n\t);\n\n\t// If there are no headings or the only heading is empty.\n\t// Note that the toolbar controls are intentionally omitted since the\n\t// \"Convert to static list\" option is useless to the placeholder state.\n\tif ( headings.length === 0 ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\t\tlabel={ __( 'Table of Contents' ) }\n\t\t\t\t\t\tinstructions={ __(\n\t\t\t\t\t\t\t'Start adding Heading blocks to create a table of contents. Headings with HTML anchors will be linked here.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t{ inspectorControls }\n\t\t\t</>\n\t\t);\n\t}\n\n\tconst ListTag = ordered ? 'ol' : 'ul';\n\n\treturn (\n\t\t<>\n\t\t\t<nav { ...blockProps }>\n\t\t\t\t<ListTag>\n\t\t\t\t\t<TableOfContentsList\n\t\t\t\t\t\tnestedHeadingList={ headingTree }\n\t\t\t\t\t\tdisableLinkActivation\n\t\t\t\t\t\tonClick={ showRedirectionPreventedNotice }\n\t\t\t\t\t\tordered={ ordered }\n\t\t\t\t\t/>\n\t\t\t\t</ListTag>\n\t\t\t</nav>\n\t\t\t{ toolbarControls }\n\t\t\t{ inspectorControls }\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,OACM;AACP,SAAS,mBAAmB;AAC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AAA,UACA,MAAO,oBAAC,aAAU,MAAc;AAAA,UAChC,OAAQ,GAAI,mBAAoB;AAAA,UAChC,cAAe;AAAA,YACd;AAAA,UACD;AAAA;AAAA,MACD,GACD;AAAA,MACE;AAAA,OACH;AAAA,EAEF;AAEA,QAAM,UAAU,UAAU,OAAO;AAEjC,SACC,iCACC;AAAA,wBAAC,SAAM,GAAG,YACT,8BAAC,WACA;AAAA,MAAC;AAAA;AAAA,QACA,mBAAoB;AAAA,QACpB,uBAAqB;AAAA,QACrB,SAAU;AAAA,QACV;AAAA;AAAA,IACD,GACD,GACD;AAAA,IACE;AAAA,IACA;AAAA,KACH;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@wordpress/block-editor";
|
|
8
8
|
import { useSelect } from "@wordpress/data";
|
|
9
9
|
import { useMemo } from "@wordpress/element";
|
|
10
|
-
import
|
|
10
|
+
import TabToolbarControls from "./tab-toolbar-controls.mjs";
|
|
11
11
|
import useTabListItemsSync from "./use-tab-list-items-sync.mjs";
|
|
12
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
13
|
var EMPTY_ARRAY = [];
|
|
@@ -54,7 +54,7 @@ function Edit({ clientId, attributes }) {
|
|
|
54
54
|
renderAppender: false
|
|
55
55
|
});
|
|
56
56
|
return /* @__PURE__ */ jsx(BlockContextProvider, { value: contextValue, children: /* @__PURE__ */ jsxs("div", { ...innerBlockProps, children: [
|
|
57
|
-
/* @__PURE__ */ jsx(
|
|
57
|
+
/* @__PURE__ */ jsx(TabToolbarControls, { tabsClientId: clientId }),
|
|
58
58
|
innerBlockProps.children
|
|
59
59
|
] }) });
|
|
60
60
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/tabs/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tBlockContextProvider,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport
|
|
5
|
-
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AAKxB,OAAO,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tBlockContextProvider,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport TabToolbarControls from './tab-toolbar-controls';\nimport useTabListItemsSync from './use-tab-list-items-sync';\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Only the two structural child blocks are specified here — without inner\n * block entries for core/tab-list or core/tab-panels.\n *\n * If inner blocks were included in this template, `synchronizeBlocksWithTemplate`\n * (called whenever templateLock === 'all') would recurse into the containers and\n * truncate them to the template count, causing data loss when a saved block with\n * more than two tabs is re-opened in the editor.\n *\n * Initial tab/panel creation is delegated to the tab-panels template in\n * tab-panels/edit.js (templateLock: false, applied only when empty).\n */\nconst TABS_TEMPLATE = [ [ 'core/tab-list' ], [ 'core/tab-panels' ] ];\n\nfunction Edit( { clientId, attributes } ) {\n\tconst { anchor, activeTabIndex, editorActiveTabIndex } = attributes;\n\n\tconst { tabPanels, tabListClientId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\t\t\tconst innerBlocks = getBlocks( clientId );\n\n\t\t\tconst tabPanelsBlock = innerBlocks.find(\n\t\t\t\t( block ) => block.name === 'core/tab-panels'\n\t\t\t);\n\t\t\tconst tabList = innerBlocks.find(\n\t\t\t\t( block ) => block.name === 'core/tab-list'\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\ttabPanels: tabPanelsBlock?.innerBlocks ?? EMPTY_ARRAY,\n\t\t\t\ttabListClientId: tabList?.clientId ?? null,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tuseTabListItemsSync( { tabPanels, tabListClientId } );\n\n\t/**\n\t * Memoize context value to prevent unnecessary re-renders.\n\t */\n\tconst contextValue = useMemo( () => {\n\t\t/**\n\t\t * Compute tabs list from innerblocks to provide via context.\n\t\t * This traverses the tab-panels block to find all tab-panel blocks\n\t\t * and extracts their label and anchor for the tab-list to consume.\n\t\t */\n\t\tconst tabList = tabPanels.map( ( tab, index ) => ( {\n\t\t\tid: tab.attributes.anchor || `tab-${ index }`,\n\t\t\tlabel: tab.attributes.label || '',\n\t\t\tclientId: tab.clientId,\n\t\t\tindex,\n\t\t} ) );\n\n\t\treturn {\n\t\t\t'core/tabs-list': tabList,\n\t\t\t'core/tabs-id': anchor,\n\t\t\t'core/tabs-activeTabIndex': activeTabIndex,\n\t\t\t'core/tabs-editorActiveTabIndex': editorActiveTabIndex,\n\t\t};\n\t}, [ tabPanels, anchor, activeTabIndex, editorActiveTabIndex ] );\n\n\tconst blockProps = useBlockProps();\n\n\tconst innerBlockProps = useInnerBlocksProps( blockProps, {\n\t\t__experimentalCaptureToolbars: true,\n\t\ttemplate: TABS_TEMPLATE,\n\t\ttemplateLock: 'all',\n\t\trenderAppender: false,\n\t} );\n\n\treturn (\n\t\t<BlockContextProvider value={ contextValue }>\n\t\t\t<div { ...innerBlockProps }>\n\t\t\t\t<TabToolbarControls tabsClientId={ clientId } />\n\t\t\t\t{ innerBlockProps.children }\n\t\t\t</div>\n\t\t</BlockContextProvider>\n\t);\n}\n\nexport default Edit;\n"],
|
|
5
|
+
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AAKxB,OAAO,wBAAwB;A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F,SACC,oBAAC,wBAAqB,OAAQ,cAC7B,+BAAC,SAAM,GAAG,iBACT;AAAA,wBAAC,sBAAmB,cAAe,UAAW;AAAA,IAC5C,gBAAgB;AAAA,KACnB,GACD;AAEF;AAEA,IAAO,eAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// packages/block-library/src/tabs/tab-toolbar-controls.js
|
|
2
|
+
import { __ } from "@wordpress/i18n";
|
|
3
|
+
import {
|
|
4
|
+
BlockControls,
|
|
5
|
+
store as blockEditorStore
|
|
6
|
+
} from "@wordpress/block-editor";
|
|
7
|
+
import { ToolbarGroup, ToolbarButton } from "@wordpress/components";
|
|
8
|
+
import { useSelect } from "@wordpress/data";
|
|
9
|
+
import useTabActions from "./use-tab-actions.mjs";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
function TabToolbarControls({ tabsClientId }) {
|
|
12
|
+
const { insertTab, removeTab } = useTabActions(tabsClientId);
|
|
13
|
+
const isRemoveDisabled = useSelect(
|
|
14
|
+
(select) => {
|
|
15
|
+
if (!tabsClientId) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
const tabPanels = select(blockEditorStore).getBlocks(tabsClientId).find((block) => block.name === "core/tab-panels");
|
|
19
|
+
return (tabPanels?.innerBlocks.length ?? 0) <= 1;
|
|
20
|
+
},
|
|
21
|
+
[tabsClientId]
|
|
22
|
+
);
|
|
23
|
+
return /* @__PURE__ */ jsx(BlockControls, { group: "other", children: /* @__PURE__ */ jsxs(ToolbarGroup, { children: [
|
|
24
|
+
/* @__PURE__ */ jsx(
|
|
25
|
+
ToolbarButton,
|
|
26
|
+
{
|
|
27
|
+
className: "components-toolbar__control",
|
|
28
|
+
onClick: () => insertTab(),
|
|
29
|
+
text: __("Add tab")
|
|
30
|
+
}
|
|
31
|
+
),
|
|
32
|
+
/* @__PURE__ */ jsx(
|
|
33
|
+
ToolbarButton,
|
|
34
|
+
{
|
|
35
|
+
className: "components-toolbar__control",
|
|
36
|
+
onClick: () => removeTab(),
|
|
37
|
+
text: __("Remove tab"),
|
|
38
|
+
disabled: isRemoveDisabled
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
] }) });
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
TabToolbarControls as default
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=tab-toolbar-controls.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/tabs/tab-toolbar-controls.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { ToolbarGroup, ToolbarButton } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport useTabActions from './use-tab-actions';\n\n/**\n * \"Add tab\" and \"Remove tab\" buttons in the block toolbar for the tabs block.\n * Inserts or removes a core/tab-panel. The tab-list items attribute is kept\n * in sync automatically via useTabListItemsSync.\n *\n * @param {Object} props\n * @param {string} props.tabsClientId The client ID of the parent tabs block.\n * @return {React.JSX.Element} The toolbar control element.\n */\nexport default function TabToolbarControls( { tabsClientId } ) {\n\tconst { insertTab, removeTab } = useTabActions( tabsClientId );\n\tconst isRemoveDisabled = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! tabsClientId ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tconst tabPanels = select( blockEditorStore )\n\t\t\t\t.getBlocks( tabsClientId )\n\t\t\t\t.find( ( block ) => block.name === 'core/tab-panels' );\n\t\t\treturn ( tabPanels?.innerBlocks.length ?? 0 ) <= 1;\n\t\t},\n\t\t[ tabsClientId ]\n\t);\n\n\treturn (\n\t\t<BlockControls group=\"other\">\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\t\tonClick={ () => insertTab() }\n\t\t\t\t\ttext={ __( 'Add tab' ) }\n\t\t\t\t/>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\t\tonClick={ () => removeTab() }\n\t\t\t\t\ttext={ __( 'Remove tab' ) }\n\t\t\t\t\tdisabled={ isRemoveDisabled }\n\t\t\t\t/>\n\t\t\t</ToolbarGroup>\n\t\t</BlockControls>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,cAAc,qBAAqB;AAC5C,SAAS,iBAAiB;AAK1B,OAAO,mBAAmB;AA4BvB,SACC,KADD;AAjBY,SAAR,mBAAqC,EAAE,aAAa,GAAI;AAC9D,QAAM,EAAE,WAAW,UAAU,IAAI,cAAe,YAAa;AAC7D,QAAM,mBAAmB;AAAA,IACxB,CAAE,WAAY;AACb,UAAK,CAAE,cAAe;AACrB,eAAO;AAAA,MACR;AACA,YAAM,YAAY,OAAQ,gBAAiB,EACzC,UAAW,YAAa,EACxB,KAAM,CAAE,UAAW,MAAM,SAAS,iBAAkB;AACtD,cAAS,WAAW,YAAY,UAAU,MAAO;AAAA,IAClD;AAAA,IACA,CAAE,YAAa;AAAA,EAChB;AAEA,SACC,oBAAC,iBAAc,OAAM,SACpB,+BAAC,gBACA;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,SAAU,MAAM,UAAU;AAAA,QAC1B,MAAO,GAAI,SAAU;AAAA;AAAA,IACtB;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,SAAU,MAAM,UAAU;AAAA,QAC1B,MAAO,GAAI,YAAa;AAAA,QACxB,UAAW;AAAA;AAAA,IACZ;AAAA,KACD,GACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// packages/block-library/src/tabs/use-tab-actions.js
|
|
2
|
+
import { __ } from "@wordpress/i18n";
|
|
3
|
+
import { createBlock } from "@wordpress/blocks";
|
|
4
|
+
import { store as blockEditorStore } from "@wordpress/block-editor";
|
|
5
|
+
import { useDispatch, useRegistry } from "@wordpress/data";
|
|
6
|
+
function useTabActions(tabsClientId) {
|
|
7
|
+
const registry = useRegistry();
|
|
8
|
+
const {
|
|
9
|
+
insertBlock,
|
|
10
|
+
removeBlock,
|
|
11
|
+
updateBlockAttributes,
|
|
12
|
+
__unstableMarkNextChangeAsNotPersistent
|
|
13
|
+
} = useDispatch(blockEditorStore);
|
|
14
|
+
const getTabsState = () => {
|
|
15
|
+
const { getBlocks, getBlockAttributes } = registry.select(blockEditorStore);
|
|
16
|
+
const tabsAttributes = tabsClientId ? getBlockAttributes(tabsClientId) : void 0;
|
|
17
|
+
const tabPanels = tabsClientId ? getBlocks(tabsClientId).find(
|
|
18
|
+
(block) => block.name === "core/tab-panels"
|
|
19
|
+
) : void 0;
|
|
20
|
+
return {
|
|
21
|
+
tabPanelsClientId: tabPanels?.clientId ?? null,
|
|
22
|
+
tabPanelBlocks: tabPanels?.innerBlocks ?? [],
|
|
23
|
+
activeIndex: tabsAttributes?.editorActiveTabIndex ?? tabsAttributes?.activeTabIndex ?? 0
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const insertTab = (atIndex) => {
|
|
27
|
+
const { tabPanelsClientId, tabPanelBlocks } = getTabsState();
|
|
28
|
+
if (!tabPanelsClientId) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const newIndex = atIndex ?? tabPanelBlocks.length;
|
|
32
|
+
insertBlock(
|
|
33
|
+
createBlock("core/tab-panel", { label: __("Tab") }),
|
|
34
|
+
newIndex,
|
|
35
|
+
tabPanelsClientId,
|
|
36
|
+
false
|
|
37
|
+
);
|
|
38
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
39
|
+
updateBlockAttributes(tabsClientId, {
|
|
40
|
+
editorActiveTabIndex: newIndex
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
const removeTab = (atIndex) => {
|
|
44
|
+
const { tabPanelBlocks, activeIndex } = getTabsState();
|
|
45
|
+
const tabCount = tabPanelBlocks.length;
|
|
46
|
+
if (tabCount <= 1) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const removeIndex = atIndex ?? activeIndex;
|
|
50
|
+
const target = tabPanelBlocks[removeIndex];
|
|
51
|
+
if (!target) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const newActiveIndex = removeIndex >= tabCount - 1 ? tabCount - 2 : removeIndex;
|
|
55
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
56
|
+
updateBlockAttributes(tabsClientId, {
|
|
57
|
+
editorActiveTabIndex: newActiveIndex
|
|
58
|
+
});
|
|
59
|
+
removeBlock(target.clientId, false);
|
|
60
|
+
};
|
|
61
|
+
return { insertTab, removeTab };
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
useTabActions as default
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=use-tab-actions.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/tabs/use-tab-actions.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { createBlock } from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useDispatch, useRegistry } from '@wordpress/data';\n\n/**\n * Provides callbacks to insert and remove tabs for a tabs block.\n *\n * The hook intentionally avoids subscribing to the store: all data is derived\n * lazily inside the callbacks via `registry.select`, so consumers don't\n * re-render when the tab structure changes.\n *\n * @param {string|null} tabsClientId The client ID of the parent tabs block.\n * @return {{ insertTab: Function, removeTab: Function }} Tab action callbacks.\n */\nexport default function useTabActions( tabsClientId ) {\n\tconst registry = useRegistry();\n\tconst {\n\t\tinsertBlock,\n\t\tremoveBlock,\n\t\tupdateBlockAttributes,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = useDispatch( blockEditorStore );\n\n\t// Derive the current tabs state at call time without subscribing.\n\tconst getTabsState = () => {\n\t\tconst { getBlocks, getBlockAttributes } =\n\t\t\tregistry.select( blockEditorStore );\n\n\t\tconst tabsAttributes = tabsClientId\n\t\t\t? getBlockAttributes( tabsClientId )\n\t\t\t: undefined;\n\t\tconst tabPanels = tabsClientId\n\t\t\t? getBlocks( tabsClientId ).find(\n\t\t\t\t\t( block ) => block.name === 'core/tab-panels'\n\t\t\t )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\ttabPanelsClientId: tabPanels?.clientId ?? null,\n\t\t\ttabPanelBlocks: tabPanels?.innerBlocks ?? [],\n\t\t\tactiveIndex:\n\t\t\t\ttabsAttributes?.editorActiveTabIndex ??\n\t\t\t\ttabsAttributes?.activeTabIndex ??\n\t\t\t\t0,\n\t\t};\n\t};\n\n\t// Insert a new tab and make it active. Defaults to appending at the end.\n\tconst insertTab = ( atIndex ) => {\n\t\tconst { tabPanelsClientId, tabPanelBlocks } = getTabsState();\n\t\tif ( ! tabPanelsClientId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newIndex = atIndex ?? tabPanelBlocks.length;\n\t\tinsertBlock(\n\t\t\tcreateBlock( 'core/tab-panel', { label: __( 'Tab' ) } ),\n\t\t\tnewIndex,\n\t\t\ttabPanelsClientId,\n\t\t\tfalse\n\t\t);\n\n\t\t// Switch editor active tab to the new tab.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tupdateBlockAttributes( tabsClientId, {\n\t\t\teditorActiveTabIndex: newIndex,\n\t\t} );\n\t};\n\n\t// Remove a tab and move the active tab to an adjacent one. Defaults to the\n\t// currently active tab.\n\tconst removeTab = ( atIndex ) => {\n\t\tconst { tabPanelBlocks, activeIndex } = getTabsState();\n\t\tconst tabCount = tabPanelBlocks.length;\n\t\tif ( tabCount <= 1 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst removeIndex = atIndex ?? activeIndex;\n\t\tconst target = tabPanelBlocks[ removeIndex ];\n\t\tif ( ! target ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Calculate new active index after removal.\n\t\tconst newActiveIndex =\n\t\t\tremoveIndex >= tabCount - 1 ? tabCount - 2 : removeIndex;\n\n\t\t// Switch editor to the adjacent tab and remove the current one.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tupdateBlockAttributes( tabsClientId, {\n\t\t\teditorActiveTabIndex: newActiveIndex,\n\t\t} );\n\t\tremoveBlock( target.clientId, false );\n\t};\n\n\treturn { insertTab, removeTab };\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,aAAa,mBAAmB;AAY1B,SAAR,cAAgC,cAAe;AACrD,QAAM,WAAW,YAAY;AAC7B,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI,YAAa,gBAAiB;AAGlC,QAAM,eAAe,MAAM;AAC1B,UAAM,EAAE,WAAW,mBAAmB,IACrC,SAAS,OAAQ,gBAAiB;AAEnC,UAAM,iBAAiB,eACpB,mBAAoB,YAAa,IACjC;AACH,UAAM,YAAY,eACf,UAAW,YAAa,EAAE;AAAA,MAC1B,CAAE,UAAW,MAAM,SAAS;AAAA,IAC5B,IACA;AAEH,WAAO;AAAA,MACN,mBAAmB,WAAW,YAAY;AAAA,MAC1C,gBAAgB,WAAW,eAAe,CAAC;AAAA,MAC3C,aACC,gBAAgB,wBAChB,gBAAgB,kBAChB;AAAA,IACF;AAAA,EACD;AAGA,QAAM,YAAY,CAAE,YAAa;AAChC,UAAM,EAAE,mBAAmB,eAAe,IAAI,aAAa;AAC3D,QAAK,CAAE,mBAAoB;AAC1B;AAAA,IACD;AAEA,UAAM,WAAW,WAAW,eAAe;AAC3C;AAAA,MACC,YAAa,kBAAkB,EAAE,OAAO,GAAI,KAAM,EAAE,CAAE;AAAA,MACtD;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAGA,4CAAwC;AACxC,0BAAuB,cAAc;AAAA,MACpC,sBAAsB;AAAA,IACvB,CAAE;AAAA,EACH;AAIA,QAAM,YAAY,CAAE,YAAa;AAChC,UAAM,EAAE,gBAAgB,YAAY,IAAI,aAAa;AACrD,UAAM,WAAW,eAAe;AAChC,QAAK,YAAY,GAAI;AACpB;AAAA,IACD;AAEA,UAAM,cAAc,WAAW;AAC/B,UAAM,SAAS,eAAgB,WAAY;AAC3C,QAAK,CAAE,QAAS;AACf;AAAA,IACD;AAGA,UAAM,iBACL,eAAe,WAAW,IAAI,WAAW,IAAI;AAG9C,4CAAwC;AACxC,0BAAuB,cAAc;AAAA,MACpC,sBAAsB;AAAA,IACvB,CAAE;AACF,gBAAa,OAAO,UAAU,KAAM;AAAA,EACrC;AAEA,SAAO,EAAE,WAAW,UAAU;AAC/B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// packages/block-library/src/tabs/use-tab-list-items-sync.js
|
|
2
2
|
import { store as blockEditorStore } from "@wordpress/block-editor";
|
|
3
|
-
import { useDispatch } from "@wordpress/data";
|
|
4
|
-
import { useEffect
|
|
3
|
+
import { useDispatch, useSelect } from "@wordpress/data";
|
|
4
|
+
import { useEffect } from "@wordpress/element";
|
|
5
5
|
function useTabListItemsSync({ tabPanels, tabListClientId }) {
|
|
6
6
|
const { updateBlockAttributes, __unstableMarkNextChangeAsNotPersistent } = useDispatch(blockEditorStore);
|
|
7
|
-
const
|
|
7
|
+
const { getBlockAttributes } = useSelect(blockEditorStore);
|
|
8
8
|
useEffect(() => {
|
|
9
9
|
if (!tabListClientId) {
|
|
10
10
|
return;
|
|
@@ -12,16 +12,16 @@ function useTabListItemsSync({ tabPanels, tabListClientId }) {
|
|
|
12
12
|
const newTabs = tabPanels.map((tab) => ({
|
|
13
13
|
label: tab.attributes.label || ""
|
|
14
14
|
}));
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
15
|
+
const currentTabs = getBlockAttributes(tabListClientId)?.tabs ?? [];
|
|
16
|
+
if (JSON.stringify(newTabs) === JSON.stringify(currentTabs)) {
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
prevTabsRef.current = serialized;
|
|
20
19
|
__unstableMarkNextChangeAsNotPersistent();
|
|
21
20
|
updateBlockAttributes(tabListClientId, { tabs: newTabs });
|
|
22
21
|
}, [
|
|
23
22
|
tabPanels,
|
|
24
23
|
tabListClientId,
|
|
24
|
+
getBlockAttributes,
|
|
25
25
|
updateBlockAttributes,
|
|
26
26
|
__unstableMarkNextChangeAsNotPersistent
|
|
27
27
|
]);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/tabs/use-tab-list-items-sync.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useDispatch } from '@wordpress/data';\nimport { useEffect
|
|
5
|
-
"mappings": ";AAGA,SAAS,SAAS,wBAAwB;AAC1C,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Keep the tab-list block's `tabs` attribute in sync with the tab-panel blocks.\n *\n * Whenever the list of core/tab-panel blocks changes (add, remove, reorder, or\n * label edit), this hook updates the `tabs` attribute on the core/tab-list\n * block so that save.js can render the correct buttons.\n *\n * @param {Object} props\n * @param {Array} props.tabPanels Raw core/tab-panel block objects.\n * @param {string|null} props.tabListClientId Client ID of the core/tab-list block.\n */\nexport default function useTabListItemsSync( { tabPanels, tabListClientId } ) {\n\tconst { updateBlockAttributes, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { getBlockAttributes } = useSelect( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( ! tabListClientId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newTabs = tabPanels.map( ( tab ) => ( {\n\t\t\tlabel: tab.attributes.label || '',\n\t\t} ) );\n\n\t\t// Skip the update when the stored tabs already match the derived ones.\n\t\tconst currentTabs = getBlockAttributes( tabListClientId )?.tabs ?? [];\n\t\tif ( JSON.stringify( newTabs ) === JSON.stringify( currentTabs ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tupdateBlockAttributes( tabListClientId, { tabs: newTabs } );\n\t}, [\n\t\ttabPanels,\n\t\ttabListClientId,\n\t\tgetBlockAttributes,\n\t\tupdateBlockAttributes,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t] );\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,SAAS,wBAAwB;AAC1C,SAAS,aAAa,iBAAiB;AACvC,SAAS,iBAAiB;AAaX,SAAR,oBAAsC,EAAE,WAAW,gBAAgB,GAAI;AAC7E,QAAM,EAAE,uBAAuB,wCAAwC,IACtE,YAAa,gBAAiB;AAC/B,QAAM,EAAE,mBAAmB,IAAI,UAAW,gBAAiB;AAE3D,YAAW,MAAM;AAChB,QAAK,CAAE,iBAAkB;AACxB;AAAA,IACD;AAEA,UAAM,UAAU,UAAU,IAAK,CAAE,SAAW;AAAA,MAC3C,OAAO,IAAI,WAAW,SAAS;AAAA,IAChC,EAAI;AAGJ,UAAM,cAAc,mBAAoB,eAAgB,GAAG,QAAQ,CAAC;AACpE,QAAK,KAAK,UAAW,OAAQ,MAAM,KAAK,UAAW,WAAY,GAAI;AAClE;AAAA,IACD;AAEA,4CAAwC;AACxC,0BAAuB,iBAAiB,EAAE,MAAM,QAAQ,CAAE;AAAA,EAC3D,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -102,7 +102,6 @@ function TagCloudEdit({ attributes, setAttributes, name }) {
|
|
|
102
102
|
children: /* @__PURE__ */ jsx(
|
|
103
103
|
SelectControl,
|
|
104
104
|
{
|
|
105
|
-
__next40pxDefaultSize: true,
|
|
106
105
|
label: __("Taxonomy"),
|
|
107
106
|
options: getTaxonomyOptions(),
|
|
108
107
|
value: taxonomy,
|
|
@@ -135,8 +134,7 @@ function TagCloudEdit({ attributes, setAttributes, name }) {
|
|
|
135
134
|
},
|
|
136
135
|
units,
|
|
137
136
|
min: MIN_FONT_SIZE,
|
|
138
|
-
max: MAX_FONT_SIZE
|
|
139
|
-
size: "__unstable-large"
|
|
137
|
+
max: MAX_FONT_SIZE
|
|
140
138
|
}
|
|
141
139
|
) }),
|
|
142
140
|
/* @__PURE__ */ jsx(FlexItem, { isBlock: true, children: /* @__PURE__ */ jsx(
|
|
@@ -152,8 +150,7 @@ function TagCloudEdit({ attributes, setAttributes, name }) {
|
|
|
152
150
|
},
|
|
153
151
|
units,
|
|
154
152
|
min: MIN_FONT_SIZE,
|
|
155
|
-
max: MAX_FONT_SIZE
|
|
156
|
-
size: "__unstable-large"
|
|
153
|
+
max: MAX_FONT_SIZE
|
|
157
154
|
}
|
|
158
155
|
) })
|
|
159
156
|
] })
|
|
@@ -169,7 +166,6 @@ function TagCloudEdit({ attributes, setAttributes, name }) {
|
|
|
169
166
|
children: /* @__PURE__ */ jsx(
|
|
170
167
|
RangeControl,
|
|
171
168
|
{
|
|
172
|
-
__next40pxDefaultSize: true,
|
|
173
169
|
label: __("Number of tags"),
|
|
174
170
|
value: numberOfTags,
|
|
175
171
|
onChange: (value) => setAttributes({ numberOfTags: value }),
|