@wordpress/block-library 10.1.1-next.v.202607070741.0 → 10.3.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 +25 -0
- package/build/accordion/block.json +1 -0
- package/build/accordion-panel/block.json +1 -0
- package/build/button/edit.cjs +18 -8
- package/build/button/edit.cjs.map +2 -2
- package/build/code/edit.cjs +3 -1
- package/build/code/edit.cjs.map +2 -2
- package/build/cover/block.json +12 -0
- package/build/cover/edit/block-controls.cjs +14 -5
- package/build/cover/edit/block-controls.cjs.map +2 -2
- package/build/cover/edit/embed-video-url-input.cjs +5 -3
- package/build/cover/edit/embed-video-url-input.cjs.map +3 -3
- package/build/cover/edit/index.cjs +76 -32
- package/build/cover/edit/index.cjs.map +2 -2
- package/build/cover/embed-video-utils.cjs +17 -7
- package/build/cover/embed-video-utils.cjs.map +2 -2
- package/build/details/transforms.cjs +1 -3
- package/build/details/transforms.cjs.map +2 -2
- package/build/embed/edit.cjs +1 -1
- package/build/embed/edit.cjs.map +2 -2
- package/build/embed/embed-placeholder.cjs +1 -2
- package/build/embed/embed-placeholder.cjs.map +2 -2
- package/build/file/edit.cjs +4 -3
- package/build/file/edit.cjs.map +2 -2
- package/build/file/transforms.cjs +25 -60
- package/build/file/transforms.cjs.map +2 -2
- package/build/gallery/block.json +4 -2
- package/build/gallery/dynamic-gallery.cjs +104 -61
- package/build/gallery/dynamic-gallery.cjs.map +3 -3
- package/build/gallery/edit.cjs +1 -1
- package/build/gallery/edit.cjs.map +3 -3
- package/build/gallery/gap-styles.cjs +49 -13
- package/build/gallery/gap-styles.cjs.map +3 -3
- package/build/gallery/use-dynamic-gallery.cjs +15 -8
- package/build/gallery/use-dynamic-gallery.cjs.map +2 -2
- package/build/group/transforms.cjs +1 -1
- package/build/group/transforms.cjs.map +2 -2
- package/build/heading/edit.cjs +1 -1
- package/build/heading/edit.cjs.map +2 -2
- package/build/html/modal.cjs +63 -54
- package/build/html/modal.cjs.map +3 -3
- package/build/icon/block.json +5 -3
- package/build/icon/components/custom-inserter/icon-grid.cjs +25 -12
- package/build/icon/components/custom-inserter/icon-grid.cjs.map +2 -2
- package/build/icon/components/custom-inserter/index.cjs +100 -31
- package/build/icon/components/custom-inserter/index.cjs.map +3 -3
- package/build/icon/edit.cjs +11 -12
- package/build/icon/edit.cjs.map +2 -2
- package/build/image/block.json +1 -1
- package/build/image/edit.cjs +1 -35
- package/build/image/edit.cjs.map +2 -2
- package/build/image/image.cjs +23 -18
- package/build/image/image.cjs.map +3 -3
- package/build/image/transforms.cjs +78 -0
- package/build/image/transforms.cjs.map +3 -3
- package/build/image/use-open-image-media-editor-modal.cjs +6 -2
- package/build/image/use-open-image-media-editor-modal.cjs.map +2 -2
- package/build/index.cjs +18 -8
- package/build/index.cjs.map +2 -2
- package/build/latest-posts/edit.cjs +5 -8
- package/build/latest-posts/edit.cjs.map +2 -2
- package/build/list-item/edit.cjs +1 -1
- package/build/list-item/edit.cjs.map +2 -2
- package/build/list-item/hooks/use-enter.cjs +14 -17
- package/build/list-item/hooks/use-enter.cjs.map +3 -3
- package/build/list-item/hooks/use-indent-list-item.cjs +10 -2
- package/build/list-item/hooks/use-indent-list-item.cjs.map +2 -2
- package/build/list-item/hooks/use-space.cjs +3 -2
- package/build/list-item/hooks/use-space.cjs.map +3 -3
- package/build/math/edit.cjs +39 -56
- package/build/math/edit.cjs.map +3 -3
- package/build/media-text/edit.cjs +2 -1
- package/build/media-text/edit.cjs.map +2 -2
- package/build/more/edit.cjs +2 -2
- package/build/more/edit.cjs.map +2 -2
- package/build/navigation/edit/index.cjs +30 -16
- package/build/navigation/edit/index.cjs.map +3 -3
- package/build/navigation/edit/use-layout-custom-properties.cjs +72 -0
- package/build/navigation/edit/use-layout-custom-properties.cjs.map +7 -0
- package/build/navigation/view.cjs +9 -6
- package/build/navigation/view.cjs.map +2 -2
- package/build/navigation-link/edit.cjs +3 -3
- package/build/navigation-link/edit.cjs.map +2 -2
- package/build/navigation-link/link-ui/index.cjs +2 -2
- package/build/navigation-link/link-ui/index.cjs.map +2 -2
- package/build/paragraph/edit.cjs +5 -2
- package/build/paragraph/edit.cjs.map +3 -3
- package/build/paragraph/index.cjs +4 -1
- package/build/paragraph/index.cjs.map +2 -2
- package/build/paragraph/use-enter.cjs +3 -7
- package/build/paragraph/use-enter.cjs.map +3 -3
- package/build/playlist/block.json +29 -10
- package/build/playlist/context.cjs +2 -1
- package/build/playlist/context.cjs.map +2 -2
- package/build/playlist/edit.cjs +328 -39
- package/build/playlist/edit.cjs.map +3 -3
- package/build/playlist/index.cjs +1 -1
- package/build/playlist/index.cjs.map +2 -2
- package/build/playlist/utils.cjs +37 -8
- package/build/playlist/utils.cjs.map +2 -2
- package/build/playlist/view.cjs +83 -13
- package/build/playlist/view.cjs.map +2 -2
- package/build/playlist-track/block.json +4 -2
- package/build/playlist-track/edit.cjs +115 -70
- package/build/playlist-track/edit.cjs.map +2 -2
- package/build/post-content/block.json +1 -0
- package/build/post-content/edit.cjs +36 -15
- package/build/post-content/edit.cjs.map +2 -2
- package/build/post-featured-image/edit.cjs +3 -2
- package/build/post-featured-image/edit.cjs.map +2 -2
- package/build/post-template/block.json +2 -1
- package/build/post-template/edit.cjs +10 -1
- package/build/post-template/edit.cjs.map +2 -2
- package/build/post-terms/edit.cjs +2 -2
- package/build/post-terms/edit.cjs.map +2 -2
- package/build/post-title/edit.cjs +2 -2
- package/build/post-title/edit.cjs.map +2 -2
- package/build/preformatted/edit.cjs +3 -1
- package/build/preformatted/edit.cjs.map +2 -2
- package/build/pullquote/block.json +3 -1
- package/build/pullquote/edit.cjs +5 -3
- package/build/pullquote/edit.cjs.map +2 -2
- package/build/query/block.json +3 -2
- package/build/query/edit/inspector-controls/index.cjs +42 -5
- package/build/query/edit/inspector-controls/index.cjs.map +2 -2
- package/build/query/edit/inspector-controls/offset-controls.cjs +1 -2
- package/build/query/edit/inspector-controls/offset-controls.cjs.map +2 -2
- package/build/query/edit/inspector-controls/pages-control.cjs +0 -1
- package/build/query/edit/inspector-controls/pages-control.cjs.map +2 -2
- package/build/query/edit/query-content.cjs +10 -3
- package/build/query/edit/query-content.cjs.map +2 -2
- package/build/query/index.cjs +2 -1
- package/build/query/index.cjs.map +2 -2
- package/build/quote/block.json +3 -1
- package/build/quote/transforms.cjs +1 -3
- package/build/quote/transforms.cjs.map +2 -2
- package/build/read-more/edit.cjs +3 -1
- package/build/read-more/edit.cjs.map +2 -2
- package/build/rss/edit.cjs +0 -1
- package/build/rss/edit.cjs.map +2 -2
- package/build/site-tagline/edit.cjs +3 -1
- package/build/site-tagline/edit.cjs.map +2 -2
- package/build/site-title/edit.cjs +3 -1
- package/build/site-title/edit.cjs.map +2 -2
- package/build/social-links/edit.cjs +11 -4
- package/build/social-links/edit.cjs.map +2 -2
- package/build/tab-list/block.json +4 -3
- package/build/tab-list/edit.cjs +67 -11
- package/build/tab-list/edit.cjs.map +3 -3
- package/build/tab-list/tab-movers.cjs +87 -0
- package/build/tab-list/tab-movers.cjs.map +7 -0
- package/build/tab-panel/block.json +1 -6
- package/build/tab-panel/edit.cjs +16 -24
- package/build/tab-panel/edit.cjs.map +2 -2
- package/build/tab-panels/block.json +0 -1
- package/build/table/edit.cjs +1 -1
- package/build/table/edit.cjs.map +2 -2
- package/build/tabs/block.json +0 -5
- package/build/tabs/edit.cjs +4 -39
- package/build/tabs/edit.cjs.map +3 -3
- package/build/tabs/use-tab-actions.cjs +23 -1
- package/build/tabs/use-tab-actions.cjs.map +2 -2
- package/build/tabs/use-tab-list-items-sync.cjs +19 -1
- package/build/tabs/use-tab-list-items-sync.cjs.map +2 -2
- package/build/term-name/block.json +1 -3
- package/build/term-name/deprecated.cjs +105 -0
- package/build/term-name/deprecated.cjs.map +7 -0
- package/build/term-name/edit.cjs +11 -37
- package/build/term-name/edit.cjs.map +3 -3
- package/build/term-name/index.cjs +3 -1
- package/build/term-name/index.cjs.map +3 -3
- package/build/utils/caption.cjs +2 -2
- package/build/utils/caption.cjs.map +2 -2
- package/build/utils/waveform-player.cjs +138 -22
- package/build/utils/waveform-player.cjs.map +2 -2
- package/build/utils/waveform-utils.cjs +315 -17
- package/build/utils/waveform-utils.cjs.map +2 -2
- package/build/verse/edit.cjs +3 -1
- package/build/verse/edit.cjs.map +2 -2
- package/build/video/edit.cjs +2 -11
- package/build/video/edit.cjs.map +3 -3
- package/build/video/tracks-editor.cjs +0 -1
- package/build/video/tracks-editor.cjs.map +2 -2
- package/build-module/accordion/block.json +1 -0
- package/build-module/accordion-panel/block.json +1 -0
- package/build-module/button/edit.mjs +19 -14
- package/build-module/button/edit.mjs.map +2 -2
- package/build-module/code/edit.mjs +3 -1
- package/build-module/code/edit.mjs.map +2 -2
- package/build-module/cover/block.json +12 -0
- package/build-module/cover/edit/block-controls.mjs +14 -5
- package/build-module/cover/edit/block-controls.mjs.map +2 -2
- package/build-module/cover/edit/embed-video-url-input.mjs +5 -4
- package/build-module/cover/edit/embed-video-url-input.mjs.map +2 -2
- package/build-module/cover/edit/index.mjs +79 -35
- package/build-module/cover/edit/index.mjs.map +2 -2
- package/build-module/cover/embed-video-utils.mjs +16 -7
- package/build-module/cover/embed-video-utils.mjs.map +2 -2
- package/build-module/details/transforms.mjs +2 -7
- package/build-module/details/transforms.mjs.map +2 -2
- package/build-module/embed/edit.mjs +1 -1
- package/build-module/embed/edit.mjs.map +2 -2
- package/build-module/embed/embed-placeholder.mjs +1 -2
- package/build-module/embed/embed-placeholder.mjs.map +2 -2
- package/build-module/file/edit.mjs +4 -3
- package/build-module/file/edit.mjs.map +2 -2
- package/build-module/file/transforms.mjs +25 -60
- package/build-module/file/transforms.mjs.map +2 -2
- package/build-module/gallery/block.json +4 -2
- package/build-module/gallery/dynamic-gallery.mjs +104 -61
- package/build-module/gallery/dynamic-gallery.mjs.map +2 -2
- package/build-module/gallery/edit.mjs +3 -3
- package/build-module/gallery/edit.mjs.map +2 -2
- package/build-module/gallery/gap-styles.mjs +53 -14
- package/build-module/gallery/gap-styles.mjs.map +2 -2
- package/build-module/gallery/use-dynamic-gallery.mjs +16 -9
- package/build-module/gallery/use-dynamic-gallery.mjs.map +2 -2
- package/build-module/group/transforms.mjs +2 -5
- package/build-module/group/transforms.mjs.map +2 -2
- package/build-module/heading/edit.mjs +1 -1
- package/build-module/heading/edit.mjs.map +2 -2
- package/build-module/html/modal.mjs +68 -55
- package/build-module/html/modal.mjs.map +2 -2
- package/build-module/icon/block.json +5 -3
- package/build-module/icon/components/custom-inserter/icon-grid.mjs +25 -12
- package/build-module/icon/components/custom-inserter/icon-grid.mjs.map +2 -2
- package/build-module/icon/components/custom-inserter/index.mjs +102 -33
- package/build-module/icon/components/custom-inserter/index.mjs.map +2 -2
- package/build-module/icon/edit.mjs +11 -12
- package/build-module/icon/edit.mjs.map +2 -2
- package/build-module/image/block.json +1 -1
- package/build-module/image/edit.mjs +1 -35
- package/build-module/image/edit.mjs.map +2 -2
- package/build-module/image/image.mjs +23 -18
- package/build-module/image/image.mjs.map +2 -2
- package/build-module/image/transforms.mjs +78 -0
- package/build-module/image/transforms.mjs.map +2 -2
- package/build-module/image/use-open-image-media-editor-modal.mjs +6 -2
- package/build-module/image/use-open-image-media-editor-modal.mjs.map +2 -2
- package/build-module/index.mjs +18 -8
- package/build-module/index.mjs.map +2 -2
- package/build-module/latest-posts/edit.mjs +5 -8
- package/build-module/latest-posts/edit.mjs.map +2 -2
- package/build-module/list-item/edit.mjs +1 -1
- package/build-module/list-item/edit.mjs.map +2 -2
- package/build-module/list-item/hooks/use-enter.mjs +15 -21
- package/build-module/list-item/hooks/use-enter.mjs.map +2 -2
- package/build-module/list-item/hooks/use-indent-list-item.mjs +10 -2
- package/build-module/list-item/hooks/use-indent-list-item.mjs.map +2 -2
- package/build-module/list-item/hooks/use-space.mjs +4 -6
- package/build-module/list-item/hooks/use-space.mjs.map +2 -2
- package/build-module/math/edit.mjs +41 -60
- package/build-module/math/edit.mjs.map +2 -2
- package/build-module/media-text/edit.mjs +2 -1
- package/build-module/media-text/edit.mjs.map +2 -2
- package/build-module/more/edit.mjs +2 -2
- package/build-module/more/edit.mjs.map +2 -2
- package/build-module/navigation/edit/index.mjs +30 -16
- package/build-module/navigation/edit/index.mjs.map +2 -2
- package/build-module/navigation/edit/use-layout-custom-properties.mjs +51 -0
- package/build-module/navigation/edit/use-layout-custom-properties.mjs.map +7 -0
- package/build-module/navigation/view.mjs +9 -6
- package/build-module/navigation/view.mjs.map +2 -2
- package/build-module/navigation-link/edit.mjs +3 -3
- package/build-module/navigation-link/edit.mjs.map +2 -2
- package/build-module/navigation-link/link-ui/index.mjs +2 -2
- package/build-module/navigation-link/link-ui/index.mjs.map +2 -2
- package/build-module/paragraph/edit.mjs +6 -2
- package/build-module/paragraph/edit.mjs.map +2 -2
- package/build-module/paragraph/index.mjs +4 -1
- package/build-module/paragraph/index.mjs.map +2 -2
- package/build-module/paragraph/use-enter.mjs +4 -11
- package/build-module/paragraph/use-enter.mjs.map +2 -2
- package/build-module/playlist/block.json +29 -10
- package/build-module/playlist/context.mjs +2 -1
- package/build-module/playlist/context.mjs.map +2 -2
- package/build-module/playlist/edit.mjs +331 -41
- package/build-module/playlist/edit.mjs.map +2 -2
- package/build-module/playlist/index.mjs +1 -1
- package/build-module/playlist/index.mjs.map +2 -2
- package/build-module/playlist/utils.mjs +35 -7
- package/build-module/playlist/utils.mjs.map +2 -2
- package/build-module/playlist/view.mjs +89 -14
- package/build-module/playlist/view.mjs.map +2 -2
- package/build-module/playlist-track/block.json +4 -2
- package/build-module/playlist-track/edit.mjs +117 -71
- package/build-module/playlist-track/edit.mjs.map +2 -2
- package/build-module/post-content/block.json +1 -0
- package/build-module/post-content/edit.mjs +37 -15
- package/build-module/post-content/edit.mjs.map +2 -2
- package/build-module/post-featured-image/edit.mjs +3 -2
- package/build-module/post-featured-image/edit.mjs.map +2 -2
- package/build-module/post-template/block.json +2 -1
- package/build-module/post-template/edit.mjs +10 -1
- package/build-module/post-template/edit.mjs.map +2 -2
- package/build-module/post-terms/edit.mjs +2 -2
- package/build-module/post-terms/edit.mjs.map +2 -2
- package/build-module/post-title/edit.mjs +2 -2
- package/build-module/post-title/edit.mjs.map +2 -2
- package/build-module/preformatted/edit.mjs +3 -1
- package/build-module/preformatted/edit.mjs.map +2 -2
- package/build-module/pullquote/block.json +3 -1
- package/build-module/pullquote/edit.mjs +5 -3
- package/build-module/pullquote/edit.mjs.map +2 -2
- package/build-module/query/block.json +3 -2
- package/build-module/query/edit/inspector-controls/index.mjs +44 -6
- package/build-module/query/edit/inspector-controls/index.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/offset-controls.mjs +2 -3
- package/build-module/query/edit/inspector-controls/offset-controls.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/pages-control.mjs +0 -1
- package/build-module/query/edit/inspector-controls/pages-control.mjs.map +2 -2
- package/build-module/query/edit/query-content.mjs +10 -3
- package/build-module/query/edit/query-content.mjs.map +2 -2
- package/build-module/query/index.mjs +2 -1
- package/build-module/query/index.mjs.map +2 -2
- package/build-module/quote/block.json +3 -1
- package/build-module/quote/transforms.mjs +2 -4
- package/build-module/quote/transforms.mjs.map +2 -2
- package/build-module/read-more/edit.mjs +3 -1
- package/build-module/read-more/edit.mjs.map +2 -2
- package/build-module/rss/edit.mjs +0 -1
- package/build-module/rss/edit.mjs.map +2 -2
- package/build-module/site-tagline/edit.mjs +3 -1
- package/build-module/site-tagline/edit.mjs.map +2 -2
- package/build-module/site-title/edit.mjs +3 -1
- package/build-module/site-title/edit.mjs.map +2 -2
- package/build-module/social-links/edit.mjs +11 -4
- package/build-module/social-links/edit.mjs.map +2 -2
- package/build-module/tab-list/block.json +4 -3
- package/build-module/tab-list/edit.mjs +74 -13
- package/build-module/tab-list/edit.mjs.map +2 -2
- package/build-module/tab-list/tab-movers.mjs +59 -0
- package/build-module/tab-list/tab-movers.mjs.map +7 -0
- package/build-module/tab-panel/block.json +1 -6
- package/build-module/tab-panel/edit.mjs +17 -25
- package/build-module/tab-panel/edit.mjs.map +2 -2
- package/build-module/tab-panels/block.json +0 -1
- package/build-module/table/edit.mjs +1 -1
- package/build-module/table/edit.mjs.map +2 -2
- package/build-module/tabs/block.json +0 -5
- package/build-module/tabs/edit.mjs +5 -45
- package/build-module/tabs/edit.mjs.map +2 -2
- package/build-module/tabs/use-tab-actions.mjs +23 -1
- package/build-module/tabs/use-tab-actions.mjs.map +2 -2
- package/build-module/tabs/use-tab-list-items-sync.mjs +19 -1
- package/build-module/tabs/use-tab-list-items-sync.mjs.map +2 -2
- package/build-module/term-name/block.json +1 -3
- package/build-module/term-name/deprecated.mjs +74 -0
- package/build-module/term-name/deprecated.mjs.map +7 -0
- package/build-module/term-name/edit.mjs +11 -28
- package/build-module/term-name/edit.mjs.map +2 -2
- package/build-module/term-name/index.mjs +3 -1
- package/build-module/term-name/index.mjs.map +2 -2
- package/build-module/utils/caption.mjs +2 -2
- package/build-module/utils/caption.mjs.map +2 -2
- package/build-module/utils/waveform-player.mjs +144 -23
- package/build-module/utils/waveform-player.mjs.map +2 -2
- package/build-module/utils/waveform-utils.mjs +310 -16
- package/build-module/utils/waveform-utils.mjs.map +2 -2
- package/build-module/verse/edit.mjs +3 -1
- package/build-module/verse/edit.mjs.map +2 -2
- package/build-module/video/edit.mjs +2 -11
- package/build-module/video/edit.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-style/cover/editor-rtl.css +3 -0
- package/build-style/cover/editor.css +3 -0
- package/build-style/editor-rtl.css +61 -59
- package/build-style/editor.css +61 -59
- package/build-style/icon/editor-rtl.css +80 -10
- package/build-style/icon/editor.css +80 -10
- package/build-style/image/editor-rtl.css +3 -32
- package/build-style/image/editor.css +3 -32
- package/build-style/more/editor-rtl.css +2 -2
- package/build-style/more/editor.css +2 -2
- package/build-style/navigation/editor-rtl.css +3 -4
- package/build-style/navigation/editor.css +3 -4
- package/build-style/navigation-link/editor-rtl.css +1 -1
- package/build-style/navigation-link/editor.css +1 -1
- package/build-style/nextpage/editor-rtl.css +2 -2
- package/build-style/nextpage/editor.css +2 -2
- package/build-style/playlist/editor-rtl.css +4 -3
- package/build-style/playlist/editor.css +4 -3
- package/build-style/playlist/style-rtl.css +81 -5
- package/build-style/playlist/style.css +81 -5
- package/build-style/playlist-track/style-rtl.css +10 -0
- package/build-style/playlist-track/style.css +10 -0
- package/build-style/pullquote/editor-rtl.css +4 -0
- package/build-style/pullquote/editor.css +4 -0
- package/build-style/style-rtl.css +91 -5
- package/build-style/style.css +91 -5
- package/build-style/tab-list/editor-rtl.css +101 -0
- package/build-style/tab-list/editor.css +101 -0
- package/build-style/video/editor-rtl.css +1 -1
- package/build-style/video/editor.css +1 -1
- package/build-types/table-of-contents/list.d.ts +1 -1
- package/build-types/table-of-contents/list.d.ts.map +1 -1
- package/package.json +47 -45
- package/src/accordion/README.md +1 -0
- package/src/accordion/block.json +1 -0
- package/src/accordion-panel/block.json +1 -0
- package/src/breadcrumbs/index.php +3 -1
- package/src/button/edit.js +21 -15
- package/src/button/index.php +1 -1
- package/src/code/edit.js +7 -2
- package/src/cover/README.md +60 -0
- package/src/cover/block.json +12 -0
- package/src/cover/edit/block-controls.js +26 -11
- package/src/cover/edit/embed-video-url-input.js +5 -4
- package/src/cover/edit/index.js +109 -46
- package/src/cover/editor.scss +6 -0
- package/src/cover/embed-video-utils.js +38 -13
- package/src/cover/index.php +9 -2
- package/src/details/transforms.js +2 -7
- package/src/editor.scss +1 -0
- package/src/embed/edit.js +3 -1
- package/src/embed/embed-placeholder.js +9 -8
- package/src/file/edit.js +8 -8
- package/src/file/transforms.js +28 -60
- package/src/form/index.php +6 -4
- package/src/gallery/README.md +1 -1
- package/src/gallery/block.json +4 -2
- package/src/gallery/dynamic-gallery.js +133 -74
- package/src/gallery/edit.js +3 -3
- package/src/gallery/gap-styles.js +79 -20
- package/src/gallery/index.php +103 -43
- package/src/gallery/use-dynamic-gallery.js +27 -12
- package/src/group/transforms.js +2 -5
- package/src/heading/edit.js +1 -1
- package/src/html/modal.js +13 -2
- package/src/icon/README.md +1 -3
- package/src/icon/block.json +5 -3
- package/src/icon/components/custom-inserter/icon-grid.js +40 -11
- package/src/icon/components/custom-inserter/index.js +98 -25
- package/src/icon/edit.js +11 -17
- package/src/icon/editor.scss +33 -11
- package/src/image/README.md +1 -1
- package/src/image/block.json +1 -1
- package/src/image/edit.js +1 -57
- package/src/image/editor.scss +6 -44
- package/src/image/image.js +56 -27
- package/src/image/test/use-open-image-media-editor-modal.js +37 -1
- package/src/image/transforms.js +128 -0
- package/src/image/use-open-image-media-editor-modal.js +8 -1
- package/src/index.js +19 -7
- package/src/latest-posts/edit.js +5 -8
- package/src/latest-posts/index.php +49 -18
- package/src/list-item/edit.js +1 -1
- package/src/list-item/hooks/use-enter.js +15 -22
- package/src/list-item/hooks/use-indent-list-item.js +10 -1
- package/src/list-item/hooks/use-space.js +4 -6
- package/src/math/edit.js +42 -59
- package/src/media-text/edit.js +1 -0
- package/src/media-text/editor.scss +1 -0
- package/src/media-text/index.php +11 -2
- package/src/more/edit.js +7 -4
- package/src/more/editor.scss +1 -1
- package/src/navigation/edit/index.js +52 -36
- package/src/navigation/edit/test/layout-custom-properties.js +138 -0
- package/src/navigation/edit/use-layout-custom-properties.js +84 -0
- package/src/navigation/editor.scss +1 -2
- package/src/navigation/index.php +123 -12
- package/src/navigation/test/view.js +51 -0
- package/src/navigation/view.js +15 -14
- package/src/navigation-link/edit.js +11 -7
- package/src/navigation-link/editor.scss +1 -1
- package/src/navigation-link/index.php +70 -3
- package/src/navigation-link/link-ui/index.js +2 -1
- package/src/navigation-link/test/__snapshots__/hooks.js.snap +1 -1
- package/src/navigation-submenu/index.php +6 -3
- package/src/nextpage/editor.scss +1 -1
- package/src/page-list/index.php +4 -3
- package/src/paragraph/edit.js +9 -2
- package/src/paragraph/index.js +4 -1
- package/src/paragraph/use-enter.js +4 -11
- package/src/pattern/index.php +5 -5
- package/src/playlist/README.md +17 -18
- package/src/playlist/block.json +29 -10
- package/src/playlist/context.js +1 -0
- package/src/playlist/edit.js +395 -59
- package/src/playlist/editor.scss +4 -5
- package/src/playlist/index.js +1 -1
- package/src/playlist/index.php +71 -22
- package/src/playlist/style.scss +54 -1
- package/src/playlist/test/edit-component.js +139 -0
- package/src/playlist/test/edit.js +43 -2
- package/src/playlist/utils.js +49 -10
- package/src/playlist/view.js +97 -16
- package/src/playlist-track/README.md +3 -3
- package/src/playlist-track/block.json +4 -2
- package/src/playlist-track/edit.js +116 -75
- package/src/playlist-track/index.php +26 -11
- package/src/playlist-track/style.scss +10 -0
- package/src/playlist-track/test/edit.js +253 -0
- package/src/post-content/README.md +1 -0
- package/src/post-content/block.json +1 -0
- package/src/post-content/edit.js +45 -16
- package/src/post-excerpt/index.php +4 -1
- package/src/post-featured-image/edit.js +3 -2
- package/src/post-featured-image/index.php +4 -1
- package/src/post-template/README.md +1 -0
- package/src/post-template/block.json +2 -1
- package/src/post-template/edit.js +9 -0
- package/src/post-terms/edit.js +7 -4
- package/src/post-title/edit.js +5 -3
- package/src/preformatted/edit.js +7 -2
- package/src/pullquote/README.md +1 -0
- package/src/pullquote/block.json +3 -1
- package/src/pullquote/edit.js +9 -4
- package/src/pullquote/editor.scss +6 -0
- package/src/query/README.md +2 -1
- package/src/query/block.json +3 -2
- package/src/query/edit/inspector-controls/index.js +47 -4
- package/src/query/edit/inspector-controls/offset-controls.js +2 -3
- package/src/query/edit/inspector-controls/pages-control.js +0 -1
- package/src/query/edit/query-content.js +19 -3
- package/src/query/index.js +1 -0
- package/src/quote/README.md +1 -0
- package/src/quote/block.json +3 -1
- package/src/quote/transforms.js +2 -4
- package/src/read-more/edit.js +7 -2
- package/src/rss/edit.js +0 -1
- package/src/rss/index.php +10 -4
- package/src/site-tagline/edit.js +7 -2
- package/src/site-title/edit.js +7 -2
- package/src/social-link/index.php +19 -9
- package/src/social-links/edit.js +21 -12
- package/src/tab-list/README.md +4 -5
- package/src/tab-list/block.json +4 -3
- package/src/tab-list/edit.js +92 -28
- package/src/tab-list/editor.scss +9 -0
- package/src/tab-list/index.php +9 -4
- package/src/tab-list/tab-movers.js +72 -0
- package/src/tab-panel/README.md +4 -6
- package/src/tab-panel/block.json +1 -6
- package/src/tab-panel/edit.js +20 -33
- package/src/tab-panels/README.md +5 -3
- package/src/tab-panels/block.json +0 -1
- package/src/table/edit.js +1 -1
- package/src/table-of-contents/index.php +386 -1
- package/src/tabs/README.md +18 -9
- package/src/tabs/block.json +0 -5
- package/src/tabs/edit.js +7 -64
- package/src/tabs/use-tab-actions.js +32 -3
- package/src/tabs/use-tab-list-items-sync.js +24 -4
- package/src/tag-cloud/index.php +3 -2
- package/src/template-part/index.php +3 -17
- package/src/term-name/README.md +1 -1
- package/src/term-name/block.json +1 -3
- package/src/term-name/deprecated.js +74 -0
- package/src/term-name/edit.js +2 -18
- package/src/term-name/index.js +2 -0
- package/src/utils/caption.js +7 -4
- package/src/utils/media-control.scss +1 -5
- package/src/utils/test/waveform-player.js +297 -34
- package/src/utils/test/waveform-utils.js +473 -5
- package/src/utils/waveform-player.js +189 -59
- package/src/utils/waveform-utils.js +443 -40
- package/src/verse/edit.js +7 -2
- package/src/video/edit.js +0 -8
- package/src/video/editor.scss +1 -1
- package/src/video/index.php +2 -2
- package/src/video/tracks-editor.js +0 -1
- package/build/image/animated-gif-convert-control.cjs +0 -105
- package/build/image/animated-gif-convert-control.cjs.map +0 -7
- package/build/utils/gif-conversion-attributes.cjs +0 -40
- package/build/utils/gif-conversion-attributes.cjs.map +0 -7
- package/build/video/gif-restore-control.cjs +0 -73
- package/build/video/gif-restore-control.cjs.map +0 -7
- package/build-module/image/animated-gif-convert-control.mjs +0 -87
- package/build-module/image/animated-gif-convert-control.mjs.map +0 -7
- package/build-module/utils/gif-conversion-attributes.mjs +0 -15
- package/build-module/utils/gif-conversion-attributes.mjs.map +0 -7
- package/build-module/video/gif-restore-control.mjs +0 -55
- package/build-module/video/gif-restore-control.mjs.map +0 -7
- package/src/image/animated-gif-convert-control.js +0 -135
- package/src/image/test/animated-gif-convert-control.js +0 -276
- package/src/utils/gif-conversion-attributes.js +0 -30
- package/src/utils/test/gif-conversion-attributes.js +0 -60
- package/src/video/gif-restore-control.js +0 -92
|
@@ -60,7 +60,9 @@ function SiteTitleEdit(props) {
|
|
|
60
60
|
onChange: setTitle,
|
|
61
61
|
allowedFormats: [],
|
|
62
62
|
disableLineBreaks: true,
|
|
63
|
-
__unstableOnSplitAtEnd: () => insertBlocksAfter(
|
|
63
|
+
__unstableOnSplitAtEnd: insertBlocksAfter ? () => insertBlocksAfter(
|
|
64
|
+
createBlock(getDefaultBlockName())
|
|
65
|
+
) : void 0
|
|
64
66
|
}
|
|
65
67
|
) }) : /* @__PURE__ */ jsx(TagName, { ...blockProps, children: isLink ? /* @__PURE__ */ jsx(
|
|
66
68
|
"a",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/site-title/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tRichText,\n\tInspectorControls,\n\tBlockControls,\n\tuseBlockProps,\n\tHeadingLevelDropdown,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\nimport useDeprecatedTextAlign from '../utils/deprecated-text-align-attributes';\n\nexport default function SiteTitleEdit( props ) {\n\tuseDeprecatedTextAlign( props );\n\n\tconst { attributes, setAttributes, insertBlocksAfter } = props;\n\n\tconst { level, levelOptions, isLink, linkTarget } = attributes;\n\tconst { canUserEdit, title } = useSelect( ( select ) => {\n\t\tconst { canUser, getEntityRecord, getEditedEntityRecord } =\n\t\t\tselect( coreStore );\n\t\tconst canEdit = canUser( 'update', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} );\n\t\tconst settings = canEdit ? getEditedEntityRecord( 'root', 'site' ) : {};\n\t\tconst readOnlySettings = getEntityRecord( 'root', '__unstableBase' );\n\n\t\treturn {\n\t\t\tcanUserEdit: canEdit,\n\t\t\ttitle: canEdit ? settings?.title : readOnlySettings?.name,\n\t\t};\n\t}, [] );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tfunction setTitle( newTitle ) {\n\t\teditEntityRecord( 'root', 'site', undefined, {\n\t\t\ttitle: newTitle.trim(),\n\t\t} );\n\t}\n\n\tconst TagName = level === 0 ? 'p' : `h${ level }`;\n\tconst blockProps = useBlockProps( {\n\t\tclassName:\n\t\t\t! canUserEdit && ! title && 'wp-block-site-title__placeholder',\n\t} );\n\tconst siteTitleContent = canUserEdit ? (\n\t\t<TagName { ...blockProps }>\n\t\t\t<RichText\n\t\t\t\ttagName={ isLink ? 'a' : 'span' }\n\t\t\t\thref={ isLink ? '#site-title-pseudo-link' : undefined }\n\t\t\t\taria-label={ __( 'Site title text' ) }\n\t\t\t\tplaceholder={ __( 'Write site title…' ) }\n\t\t\t\tvalue={ title }\n\t\t\t\tonChange={ setTitle }\n\t\t\t\tallowedFormats={ [] }\n\t\t\t\tdisableLineBreaks\n\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\tinsertBlocksAfter(
|
|
5
|
-
"mappings": ";AAGA,SAAS,aAAa,iBAAiB;AACvC,SAAS,SAAS,iBAAiB;AACnC,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,OAC1B;AACP,SAAS,aAAa,2BAA2B;AACjD,SAAS,sBAAsB;AAK/B,SAAS,sCAAsC;AAC/C,OAAO,4BAA4B;AAwChC,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tRichText,\n\tInspectorControls,\n\tBlockControls,\n\tuseBlockProps,\n\tHeadingLevelDropdown,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\nimport useDeprecatedTextAlign from '../utils/deprecated-text-align-attributes';\n\nexport default function SiteTitleEdit( props ) {\n\tuseDeprecatedTextAlign( props );\n\n\tconst { attributes, setAttributes, insertBlocksAfter } = props;\n\n\tconst { level, levelOptions, isLink, linkTarget } = attributes;\n\tconst { canUserEdit, title } = useSelect( ( select ) => {\n\t\tconst { canUser, getEntityRecord, getEditedEntityRecord } =\n\t\t\tselect( coreStore );\n\t\tconst canEdit = canUser( 'update', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} );\n\t\tconst settings = canEdit ? getEditedEntityRecord( 'root', 'site' ) : {};\n\t\tconst readOnlySettings = getEntityRecord( 'root', '__unstableBase' );\n\n\t\treturn {\n\t\t\tcanUserEdit: canEdit,\n\t\t\ttitle: canEdit ? settings?.title : readOnlySettings?.name,\n\t\t};\n\t}, [] );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tfunction setTitle( newTitle ) {\n\t\teditEntityRecord( 'root', 'site', undefined, {\n\t\t\ttitle: newTitle.trim(),\n\t\t} );\n\t}\n\n\tconst TagName = level === 0 ? 'p' : `h${ level }`;\n\tconst blockProps = useBlockProps( {\n\t\tclassName:\n\t\t\t! canUserEdit && ! title && 'wp-block-site-title__placeholder',\n\t} );\n\tconst siteTitleContent = canUserEdit ? (\n\t\t<TagName { ...blockProps }>\n\t\t\t<RichText\n\t\t\t\ttagName={ isLink ? 'a' : 'span' }\n\t\t\t\thref={ isLink ? '#site-title-pseudo-link' : undefined }\n\t\t\t\taria-label={ __( 'Site title text' ) }\n\t\t\t\tplaceholder={ __( 'Write site title…' ) }\n\t\t\t\tvalue={ title }\n\t\t\t\tonChange={ setTitle }\n\t\t\t\tallowedFormats={ [] }\n\t\t\t\tdisableLineBreaks\n\t\t\t\t__unstableOnSplitAtEnd={\n\t\t\t\t\tinsertBlocksAfter\n\t\t\t\t\t\t? () =>\n\t\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t/>\n\t\t</TagName>\n\t) : (\n\t\t<TagName { ...blockProps }>\n\t\t\t{ isLink ? (\n\t\t\t\t<a\n\t\t\t\t\thref=\"#site-title-pseudo-link\"\n\t\t\t\t\tonClick={ ( event ) => event.preventDefault() }\n\t\t\t\t>\n\t\t\t\t\t{ decodeEntities( title ) ||\n\t\t\t\t\t\t__( 'Site Title placeholder' ) }\n\t\t\t\t</a>\n\t\t\t) : (\n\t\t\t\t<span>\n\t\t\t\t\t{ decodeEntities( title ) ||\n\t\t\t\t\t\t__( 'Site Title placeholder' ) }\n\t\t\t\t</span>\n\t\t\t) }\n\t\t</TagName>\n\t);\n\treturn (\n\t\t<>\n\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t<HeadingLevelDropdown\n\t\t\t\t\t\tvalue={ level }\n\t\t\t\t\t\toptions={ levelOptions }\n\t\t\t\t\t\tonChange={ ( newLevel ) =>\n\t\t\t\t\t\t\tsetAttributes( { level: newLevel } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\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\tsetAttributes( {\n\t\t\t\t\t\t\tisLink: true,\n\t\t\t\t\t\t\tlinkTarget: '_self',\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\thasValue={ () => ! isLink }\n\t\t\t\t\t\tlabel={ __( 'Make title link to home' ) }\n\t\t\t\t\t\tonDeselect={ () => setAttributes( { isLink: true } ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Make title link to home' ) }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { isLink: ! isLink } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tchecked={ isLink }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t{ isLink && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => linkTarget !== '_self' }\n\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { linkTarget: '_self' } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlinkTarget: value ? '_blank' : '_self',\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\tchecked={ linkTarget === '_blank' }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t{ siteTitleContent }\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,aAAa,iBAAiB;AACvC,SAAS,SAAS,iBAAiB;AACnC,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,OAC1B;AACP,SAAS,aAAa,2BAA2B;AACjD,SAAS,sBAAsB;AAK/B,SAAS,sCAAsC;AAC/C,OAAO,4BAA4B;AAwChC,SAsCD,UAtCC,KAmDC,YAnDD;AAtCY,SAAR,cAAgC,OAAQ;AAC9C,yBAAwB,KAAM;AAE9B,QAAM,EAAE,YAAY,eAAe,kBAAkB,IAAI;AAEzD,QAAM,EAAE,OAAO,cAAc,QAAQ,WAAW,IAAI;AACpD,QAAM,EAAE,aAAa,MAAM,IAAI,UAAW,CAAE,WAAY;AACvD,UAAM,EAAE,SAAS,iBAAiB,sBAAsB,IACvD,OAAQ,SAAU;AACnB,UAAM,UAAU,QAAS,UAAU;AAAA,MAClC,MAAM;AAAA,MACN,MAAM;AAAA,IACP,CAAE;AACF,UAAM,WAAW,UAAU,sBAAuB,QAAQ,MAAO,IAAI,CAAC;AACtE,UAAM,mBAAmB,gBAAiB,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ACV,UAAW,CAAE,aACZ,cAAe,EAAE,OAAO,SAAS,CAAE;AAAA;AAAA,IAErC,GACD;AAAA,IAED,oBAAC,qBACA;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ,GAAI,UAAW;AAAA,QACvB,UAAW,MAAM;AAChB,wBAAe;AAAA,YACd,QAAQ;AAAA,YACR,YAAY;AAAA,UACb,CAAE;AAAA,QACH;AAAA,QACA;AAAA,QAEA;AAAA;AAAA,YAAC;AAAA;AAAA,cACA,UAAW,MAAM,CAAE;AAAA,cACnB,OAAQ,GAAI,yBAA0B;AAAA,cACtC,YAAa,MAAM,cAAe,EAAE,QAAQ,KAAK,CAAE;AAAA,cACnD,kBAAgB;AAAA,cAEhB;AAAA,gBAAC;AAAA;AAAA,kBACA,OAAQ,GAAI,yBAA0B;AAAA,kBACtC,UAAW,MACV,cAAe,EAAE,QAAQ,CAAE,OAAO,CAAE;AAAA,kBAErC,SAAU;AAAA;AAAA,cACX;AAAA;AAAA,UACD;AAAA,UACE,UACD;AAAA,YAAC;AAAA;AAAA,cACA,UAAW,MAAM,eAAe;AAAA,cAChC,OAAQ,GAAI,iBAAkB;AAAA,cAC9B,YAAa,MACZ,cAAe,EAAE,YAAY,QAAQ,CAAE;AAAA,cAExC,kBAAgB;AAAA,cAEhB;AAAA,gBAAC;AAAA;AAAA,kBACA,OAAQ,GAAI,iBAAkB;AAAA,kBAC9B,UAAW,CAAE,UACZ,cAAe;AAAA,oBACd,YAAY,QAAQ,WAAW;AAAA,kBAChC,CAAE;AAAA,kBAEH,SAAU,eAAe;AAAA;AAAA,cAC1B;AAAA;AAAA,UACD;AAAA;AAAA;AAAA,IAEF,GACD;AAAA,IACE;AAAA,KACH;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
} from "@wordpress/components";
|
|
21
21
|
import { __ } from "@wordpress/i18n";
|
|
22
22
|
import { useSelect } from "@wordpress/data";
|
|
23
|
+
import { unlock } from "../lock-unlock.mjs";
|
|
23
24
|
import { useToolsPanelDropdownMenuProps } from "../utils/hooks.mjs";
|
|
24
25
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
25
26
|
var sizeOptions = [
|
|
@@ -47,12 +48,17 @@ function SocialLinksEdit(props) {
|
|
|
47
48
|
showLabels,
|
|
48
49
|
size
|
|
49
50
|
} = attributes;
|
|
50
|
-
const { hasSocialIcons, hasSelectedChild } = useSelect(
|
|
51
|
+
const { hasSocialIcons, hasSelectedChild, hasSelectedStyleState } = useSelect(
|
|
51
52
|
(select) => {
|
|
52
|
-
const {
|
|
53
|
+
const {
|
|
54
|
+
getBlockCount,
|
|
55
|
+
hasSelectedInnerBlock,
|
|
56
|
+
hasSelectedStyleState: hasSelectedBlockStyleState
|
|
57
|
+
} = unlock(select(blockEditorStore));
|
|
53
58
|
return {
|
|
54
59
|
hasSocialIcons: getBlockCount(clientId) > 0,
|
|
55
|
-
hasSelectedChild: hasSelectedInnerBlock(clientId)
|
|
60
|
+
hasSelectedChild: hasSelectedInnerBlock(clientId),
|
|
61
|
+
hasSelectedStyleState: hasSelectedBlockStyleState(clientId)
|
|
56
62
|
};
|
|
57
63
|
},
|
|
58
64
|
[clientId]
|
|
@@ -125,6 +131,7 @@ function SocialLinksEdit(props) {
|
|
|
125
131
|
});
|
|
126
132
|
}
|
|
127
133
|
const colorGradientSettings = useMultipleOriginColorsAndGradients();
|
|
134
|
+
const showColorControls = colorGradientSettings.hasColorsOrGradients && !hasSelectedStyleState;
|
|
128
135
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
129
136
|
/* @__PURE__ */ jsx(InspectorControls, { children: /* @__PURE__ */ jsxs(
|
|
130
137
|
ToolsPanel,
|
|
@@ -200,7 +207,7 @@ function SocialLinksEdit(props) {
|
|
|
200
207
|
]
|
|
201
208
|
}
|
|
202
209
|
) }),
|
|
203
|
-
|
|
210
|
+
showColorControls && /* @__PURE__ */ jsxs(InspectorControls, { group: "color", children: [
|
|
204
211
|
colorSettings.map(
|
|
205
212
|
({ onChange, label, value, resetAllFilter }) => /* @__PURE__ */ jsx(
|
|
206
213
|
ColorGradientSettingsDropdown,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/social-links/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport {\n\tuseInnerBlocksProps,\n\tuseBlockProps,\n\tInspectorControls,\n\tContrastChecker,\n\twithColors,\n\tInnerBlocks,\n\t__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,\n\t__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\tSelectControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst sizeOptions = [\n\t{ label: __( 'Default' ), value: '' },\n\t{ label: __( 'Small' ), value: 'has-small-icon-size' },\n\t{ label: __( 'Normal' ), value: 'has-normal-icon-size' },\n\t{ label: __( 'Large' ), value: 'has-large-icon-size' },\n\t{ label: __( 'Huge' ), value: 'has-huge-icon-size' },\n];\n\nexport function SocialLinksEdit( props ) {\n\tconst {\n\t\tclientId,\n\t\tattributes,\n\t\ticonBackgroundColor,\n\t\ticonColor,\n\t\tisSelected,\n\t\tsetAttributes,\n\t\tsetIconBackgroundColor,\n\t\tsetIconColor,\n\t} = props;\n\n\tconst {\n\t\ticonBackgroundColorValue,\n\t\ticonColorValue,\n\t\topenInNewTab,\n\t\tshowLabels,\n\t\tsize,\n\t} = attributes;\n\n\tconst { hasSocialIcons, hasSelectedChild }
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,iBAAiB;AAC1B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,+CAA+C;AAAA,EAC/C,qDAAqD;AAAA,EACrD,SAAS;AAAA,OACH;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,OAC1B;AACP,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAK1B,SAAS,sCAAsC;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport {\n\tuseInnerBlocksProps,\n\tuseBlockProps,\n\tInspectorControls,\n\tContrastChecker,\n\twithColors,\n\tInnerBlocks,\n\t__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,\n\t__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\tSelectControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst sizeOptions = [\n\t{ label: __( 'Default' ), value: '' },\n\t{ label: __( 'Small' ), value: 'has-small-icon-size' },\n\t{ label: __( 'Normal' ), value: 'has-normal-icon-size' },\n\t{ label: __( 'Large' ), value: 'has-large-icon-size' },\n\t{ label: __( 'Huge' ), value: 'has-huge-icon-size' },\n];\n\nexport function SocialLinksEdit( props ) {\n\tconst {\n\t\tclientId,\n\t\tattributes,\n\t\ticonBackgroundColor,\n\t\ticonColor,\n\t\tisSelected,\n\t\tsetAttributes,\n\t\tsetIconBackgroundColor,\n\t\tsetIconColor,\n\t} = props;\n\n\tconst {\n\t\ticonBackgroundColorValue,\n\t\ticonColorValue,\n\t\topenInNewTab,\n\t\tshowLabels,\n\t\tsize,\n\t} = attributes;\n\n\tconst { hasSocialIcons, hasSelectedChild, hasSelectedStyleState } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetBlockCount,\n\t\t\t\t\thasSelectedInnerBlock,\n\t\t\t\t\thasSelectedStyleState: hasSelectedBlockStyleState,\n\t\t\t\t} = unlock( select( blockEditorStore ) );\n\t\t\t\treturn {\n\t\t\t\t\thasSocialIcons: getBlockCount( clientId ) > 0,\n\t\t\t\t\thasSelectedChild: hasSelectedInnerBlock( clientId ),\n\t\t\t\t\thasSelectedStyleState:\n\t\t\t\t\t\thasSelectedBlockStyleState( clientId ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId ]\n\t\t);\n\n\tconst hasAnySelected = isSelected || hasSelectedChild;\n\n\tconst logosOnly = attributes.className?.includes( 'is-style-logos-only' );\n\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\t// Remove icon background color when logos only style is selected or\n\t// restore it when any other style is selected.\n\tuseEffect( () => {\n\t\tif ( logosOnly ) {\n\t\t\tlet restore;\n\t\t\tsetAttributes( ( prev ) => {\n\t\t\t\trestore = {\n\t\t\t\t\ticonBackgroundColor: prev.iconBackgroundColor,\n\t\t\t\t\ticonBackgroundColorValue: prev.iconBackgroundColorValue,\n\t\t\t\t\tcustomIconBackgroundColor: prev.customIconBackgroundColor,\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\ticonBackgroundColor: undefined,\n\t\t\t\t\ticonBackgroundColorValue: undefined,\n\t\t\t\t\tcustomIconBackgroundColor: undefined,\n\t\t\t\t};\n\t\t\t} );\n\n\t\t\treturn () => setAttributes( { ...restore } );\n\t\t}\n\t}, [ logosOnly, setAttributes ] );\n\n\t// Fallback color values are used maintain selections in case switching\n\t// themes and named colors in palette do not match.\n\tconst className = clsx( size, {\n\t\t'has-visible-labels': showLabels,\n\t\t'has-icon-color': iconColor.color || iconColorValue,\n\t\t'has-icon-background-color':\n\t\t\ticonBackgroundColor.color || iconBackgroundColorValue,\n\t} );\n\n\tconst blockProps = useBlockProps( { className } );\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplateLock: false,\n\t\torientation: attributes.layout?.orientation ?? 'horizontal',\n\t\t__experimentalAppenderTagName: 'li',\n\t\trenderAppender:\n\t\t\t! hasSocialIcons || hasAnySelected\n\t\t\t\t? InnerBlocks.ButtonBlockAppender\n\t\t\t\t: undefined,\n\t} );\n\n\tconst colorSettings = [\n\t\t{\n\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\tvalue: iconColor.color || iconColorValue,\n\t\t\tonChange: ( colorValue ) => {\n\t\t\t\tsetIconColor( colorValue );\n\t\t\t\tsetAttributes( { iconColorValue: colorValue } );\n\t\t\t},\n\t\t\tlabel: __( 'Icon color' ),\n\t\t\tresetAllFilter: () => {\n\t\t\t\tsetIconColor( undefined );\n\t\t\t\tsetAttributes( { iconColorValue: undefined } );\n\t\t\t},\n\t\t},\n\t];\n\n\tif ( ! logosOnly ) {\n\t\tcolorSettings.push( {\n\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\tvalue: iconBackgroundColor.color || iconBackgroundColorValue,\n\t\t\tonChange: ( colorValue ) => {\n\t\t\t\tsetIconBackgroundColor( colorValue );\n\t\t\t\tsetAttributes( {\n\t\t\t\t\ticonBackgroundColorValue: colorValue,\n\t\t\t\t} );\n\t\t\t},\n\t\t\tlabel: __( 'Icon background' ),\n\t\t\tresetAllFilter: () => {\n\t\t\t\tsetIconBackgroundColor( undefined );\n\t\t\t\tsetAttributes( { iconBackgroundColorValue: undefined } );\n\t\t\t},\n\t\t} );\n\t}\n\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\tconst showColorControls =\n\t\tcolorGradientSettings.hasColorsOrGradients && ! hasSelectedStyleState;\n\n\treturn (\n\t\t<>\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\tsetAttributes( {\n\t\t\t\t\t\t\topenInNewTab: false,\n\t\t\t\t\t\t\tshowLabels: false,\n\t\t\t\t\t\t\tsize: undefined,\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\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! size }\n\t\t\t\t\t\tlabel={ __( 'Icon size' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { size: undefined } )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\tlabel={ __( 'Icon size' ) }\n\t\t\t\t\t\t\tonChange={ ( newSize ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tsize: newSize === '' ? undefined : newSize,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tvalue={ size ?? '' }\n\t\t\t\t\t\t\toptions={ sizeOptions }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\tlabel={ __( 'Show text' ) }\n\t\t\t\t\t\thasValue={ () => !! showLabels }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { showLabels: false } )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Show text' ) }\n\t\t\t\t\t\t\tchecked={ showLabels }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { showLabels: ! showLabels } )\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\t<ToolsPanelItem\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\tlabel={ __( 'Open links in new tab' ) }\n\t\t\t\t\t\thasValue={ () => !! openInNewTab }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { openInNewTab: false } )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Open links in new tab' ) }\n\t\t\t\t\t\t\tchecked={ openInNewTab }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\topenInNewTab: ! openInNewTab,\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\t{ showColorControls && (\n\t\t\t\t<InspectorControls group=\"color\">\n\t\t\t\t\t{ colorSettings.map(\n\t\t\t\t\t\t( { onChange, label, value, resetAllFilter } ) => (\n\t\t\t\t\t\t\t<ColorGradientSettingsDropdown\n\t\t\t\t\t\t\t\tkey={ `social-links-color-${ label }` }\n\t\t\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\t\t\tsettings={ [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcolorValue: value,\n\t\t\t\t\t\t\t\t\t\tlabel,\n\t\t\t\t\t\t\t\t\t\tonColorChange: onChange,\n\t\t\t\t\t\t\t\t\t\tisShownByDefault: true,\n\t\t\t\t\t\t\t\t\t\tresetAllFilter,\n\t\t\t\t\t\t\t\t\t\tenableAlpha: true,\n\t\t\t\t\t\t\t\t\t\tclearable: true,\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\tpanelId={ clientId }\n\t\t\t\t\t\t\t\t{ ...colorGradientSettings }\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{ ! logosOnly && (\n\t\t\t\t\t\t<ContrastChecker\n\t\t\t\t\t\t\t{ ...{\n\t\t\t\t\t\t\t\ttextColor: iconColorValue,\n\t\t\t\t\t\t\t\tbackgroundColor: iconBackgroundColorValue,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tisLargeText={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t<ul { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n\nconst iconColorAttributes = {\n\ticonColor: 'icon-color',\n\ticonBackgroundColor: 'icon-background-color',\n};\n\nexport default withColors( iconColorAttributes )( SocialLinksEdit );\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,iBAAiB;AAC1B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,+CAA+C;AAAA,EAC/C,qDAAqD;AAAA,EACrD,SAAS;AAAA,OACH;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,OAC1B;AACP,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAK1B,SAAS,cAAc;AACvB,SAAS,sCAAsC;AAyI7C,mBAqBI,KAnBF,YAFF;AAvIF,IAAM,cAAc;AAAA,EACnB,EAAE,OAAO,GAAI,SAAU,GAAG,OAAO,GAAG;AAAA,E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A,oBACd,cAAc,CAAE;AAAA,kBACjB,CAAE;AAAA;AAAA,cAEJ;AAAA;AAAA,UACD;AAAA;AAAA;AAAA,IACD,GACD;AAAA,IACE,qBACD,qBAAC,qBAAkB,OAAM,SACtB;AAAA,oBAAc;AAAA,QACf,CAAE,EAAE,UAAU,OAAO,OAAO,eAAe,MAC1C;AAAA,UAAC;AAAA;AAAA,YAEA,mCAAiC;AAAA,YACjC,UAAW;AAAA,cACV;AAAA,gBACC,YAAY;AAAA,gBACZ;AAAA,gBACA,eAAe;AAAA,gBACf,kBAAkB;AAAA,gBAClB;AAAA,gBACA,aAAa;AAAA,gBACb,WAAW;AAAA,cACZ;AAAA,YACD;AAAA,YACA,SAAU;AAAA,YACR,GAAG;AAAA;AAAA,UAdC,sBAAuB,KAAM;AAAA,QAepC;AAAA,MAEF;AAAA,MACE,CAAE,aACH;AAAA,QAAC;AAAA;AAAA,UACE,GAAG;AAAA,YACJ,WAAW;AAAA,YACX,iBAAiB;AAAA,UAClB;AAAA,UACA,aAAc;AAAA;AAAA,MACf;AAAA,OAEF;AAAA,IAED,oBAAC,QAAK,GAAG,kBAAmB;AAAA,KAC7B;AAEF;AAEA,IAAM,sBAAsB;AAAA,EAC3B,WAAW;AAAA,EACX,qBAAqB;AACtB;AAEA,IAAO,eAAQ,WAAY,mBAAoB,EAAG,eAAgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
-
"__experimental": true,
|
|
4
3
|
"apiVersion": 3,
|
|
5
4
|
"name": "core/tab-list",
|
|
6
5
|
"title": "Tab List",
|
|
@@ -26,6 +25,7 @@
|
|
|
26
25
|
},
|
|
27
26
|
"supports": {
|
|
28
27
|
"html": false,
|
|
28
|
+
"ariaLabel": true,
|
|
29
29
|
"visibility": false,
|
|
30
30
|
"lock": false,
|
|
31
31
|
"color": {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"layout": {
|
|
52
52
|
"default": {
|
|
53
53
|
"type": "flex",
|
|
54
|
-
"flexWrap": "
|
|
54
|
+
"flexWrap": "wrap"
|
|
55
55
|
},
|
|
56
56
|
"allowVerticalAlignment": false,
|
|
57
57
|
"allowOrientation": false,
|
|
@@ -77,5 +77,6 @@
|
|
|
77
77
|
"padding": ".wp-block-tab-list button"
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
|
-
"style": "wp-block-tab-list"
|
|
80
|
+
"style": "wp-block-tab-list",
|
|
81
|
+
"editorStyle": "wp-block-tab-list-editor"
|
|
81
82
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import clsx from "clsx";
|
|
3
3
|
import { __ } from "@wordpress/i18n";
|
|
4
4
|
import {
|
|
5
|
+
InspectorControls,
|
|
5
6
|
useBlockProps,
|
|
6
7
|
store as blockEditorStore,
|
|
7
8
|
RichText,
|
|
@@ -9,44 +10,71 @@ import {
|
|
|
9
10
|
__experimentalUseColorProps as useColorProps,
|
|
10
11
|
__experimentalGetSpacingClassesAndStyles as getSpacingClassesAndStyles
|
|
11
12
|
} from "@wordpress/block-editor";
|
|
12
|
-
import {
|
|
13
|
-
|
|
13
|
+
import {
|
|
14
|
+
TextControl,
|
|
15
|
+
__experimentalToolsPanel as ToolsPanel,
|
|
16
|
+
__experimentalToolsPanelItem as ToolsPanelItem
|
|
17
|
+
} from "@wordpress/components";
|
|
18
|
+
import { useSelect, useDispatch, useRegistry } from "@wordpress/data";
|
|
19
|
+
import { useEffect, useMemo, useRef } from "@wordpress/element";
|
|
14
20
|
import TabToolbarControls from "../tabs/tab-toolbar-controls.mjs";
|
|
21
|
+
import TabMovers from "./tab-movers.mjs";
|
|
15
22
|
import useTabActions from "../tabs/use-tab-actions.mjs";
|
|
23
|
+
import { useToolsPanelDropdownMenuProps } from "../utils/hooks.mjs";
|
|
16
24
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
17
25
|
var EMPTY_ARRAY = [];
|
|
18
26
|
function Edit({
|
|
19
27
|
attributes,
|
|
20
28
|
clientId,
|
|
21
|
-
|
|
29
|
+
setAttributes,
|
|
22
30
|
__unstableLayoutClassNames: layoutClassNames
|
|
23
31
|
}) {
|
|
24
|
-
const
|
|
32
|
+
const { ariaLabel } = attributes;
|
|
25
33
|
const colorProps = useColorProps(attributes);
|
|
26
34
|
const borderProps = useBorderProps(attributes);
|
|
27
35
|
const spacingProps = getSpacingClassesAndStyles(attributes);
|
|
28
|
-
const
|
|
36
|
+
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
37
|
+
const { tabsClientId, tabPanels, editorActiveTabIndex, activeTabIndex } = useSelect(
|
|
29
38
|
(select) => {
|
|
30
|
-
const { getBlockRootClientId, getBlockAttributes } = select(blockEditorStore);
|
|
31
|
-
const
|
|
32
|
-
const tabsAttributes =
|
|
39
|
+
const { getBlockRootClientId, getBlockAttributes, getBlocks } = select(blockEditorStore);
|
|
40
|
+
const rootClientId = getBlockRootClientId(clientId);
|
|
41
|
+
const tabsAttributes = getBlockAttributes(rootClientId);
|
|
42
|
+
const tabPanelsBlock = getBlocks(rootClientId)?.find(
|
|
43
|
+
(block) => block.name === "core/tab-panels"
|
|
44
|
+
);
|
|
33
45
|
return {
|
|
34
|
-
tabsClientId:
|
|
46
|
+
tabsClientId: rootClientId,
|
|
47
|
+
tabPanels: tabPanelsBlock?.innerBlocks ?? EMPTY_ARRAY,
|
|
35
48
|
editorActiveTabIndex: tabsAttributes?.editorActiveTabIndex,
|
|
36
49
|
activeTabIndex: tabsAttributes?.activeTabIndex ?? 0
|
|
37
50
|
};
|
|
38
51
|
},
|
|
39
52
|
[clientId]
|
|
40
53
|
);
|
|
54
|
+
const registry = useRegistry();
|
|
41
55
|
const { isBlockSelected, hasSelectedInnerBlock } = useSelect(blockEditorStore);
|
|
42
|
-
const {
|
|
56
|
+
const {
|
|
57
|
+
updateBlockAttributes,
|
|
58
|
+
selectBlock,
|
|
59
|
+
__unstableMarkNextChangeAsNotPersistent
|
|
60
|
+
} = useDispatch(blockEditorStore);
|
|
43
61
|
const { insertTab, removeTab } = useTabActions(tabsClientId);
|
|
44
62
|
const effectiveActiveIndex = editorActiveTabIndex ?? activeTabIndex;
|
|
63
|
+
const tabsList = useMemo(
|
|
64
|
+
() => tabPanels.map((tab) => ({
|
|
65
|
+
label: tab.attributes.label || "",
|
|
66
|
+
clientId: tab.clientId
|
|
67
|
+
})),
|
|
68
|
+
[tabPanels]
|
|
69
|
+
);
|
|
45
70
|
function selectTabPanel(tabIndex) {
|
|
46
71
|
if (tabsClientId && tabIndex !== effectiveActiveIndex) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
72
|
+
registry.batch(() => {
|
|
73
|
+
selectBlock(clientId);
|
|
74
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
75
|
+
updateBlockAttributes(tabsClientId, {
|
|
76
|
+
editorActiveTabIndex: tabIndex
|
|
77
|
+
});
|
|
50
78
|
});
|
|
51
79
|
}
|
|
52
80
|
}
|
|
@@ -95,6 +123,39 @@ function Edit({
|
|
|
95
123
|
...spacingProps.style
|
|
96
124
|
};
|
|
97
125
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
126
|
+
/* @__PURE__ */ jsx(InspectorControls, { group: "settings", children: /* @__PURE__ */ jsx(
|
|
127
|
+
ToolsPanel,
|
|
128
|
+
{
|
|
129
|
+
label: __("Settings"),
|
|
130
|
+
resetAll: () => setAttributes({
|
|
131
|
+
ariaLabel: void 0
|
|
132
|
+
}),
|
|
133
|
+
dropdownMenuProps,
|
|
134
|
+
children: /* @__PURE__ */ jsx(
|
|
135
|
+
ToolsPanelItem,
|
|
136
|
+
{
|
|
137
|
+
label: __("Label"),
|
|
138
|
+
isShownByDefault: true,
|
|
139
|
+
hasValue: () => !!ariaLabel,
|
|
140
|
+
onDeselect: () => setAttributes({ ariaLabel: void 0 }),
|
|
141
|
+
children: /* @__PURE__ */ jsx(
|
|
142
|
+
TextControl,
|
|
143
|
+
{
|
|
144
|
+
label: __("Label"),
|
|
145
|
+
help: __(
|
|
146
|
+
"Briefly describe this tab section for screen reader users. Examples: Event information, Product details, and Account settings."
|
|
147
|
+
),
|
|
148
|
+
value: ariaLabel || "",
|
|
149
|
+
onChange: (value) => setAttributes({
|
|
150
|
+
ariaLabel: value || void 0
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
)
|
|
154
|
+
}
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
) }),
|
|
158
|
+
/* @__PURE__ */ jsx(TabMovers, { tabsClientId }),
|
|
98
159
|
/* @__PURE__ */ jsx(TabToolbarControls, { tabsClientId }),
|
|
99
160
|
/* @__PURE__ */ jsx("div", { ...blockProps, children: tabsList.map((tab, index) => {
|
|
100
161
|
const isActive = index === effectiveActiveIndex;
|
|
@@ -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 { 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\
|
|
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;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tInspectorControls,\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 {\n\tTextControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useSelect, useDispatch, useRegistry } from '@wordpress/data';\nimport { useEffect, useMemo, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport TabToolbarControls from '../tabs/tab-toolbar-controls';\nimport TabMovers from './tab-movers';\nimport useTabActions from '../tabs/use-tab-actions';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst EMPTY_ARRAY = [];\n\nfunction Edit( {\n\tattributes,\n\tclientId,\n\tsetAttributes,\n\t__unstableLayoutClassNames: layoutClassNames,\n} ) {\n\tconst { ariaLabel } = attributes;\n\n\tconst colorProps = useColorProps( attributes );\n\tconst borderProps = useBorderProps( attributes );\n\tconst spacingProps = getSpacingClassesAndStyles( attributes );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tconst { tabsClientId, tabPanels, editorActiveTabIndex, activeTabIndex } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getBlockRootClientId, getBlockAttributes, getBlocks } =\n\t\t\t\t\tselect( blockEditorStore );\n\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\tconst tabsAttributes = getBlockAttributes( rootClientId );\n\t\t\t\tconst tabPanelsBlock = getBlocks( rootClientId )?.find(\n\t\t\t\t\t( block ) => block.name === 'core/tab-panels'\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\ttabsClientId: rootClientId,\n\t\t\t\t\ttabPanels: tabPanelsBlock?.innerBlocks ?? EMPTY_ARRAY,\n\t\t\t\t\teditorActiveTabIndex: tabsAttributes?.editorActiveTabIndex,\n\t\t\t\t\tactiveTabIndex: tabsAttributes?.activeTabIndex ?? 0,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId ]\n\t\t);\n\tconst registry = useRegistry();\n\tconst { isBlockSelected, hasSelectedInnerBlock } =\n\t\tuseSelect( blockEditorStore );\n\tconst {\n\t\tupdateBlockAttributes,\n\t\tselectBlock,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = useDispatch( blockEditorStore );\n\tconst { insertTab, removeTab } = useTabActions( tabsClientId );\n\n\tconst effectiveActiveIndex = editorActiveTabIndex ?? activeTabIndex;\n\tconst tabsList = useMemo(\n\t\t() =>\n\t\t\ttabPanels.map( ( tab ) => ( {\n\t\t\t\tlabel: tab.attributes.label || '',\n\t\t\t\tclientId: tab.clientId,\n\t\t\t} ) ),\n\t\t[ tabPanels ]\n\t);\n\n\tfunction selectTabPanel( tabIndex ) {\n\t\tif ( tabsClientId && tabIndex !== effectiveActiveIndex ) {\n\t\t\t// Batch the selection and index update so the sync effect in\n\t\t\t// the tab-panel block can't revert the switch from a stale\n\t\t\t// inner-block selection in the previously active panel.\n\t\t\tregistry.batch( () => {\n\t\t\t\tselectBlock( clientId );\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tupdateBlockAttributes( tabsClientId, {\n\t\t\t\t\teditorActiveTabIndex: tabIndex,\n\t\t\t\t} );\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<InspectorControls group=\"settings\">\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\tsetAttributes( {\n\t\t\t\t\t\t\tariaLabel: undefined,\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={ __( 'Label' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! ariaLabel }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { ariaLabel: undefined } )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\tlabel={ __( 'Label' ) }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Briefly describe this tab section for screen reader users. Examples: Event information, Product details, and Account settings.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tvalue={ ariaLabel || '' }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tariaLabel: value || undefined,\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\t<TabMovers tabsClientId={ tabsClientId } />\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,UAAU;AAKjB,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA,gCAAgC;AAAA,EAChC,+BAA+B;AAAA,EAC/B,4CAA4C;AAAA,OACtC;AACP;AAAA,EACC;AAAA,EACA,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,OAC1B;AACP,SAAS,WAAW,aAAa,mBAAmB;AACpD,SAAS,WAAW,SAAS,cAAc;AAK3C,OAAO,wBAAwB;AAC/B,OAAO,eAAe;AACtB,OAAO,mBAAmB;AAC1B,SAAS,sCAAsC;AAwI7C,mBAmBI,KAnBJ;AAtIF,IAAM,cAAc,CAAC;AAErB,SAAS,KAAM;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA,4BAA4B;AAC7B,GAAI;AACH,QAAM,EAAE,UAAU,IAAI;AAE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tab-list/tab-movers.js
|
|
2
|
+
import { __, isRTL } from "@wordpress/i18n";
|
|
3
|
+
import {
|
|
4
|
+
BlockControls,
|
|
5
|
+
store as blockEditorStore
|
|
6
|
+
} from "@wordpress/block-editor";
|
|
7
|
+
import { ToolbarButton } from "@wordpress/components";
|
|
8
|
+
import { chevronLeft, chevronRight } from "@wordpress/icons";
|
|
9
|
+
import { useSelect } from "@wordpress/data";
|
|
10
|
+
import useTabActions from "../tabs/use-tab-actions.mjs";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
function TabMovers({ tabsClientId }) {
|
|
13
|
+
const { moveTab } = useTabActions(tabsClientId);
|
|
14
|
+
const { tabCount, activeIndex } = useSelect(
|
|
15
|
+
(select) => {
|
|
16
|
+
if (!tabsClientId) {
|
|
17
|
+
return { tabCount: 0, activeIndex: 0 };
|
|
18
|
+
}
|
|
19
|
+
const { getBlocks, getBlockAttributes } = select(blockEditorStore);
|
|
20
|
+
const tabsAttributes = getBlockAttributes(tabsClientId);
|
|
21
|
+
const tabPanels = getBlocks(tabsClientId).find(
|
|
22
|
+
(block) => block.name === "core/tab-panels"
|
|
23
|
+
);
|
|
24
|
+
return {
|
|
25
|
+
tabCount: tabPanels?.innerBlocks.length ?? 0,
|
|
26
|
+
activeIndex: tabsAttributes?.editorActiveTabIndex ?? tabsAttributes?.activeTabIndex ?? 0
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
[tabsClientId]
|
|
30
|
+
);
|
|
31
|
+
return /* @__PURE__ */ jsxs(BlockControls, { group: "parent", children: [
|
|
32
|
+
/* @__PURE__ */ jsx(
|
|
33
|
+
ToolbarButton,
|
|
34
|
+
{
|
|
35
|
+
className: "wp-block-tab-list__mover-button",
|
|
36
|
+
icon: isRTL() ? chevronRight : chevronLeft,
|
|
37
|
+
label: __("Move tab before"),
|
|
38
|
+
onClick: () => moveTab(-1),
|
|
39
|
+
disabled: activeIndex <= 0,
|
|
40
|
+
accessibleWhenDisabled: true
|
|
41
|
+
}
|
|
42
|
+
),
|
|
43
|
+
/* @__PURE__ */ jsx(
|
|
44
|
+
ToolbarButton,
|
|
45
|
+
{
|
|
46
|
+
className: "wp-block-tab-list__mover-button",
|
|
47
|
+
icon: isRTL() ? chevronLeft : chevronRight,
|
|
48
|
+
label: __("Move tab after"),
|
|
49
|
+
onClick: () => moveTab(1),
|
|
50
|
+
disabled: activeIndex >= tabCount - 1,
|
|
51
|
+
accessibleWhenDisabled: true
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
] });
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
TabMovers as default
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=tab-movers.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/tab-list/tab-movers.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { ToolbarButton } from '@wordpress/components';\nimport { chevronLeft, chevronRight } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport useTabActions from '../tabs/use-tab-actions';\n\n/**\n * Block toolbar buttons that reorder the active tab one position before or after.\n * Reordering acts on the underlying core/tab-panel blocks; the tab-list labels\n * follow their panel automatically via useTabListItemsSync. The buttons are\n * disabled at the first/last position.\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 TabMovers( { tabsClientId } ) {\n\tconst { moveTab } = useTabActions( tabsClientId );\n\tconst { tabCount, activeIndex } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! tabsClientId ) {\n\t\t\t\treturn { tabCount: 0, activeIndex: 0 };\n\t\t\t}\n\t\t\tconst { getBlocks, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst tabsAttributes = getBlockAttributes( tabsClientId );\n\t\t\tconst tabPanels = getBlocks( tabsClientId ).find(\n\t\t\t\t( block ) => block.name === 'core/tab-panels'\n\t\t\t);\n\t\t\treturn {\n\t\t\t\ttabCount: tabPanels?.innerBlocks.length ?? 0,\n\t\t\t\tactiveIndex:\n\t\t\t\t\ttabsAttributes?.editorActiveTabIndex ??\n\t\t\t\t\ttabsAttributes?.activeTabIndex ??\n\t\t\t\t\t0,\n\t\t\t};\n\t\t},\n\t\t[ tabsClientId ]\n\t);\n\n\treturn (\n\t\t<BlockControls group=\"parent\">\n\t\t\t<ToolbarButton\n\t\t\t\tclassName=\"wp-block-tab-list__mover-button\"\n\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\tlabel={ __( 'Move tab before' ) }\n\t\t\t\tonClick={ () => moveTab( -1 ) }\n\t\t\t\tdisabled={ activeIndex <= 0 }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t/>\n\t\t\t<ToolbarButton\n\t\t\t\tclassName=\"wp-block-tab-list__mover-button\"\n\t\t\t\ticon={ isRTL() ? chevronLeft : chevronRight }\n\t\t\t\tlabel={ __( 'Move tab after' ) }\n\t\t\t\tonClick={ () => moveTab( 1 ) }\n\t\t\t\tdisabled={ activeIndex >= tabCount - 1 }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,IAAI,aAAa;AAC1B;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,qBAAqB;AAC9B,SAAS,aAAa,oBAAoB;AAC1C,SAAS,iBAAiB;AAK1B,OAAO,mBAAmB;AAqCxB,SACC,KADD;AAzBa,SAAR,UAA4B,EAAE,aAAa,GAAI;AACrD,QAAM,EAAE,QAAQ,IAAI,cAAe,YAAa;AAChD,QAAM,EAAE,UAAU,YAAY,IAAI;AAAA,IACjC,CAAE,WAAY;AACb,UAAK,CAAE,cAAe;AACrB,eAAO,EAAE,UAAU,GAAG,aAAa,EAAE;AAAA,MACtC;AACA,YAAM,EAAE,WAAW,mBAAmB,IACrC,OAAQ,gBAAiB;AAC1B,YAAM,iBAAiB,mBAAoB,YAAa;AACxD,YAAM,YAAY,UAAW,YAAa,EAAE;AAAA,QAC3C,CAAE,UAAW,MAAM,SAAS;AAAA,MAC7B;AACA,aAAO;AAAA,QACN,UAAU,WAAW,YAAY,UAAU;AAAA,QAC3C,aACC,gBAAgB,wBAChB,gBAAgB,kBAChB;AAAA,MACF;AAAA,IACD;AAAA,IACA,CAAE,YAAa;AAAA,EAChB;AAEA,SACC,qBAAC,iBAAc,OAAM,UACpB;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,MAAO,MAAM,IAAI,eAAe;AAAA,QAChC,OAAQ,GAAI,iBAAkB;AAAA,QAC9B,SAAU,MAAM,QAAS,EAAG;AAAA,QAC5B,UAAW,eAAe;AAAA,QAC1B,wBAAsB;AAAA;AAAA,IACvB;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,MAAO,MAAM,IAAI,cAAc;AAAA,QAC/B,OAAQ,GAAI,gBAAiB;AAAA,QAC7B,SAAU,MAAM,QAAS,CAAE;AAAA,QAC3B,UAAW,eAAe,WAAW;AAAA,QACrC,wBAAsB;AAAA;AAAA,IACvB;AAAA,KACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
-
"__experimental": true,
|
|
4
3
|
"apiVersion": 3,
|
|
5
4
|
"name": "core/tab-panel",
|
|
6
5
|
"title": "Tab Panel",
|
|
@@ -14,11 +13,7 @@
|
|
|
14
13
|
}
|
|
15
14
|
},
|
|
16
15
|
"parent": [ "core/tab-panels" ],
|
|
17
|
-
"usesContext": [
|
|
18
|
-
"core/tabs-activeTabIndex",
|
|
19
|
-
"core/tabs-editorActiveTabIndex",
|
|
20
|
-
"core/tabs-id"
|
|
21
|
-
],
|
|
16
|
+
"usesContext": [ "core/tabs-id" ],
|
|
22
17
|
"supports": {
|
|
23
18
|
"anchor": true,
|
|
24
19
|
"html": false,
|
|
@@ -1,41 +1,40 @@
|
|
|
1
1
|
// packages/block-library/src/tab-panel/edit.js
|
|
2
|
-
import { __ } from "@wordpress/i18n";
|
|
3
2
|
import {
|
|
4
3
|
useBlockProps,
|
|
5
4
|
useInnerBlocksProps,
|
|
6
5
|
store as blockEditorStore
|
|
7
6
|
} from "@wordpress/block-editor";
|
|
8
7
|
import { useSelect, useDispatch } from "@wordpress/data";
|
|
9
|
-
import {
|
|
8
|
+
import { useEffect } from "@wordpress/element";
|
|
10
9
|
import Controls from "./controls.mjs";
|
|
11
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
var TEMPLATE = [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const activeTabIndex = context["core/tabs-activeTabIndex"];
|
|
22
|
-
const editorActiveTabIndex = context["core/tabs-editorActiveTabIndex"];
|
|
23
|
-
const effectiveActiveIndex = editorActiveTabIndex ?? activeTabIndex;
|
|
24
|
-
const { blockIndex, hasInnerBlocksSelected, tabsClientId } = useSelect(
|
|
11
|
+
var TEMPLATE = [["core/paragraph"]];
|
|
12
|
+
function Edit({ clientId, isSelected }) {
|
|
13
|
+
const {
|
|
14
|
+
activeTabIndex,
|
|
15
|
+
editorActiveTabIndex,
|
|
16
|
+
blockIndex,
|
|
17
|
+
hasInnerBlocksSelected,
|
|
18
|
+
tabsClientId
|
|
19
|
+
} = useSelect(
|
|
25
20
|
(select) => {
|
|
26
21
|
const {
|
|
27
22
|
getBlockRootClientId,
|
|
28
23
|
getBlockIndex,
|
|
29
|
-
hasSelectedInnerBlock
|
|
24
|
+
hasSelectedInnerBlock,
|
|
25
|
+
getBlockAttributes
|
|
30
26
|
} = select(blockEditorStore);
|
|
31
27
|
const tabPanelsClientId = getBlockRootClientId(clientId);
|
|
32
28
|
const _tabsClientId = getBlockRootClientId(tabPanelsClientId);
|
|
29
|
+
const tabsAttributes = getBlockAttributes(_tabsClientId) ?? {};
|
|
33
30
|
const _blockIndex = getBlockIndex(clientId);
|
|
34
31
|
const _hasInnerBlocksSelected = hasSelectedInnerBlock(
|
|
35
32
|
clientId,
|
|
36
33
|
true
|
|
37
34
|
);
|
|
38
35
|
return {
|
|
36
|
+
activeTabIndex: tabsAttributes.activeTabIndex,
|
|
37
|
+
editorActiveTabIndex: tabsAttributes.editorActiveTabIndex,
|
|
39
38
|
blockIndex: _blockIndex,
|
|
40
39
|
hasInnerBlocksSelected: _hasInnerBlocksSelected,
|
|
41
40
|
tabsClientId: _tabsClientId
|
|
@@ -43,6 +42,7 @@ function Edit({ clientId, context, isSelected }) {
|
|
|
43
42
|
},
|
|
44
43
|
[clientId]
|
|
45
44
|
);
|
|
45
|
+
const effectiveActiveIndex = editorActiveTabIndex ?? activeTabIndex;
|
|
46
46
|
const { updateBlockAttributes, __unstableMarkNextChangeAsNotPersistent } = useDispatch(blockEditorStore);
|
|
47
47
|
useEffect(() => {
|
|
48
48
|
const isTabSelected = isSelected || hasInnerBlocksSelected;
|
|
@@ -63,15 +63,7 @@ function Edit({ clientId, context, isSelected }) {
|
|
|
63
63
|
]);
|
|
64
64
|
const isActiveTab = effectiveActiveIndex === blockIndex;
|
|
65
65
|
const isDefaultTab = activeTabIndex === blockIndex;
|
|
66
|
-
const isSelectedTab =
|
|
67
|
-
if (isSelected || hasInnerBlocksSelected) {
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
if (isActiveTab) {
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
return false;
|
|
74
|
-
}, [isSelected, hasInnerBlocksSelected, isActiveTab]);
|
|
66
|
+
const isSelectedTab = isSelected || hasInnerBlocksSelected || isActiveTab;
|
|
75
67
|
const blockProps = useBlockProps({
|
|
76
68
|
hidden: !isSelectedTab,
|
|
77
69
|
tabIndex: isSelectedTab ? 0 : -1
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/tab-panel/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {
|
|
5
|
-
"mappings": ";AAGA
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Controls from './controls';\n\nconst TEMPLATE = [ [ 'core/paragraph' ] ];\n\nexport default function Edit( { clientId, isSelected } ) {\n\tconst {\n\t\tactiveTabIndex,\n\t\teditorActiveTabIndex,\n\t\tblockIndex,\n\t\thasInnerBlocksSelected,\n\t\ttabsClientId,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockIndex,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetBlockAttributes,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\t// Get the tab-panel parent first\n\t\t\tconst tabPanelsClientId = getBlockRootClientId( clientId );\n\t\t\t// Then get the tabs parent\n\t\t\tconst _tabsClientId = getBlockRootClientId( tabPanelsClientId );\n\n\t\t\t// Read the active tab indices directly from the tabs block.\n\t\t\tconst tabsAttributes = getBlockAttributes( _tabsClientId ) ?? {};\n\n\t\t\t// Get data about this instance of core/tab.\n\t\t\tconst _blockIndex = getBlockIndex( clientId );\n\t\t\tconst _hasInnerBlocksSelected = hasSelectedInnerBlock(\n\t\t\t\tclientId,\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tactiveTabIndex: tabsAttributes.activeTabIndex,\n\t\t\t\teditorActiveTabIndex: tabsAttributes.editorActiveTabIndex,\n\t\t\t\tblockIndex: _blockIndex,\n\t\t\t\thasInnerBlocksSelected: _hasInnerBlocksSelected,\n\t\t\t\ttabsClientId: _tabsClientId,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst effectiveActiveIndex = editorActiveTabIndex ?? activeTabIndex;\n\n\tconst { updateBlockAttributes, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Sync editorActiveTabIndex when this tab is selected directly\n\tuseEffect( () => {\n\t\t// Only update if this tab is selected and not already the active index\n\t\tconst isTabSelected = isSelected || hasInnerBlocksSelected;\n\t\tif (\n\t\t\tisTabSelected &&\n\t\t\ttabsClientId &&\n\t\t\teffectiveActiveIndex !== blockIndex\n\t\t) {\n\t\t\t// Mark as non-persistent so it doesn't add to undo history\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateBlockAttributes( tabsClientId, {\n\t\t\t\teditorActiveTabIndex: blockIndex,\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tisSelected,\n\t\thasInnerBlocksSelected,\n\t\ttabsClientId,\n\t\teffectiveActiveIndex,\n\t\tblockIndex,\n\t\tupdateBlockAttributes,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t] );\n\n\t// Determine if this is the currently active tab (for editor visibility)\n\tconst isActiveTab = effectiveActiveIndex === blockIndex;\n\n\t// Determine if this is the default tab (for the \"Default Tab\" toggle in controls)\n\tconst isDefaultTab = activeTabIndex === blockIndex;\n\n\t// Visible when selected, containing the selection, or the active tab.\n\tconst isSelectedTab = isSelected || hasInnerBlocksSelected || isActiveTab;\n\n\tconst blockProps = useBlockProps( {\n\t\thidden: ! isSelectedTab,\n\t\ttabIndex: isSelectedTab ? 0 : -1,\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t} );\n\n\treturn (\n\t\t<section { ...innerBlocksProps }>\n\t\t\t<Controls\n\t\t\t\ttabsClientId={ tabsClientId }\n\t\t\t\tblockIndex={ blockIndex }\n\t\t\t\tisDefaultTab={ isDefaultTab }\n\t\t\t/>\n\t\t\t{ isSelectedTab && innerBlocksProps.children }\n\t\t</section>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,WAAW,mBAAmB;AACvC,SAAS,iBAAiB;AAK1B,OAAO,cAAc;AA+FnB,SACC,KADD;AA7FF,IAAM,WAAW,CAAE,CAAE,gBAAiB,CAAE;AAEzB,SAAR,KAAuB,EAAE,UAAU,WAAW,GAAI;AACxD,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAAA,IACH,CAAE,WAAY;AACb,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,IAAI,OAAQ,gBAAiB;AAG7B,YAAM,oBAAoB,qBAAsB,QAAS;AAEzD,YAAM,gBAAgB,qBAAsB,iBAAkB;AAG9D,YAAM,iBAAiB,mBAAoB,aAAc,KAAK,CAAC;AAG/D,YAAM,cAAc,cAAe,QAAS;AAC5C,YAAM,0BAA0B;AAAA,QAC/B;AAAA,QACA;AAAA,MACD;AAEA,aAAO;AAAA,QACN,gBAAgB,eAAe;AAAA,QAC/B,sBAAsB,eAAe;AAAA,QACrC,YAAY;AAAA,QACZ,wBAAwB;AAAA,QACxB,cAAc;AAAA,MACf;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,QAAM,uBAAuB,wBAAwB;AAErD,QAAM,EAAE,uBAAuB,wCAAwC,IACtE,YAAa,gBAAiB;AAG/B,YAAW,MAAM;AAEhB,UAAM,gBAAgB,cAAc;AACpC,QACC,iBACA,gBACA,yBAAyB,YACxB;AAED,8CAAwC;AACxC,4BAAuB,cAAc;AAAA,QACpC,sBAAsB;AAAA,MACvB,CAAE;AAAA,IACH;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AAGF,QAAM,cAAc,yBAAyB;AAG7C,QAAM,eAAe,mBAAmB;AAGxC,QAAM,gBAAgB,cAAc,0BAA0B;AAE9D,QAAM,aAAa,cAAe;AAAA,IACjC,QAAQ,CAAE;AAAA,IACV,UAAU,gBAAgB,IAAI;AAAA,EAC/B,CAAE;AAEF,QAAM,mBAAmB,oBAAqB,YAAY;AAAA,IACzD,UAAU;AAAA,EACX,CAAE;AAEF,SACC,qBAAC,aAAU,GAAG,kBACb;AAAA;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,IACE,iBAAiB,iBAAiB;AAAA,KACrC;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -314,7 +314,7 @@ function TableEdit({
|
|
|
314
314
|
/* @__PURE__ */ jsx(BlockControls, { group: "block", children: /* @__PURE__ */ jsx(
|
|
315
315
|
AlignmentControl,
|
|
316
316
|
{
|
|
317
|
-
label: __("
|
|
317
|
+
label: __("Align column content"),
|
|
318
318
|
alignmentControls: ALIGNMENT_CONTROLS,
|
|
319
319
|
value: getCellAlignment(),
|
|
320
320
|
onChange: (nextAlign) => onChangeColumnAlignment(nextAlign)
|