@wordpress/block-library 11.0.0 → 11.0.2-next.v.202609171837.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 +18 -0
- package/README.md +7 -7
- package/build/archives/edit.cjs.map +3 -3
- package/build/audio/edit.cjs.map +3 -3
- package/build/avatar/hooks.cjs.map +2 -2
- package/build/button/edit.cjs.map +2 -2
- package/build/categories/edit.cjs.map +3 -3
- package/build/code/block.json +1 -0
- package/build/code/save.cjs.map +2 -2
- package/build/comment-template/hooks.cjs.map +2 -2
- package/build/cover/edit/index.cjs.map +2 -2
- package/build/cover/edit/inspector-controls.cjs.map +2 -2
- package/build/cover/transforms.cjs.map +2 -2
- package/build/details/block.json +1 -0
- package/build/details/index.cjs.map +2 -2
- package/build/embed/embed-controls.cjs.map +2 -2
- package/build/file/deprecated.cjs.map +2 -2
- package/build/file/edit.cjs.map +2 -2
- package/build/file/inspector.cjs.map +3 -3
- package/build/file/save.cjs.map +2 -2
- package/build/footnotes/block.json +1 -0
- package/build/footnotes/edit.cjs.map +2 -2
- package/build/gallery/dynamic-gallery.cjs.map +3 -3
- package/build/gallery/edit.cjs +64 -37
- package/build/gallery/edit.cjs.map +3 -3
- package/build/gallery/{flex-styles.cjs → gallery-styles.cjs} +31 -32
- package/build/gallery/gallery-styles.cjs.map +7 -0
- package/build/gallery/responsive-styles.cjs +27 -5
- package/build/gallery/responsive-styles.cjs.map +2 -2
- package/build/heading/block.json +2 -0
- package/build/heading/index.cjs.map +2 -2
- package/build/html/modal.cjs +3 -6
- package/build/html/modal.cjs.map +2 -2
- package/build/image/edit.cjs.map +2 -2
- package/build/image/image.cjs.map +2 -2
- package/build/index.cjs.map +2 -2
- package/build/latest-comments/edit.cjs.map +3 -3
- package/build/latest-posts/edit.cjs.map +2 -2
- package/build/list/ordered-list-settings.cjs.map +3 -3
- package/build/list-item/hooks/use-enter.cjs.map +2 -2
- package/build/math/block.json +2 -0
- package/build/math/deprecated.cjs +29 -12
- package/build/math/deprecated.cjs.map +2 -2
- package/build/math/edit.cjs +67 -46
- package/build/math/edit.cjs.map +2 -2
- package/build/math/save.cjs +2 -2
- package/build/math/save.cjs.map +2 -2
- package/build/media-text/constants.cjs +3 -0
- package/build/media-text/constants.cjs.map +2 -2
- package/build/media-text/deprecated.cjs.map +2 -2
- package/build/media-text/edit.cjs +40 -0
- package/build/media-text/edit.cjs.map +3 -3
- package/build/media-text/image-fill.cjs.map +2 -2
- package/build/media-text/media-container.cjs +3 -3
- package/build/media-text/media-container.cjs.map +2 -2
- package/build/navigation/edit/index.cjs.map +2 -2
- package/build/navigation/edit/menu-inspector-controls.cjs.map +2 -2
- package/build/navigation/edit/overlay-template-part-selector.cjs.map +3 -3
- package/build/navigation/edit/responsive-wrapper.cjs.map +2 -2
- package/build/navigation/edit/use-generate-default-navigation-title.cjs.map +2 -2
- package/build/navigation/view.cjs +2 -2
- package/build/navigation/view.cjs.map +2 -2
- package/build/navigation-link/edit.cjs.map +2 -2
- package/build/navigation-link/shared/invalid-draft-display.cjs.map +2 -2
- package/build/navigation-submenu/edit.cjs.map +2 -2
- package/build/paragraph/block.json +1 -0
- package/build/paragraph/edit.cjs.map +2 -2
- package/build/paragraph/index.cjs +6 -0
- package/build/paragraph/index.cjs.map +3 -3
- package/build/playlist/edit.cjs +2 -1
- package/build/playlist/edit.cjs.map +3 -3
- package/build/post-author/edit.cjs.map +3 -3
- package/build/post-author-name/edit.cjs.map +2 -2
- package/build/post-content/block.json +1 -0
- package/build/post-date/edit.cjs.map +2 -2
- package/build/post-excerpt/block.json +1 -0
- package/build/post-excerpt/edit.cjs.map +2 -2
- package/build/post-featured-image/edit.cjs.map +2 -2
- package/build/post-navigation-link/edit.cjs.map +3 -3
- package/build/post-time-to-read/edit.cjs.map +2 -2
- package/build/pullquote/deprecated.cjs.map +2 -2
- package/build/query/deprecated.cjs.map +2 -2
- package/build/query/edit/inspector-controls/index.cjs.map +3 -3
- package/build/query/edit/inspector-controls/order-control.cjs.map +3 -3
- package/build/query/edit/inspector-controls/sticky-control.cjs.map +3 -3
- package/build/query/view.cjs.map +2 -2
- package/build/query-title/use-archive-label.cjs.map +2 -2
- package/build/quote/deprecated.cjs.map +2 -2
- package/build/quote/transforms.cjs.map +2 -2
- package/build/search/edit.cjs.map +3 -3
- package/build/separator/edit.cjs.map +3 -3
- package/build/social-links/edit.cjs.map +3 -3
- package/build/table/state.cjs.map +2 -2
- package/build/table-of-contents/edit.cjs.map +3 -3
- package/build/table-of-contents/utils.cjs.map +2 -2
- package/build/tabs/use-tab-actions.cjs.map +2 -2
- package/build/tag-cloud/edit.cjs.map +3 -3
- package/build/template-part/edit/advanced-controls.cjs.map +3 -3
- package/build/template-part/edit/import-controls.cjs.map +3 -3
- package/build/template-part/edit/index.cjs.map +2 -2
- package/build/template-part/edit/inner-blocks.cjs.map +2 -2
- package/build/template-part/edit/placeholder.cjs.map +2 -2
- package/build/term-count/use-term-count.cjs.map +2 -2
- package/build/term-description/use-term-description.cjs.map +2 -2
- package/build/term-name/use-term-name.cjs.map +2 -2
- package/build/terms-query/edit/inspector-controls/index.cjs.map +2 -2
- package/build/terms-query/edit/inspector-controls/inherit-control.cjs.map +2 -2
- package/build/terms-query/edit/inspector-controls/order-control.cjs.map +3 -3
- package/build/terms-query/edit/inspector-controls/taxonomy-control.cjs.map +3 -3
- package/build/utils/hooks.cjs.map +2 -2
- package/build/utils/media-control.cjs +5 -1
- package/build/utils/media-control.cjs.map +2 -2
- package/build/utils/poster-image.cjs.map +2 -2
- package/build/verse/block.json +1 -0
- package/build/video/edit-common-settings.cjs.map +3 -3
- package/build/video/tracks-editor.cjs.map +3 -3
- package/build-module/archives/edit.mjs +2 -2
- package/build-module/archives/edit.mjs.map +2 -2
- package/build-module/audio/edit.mjs +2 -2
- package/build-module/audio/edit.mjs.map +2 -2
- package/build-module/avatar/hooks.mjs.map +2 -2
- package/build-module/button/edit.mjs.map +2 -2
- package/build-module/categories/edit.mjs +2 -2
- package/build-module/categories/edit.mjs.map +2 -2
- package/build-module/code/block.json +1 -0
- package/build-module/code/save.mjs.map +2 -2
- package/build-module/comment-template/hooks.mjs.map +2 -2
- package/build-module/cover/edit/index.mjs.map +2 -2
- package/build-module/cover/edit/inspector-controls.mjs.map +2 -2
- package/build-module/cover/transforms.mjs.map +2 -2
- package/build-module/details/block.json +1 -0
- package/build-module/details/index.mjs.map +2 -2
- package/build-module/embed/embed-controls.mjs.map +2 -2
- package/build-module/file/deprecated.mjs.map +2 -2
- package/build-module/file/edit.mjs.map +2 -2
- package/build-module/file/inspector.mjs +2 -2
- package/build-module/file/inspector.mjs.map +2 -2
- package/build-module/file/save.mjs.map +2 -2
- package/build-module/footnotes/block.json +1 -0
- package/build-module/footnotes/edit.mjs.map +2 -2
- package/build-module/gallery/dynamic-gallery.mjs +2 -2
- package/build-module/gallery/dynamic-gallery.mjs.map +2 -2
- package/build-module/gallery/edit.mjs +67 -40
- package/build-module/gallery/edit.mjs.map +2 -2
- package/build-module/gallery/{flex-styles.mjs → gallery-styles.mjs} +29 -30
- package/build-module/gallery/gallery-styles.mjs.map +7 -0
- package/build-module/gallery/responsive-styles.mjs +25 -4
- package/build-module/gallery/responsive-styles.mjs.map +2 -2
- package/build-module/heading/block.json +2 -0
- package/build-module/heading/index.mjs.map +2 -2
- package/build-module/html/modal.mjs +3 -6
- package/build-module/html/modal.mjs.map +2 -2
- package/build-module/image/edit.mjs.map +2 -2
- package/build-module/image/image.mjs.map +2 -2
- package/build-module/index.mjs.map +2 -2
- package/build-module/latest-comments/edit.mjs +2 -2
- package/build-module/latest-comments/edit.mjs.map +2 -2
- package/build-module/latest-posts/edit.mjs.map +2 -2
- package/build-module/list/ordered-list-settings.mjs +2 -2
- package/build-module/list/ordered-list-settings.mjs.map +2 -2
- package/build-module/list-item/hooks/use-enter.mjs.map +2 -2
- package/build-module/math/block.json +2 -0
- package/build-module/math/deprecated.mjs +29 -12
- package/build-module/math/deprecated.mjs.map +2 -2
- package/build-module/math/edit.mjs +68 -47
- package/build-module/math/edit.mjs.map +2 -2
- package/build-module/math/save.mjs +2 -2
- package/build-module/math/save.mjs.map +2 -2
- package/build-module/media-text/constants.mjs +2 -0
- package/build-module/media-text/constants.mjs.map +2 -2
- package/build-module/media-text/deprecated.mjs.map +2 -2
- package/build-module/media-text/edit.mjs +42 -1
- package/build-module/media-text/edit.mjs.map +2 -2
- package/build-module/media-text/image-fill.mjs.map +2 -2
- package/build-module/media-text/media-container.mjs +1 -1
- package/build-module/media-text/media-container.mjs.map +2 -2
- package/build-module/navigation/edit/index.mjs.map +2 -2
- package/build-module/navigation/edit/menu-inspector-controls.mjs.map +2 -2
- package/build-module/navigation/edit/overlay-template-part-selector.mjs +2 -2
- package/build-module/navigation/edit/overlay-template-part-selector.mjs.map +2 -2
- package/build-module/navigation/edit/responsive-wrapper.mjs.map +2 -2
- package/build-module/navigation/edit/use-generate-default-navigation-title.mjs.map +2 -2
- package/build-module/navigation/view.mjs +2 -2
- package/build-module/navigation/view.mjs.map +2 -2
- package/build-module/navigation-link/edit.mjs.map +2 -2
- package/build-module/navigation-link/shared/invalid-draft-display.mjs.map +2 -2
- package/build-module/navigation-submenu/edit.mjs.map +2 -2
- package/build-module/paragraph/block.json +1 -0
- package/build-module/paragraph/edit.mjs.map +2 -2
- package/build-module/paragraph/index.mjs +6 -0
- package/build-module/paragraph/index.mjs.map +2 -2
- package/build-module/playlist/edit.mjs +5 -4
- package/build-module/playlist/edit.mjs.map +2 -2
- package/build-module/post-author/edit.mjs +2 -2
- package/build-module/post-author/edit.mjs.map +2 -2
- package/build-module/post-author-name/edit.mjs.map +2 -2
- package/build-module/post-content/block.json +1 -0
- package/build-module/post-date/edit.mjs.map +2 -2
- package/build-module/post-excerpt/block.json +1 -0
- package/build-module/post-excerpt/edit.mjs.map +2 -2
- package/build-module/post-featured-image/edit.mjs.map +2 -2
- package/build-module/post-navigation-link/edit.mjs +2 -2
- package/build-module/post-navigation-link/edit.mjs.map +2 -2
- package/build-module/post-time-to-read/edit.mjs.map +2 -2
- package/build-module/pullquote/deprecated.mjs.map +2 -2
- package/build-module/query/deprecated.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/index.mjs +2 -2
- package/build-module/query/edit/inspector-controls/index.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/order-control.mjs +2 -2
- package/build-module/query/edit/inspector-controls/order-control.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/sticky-control.mjs +2 -2
- package/build-module/query/edit/inspector-controls/sticky-control.mjs.map +2 -2
- package/build-module/query/view.mjs.map +2 -2
- package/build-module/query-title/use-archive-label.mjs.map +2 -2
- package/build-module/quote/deprecated.mjs.map +2 -2
- package/build-module/quote/transforms.mjs.map +2 -2
- package/build-module/search/edit.mjs +3 -3
- package/build-module/search/edit.mjs.map +2 -2
- package/build-module/separator/edit.mjs +5 -2
- package/build-module/separator/edit.mjs.map +2 -2
- package/build-module/social-links/edit.mjs +2 -2
- package/build-module/social-links/edit.mjs.map +2 -2
- package/build-module/table/state.mjs.map +2 -2
- package/build-module/table-of-contents/edit.mjs +2 -2
- package/build-module/table-of-contents/edit.mjs.map +2 -2
- package/build-module/table-of-contents/utils.mjs.map +2 -2
- package/build-module/tabs/use-tab-actions.mjs.map +2 -2
- package/build-module/tag-cloud/edit.mjs +2 -2
- package/build-module/tag-cloud/edit.mjs.map +2 -2
- package/build-module/template-part/edit/advanced-controls.mjs +5 -2
- package/build-module/template-part/edit/advanced-controls.mjs.map +2 -2
- package/build-module/template-part/edit/import-controls.mjs +2 -2
- package/build-module/template-part/edit/import-controls.mjs.map +2 -2
- package/build-module/template-part/edit/index.mjs.map +2 -2
- package/build-module/template-part/edit/inner-blocks.mjs.map +2 -2
- package/build-module/template-part/edit/placeholder.mjs.map +2 -2
- package/build-module/term-count/use-term-count.mjs.map +2 -2
- package/build-module/term-description/use-term-description.mjs.map +2 -2
- package/build-module/term-name/use-term-name.mjs.map +2 -2
- package/build-module/terms-query/edit/inspector-controls/index.mjs.map +2 -2
- package/build-module/terms-query/edit/inspector-controls/inherit-control.mjs.map +2 -2
- package/build-module/terms-query/edit/inspector-controls/order-control.mjs +2 -2
- package/build-module/terms-query/edit/inspector-controls/order-control.mjs.map +2 -2
- package/build-module/terms-query/edit/inspector-controls/taxonomy-control.mjs +2 -2
- package/build-module/terms-query/edit/inspector-controls/taxonomy-control.mjs.map +2 -2
- package/build-module/utils/hooks.mjs.map +2 -2
- package/build-module/utils/media-control.mjs +5 -1
- package/build-module/utils/media-control.mjs.map +2 -2
- package/build-module/utils/poster-image.mjs.map +2 -2
- package/build-module/verse/block.json +1 -0
- package/build-module/video/edit-common-settings.mjs +2 -2
- package/build-module/video/edit-common-settings.mjs.map +2 -2
- package/build-module/video/tracks-editor.mjs +2 -2
- package/build-module/video/tracks-editor.mjs.map +2 -2
- package/build-style/button/style-rtl.css +2 -1
- package/build-style/button/style.css +2 -1
- package/build-style/columns/style-rtl.css +1 -1
- package/build-style/columns/style.css +1 -1
- package/build-style/comments/editor-rtl.css +1 -1
- package/build-style/comments/editor.css +1 -1
- package/build-style/comments/style-rtl.css +1 -1
- package/build-style/comments/style.css +1 -1
- package/build-style/common-rtl.css +1 -1
- package/build-style/common.css +1 -1
- package/build-style/cover/style-rtl.css +6 -0
- package/build-style/cover/style.css +6 -0
- package/build-style/editor-rtl.css +9 -5
- package/build-style/editor.css +9 -5
- package/build-style/embed/editor-rtl.css +2 -1
- package/build-style/embed/editor.css +2 -1
- package/build-style/gallery/style-rtl.css +1 -2
- package/build-style/gallery/style.css +1 -2
- package/build-style/image/style-rtl.css +6 -9
- package/build-style/image/style.css +6 -9
- package/build-style/math/editor-rtl.css +5 -0
- package/build-style/math/editor.css +5 -0
- package/build-style/navigation/editor-rtl.css +1 -0
- package/build-style/navigation/editor.css +1 -0
- package/build-style/navigation/style-rtl.css +1 -1
- package/build-style/navigation/style.css +1 -1
- package/build-style/post-title/style-rtl.css +2 -2
- package/build-style/post-title/style.css +2 -2
- package/build-style/query-pagination/editor-rtl.css +0 -3
- package/build-style/query-pagination/editor.css +0 -3
- package/build-style/search/theme-rtl.css +1 -1
- package/build-style/search/theme.css +1 -1
- package/build-style/style-rtl.css +23 -19
- package/build-style/style.css +23 -19
- package/build-style/theme-rtl.css +1 -1
- package/build-style/theme.css +1 -1
- package/build-style/verse/style-rtl.css +2 -1
- package/build-style/verse/style.css +2 -1
- package/package.json +40 -40
- package/src/archives/edit.jsx +2 -2
- package/src/audio/edit.jsx +2 -2
- package/src/avatar/hooks.js +2 -2
- package/src/button/edit.jsx +1 -1
- package/src/button/style.scss +2 -2
- package/src/calendar/index.php +1 -1
- package/src/categories/edit.jsx +2 -2
- package/src/code/README.md +1 -0
- package/src/code/block.json +1 -0
- package/src/code/save.jsx +1 -1
- package/src/columns/style.scss +2 -3
- package/src/comment-template/hooks.js +1 -1
- package/src/comments/style.scss +1 -1
- package/src/common.scss +1 -2
- package/src/cover/edit/index.jsx +2 -2
- package/src/cover/edit/inspector-controls.jsx +2 -2
- package/src/cover/style.scss +10 -0
- package/src/cover/test/{edit.jsdom.test.js → edit.browser.test.js} +104 -145
- package/src/cover/transforms.js +3 -3
- package/src/details/README.md +1 -0
- package/src/details/block.json +1 -0
- package/src/details/index.js +1 -1
- package/src/embed/editor.scss +2 -2
- package/src/embed/embed-controls.jsx +2 -2
- package/src/file/deprecated.jsx +3 -3
- package/src/file/edit.jsx +5 -3
- package/src/file/inspector.jsx +3 -3
- package/src/file/save.jsx +2 -2
- package/src/footnotes/README.md +1 -0
- package/src/footnotes/block.json +1 -0
- package/src/footnotes/edit.jsx +1 -1
- package/src/gallery/dynamic-gallery.jsx +4 -4
- package/src/gallery/edit.jsx +121 -68
- package/src/gallery/gallery-styles.js +117 -0
- package/src/gallery/index.php +181 -67
- package/src/gallery/responsive-styles.js +59 -5
- package/src/gallery/test/edit.jsdom.test.js +71 -3
- package/src/gallery/test/responsive-styles.js +59 -5
- package/src/heading/README.md +2 -0
- package/src/heading/block.json +2 -0
- package/src/heading/index.js +2 -2
- package/src/html/modal.jsx +0 -3
- package/src/image/edit.jsx +1 -1
- package/src/image/image.jsx +7 -7
- package/src/image/index.php +10 -4
- package/src/image/style.scss +1 -0
- package/src/image/test/use-open-image-media-editor-modal.jsdom.test.js +1 -1
- package/src/index.jsx +1 -1
- package/src/latest-comments/edit.jsx +2 -2
- package/src/latest-posts/edit.jsx +1 -1
- package/src/list/ordered-list-settings.jsx +2 -2
- package/src/list-item/hooks/use-enter.js +1 -1
- package/src/math/README.md +2 -2
- package/src/math/block.json +2 -0
- package/src/math/deprecated.jsx +38 -12
- package/src/math/edit.jsx +49 -20
- package/src/math/editor.scss +5 -0
- package/src/math/save.jsx +20 -4
- package/src/media-text/constants.js +1 -0
- package/src/media-text/deprecated.jsx +3 -3
- package/src/media-text/edit.jsx +48 -3
- package/src/media-text/image-fill.js +2 -2
- package/src/media-text/media-container.jsx +1 -1
- package/src/navigation/edit/index.jsx +1 -1
- package/src/navigation/edit/menu-inspector-controls.jsx +2 -2
- package/src/navigation/edit/overlay-template-part-selector.jsx +3 -3
- package/src/navigation/edit/responsive-wrapper.jsx +1 -1
- package/src/navigation/edit/use-generate-default-navigation-title.js +2 -2
- package/src/navigation/editor.scss +1 -0
- package/src/navigation/index.php +12 -0
- package/src/navigation/style.scss +1 -1
- package/src/navigation/test/use-navigation-menu.jsdom.test.js +6 -28
- package/src/navigation/test/view.jsdom.test.js +23 -0
- package/src/navigation/view.js +9 -6
- package/src/navigation-link/edit.jsx +1 -1
- package/src/navigation-link/shared/invalid-draft-display.jsx +2 -2
- package/src/navigation-link/test/__snapshots__/hooks.jsdom.test.js.snap +41 -11
- package/src/navigation-submenu/edit.jsx +1 -1
- package/src/paragraph/README.md +1 -0
- package/src/paragraph/block.json +1 -0
- package/src/paragraph/edit.jsx +1 -1
- package/src/paragraph/index.js +7 -0
- package/src/pattern/index.php +2 -2
- package/src/playlist/edit.jsx +6 -4
- package/src/playlist-track/test/edit.jsdom.test.jsx +2 -3
- package/src/post-author/edit.jsx +2 -2
- package/src/post-author-name/edit.jsx +1 -1
- package/src/post-content/README.md +1 -0
- package/src/post-content/block.json +1 -0
- package/src/post-date/edit.jsx +2 -2
- package/src/post-excerpt/README.md +1 -0
- package/src/post-excerpt/block.json +1 -0
- package/src/post-excerpt/edit.jsx +1 -1
- package/src/post-featured-image/edit.jsx +2 -2
- package/src/post-navigation-link/edit.jsx +4 -4
- package/src/post-time-to-read/edit.jsx +2 -2
- package/src/post-title/style.scss +2 -3
- package/src/pullquote/deprecated.jsx +1 -1
- package/src/query/deprecated.jsx +1 -1
- package/src/query/edit/inspector-controls/index.jsx +4 -4
- package/src/query/edit/inspector-controls/order-control.jsx +2 -2
- package/src/query/edit/inspector-controls/sticky-control.jsx +2 -2
- package/src/query/view.js +6 -9
- package/src/query-pagination/editor.scss +0 -3
- package/src/query-title/use-archive-label.js +1 -1
- package/src/quote/deprecated.jsx +2 -2
- package/src/quote/transforms.js +3 -3
- package/src/search/edit.jsx +6 -6
- package/src/search/theme.scss +1 -1
- package/src/separator/edit.jsx +7 -4
- package/src/social-links/edit.jsx +2 -2
- package/src/table/state.js +1 -1
- package/src/table-of-contents/edit.jsx +6 -6
- package/src/table-of-contents/utils.ts +2 -2
- package/src/tabs/use-tab-actions.js +1 -1
- package/src/tag-cloud/edit.jsx +2 -2
- package/src/template-part/edit/advanced-controls.jsx +5 -2
- package/src/template-part/edit/import-controls.jsx +2 -2
- package/src/template-part/edit/index.jsx +2 -2
- package/src/template-part/edit/inner-blocks.jsx +1 -1
- package/src/template-part/edit/placeholder.jsx +2 -2
- package/src/term-count/use-term-count.js +1 -1
- package/src/term-description/use-term-description.js +1 -1
- package/src/term-name/use-term-name.js +1 -1
- package/src/terms-query/edit/inspector-controls/index.jsx +2 -2
- package/src/terms-query/edit/inspector-controls/inherit-control.jsx +1 -1
- package/src/terms-query/edit/inspector-controls/order-control.jsx +2 -2
- package/src/terms-query/edit/inspector-controls/taxonomy-control.jsx +2 -2
- package/src/utils/hooks.js +1 -1
- package/src/utils/media-control.jsx +16 -10
- package/src/utils/poster-image.jsx +2 -2
- package/src/utils/test/waveform-player.jsdom.test.jsx +36 -38
- package/src/utils/test/{waveform-utils.jsdom.test.js → waveform-utils.browser.test.js} +64 -44
- package/src/verse/README.md +1 -0
- package/src/verse/block.json +1 -0
- package/src/verse/style.scss +2 -2
- package/src/video/edit-common-settings.jsx +3 -3
- package/src/video/tracks-editor.jsx +2 -2
- package/build/gallery/flex-styles.cjs.map +0 -7
- package/build-module/gallery/flex-styles.mjs.map +0 -7
- package/src/gallery/flex-styles.js +0 -99
|
@@ -6,13 +6,16 @@ import {
|
|
|
6
6
|
useBlockProps,
|
|
7
7
|
__experimentalUseColorProps as useColorProps
|
|
8
8
|
} from "@wordpress/block-editor";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
HorizontalRule,
|
|
11
|
+
SelectControl as WCSelectControl
|
|
12
|
+
} from "@wordpress/components";
|
|
10
13
|
import { __ } from "@wordpress/i18n";
|
|
11
14
|
import useDeprecatedOpacity from "./use-deprecated-opacity.mjs";
|
|
12
15
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
16
|
var HtmlElementControl = ({ tagName, setAttributes }) => {
|
|
14
17
|
return /* @__PURE__ */ jsx(
|
|
15
|
-
|
|
18
|
+
WCSelectControl,
|
|
16
19
|
{
|
|
17
20
|
label: __("HTML element"),
|
|
18
21
|
value: tagName,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/separator/edit.jsx"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\nimport {\n\tgetColorClassName,\n\tInspectorControls,\n\tuseBlockProps,\n\t__experimentalUseColorProps as useColorProps,\n} from '@wordpress/block-editor';\nimport {
|
|
5
|
-
"mappings": ";AAAA,OAAO,UAAU;AACjB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,+BAA+B;AAAA,OACzB;AACP,
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport {\n\tgetColorClassName,\n\tInspectorControls,\n\tuseBlockProps,\n\t__experimentalUseColorProps as useColorProps,\n} from '@wordpress/block-editor';\nimport {\n\tHorizontalRule,\n\tSelectControl as WCSelectControl,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport useDeprecatedOpacity from './use-deprecated-opacity';\n\nconst HtmlElementControl = ( { tagName, setAttributes } ) => {\n\treturn (\n\t\t<WCSelectControl\n\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\tvalue={ tagName }\n\t\t\tonChange={ ( newValue ) => setAttributes( { tagName: newValue } ) }\n\t\t\toptions={ [\n\t\t\t\t{ label: __( 'Default (<hr>)' ), value: 'hr' },\n\t\t\t\t{ label: '<div>', value: 'div' },\n\t\t\t] }\n\t\t\thelp={\n\t\t\t\ttagName === 'hr'\n\t\t\t\t\t? __(\n\t\t\t\t\t\t\t'Only select <hr> if the separator conveys important information and should be announced by screen readers.'\n\t\t\t\t\t\t)\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'The <div> element should only be used if the block is a design element with no semantic meaning.'\n\t\t\t\t\t\t)\n\t\t\t}\n\t\t/>\n\t);\n};\n\nexport default function SeparatorEdit( { attributes, setAttributes } ) {\n\tconst { backgroundColor, opacity, style, tagName } = attributes;\n\tconst colorProps = useColorProps( attributes );\n\tconst currentColor = colorProps?.style?.backgroundColor;\n\tconst hasCustomColor = !! style?.color?.background;\n\n\tuseDeprecatedOpacity( opacity, currentColor, setAttributes );\n\n\t// The dots styles uses text for the dots, to change those dots color is\n\t// using color, not backgroundColor.\n\tconst colorClass = getColorClassName( 'color', backgroundColor );\n\n\tconst className = clsx(\n\t\t{\n\t\t\t'has-text-color': backgroundColor || currentColor,\n\t\t\t[ colorClass ]: colorClass,\n\t\t\t'has-css-opacity': opacity === 'css',\n\t\t\t'has-alpha-channel-opacity': opacity === 'alpha-channel',\n\t\t},\n\t\tcolorProps.className\n\t);\n\n\tconst styles = {\n\t\tcolor: currentColor,\n\t\tbackgroundColor: currentColor,\n\t};\n\tconst Wrapper = tagName === 'hr' ? HorizontalRule : tagName;\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<HtmlElementControl\n\t\t\t\t\ttagName={ tagName }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<Wrapper\n\t\t\t\t{ ...useBlockProps( {\n\t\t\t\t\tclassName,\n\t\t\t\t\tstyle: hasCustomColor ? styles : undefined,\n\t\t\t\t} ) }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,UAAU;AACjB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,+BAA+B;AAAA,OACzB;AACP;AAAA,EACC;AAAA,EACA,iBAAiB;AAAA,OACX;AACP,SAAS,UAAU;AACnB,OAAO,0BAA0B;AAI/B,SAkDA,UAlDA,KAkDA,YAlDA;AAFF,IAAM,qBAAqB,CAAE,EAAE,SAAS,cAAc,MAAO;AAC5D,SACC;AAAA,IAAC;AAAA;AAAA,MACA,OAAQ,GAAI,cAAe;AAAA,MAC3B,OAAQ;AAAA,MACR,UAAW,CAAE,aAAc,cAAe,EAAE,SAAS,SAAS,CAAE;AAAA,MAChE,SAAU;AAAA,QACT,EAAE,OAAO,GAAI,gBAAiB,GAAG,OAAO,KAAK;AAAA,QAC7C,EAAE,OAAO,SAAS,OAAO,MAAM;AAAA,MAChC;AAAA,MACA,MACC,YAAY,OACT;AAAA,QACA;AAAA,MACD,IACC;AAAA,QACA;AAAA,MACD;AAAA;AAAA,EAEJ;AAEF;AAEe,SAAR,cAAgC,EAAE,YAAY,cAAc,GAAI;AACtE,QAAM,EAAE,iBAAiB,SAAS,OAAO,QAAQ,IAAI;AACrD,QAAM,aAAa,cAAe,UAAW;AAC7C,QAAM,eAAe,YAAY,OAAO;AACxC,QAAM,iBAAiB,CAAC,CAAE,OAAO,OAAO;AAExC,uBAAsB,SAAS,cAAc,aAAc;AAI3D,QAAM,aAAa,kBAAmB,SAAS,eAAgB;AAE/D,QAAM,YAAY;AAAA,IACjB;AAAA,MACC,kBAAkB,mBAAmB;AAAA,MACrC,CAAE,UAAW,GAAG;AAAA,MAChB,mBAAmB,YAAY;AAAA,MAC/B,6BAA6B,YAAY;AAAA,IAC1C;AAAA,IACA,WAAW;AAAA,EACZ;AAEA,QAAM,SAAS;AAAA,IACd,OAAO;AAAA,IACP,iBAAiB;AAAA,EAClB;AACA,QAAM,UAAU,YAAY,OAAO,iBAAiB;AAEpD,SACC,iCACC;AAAA,wBAAC,qBAAkB,OAAM,YACxB;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD,GACD;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACE,GAAG,cAAe;AAAA,UACnB;AAAA,UACA,OAAO,iBAAiB,SAAS;AAAA,QAClC,CAAE;AAAA;AAAA,IACH;AAAA,KACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from "@wordpress/block-editor";
|
|
15
15
|
import {
|
|
16
16
|
ToggleControl,
|
|
17
|
-
SelectControl,
|
|
17
|
+
SelectControl as WCSelectControl,
|
|
18
18
|
__experimentalToolsPanel as ToolsPanel,
|
|
19
19
|
__experimentalToolsPanelItem as ToolsPanelItem
|
|
20
20
|
} from "@wordpress/components";
|
|
@@ -154,7 +154,7 @@ function SocialLinksEdit(props) {
|
|
|
154
154
|
label: __("Icon size"),
|
|
155
155
|
onDeselect: () => setAttributes({ size: void 0 }),
|
|
156
156
|
children: /* @__PURE__ */ jsx(
|
|
157
|
-
|
|
157
|
+
WCSelectControl,
|
|
158
158
|
{
|
|
159
159
|
label: __("Icon size"),
|
|
160
160
|
onChange: (newSize) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/social-links/edit.jsx"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\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';\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<
|
|
5
|
-
"mappings": ";AAAA,OAAO,UAAU;AACjB,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,
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\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 as WCSelectControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\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<WCSelectControl\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": ";AAAA,OAAO,UAAU;AACjB,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,iBAAiB;AAAA,EACjB,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,OAC1B;AACP,SAAS,UAAU;AACnB,SAAS,iBA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,MACZ,cAAe,EAAE,cAAc,MAAM,CAAE;AAAA,cAGxC;AAAA,gBAAC;AAAA;AAAA,kBACA,OAAQ,GAAI,uBAAwB;AAAA,kBACpC,SAAU;AAAA,kBACV,UAAW,MACV,cAAe;AAAA,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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/table/state.js"],
|
|
4
|
-
"sourcesContent": ["const INHERITED_COLUMN_ATTRIBUTES = [ 'align' ];\n\n/**\n * Creates a table state.\n *\n * @param {Object} options\n * @param {number} options.rowCount Row count for the table to create.\n * @param {number} options.columnCount Column count for the table to create.\n *\n * @return {Object} New table state.\n */\nexport function createTable( { rowCount, columnCount } ) {\n\treturn {\n\t\tbody: Array.from( { length: rowCount } ).map( () => ( {\n\t\t\tcells: Array.from( { length: columnCount } ).map( () => ( {\n\t\t\t\tcontent: '',\n\t\t\t\ttag: 'td',\n\t\t\t} ) ),\n\t\t} ) ),\n\t};\n}\n\n/**\n * Returns the first row in the table.\n *\n * @param {Object} state Current table state.\n *\n * @return {Object | undefined} The first table row.\n */\nexport function getFirstRow( state ) {\n\tif ( ! isEmptyTableSection( state.head ) ) {\n\t\treturn state.head[ 0 ];\n\t}\n\tif ( ! isEmptyTableSection( state.body ) ) {\n\t\treturn state.body[ 0 ];\n\t}\n\tif ( ! isEmptyTableSection( state.foot ) ) {\n\t\treturn state.foot[ 0 ];\n\t}\n}\n\n/**\n * Gets an attribute for a cell.\n *\n * @param {Object} state Current table state.\n * @param {Object} cellLocation The location of the cell\n * @param {string} attributeName The name of the attribute to get the value of.\n *\n * @return {*} The attribute value.\n */\nexport function getCellAttribute( state, cellLocation, attributeName ) {\n\tconst { sectionName, rowIndex, columnIndex } = cellLocation;\n\treturn state[ sectionName ]?.[ rowIndex ]?.cells?.[ columnIndex ]?.[\n\t\tattributeName\n\t];\n}\n\n/**\n * Returns updated cell attributes after applying the `updateCell` function to the selection.\n *\n * @param {Object} state The block attributes.\n * @param {Object} selection The selection of cells to update.\n * @param {Function} updateCell A function to update the selected cell attributes.\n *\n * @return {Object} New table state including the updated cells.\n */\nexport function updateSelectedCell( state, selection, updateCell ) {\n\tif ( ! selection ) {\n\t\treturn state;\n\t}\n\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\tconst { sectionName: selectionSectionName, rowIndex: selectionRowIndex } =\n\t\tselection;\n\n\treturn Object.fromEntries(\n\t\tObject.entries( tableSections ).map( ( [ sectionName, section ] ) => {\n\t\t\tif (\n\t\t\t\tselectionSectionName &&\n\t\t\t\tselectionSectionName !== sectionName\n\t\t\t) {\n\t\t\t\treturn [ sectionName, section ];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\tsectionName,\n\t\t\t\tsection.map( ( row, rowIndex ) => {\n\t\t\t\t\tif ( selectionRowIndex && selectionRowIndex !== rowIndex ) {\n\t\t\t\t\t\treturn row;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcells: row.cells.map(\n\t\t\t\t\t\t\t( cellAttributes, columnIndex ) => {\n\t\t\t\t\t\t\t\tconst cellLocation = {\n\t\t\t\t\t\t\t\t\tsectionName,\n\t\t\t\t\t\t\t\t\tcolumnIndex,\n\t\t\t\t\t\t\t\t\trowIndex,\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t! isCellSelected( cellLocation, selection )\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\treturn cellAttributes;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn updateCell( cellAttributes );\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} ),\n\t\t\t];\n\t\t} )\n\t);\n}\n\n/**\n * Returns whether the cell at `cellLocation` is included in the selection `selection`.\n *\n * @param {Object} cellLocation An object containing cell location properties.\n * @param {Object} selection An object containing selection properties.\n *\n * @return {boolean} True if the cell is selected, false otherwise.\n */\nexport function isCellSelected( cellLocation, selection ) {\n\tif ( ! cellLocation || ! selection ) {\n\t\treturn false;\n\t}\n\n\tswitch ( selection.type ) {\n\t\tcase 'column':\n\t\t\treturn (\n\t\t\t\tselection.type === 'column' &&\n\t\t\t\tcellLocation.columnIndex === selection.columnIndex\n\t\t\t);\n\t\tcase 'cell':\n\t\t\treturn (\n\t\t\t\tselection.type === 'cell' &&\n\t\t\t\tcellLocation.sectionName === selection.sectionName &&\n\t\t\t\tcellLocation.columnIndex === selection.columnIndex &&\n\t\t\t\tcellLocation.rowIndex === selection.rowIndex\n\t\t\t);\n\t}\n}\n\n/**\n * Inserts a row in the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {string} options.sectionName Section in which to insert the row.\n * @param {number} options.rowIndex Row index at which to insert the row.\n * @param {number} options.columnCount Column count for the table to create.\n *\n * @return {Object} New table state.\n */\nexport function insertRow( state, { sectionName, rowIndex, columnCount } ) {\n\tconst firstRow = getFirstRow( state );\n\tconst cellCount =\n\t\tcolumnCount === undefined ? firstRow?.cells?.length : columnCount;\n\n\t// Bail early if the function cannot determine how many cells to add.\n\tif ( ! cellCount ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\t[ sectionName ]: [\n\t\t\t...state[ sectionName ].slice( 0, rowIndex ),\n\t\t\t{\n\t\t\t\tcells: Array.from( { length: cellCount } ).map(\n\t\t\t\t\t( _, index ) => {\n\t\t\t\t\t\tconst firstCellInColumn =\n\t\t\t\t\t\t\tfirstRow?.cells?.[ index ] ?? {};\n\n\t\t\t\t\t\tconst inheritedAttributes = Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries( firstCellInColumn ).filter(\n\t\t\t\t\t\t\t\t( [ key ] ) =>\n\t\t\t\t\t\t\t\t\tINHERITED_COLUMN_ATTRIBUTES.includes( key )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...inheritedAttributes,\n\t\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\t\ttag: sectionName === 'head' ? 'th' : 'td',\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\t...state[ sectionName ].slice( rowIndex ),\n\t\t],\n\t};\n}\n\n/**\n * Deletes a row from the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {string} options.sectionName Section in which to delete the row.\n * @param {number} options.rowIndex Row index to delete.\n *\n * @return {Object} New table state.\n */\nexport function deleteRow( state, { sectionName, rowIndex } ) {\n\treturn {\n\t\t[ sectionName ]: state[ sectionName ].filter(\n\t\t\t( row, index ) => index !== rowIndex\n\t\t),\n\t};\n}\n\n/**\n * Inserts a column in the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {number} options.columnIndex Column index at which to insert the column.\n *\n * @return {Object} New table state.\n */\nexport function insertColumn( state, { columnIndex } ) {\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\n\treturn Object.fromEntries(\n\t\tObject.entries( tableSections ).map( ( [ sectionName, section ] ) => {\n\t\t\t// Bail early if the table section is empty.\n\t\t\tif ( isEmptyTableSection( section ) ) {\n\t\t\t\treturn [ sectionName, section ];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\tsectionName,\n\t\t\t\tsection.map( ( row ) => {\n\t\t\t\t\t// Bail early if the row is empty or it's an attempt to insert past\n\t\t\t\t\t// the last possible index of the array.\n\t\t\t\t\tif ( isEmptyRow( row ) || row.cells.length < columnIndex ) {\n\t\t\t\t\t\treturn row;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcells: [\n\t\t\t\t\t\t\t...row.cells.slice( 0, columnIndex ),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\t\t\ttag: sectionName === 'head' ? 'th' : 'td',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t...row.cells.slice( columnIndex ),\n\t\t\t\t\t\t],\n\t\t\t\t\t};\n\t\t\t\t} ),\n\t\t\t];\n\t\t} )\n\t);\n}\n\n/**\n * Deletes a column from the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {number} options.columnIndex Column index to delete.\n *\n * @return {Object} New table state.\n */\nexport function deleteColumn( state, { columnIndex } ) {\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\n\treturn Object.fromEntries(\n\t\tObject.entries( tableSections ).map( ( [ sectionName, section ] ) => {\n\t\t\t// Bail early if the table section is empty.\n\t\t\tif ( isEmptyTableSection( section ) ) {\n\t\t\t\treturn [ sectionName, section ];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\tsectionName,\n\t\t\t\tsection\n\t\t\t\t\t.map( ( row ) => ( {\n\t\t\t\t\t\tcells:\n\t\t\t\t\t\t\trow.cells.length >= columnIndex\n\t\t\t\t\t\t\t\t? row.cells.filter(\n\t\t\t\t\t\t\t\t\t\t( cell, index ) => index !== columnIndex\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: row.cells,\n\t\t\t\t\t} ) )\n\t\t\t\t\t.filter( ( row ) => row.cells.length ),\n\t\t\t];\n\t\t} )\n\t);\n}\n\n/**\n * Toggles the existence of a section.\n *\n * @param {Object} state Current table state.\n * @param {string} sectionName Name of the section to toggle.\n *\n * @return {Object} New table state.\n */\nexport function toggleSection( state, sectionName ) {\n\t// Section exists, replace it with an empty row to remove it.\n\tif ( ! isEmptyTableSection( state[ sectionName ] ) ) {\n\t\treturn { [ sectionName ]: [] };\n\t}\n\n\t// Get the length of the first row of the body to use when creating the header.\n\tconst columnCount = state.body?.[ 0 ]?.cells?.length ?? 1;\n\n\t// Section doesn't exist, insert an empty row to create the section.\n\treturn insertRow( state, { sectionName, rowIndex: 0, columnCount } );\n}\n\n/**\n * Determines whether a table section is empty.\n *\n * @param {Object} section Table section state.\n *\n * @return {boolean} True if the table section is empty, false otherwise.\n */\nexport function isEmptyTableSection( section ) {\n\treturn ! section || ! section.length || section.every( isEmptyRow );\n}\n\n/**\n * Determines whether a table row is empty.\n *\n * @param {Object} row Table row state.\n *\n * @return {boolean} True if the table section is empty, false otherwise.\n */\nexport function isEmptyRow( row ) {\n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cACtC;AAAA,cACA,GAAG,IAAI,MAAM,MAAO,WAAY;AAAA,YACjC;AAAA,UACD;AAAA,QACD,CAAE;AAAA,MACH;AAAA,IACD,CAAE;AAAA,EACH;AACD;AAWO,SAAS,aAAc,OAAO,EAAE,YAAY,GAAI;AACtD,QAAM,gBAAgB,OAAO;AAAA,IAC5B,OAAO,QAAS,KAAM,EAAE;AAAA,MAAQ,CAAE,CAAE,GAAI,MACvC,CAAE,QAAQ,QAAQ,MAAO,EAAE,SAAU,GAAI;AAAA,IAC1C;AAAA,EACD;AAEA,SAAO,OAAO;AAAA,IACb,OAAO,QAAS,aAAc,EAAE,IAAK,CAAE,CAAE,aAAa,OAAQ,MAAO;AAEpE,UAAK,oBAAqB,OAAQ,GAAI;AACrC,eAAO,CAAE,aAAa,OAAQ;AAAA,MAC/B;AAEA,aAAO;AAAA,QACN;AAAA,QACA,QACE,IAAK,CAAE,SAAW;AAAA,UAClB,OACC,IAAI,MAAM,UAAU,cACjB,IAAI,MAAM;AAAA,YACV,CAAE,MAAM,UAAW,UAAU;AAAA,
|
|
4
|
+
"sourcesContent": ["const INHERITED_COLUMN_ATTRIBUTES = [ 'align' ];\n\n/**\n * Creates a table state.\n *\n * @param {Object} options\n * @param {number} options.rowCount Row count for the table to create.\n * @param {number} options.columnCount Column count for the table to create.\n *\n * @return {Object} New table state.\n */\nexport function createTable( { rowCount, columnCount } ) {\n\treturn {\n\t\tbody: Array.from( { length: rowCount } ).map( () => ( {\n\t\t\tcells: Array.from( { length: columnCount } ).map( () => ( {\n\t\t\t\tcontent: '',\n\t\t\t\ttag: 'td',\n\t\t\t} ) ),\n\t\t} ) ),\n\t};\n}\n\n/**\n * Returns the first row in the table.\n *\n * @param {Object} state Current table state.\n *\n * @return {Object | undefined} The first table row.\n */\nexport function getFirstRow( state ) {\n\tif ( ! isEmptyTableSection( state.head ) ) {\n\t\treturn state.head[ 0 ];\n\t}\n\tif ( ! isEmptyTableSection( state.body ) ) {\n\t\treturn state.body[ 0 ];\n\t}\n\tif ( ! isEmptyTableSection( state.foot ) ) {\n\t\treturn state.foot[ 0 ];\n\t}\n}\n\n/**\n * Gets an attribute for a cell.\n *\n * @param {Object} state Current table state.\n * @param {Object} cellLocation The location of the cell\n * @param {string} attributeName The name of the attribute to get the value of.\n *\n * @return {*} The attribute value.\n */\nexport function getCellAttribute( state, cellLocation, attributeName ) {\n\tconst { sectionName, rowIndex, columnIndex } = cellLocation;\n\treturn state[ sectionName ]?.[ rowIndex ]?.cells?.[ columnIndex ]?.[\n\t\tattributeName\n\t];\n}\n\n/**\n * Returns updated cell attributes after applying the `updateCell` function to the selection.\n *\n * @param {Object} state The block attributes.\n * @param {Object} selection The selection of cells to update.\n * @param {Function} updateCell A function to update the selected cell attributes.\n *\n * @return {Object} New table state including the updated cells.\n */\nexport function updateSelectedCell( state, selection, updateCell ) {\n\tif ( ! selection ) {\n\t\treturn state;\n\t}\n\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\tconst { sectionName: selectionSectionName, rowIndex: selectionRowIndex } =\n\t\tselection;\n\n\treturn Object.fromEntries(\n\t\tObject.entries( tableSections ).map( ( [ sectionName, section ] ) => {\n\t\t\tif (\n\t\t\t\tselectionSectionName &&\n\t\t\t\tselectionSectionName !== sectionName\n\t\t\t) {\n\t\t\t\treturn [ sectionName, section ];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\tsectionName,\n\t\t\t\tsection.map( ( row, rowIndex ) => {\n\t\t\t\t\tif ( selectionRowIndex && selectionRowIndex !== rowIndex ) {\n\t\t\t\t\t\treturn row;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcells: row.cells.map(\n\t\t\t\t\t\t\t( cellAttributes, columnIndex ) => {\n\t\t\t\t\t\t\t\tconst cellLocation = {\n\t\t\t\t\t\t\t\t\tsectionName,\n\t\t\t\t\t\t\t\t\tcolumnIndex,\n\t\t\t\t\t\t\t\t\trowIndex,\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t! isCellSelected( cellLocation, selection )\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\treturn cellAttributes;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn updateCell( cellAttributes );\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} ),\n\t\t\t];\n\t\t} )\n\t);\n}\n\n/**\n * Returns whether the cell at `cellLocation` is included in the selection `selection`.\n *\n * @param {Object} cellLocation An object containing cell location properties.\n * @param {Object} selection An object containing selection properties.\n *\n * @return {boolean} True if the cell is selected, false otherwise.\n */\nexport function isCellSelected( cellLocation, selection ) {\n\tif ( ! cellLocation || ! selection ) {\n\t\treturn false;\n\t}\n\n\tswitch ( selection.type ) {\n\t\tcase 'column':\n\t\t\treturn (\n\t\t\t\tselection.type === 'column' &&\n\t\t\t\tcellLocation.columnIndex === selection.columnIndex\n\t\t\t);\n\t\tcase 'cell':\n\t\t\treturn (\n\t\t\t\tselection.type === 'cell' &&\n\t\t\t\tcellLocation.sectionName === selection.sectionName &&\n\t\t\t\tcellLocation.columnIndex === selection.columnIndex &&\n\t\t\t\tcellLocation.rowIndex === selection.rowIndex\n\t\t\t);\n\t}\n}\n\n/**\n * Inserts a row in the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {string} options.sectionName Section in which to insert the row.\n * @param {number} options.rowIndex Row index at which to insert the row.\n * @param {number} options.columnCount Column count for the table to create.\n *\n * @return {Object} New table state.\n */\nexport function insertRow( state, { sectionName, rowIndex, columnCount } ) {\n\tconst firstRow = getFirstRow( state );\n\tconst cellCount =\n\t\tcolumnCount === undefined ? firstRow?.cells?.length : columnCount;\n\n\t// Bail early if the function cannot determine how many cells to add.\n\tif ( ! cellCount ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\t[ sectionName ]: [\n\t\t\t...state[ sectionName ].slice( 0, rowIndex ),\n\t\t\t{\n\t\t\t\tcells: Array.from( { length: cellCount } ).map(\n\t\t\t\t\t( _, index ) => {\n\t\t\t\t\t\tconst firstCellInColumn =\n\t\t\t\t\t\t\tfirstRow?.cells?.[ index ] ?? {};\n\n\t\t\t\t\t\tconst inheritedAttributes = Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries( firstCellInColumn ).filter(\n\t\t\t\t\t\t\t\t( [ key ] ) =>\n\t\t\t\t\t\t\t\t\tINHERITED_COLUMN_ATTRIBUTES.includes( key )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...inheritedAttributes,\n\t\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\t\ttag: sectionName === 'head' ? 'th' : 'td',\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\t...state[ sectionName ].slice( rowIndex ),\n\t\t],\n\t};\n}\n\n/**\n * Deletes a row from the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {string} options.sectionName Section in which to delete the row.\n * @param {number} options.rowIndex Row index to delete.\n *\n * @return {Object} New table state.\n */\nexport function deleteRow( state, { sectionName, rowIndex } ) {\n\treturn {\n\t\t[ sectionName ]: state[ sectionName ].filter(\n\t\t\t( row, index ) => index !== rowIndex\n\t\t),\n\t};\n}\n\n/**\n * Inserts a column in the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {number} options.columnIndex Column index at which to insert the column.\n *\n * @return {Object} New table state.\n */\nexport function insertColumn( state, { columnIndex } ) {\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\n\treturn Object.fromEntries(\n\t\tObject.entries( tableSections ).map( ( [ sectionName, section ] ) => {\n\t\t\t// Bail early if the table section is empty.\n\t\t\tif ( isEmptyTableSection( section ) ) {\n\t\t\t\treturn [ sectionName, section ];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\tsectionName,\n\t\t\t\tsection.map( ( row ) => {\n\t\t\t\t\t// Bail early if the row is empty or it's an attempt to insert past\n\t\t\t\t\t// the last possible index of the array.\n\t\t\t\t\tif ( isEmptyRow( row ) || row.cells.length < columnIndex ) {\n\t\t\t\t\t\treturn row;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcells: [\n\t\t\t\t\t\t\t...row.cells.slice( 0, columnIndex ),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\t\t\ttag: sectionName === 'head' ? 'th' : 'td',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t...row.cells.slice( columnIndex ),\n\t\t\t\t\t\t],\n\t\t\t\t\t};\n\t\t\t\t} ),\n\t\t\t];\n\t\t} )\n\t);\n}\n\n/**\n * Deletes a column from the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {number} options.columnIndex Column index to delete.\n *\n * @return {Object} New table state.\n */\nexport function deleteColumn( state, { columnIndex } ) {\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\n\treturn Object.fromEntries(\n\t\tObject.entries( tableSections ).map( ( [ sectionName, section ] ) => {\n\t\t\t// Bail early if the table section is empty.\n\t\t\tif ( isEmptyTableSection( section ) ) {\n\t\t\t\treturn [ sectionName, section ];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\tsectionName,\n\t\t\t\tsection\n\t\t\t\t\t.map( ( row ) => ( {\n\t\t\t\t\t\tcells:\n\t\t\t\t\t\t\trow.cells.length >= columnIndex\n\t\t\t\t\t\t\t\t? row.cells.filter(\n\t\t\t\t\t\t\t\t\t\t( cell, index ) => index !== columnIndex\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t: row.cells,\n\t\t\t\t\t} ) )\n\t\t\t\t\t.filter( ( row ) => row.cells.length ),\n\t\t\t];\n\t\t} )\n\t);\n}\n\n/**\n * Toggles the existence of a section.\n *\n * @param {Object} state Current table state.\n * @param {string} sectionName Name of the section to toggle.\n *\n * @return {Object} New table state.\n */\nexport function toggleSection( state, sectionName ) {\n\t// Section exists, replace it with an empty row to remove it.\n\tif ( ! isEmptyTableSection( state[ sectionName ] ) ) {\n\t\treturn { [ sectionName ]: [] };\n\t}\n\n\t// Get the length of the first row of the body to use when creating the header.\n\tconst columnCount = state.body?.[ 0 ]?.cells?.length ?? 1;\n\n\t// Section doesn't exist, insert an empty row to create the section.\n\treturn insertRow( state, { sectionName, rowIndex: 0, columnCount } );\n}\n\n/**\n * Determines whether a table section is empty.\n *\n * @param {Object} section Table section state.\n *\n * @return {boolean} True if the table section is empty, false otherwise.\n */\nexport function isEmptyTableSection( section ) {\n\treturn ! section || ! section.length || section.every( isEmptyRow );\n}\n\n/**\n * Determines whether a table row is empty.\n *\n * @param {Object} row Table row state.\n *\n * @return {boolean} True if the table section is empty, false otherwise.\n */\nexport function isEmptyRow( row ) {\n\treturn ! ( row.cells && row.cells.length );\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,IAAM,8BAA8B,CAAE,OAAQ;AAWvC,SAAS,YAAa,EAAE,UAAU,YAAY,GAAI;AACxD,SAAO;AAAA,IACN,MAAM,MAAM,KAAM,EAAE,QAAQ,SAAS,CAAE,EAAE,IAAK,OAAQ;AAAA,MACrD,OAAO,MAAM,KAAM,EAAE,QAAQ,YAAY,CAAE,EAAE,IAAK,OAAQ;AAAA,QACzD,SAAS;AAAA,QACT,KAAK;AAAA,MACN,EAAI;AAAA,IACL,EAAI;AAAA,EACL;AACD;AASO,SAAS,YAAa,OAAQ;AACpC,MAAK,CAAE,oBAAqB,MAAM,IAAK,GAAI;AAC1C,WAAO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AQ,GAAI;AACrC,eAAO,CAAE,aAAa,OAAQ;AAAA,MAC/B;AAEA,aAAO;AAAA,QACN;AAAA,QACA,QACE,IAAK,CAAE,SAAW;AAAA,UAClB,OACC,IAAI,MAAM,UAAU,cACjB,IAAI,MAAM;AAAA,YACV,CAAE,MAAM,UAAW,UAAU;AAAA,UAC9B,IACC,IAAI;AAAA,QACT,EAAI,EACH,OAAQ,CAAE,QAAS,IAAI,MAAM,MAAO;AAAA,MACvC;AAAA,IACD,CAAE;AAAA,EACH;AACD;AAUO,SAAS,cAAe,OAAO,aAAc;AAEnD,MAAK,CAAE,oBAAqB,MAAO,WAAY,CAAE,GAAI;AACpD,WAAO,EAAE,CAAE,WAAY,GAAG,CAAC,EAAE;AAAA,EAC9B;AAGA,QAAM,cAAc,MAAM,OAAQ,CAAE,GAAG,OAAO,UAAU;AAGxD,SAAO,UAAW,OAAO,EAAE,aAAa,UAAU,GAAG,YAAY,CAAE;AACpE;AASO,SAAS,oBAAqB,SAAU;AAC9C,SAAO,CAAE,WAAW,CAAE,QAAQ,UAAU,QAAQ,MAAO,UAAW;AACnE;AASO,SAAS,WAAY,KAAM;AACjC,SAAO,EAAI,IAAI,SAAS,IAAI,MAAM;AACnC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -10,7 +10,7 @@ import { createBlock } from "@wordpress/blocks";
|
|
|
10
10
|
import {
|
|
11
11
|
Placeholder,
|
|
12
12
|
ToggleControl,
|
|
13
|
-
SelectControl,
|
|
13
|
+
SelectControl as WCSelectControl,
|
|
14
14
|
ToolbarButton,
|
|
15
15
|
ToolbarGroup,
|
|
16
16
|
__experimentalConfirmDialog as ConfirmDialog,
|
|
@@ -187,7 +187,7 @@ function TableOfContentsEdit({
|
|
|
187
187
|
onDeselect: () => setAttributes({ maxLevel: void 0 }),
|
|
188
188
|
isShownByDefault: true,
|
|
189
189
|
children: /* @__PURE__ */ jsx(
|
|
190
|
-
|
|
190
|
+
WCSelectControl,
|
|
191
191
|
{
|
|
192
192
|
label: __("Include headings down to level"),
|
|
193
193
|
value: maxLevel || "",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/table-of-contents/edit.jsx"],
|
|
4
|
-
"sourcesContent": ["import {\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__experimentalConfirmDialog as ConfirmDialog,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } 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';\nimport TableOfContentsList from './list';\nimport { createListItemBlocks, linearToNestedHeadingList } from './utils';\nimport { useObserveHeadings } from './hooks';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\n/** @typedef {import('./utils').HeadingData} HeadingData */\n\nfunction TableOfContentsToolbar( {\n\tclientId,\n\theadingTree,\n\tordered,\n\tsetAttributes,\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\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst [ isConfirmingDetach, setIsConfirmingDetach ] = useState( false );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\tisRTL() ? formatListBulletsRTL : formatListBullets\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttitle={ __( 'Unordered' ) }\n\t\t\t\t\t\tdescription={ __( 'Convert to unordered list' ) }\n\t\t\t\t\t\tonClick={ () => setAttributes( { ordered: false } ) }\n\t\t\t\t\t\tisActive={ ordered === false }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\tisRTL() ? formatListNumberedRTL : formatListNumbered\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttitle={ __( 'Ordered' ) }\n\t\t\t\t\t\tdescription={ __( 'Convert to ordered list' ) }\n\t\t\t\t\t\tonClick={ () => setAttributes( { ordered: true } ) }\n\t\t\t\t\t\tisActive={ ordered === true }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t\t{ canInsertList && (\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tonClick={ () => setIsConfirmingDetach( true ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Detach' ) }\n\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t\t{ isConfirmingDetach && (\n\t\t\t\t<ConfirmDialog\n\t\t\t\t\tisOpen\n\t\t\t\t\ttitle={ __( 'Detach Table of Contents' ) }\n\t\t\t\t\t__experimentalHideHeader={ false }\n\t\t\t\t\tconfirmButtonText={ __( 'Detach' ) }\n\t\t\t\t\tonConfirm={ () => {\n\t\t\t\t\t\tsetIsConfirmingDetach( false );\n\t\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t\t'core/list',\n\t\t\t\t\t\t\t\t{ ordered },\n\t\t\t\t\t\t\t\tcreateListItemBlocks( headingTree, ordered )\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\tonCancel={ () => setIsConfirmingDetach( false ) }\n\t\t\t\t\tsize=\"medium\"\n\t\t\t\t>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'The Table of Contents block lists the headings in the post. Detaching will enable you to edit, reorder, or remove entries. However, new headings will no longer be added automatically.'\n\t\t\t\t\t) }\n\t\t\t\t</ConfirmDialog>\n\t\t\t) }\n\t\t</>\n\t);\n}\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 dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst headingTree = linearToNestedHeadingList( headings );\n\n\tconst toolbarControls = (\n\t\t<TableOfContentsToolbar\n\t\t\tclientId={ clientId }\n\t\t\theadingTree={ headingTree }\n\t\t\tordered={ ordered }\n\t\t\tsetAttributes={ setAttributes }\n\t\t/>\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
|
|
5
|
-
"mappings": ";AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,OACM;AACP,SAAS,mBAAmB;AAC5B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,
|
|
4
|
+
"sourcesContent": ["import {\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 as WCSelectControl,\n\tToolbarButton,\n\tToolbarGroup,\n\t__experimentalConfirmDialog as ConfirmDialog,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } 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';\nimport TableOfContentsList from './list';\nimport { createListItemBlocks, linearToNestedHeadingList } from './utils';\nimport { useObserveHeadings } from './hooks';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\n/** @typedef {import('./utils').HeadingData} HeadingData */\n\nfunction TableOfContentsToolbar( {\n\tclientId,\n\theadingTree,\n\tordered,\n\tsetAttributes,\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\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst [ isConfirmingDetach, setIsConfirmingDetach ] = useState( false );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\tisRTL() ? formatListBulletsRTL : formatListBullets\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttitle={ __( 'Unordered' ) }\n\t\t\t\t\t\tdescription={ __( 'Convert to unordered list' ) }\n\t\t\t\t\t\tonClick={ () => setAttributes( { ordered: false } ) }\n\t\t\t\t\t\tisActive={ ordered === false }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\tisRTL() ? formatListNumberedRTL : formatListNumbered\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttitle={ __( 'Ordered' ) }\n\t\t\t\t\t\tdescription={ __( 'Convert to ordered list' ) }\n\t\t\t\t\t\tonClick={ () => setAttributes( { ordered: true } ) }\n\t\t\t\t\t\tisActive={ ordered === true }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t\t{ canInsertList && (\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tonClick={ () => setIsConfirmingDetach( true ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Detach' ) }\n\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t\t{ isConfirmingDetach && (\n\t\t\t\t<ConfirmDialog\n\t\t\t\t\tisOpen\n\t\t\t\t\ttitle={ __( 'Detach Table of Contents' ) }\n\t\t\t\t\t__experimentalHideHeader={ false }\n\t\t\t\t\tconfirmButtonText={ __( 'Detach' ) }\n\t\t\t\t\tonConfirm={ () => {\n\t\t\t\t\t\tsetIsConfirmingDetach( false );\n\t\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t\t'core/list',\n\t\t\t\t\t\t\t\t{ ordered },\n\t\t\t\t\t\t\t\tcreateListItemBlocks( headingTree, ordered )\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\tonCancel={ () => setIsConfirmingDetach( false ) }\n\t\t\t\t\tsize=\"medium\"\n\t\t\t\t>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'The Table of Contents block lists the headings in the post. Detaching will enable you to edit, reorder, or remove entries. However, new headings will no longer be added automatically.'\n\t\t\t\t\t) }\n\t\t\t\t</ConfirmDialog>\n\t\t\t) }\n\t\t</>\n\t);\n}\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 dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst headingTree = linearToNestedHeadingList( headings );\n\n\tconst toolbarControls = (\n\t\t<TableOfContentsToolbar\n\t\t\tclientId={ clientId }\n\t\t\theadingTree={ headingTree }\n\t\t\tordered={ ordered }\n\t\t\tsetAttributes={ setAttributes }\n\t\t/>\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\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\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<WCSelectControl\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\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\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// \"Detach\" 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{ inspector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4
|
-
"sourcesContent": ["import { createBlock } from '@wordpress/blocks';\nimport type { Block } from '@wordpress/blocks';\nimport { escapeAttribute, escapeEditableHTML } from '@wordpress/escape-html';\n\nexport interface HeadingData {\n\t/** The plain text content of the heading. */\n\tcontent: string;\n\t/** The heading level. */\n\tlevel: number;\n\t/** Link to the heading. */\n\tlink: string;\n}\n\nexport interface NestedHeadingData {\n\t/** The heading content, level, and link. */\n\theading: HeadingData;\n\t/** The sub-headings of this heading, if any. */\n\tchildren: NestedHeadingData[] | null;\n}\n\n/**\n * Takes a flat list of heading parameters and nests them based on each header's\n * immediate parent's level.\n *\n * @param headingList The flat list of headings to nest.\n *\n * @return The nested list of headings.\n */\nexport function linearToNestedHeadingList(\n\theadingList: HeadingData[]\n): NestedHeadingData[] {\n\tconst nestedHeadingList: NestedHeadingData[] = [];\n\n\theadingList.forEach( ( heading, key ) => {\n\t\tif ( heading.content === '' ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Make sure we are only working with the same level as the first iteration in our set.\n\t\tif ( heading.level === headingList[ 0 ].level ) {\n\t\t\t// Check that the next iteration will return a value.\n\t\t\t// If it does and the next level is greater than the current level,\n\t\t\t// the next iteration becomes a child of the current iteration.\n\t\t\tif ( headingList[ key + 1 ]?.level > heading.level ) {\n\t\t\t\t// We must calculate the last index before the next iteration that\n\t\t\t\t// has the same level (siblings). We then use this index to slice\n\t\t\t\t// the array for use in recursion. This prevents duplicate nodes.\n\t\t\t\tlet endOfSlice = headingList.length;\n\t\t\t\tfor ( let i = key + 1; i < headingList.length; i++ ) {\n\t\t\t\t\tif ( headingList[ i ].level === heading.level ) {\n\t\t\t\t\t\tendOfSlice = i;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// We found a child node: Push a new node onto the return array\n\t\t\t\t// with children.\n\t\t\t\tnestedHeadingList.push( {\n\t\t\t\t\theading,\n\t\t\t\t\tchildren: linearToNestedHeadingList(\n\t\t\t\t\t\theadingList.slice( key + 1, endOfSlice )\n\t\t\t\t\t),\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\t// No child node: Push a new node onto the return array.\n\t\t\t\tnestedHeadingList.push( {\n\t\t\t\t\theading,\n\t\t\t\t\tchildren: null,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t} );\n\n\treturn nestedHeadingList;\n}\n\n/**\n * Converts a nested heading list into `core/list-item` blocks, with\n * sub-headings nested in a `core/list` block inside their parent item.\n *\n * @param nestedHeadingList The nested list of headings.\n * @param ordered Whether nested lists are ordered.\n *\n * @return The list item blocks.\n */\nexport function createListItemBlocks(\n\tnestedHeadingList: NestedHeadingData[],\n\tordered: boolean\n): Block[] {\n\treturn nestedHeadingList.map(\n\t\t( { heading: { content, link }, children } ) =>\n\t\t\tcreateBlock(\n\t\t\t\t'core/list-item',\n\t\t\t\t{\n\t\t\t\t\t// Headings are plain text, and links can carry query args on\n\t\t\t\t\t// paginated posts, so both need escaping to become markup.\n\t\t\t\t\tcontent: link\n\t\t\t\t\t\t? `<a href=\"${ escapeAttribute(\n\t\t\t\t\t\t\t\tlink\n\t\t\t\t\t\t
|
|
5
|
-
"mappings": ";AAAA,SAAS,mBAAmB;AAE5B,SAAS,iBAAiB,0BAA0B;AA0B7C,SAAS,0BACf,aACsB;AACtB,QAAM,oBAAyC,CAAC;AAEhD,cAAY,QAAS,CAAE,SAAS,QAAS;AACxC,QAAK,QAAQ,YAAY,IAAK;AAC7B;AAAA,IACD;AAGA,QAAK,QAAQ,UAAU,YAAa,CAAE,EAAE,OAAQ;AAI/C,UAAK,YAAa,MAAM,CAAE,GAAG,QAAQ,QAAQ,OAAQ;AAIpD,YAAI,aAAa,YAAY;AAC7B,iBAAU,IAAI,MAAM,GAAG,IAAI,YAAY,QAAQ,KAAM;AACpD,cAAK,YAAa,CAAE,EAAE,UAAU,QAAQ,OAAQ;AAC/C,yBAAa;AACb;AAAA,UACD;AAAA,QACD;AAIA,0BAAkB,KAAM;AAAA,UACvB;AAAA,UACA,UAAU;AAAA,YACT,YAAY,MAAO,MAAM,GAAG,UAAW;AAAA,UACxC;AAAA,QACD,CAAE;AAAA,MACH,OAAO;AAEN,0BAAkB,KAAM;AAAA,UACvB;AAAA,UACA,UAAU;AAAA,QACX,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD,CAAE;AAEF,SAAO;AACR;AAWO,SAAS,qBACf,mBACA,SACU;AACV,SAAO,kBAAkB;AAAA,IACxB,CAAE,EAAE,SAAS,EAAE,SAAS,KAAK,GAAG,SAAS,MACxC;AAAA,MACC;AAAA,MACA;AAAA;AAAA;AAAA,QAGC,SAAS,OACN,YAAa;AAAA,UACb;AAAA,
|
|
4
|
+
"sourcesContent": ["import { createBlock } from '@wordpress/blocks';\nimport type { Block } from '@wordpress/blocks';\nimport { escapeAttribute, escapeEditableHTML } from '@wordpress/escape-html';\n\nexport interface HeadingData {\n\t/** The plain text content of the heading. */\n\tcontent: string;\n\t/** The heading level. */\n\tlevel: number;\n\t/** Link to the heading. */\n\tlink: string;\n}\n\nexport interface NestedHeadingData {\n\t/** The heading content, level, and link. */\n\theading: HeadingData;\n\t/** The sub-headings of this heading, if any. */\n\tchildren: NestedHeadingData[] | null;\n}\n\n/**\n * Takes a flat list of heading parameters and nests them based on each header's\n * immediate parent's level.\n *\n * @param headingList The flat list of headings to nest.\n *\n * @return The nested list of headings.\n */\nexport function linearToNestedHeadingList(\n\theadingList: HeadingData[]\n): NestedHeadingData[] {\n\tconst nestedHeadingList: NestedHeadingData[] = [];\n\n\theadingList.forEach( ( heading, key ) => {\n\t\tif ( heading.content === '' ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Make sure we are only working with the same level as the first iteration in our set.\n\t\tif ( heading.level === headingList[ 0 ].level ) {\n\t\t\t// Check that the next iteration will return a value.\n\t\t\t// If it does and the next level is greater than the current level,\n\t\t\t// the next iteration becomes a child of the current iteration.\n\t\t\tif ( headingList[ key + 1 ]?.level > heading.level ) {\n\t\t\t\t// We must calculate the last index before the next iteration that\n\t\t\t\t// has the same level (siblings). We then use this index to slice\n\t\t\t\t// the array for use in recursion. This prevents duplicate nodes.\n\t\t\t\tlet endOfSlice = headingList.length;\n\t\t\t\tfor ( let i = key + 1; i < headingList.length; i++ ) {\n\t\t\t\t\tif ( headingList[ i ].level === heading.level ) {\n\t\t\t\t\t\tendOfSlice = i;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// We found a child node: Push a new node onto the return array\n\t\t\t\t// with children.\n\t\t\t\tnestedHeadingList.push( {\n\t\t\t\t\theading,\n\t\t\t\t\tchildren: linearToNestedHeadingList(\n\t\t\t\t\t\theadingList.slice( key + 1, endOfSlice )\n\t\t\t\t\t),\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\t// No child node: Push a new node onto the return array.\n\t\t\t\tnestedHeadingList.push( {\n\t\t\t\t\theading,\n\t\t\t\t\tchildren: null,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t} );\n\n\treturn nestedHeadingList;\n}\n\n/**\n * Converts a nested heading list into `core/list-item` blocks, with\n * sub-headings nested in a `core/list` block inside their parent item.\n *\n * @param nestedHeadingList The nested list of headings.\n * @param ordered Whether nested lists are ordered.\n *\n * @return The list item blocks.\n */\nexport function createListItemBlocks(\n\tnestedHeadingList: NestedHeadingData[],\n\tordered: boolean\n): Block[] {\n\treturn nestedHeadingList.map(\n\t\t( { heading: { content, link }, children } ) =>\n\t\t\tcreateBlock(\n\t\t\t\t'core/list-item',\n\t\t\t\t{\n\t\t\t\t\t// Headings are plain text, and links can carry query args on\n\t\t\t\t\t// paginated posts, so both need escaping to become markup.\n\t\t\t\t\tcontent: link\n\t\t\t\t\t\t? `<a href=\"${ escapeAttribute(\n\t\t\t\t\t\t\t\tlink\n\t\t\t\t\t\t\t) }\">${ escapeEditableHTML( content ) }</a>`\n\t\t\t\t\t\t: escapeEditableHTML( content ),\n\t\t\t\t},\n\t\t\t\tchildren?.length\n\t\t\t\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AAAA,MACA,UAAU,SACP;AAAA,QACA;AAAA,UACC;AAAA,UACA,EAAE,QAAQ;AAAA,UACV,qBAAsB,UAAU,OAAQ;AAAA,QACzC;AAAA,MACD,IACC,CAAC;AAAA,IACL;AAAA,EACF;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/tabs/use-tab-actions.js"],
|
|
4
|
-
"sourcesContent": ["import { 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, remove and move 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, moveTab: Function }} Tab action callbacks.\n */\nexport default function useTabActions( tabsClientId ) {\n\tconst registry = useRegistry();\n\tconst {\n\t\tinsertBlock,\n\t\tremoveBlock,\n\t\tmoveBlocksToPosition,\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
|
|
5
|
-
"mappings": ";AAAA,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,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,
|
|
4
|
+
"sourcesContent": ["import { 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, remove and move 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, moveTab: Function }} Tab action callbacks.\n */\nexport default function useTabActions( tabsClientId ) {\n\tconst registry = useRegistry();\n\tconst {\n\t\tinsertBlock,\n\t\tremoveBlock,\n\t\tmoveBlocksToPosition,\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\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' ),\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\t// Move the active tab one position left or right by reordering the\n\t// underlying tab-panel. The tab-list labels follow their panel\n\t// automatically via useTabListItemsSync.\n\tconst moveTab = ( direction ) => {\n\t\tconst { tabPanelsClientId, tabPanelBlocks, activeIndex } =\n\t\t\tgetTabsState();\n\t\tif ( ! tabPanelsClientId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst toIndex = activeIndex + direction;\n\t\tconst target = tabPanelBlocks[ activeIndex ];\n\t\tif ( ! target || toIndex < 0 || toIndex >= tabPanelBlocks.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tupdateBlockAttributes( tabsClientId, {\n\t\t\teditorActiveTabIndex: toIndex,\n\t\t} );\n\t\tmoveBlocksToPosition(\n\t\t\t[ target.clientId ],\n\t\t\ttabPanelsClientId,\n\t\t\ttabPanelsClientId,\n\t\t\ttoIndex\n\t\t);\n\t};\n\n\treturn { insertTab, removeTab, moveTab };\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,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,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,IAC7B,IACC;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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SelectControl as WCSelectControl,
|
|
7
7
|
Spinner,
|
|
8
8
|
RangeControl,
|
|
9
9
|
__experimentalUnitControl as UnitControl,
|
|
@@ -100,7 +100,7 @@ function TagCloudEdit({ attributes, setAttributes, name }) {
|
|
|
100
100
|
onDeselect: () => setAttributes({ taxonomy: "post_tag" }),
|
|
101
101
|
isShownByDefault: true,
|
|
102
102
|
children: /* @__PURE__ */ jsx(
|
|
103
|
-
|
|
103
|
+
WCSelectControl,
|
|
104
104
|
{
|
|
105
105
|
label: __("Taxonomy"),
|
|
106
106
|
options: getTaxonomyOptions(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/tag-cloud/edit.jsx"],
|
|
4
|
-
"sourcesContent": ["import {\n\tFlex,\n\tFlexItem,\n\tToggleControl,\n\tSelectControl,\n\tSpinner,\n\tRangeControl,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tInspectorControls,\n\tuseBlockProps,\n\tuseSettings,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useServerSideRender } from '@wordpress/server-side-render';\nimport { useDisabled } from '@wordpress/compose';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\nimport HtmlRenderer from '../utils/html-renderer';\n\n/**\n * Minimum number of tags a user can show using this block.\n *\n * @type {number}\n */\nconst MIN_TAGS = 1;\n\n/**\n * Maximum number of tags a user can show using this block.\n *\n * @type {number}\n */\nconst MAX_TAGS = 100;\n\nconst MIN_FONT_SIZE = 0.1;\nconst MAX_FONT_SIZE = 100;\n\nfunction TagCloudEdit( { attributes, setAttributes, name } ) {\n\tconst {\n\t\ttaxonomy,\n\t\tshowTagCounts,\n\t\tnumberOfTags,\n\t\tsmallestFontSize,\n\t\tlargestFontSize,\n\t} = attributes;\n\n\tconst [ availableUnits ] = useSettings( 'spacing.units' );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\t// The `pt` unit is used as the default value and is therefore\n\t// always considered an available unit.\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: availableUnits\n\t\t\t? [ ...availableUnits, 'pt' ]\n\t\t\t: [ '%', 'px', 'em', 'rem', 'pt' ],\n\t} );\n\n\tconst taxonomies = useSelect(\n\t\t( select ) => select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t[]\n\t);\n\n\tconst getTaxonomyOptions = () => {\n\t\tconst selectOption = {\n\t\t\tlabel: __( '- Select -' ),\n\t\t\tvalue: '',\n\t\t\tdisabled: true,\n\t\t};\n\t\tconst taxonomyOptions = ( taxonomies ?? [] )\n\t\t\t.filter( ( tax ) => !! tax.show_cloud )\n\t\t\t.map( ( item ) => {\n\t\t\t\treturn {\n\t\t\t\t\tvalue: item.slug,\n\t\t\t\t\tlabel: item.name,\n\t\t\t\t};\n\t\t\t} );\n\n\t\treturn [ selectOption, ...taxonomyOptions ];\n\t};\n\n\tconst onFontSizeChange = ( fontSizeLabel, newValue ) => {\n\t\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\t\tconst [ quantity, newUnit ] =\n\t\t\tparseQuantityAndUnitFromRawValue( newValue );\n\t\tif ( ! Number.isFinite( quantity ) ) {\n\t\t\treturn;\n\t\t}\n\t\tconst updateObj = { [ fontSizeLabel ]: newValue };\n\t\t// We need to keep in sync the `unit` changes to both `smallestFontSize`\n\t\t// and `largestFontSize` attributes.\n\t\tObject.entries( {\n\t\t\tsmallestFontSize,\n\t\t\tlargestFontSize,\n\t\t} ).forEach( ( [ attribute, currentValue ] ) => {\n\t\t\tconst [ currentQuantity, currentUnit ] =\n\t\t\t\tparseQuantityAndUnitFromRawValue( currentValue );\n\t\t\t// Only add an update if the other font size attribute has a different unit.\n\t\t\tif ( attribute !== fontSizeLabel && currentUnit !== newUnit ) {\n\t\t\t\tupdateObj[ attribute ] = `${ currentQuantity }${ newUnit }`;\n\t\t\t}\n\t\t} );\n\t\tsetAttributes( updateObj );\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\ttaxonomy: 'post_tag',\n\t\t\t\t\t\tshowTagCounts: false,\n\t\t\t\t\t\tnumberOfTags: 45,\n\t\t\t\t\t\tsmallestFontSize: '8pt',\n\t\t\t\t\t\tlargestFontSize: '22pt',\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={ () => taxonomy !== 'post_tag' }\n\t\t\t\t\tlabel={ __( 'Taxonomy' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { taxonomy: 'post_tag' } )\n\t\t\t\t\t}\n\t\t\t\t\tisShownByDefault\n\t\t\t\t>\n\t\t\t\t\t<
|
|
5
|
-
"mappings": ";AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,
|
|
4
|
+
"sourcesContent": ["import {\n\tFlex,\n\tFlexItem,\n\tToggleControl,\n\tSelectControl as WCSelectControl,\n\tSpinner,\n\tRangeControl,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tInspectorControls,\n\tuseBlockProps,\n\tuseSettings,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useServerSideRender } from '@wordpress/server-side-render';\nimport { useDisabled } from '@wordpress/compose';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\nimport HtmlRenderer from '../utils/html-renderer';\n\n/**\n * Minimum number of tags a user can show using this block.\n *\n * @type {number}\n */\nconst MIN_TAGS = 1;\n\n/**\n * Maximum number of tags a user can show using this block.\n *\n * @type {number}\n */\nconst MAX_TAGS = 100;\n\nconst MIN_FONT_SIZE = 0.1;\nconst MAX_FONT_SIZE = 100;\n\nfunction TagCloudEdit( { attributes, setAttributes, name } ) {\n\tconst {\n\t\ttaxonomy,\n\t\tshowTagCounts,\n\t\tnumberOfTags,\n\t\tsmallestFontSize,\n\t\tlargestFontSize,\n\t} = attributes;\n\n\tconst [ availableUnits ] = useSettings( 'spacing.units' );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\t// The `pt` unit is used as the default value and is therefore\n\t// always considered an available unit.\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: availableUnits\n\t\t\t? [ ...availableUnits, 'pt' ]\n\t\t\t: [ '%', 'px', 'em', 'rem', 'pt' ],\n\t} );\n\n\tconst taxonomies = useSelect(\n\t\t( select ) => select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t[]\n\t);\n\n\tconst getTaxonomyOptions = () => {\n\t\tconst selectOption = {\n\t\t\tlabel: __( '- Select -' ),\n\t\t\tvalue: '',\n\t\t\tdisabled: true,\n\t\t};\n\t\tconst taxonomyOptions = ( taxonomies ?? [] )\n\t\t\t.filter( ( tax ) => !! tax.show_cloud )\n\t\t\t.map( ( item ) => {\n\t\t\t\treturn {\n\t\t\t\t\tvalue: item.slug,\n\t\t\t\t\tlabel: item.name,\n\t\t\t\t};\n\t\t\t} );\n\n\t\treturn [ selectOption, ...taxonomyOptions ];\n\t};\n\n\tconst onFontSizeChange = ( fontSizeLabel, newValue ) => {\n\t\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\t\tconst [ quantity, newUnit ] =\n\t\t\tparseQuantityAndUnitFromRawValue( newValue );\n\t\tif ( ! Number.isFinite( quantity ) ) {\n\t\t\treturn;\n\t\t}\n\t\tconst updateObj = { [ fontSizeLabel ]: newValue };\n\t\t// We need to keep in sync the `unit` changes to both `smallestFontSize`\n\t\t// and `largestFontSize` attributes.\n\t\tObject.entries( {\n\t\t\tsmallestFontSize,\n\t\t\tlargestFontSize,\n\t\t} ).forEach( ( [ attribute, currentValue ] ) => {\n\t\t\tconst [ currentQuantity, currentUnit ] =\n\t\t\t\tparseQuantityAndUnitFromRawValue( currentValue );\n\t\t\t// Only add an update if the other font size attribute has a different unit.\n\t\t\tif ( attribute !== fontSizeLabel && currentUnit !== newUnit ) {\n\t\t\t\tupdateObj[ attribute ] = `${ currentQuantity }${ newUnit }`;\n\t\t\t}\n\t\t} );\n\t\tsetAttributes( updateObj );\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\ttaxonomy: 'post_tag',\n\t\t\t\t\t\tshowTagCounts: false,\n\t\t\t\t\t\tnumberOfTags: 45,\n\t\t\t\t\t\tsmallestFontSize: '8pt',\n\t\t\t\t\t\tlargestFontSize: '22pt',\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={ () => taxonomy !== 'post_tag' }\n\t\t\t\t\tlabel={ __( 'Taxonomy' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { taxonomy: 'post_tag' } )\n\t\t\t\t\t}\n\t\t\t\t\tisShownByDefault\n\t\t\t\t>\n\t\t\t\t\t<WCSelectControl\n\t\t\t\t\t\tlabel={ __( 'Taxonomy' ) }\n\t\t\t\t\t\toptions={ getTaxonomyOptions() }\n\t\t\t\t\t\tvalue={ taxonomy }\n\t\t\t\t\t\tonChange={ ( selectedTaxonomy ) =>\n\t\t\t\t\t\t\tsetAttributes( { taxonomy: selectedTaxonomy } )\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={ () =>\n\t\t\t\t\t\tsmallestFontSize !== '8pt' || largestFontSize !== '22pt'\n\t\t\t\t\t}\n\t\t\t\t\tlabel={ __( 'Font size' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tsmallestFontSize: '8pt',\n\t\t\t\t\t\t\tlargestFontSize: '22pt',\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t\tisShownByDefault\n\t\t\t\t>\n\t\t\t\t\t<Flex gap={ 4 }>\n\t\t\t\t\t\t<FlexItem isBlock>\n\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Smallest size' ) }\n\t\t\t\t\t\t\t\tvalue={ smallestFontSize }\n\t\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\t\tonFontSizeChange(\n\t\t\t\t\t\t\t\t\t\t'smallestFontSize',\n\t\t\t\t\t\t\t\t\t\tvalue\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\tunits={ units }\n\t\t\t\t\t\t\t\tmin={ MIN_FONT_SIZE }\n\t\t\t\t\t\t\t\tmax={ MAX_FONT_SIZE }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t<FlexItem isBlock>\n\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Largest size' ) }\n\t\t\t\t\t\t\t\tvalue={ largestFontSize }\n\t\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\t\tonFontSizeChange(\n\t\t\t\t\t\t\t\t\t\t'largestFontSize',\n\t\t\t\t\t\t\t\t\t\tvalue\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\tunits={ units }\n\t\t\t\t\t\t\t\tmin={ MIN_FONT_SIZE }\n\t\t\t\t\t\t\t\tmax={ MAX_FONT_SIZE }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t</Flex>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => numberOfTags !== 45 }\n\t\t\t\t\tlabel={ __( 'Number of tags' ) }\n\t\t\t\t\tonDeselect={ () => setAttributes( { numberOfTags: 45 } ) }\n\t\t\t\t\tisShownByDefault\n\t\t\t\t>\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\tlabel={ __( 'Number of tags' ) }\n\t\t\t\t\t\tvalue={ numberOfTags }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { numberOfTags: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmin={ MIN_TAGS }\n\t\t\t\t\t\tmax={ MAX_TAGS }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => showTagCounts !== false }\n\t\t\t\t\tlabel={ __( 'Show tag counts' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { showTagCounts: 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={ __( 'Show tag counts' ) }\n\t\t\t\t\t\tchecked={ showTagCounts }\n\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\tsetAttributes( { showTagCounts: ! showTagCounts } )\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\tconst { content, status, error } = useServerSideRender( {\n\t\tattributes,\n\t\tskipBlockSupportAttributes: true,\n\t\tblock: name,\n\t} );\n\n\tconst disabledRef = useDisabled();\n\tconst blockProps = useBlockProps( { ref: disabledRef } );\n\n\treturn (\n\t\t<>\n\t\t\t{ inspectorControls }\n\t\t\t{ status === 'loading' && (\n\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ status === 'error' && (\n\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t/* translators: %s: error message returned when rendering the block. */\n\t\t\t\t\t\t\t__( 'Error: %s' ),\n\t\t\t\t\t\t\terror\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ status === 'success' && (\n\t\t\t\t<HtmlRenderer wrapperProps={ blockProps } html={ content } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default TagCloudEdit;\n"],
|
|
5
|
+
"mappings": ";AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB;AAAA,EACA;AAAA,EACA,6BAA6B;AAAA,EAC7B,gCAAgC;AAAA,EAChC,kDAAkD;AAAA,EAClD,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,OAC1B;AACP,SAAS,iBAAiB;AAC1B,SAAS,IAAI,eAAe;AAC5B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,SAAS,iBAAiB;AACnC,SAAS,2BAA2B;AACpC,SAAS,mBAAmB;AAC5B,SAAS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A,EACD,GACD;AAGD,QAAM,EAAE,SAAS,QAAQ,MAAM,IAAI,oBAAqB;AAAA,IACvD;AAAA,IACA,4BAA4B;AAAA,IAC5B,OAAO;AAAA,EACR,CAAE;AAEF,QAAM,cAAc,YAAY;AAChC,QAAM,aAAa,cAAe,EAAE,KAAK,YAAY,CAAE;AAEvD,SACC,iCACG;AAAA;AAAA,IACA,WAAW,aACZ,oBAAC,SAAM,GAAG,YACT,8BAAC,WAAQ,GACV;AAAA,IAEC,WAAW,WACZ,oBAAC,SAAM,GAAG,YACT,8BAAC,OACE;AAAA;AAAA,MAED,GAAI,WAAY;AAAA,MAChB;AAAA,IACD,GACD,GACD;AAAA,IAEC,WAAW,aACZ,oBAAC,gBAAa,cAAe,YAAa,MAAO,SAAU;AAAA,KAE7D;AAEF;AAEA,IAAO,eAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// packages/block-library/src/template-part/edit/advanced-controls.jsx
|
|
2
2
|
import { useEntityProp, store as coreStore } from "@wordpress/core-data";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
SelectControl as WCSelectControl,
|
|
5
|
+
TextControl
|
|
6
|
+
} from "@wordpress/components";
|
|
4
7
|
import { sprintf, __ } from "@wordpress/i18n";
|
|
5
8
|
import { useSelect } from "@wordpress/data";
|
|
6
9
|
import { privateApis as blockEditorPrivateApis } from "@wordpress/block-editor";
|
|
@@ -53,7 +56,7 @@ function TemplatePartAdvancedControls({
|
|
|
53
56
|
}
|
|
54
57
|
),
|
|
55
58
|
/* @__PURE__ */ jsx(
|
|
56
|
-
|
|
59
|
+
WCSelectControl,
|
|
57
60
|
{
|
|
58
61
|
label: __("Area"),
|
|
59
62
|
labelPosition: "top",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/template-part/edit/advanced-controls.jsx"],
|
|
4
|
-
"sourcesContent": ["import { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport {
|
|
5
|
-
"mappings": ";AAAA,SAAS,eAAe,SAAS,iBAAiB;AAClD,
|
|
4
|
+
"sourcesContent": ["import { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport {\n\tSelectControl as WCSelectControl,\n\tTextControl,\n} from '@wordpress/components';\nimport { sprintf, __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { TemplatePartImportControls } from './import-controls';\nimport { unlock } from '../../lock-unlock';\n\nconst { HTMLElementControl } = unlock( blockEditorPrivateApis );\n\nexport function TemplatePartAdvancedControls( {\n\ttagName,\n\tsetAttributes,\n\tisEntityAvailable,\n\ttemplatePartId,\n\tdefaultWrapper,\n\thasInnerBlocks,\n\tclientId,\n} ) {\n\tconst [ area, setArea ] = useEntityProp(\n\t\t'postType',\n\t\t'wp_template_part',\n\t\t'area',\n\t\ttemplatePartId\n\t);\n\n\tconst [ title, setTitle ] = useEntityProp(\n\t\t'postType',\n\t\t'wp_template_part',\n\t\t'title',\n\t\ttemplatePartId\n\t);\n\n\tconst defaultTemplatePartAreas = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getCurrentTheme()\n\t\t\t\t?.default_template_part_areas || [],\n\t\t[]\n\t);\n\n\tconst areaOptions = defaultTemplatePartAreas.map(\n\t\t( { label, area: _area } ) => ( {\n\t\t\tlabel,\n\t\t\tvalue: _area,\n\t\t} )\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ isEntityAvailable && (\n\t\t\t\t<>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'Title' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\tsetTitle( value );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonFocus={ ( event ) => event.target.select() }\n\t\t\t\t\t/>\n\t\t\t\t\t<WCSelectControl\n\t\t\t\t\t\tlabel={ __( 'Area' ) }\n\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\toptions={ areaOptions }\n\t\t\t\t\t\tvalue={ area }\n\t\t\t\t\t\tonChange={ setArea }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<HTMLElementControl\n\t\t\t\ttagName={ tagName || '' }\n\t\t\t\tonChange={ ( value ) => setAttributes( { tagName: value } ) }\n\t\t\t\tclientId={ clientId }\n\t\t\t\toptions={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: sprintf(\n\t\t\t\t\t\t\t/* translators: %s: HTML tag based on area. */\n\t\t\t\t\t\t\t__( 'Default based on area (%s)' ),\n\t\t\t\t\t\t\t`<${ defaultWrapper }>`\n\t\t\t\t\t\t),\n\t\t\t\t\t\tvalue: '',\n\t\t\t\t\t},\n\t\t\t\t\t{ label: '<header>', value: 'header' },\n\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t{ label: '<article>', value: 'article' },\n\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t{ label: '<footer>', value: 'footer' },\n\t\t\t\t\t{ label: '<div>', value: 'div' },\n\t\t\t\t] }\n\t\t\t/>\n\t\t\t{ ! hasInnerBlocks && (\n\t\t\t\t<TemplatePartImportControls\n\t\t\t\t\tarea={ area }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,eAAe,SAAS,iBAAiB;AAClD;AAAA,EACC,iBAAiB;AAAA,EACjB;AAAA,OACM;AACP,SAAS,SAAS,UAAU;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,eAAe,8BAA8B;AACtD,SAAS,kCAAkC;AAC3C,SAAS,cAAc;AA4CnB,mBACC,KADD;AA1CJ,IAAM,EAAE,mB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AA,UACA,EAAE,OAAO,YAAY,OAAO,SAAS;AAAA,UACrC,EAAE,OAAO,UAAU,OAAO,OAAO;AAAA,UACjC,EAAE,OAAO,aAAa,OAAO,UAAU;AAAA,UACvC,EAAE,OAAO,aAAa,OAAO,UAAU;AAAA,UACvC,EAAE,OAAO,WAAW,OAAO,QAAQ;AAAA,UACnC,EAAE,OAAO,YAAY,OAAO,SAAS;AAAA,UACrC,EAAE,OAAO,SAAS,OAAO,MAAM;AAAA,QAChC;AAAA;AAAA,IACD;AAAA,IACE,CAAE,kBACH;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
Button,
|
|
7
7
|
FlexBlock,
|
|
8
8
|
FlexItem,
|
|
9
|
-
SelectControl,
|
|
9
|
+
SelectControl as WCSelectControl,
|
|
10
10
|
__experimentalHStack as HStack,
|
|
11
11
|
__experimentalSpacer as Spacer
|
|
12
12
|
} from "@wordpress/components";
|
|
@@ -104,7 +104,7 @@ function TemplatePartImportControls({ area, setAttributes }) {
|
|
|
104
104
|
}
|
|
105
105
|
return /* @__PURE__ */ jsx(Spacer, { marginBottom: "4", children: /* @__PURE__ */ jsxs(HStack, { as: "form", onSubmit: createFromWidgets, children: [
|
|
106
106
|
/* @__PURE__ */ jsx(FlexBlock, { children: /* @__PURE__ */ jsx(
|
|
107
|
-
|
|
107
|
+
WCSelectControl,
|
|
108
108
|
{
|
|
109
109
|
label: __("Import widget area"),
|
|
110
110
|
value: selectedSidebar,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/template-part/edit/import-controls.jsx"],
|
|
4
|
-
"sourcesContent": ["import { __, _x, sprintf } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport {\n\tButton,\n\tFlexBlock,\n\tFlexItem,\n\tSelectControl,\n\t__experimentalHStack as HStack,\n\t__experimentalSpacer as Spacer,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useCreateTemplatePartFromBlocks } from './utils/hooks';\nimport { transformWidgetToBlock } from './utils/transformers';\n\nconst SIDEBARS_QUERY = {\n\tper_page: -1,\n\t_fields: 'id,name,description,status,widgets',\n};\n\nexport function TemplatePartImportControls( { area, setAttributes } ) {\n\tconst [ selectedSidebar, setSelectedSidebar ] = useState( '' );\n\tconst [ isBusy, setIsBusy ] = useState( false );\n\n\tconst registry = useRegistry();\n\tconst { sidebars, hasResolved } = useSelect( ( select ) => {\n\t\tconst { getSidebars, hasFinishedResolution } = select( coreStore );\n\n\t\treturn {\n\t\t\tsidebars: getSidebars( SIDEBARS_QUERY ),\n\t\t\thasResolved: hasFinishedResolution( 'getSidebars', [\n\t\t\t\tSIDEBARS_QUERY,\n\t\t\t] ),\n\t\t};\n\t}, [] );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tconst createFromBlocks = useCreateTemplatePartFromBlocks(\n\t\tarea,\n\t\tsetAttributes\n\t);\n\n\tconst options = useMemo( () => {\n\t\tconst sidebarOptions = ( sidebars ?? [] )\n\t\t\t.filter(\n\t\t\t\t( widgetArea ) =>\n\t\t\t\t\twidgetArea.id !== 'wp_inactive_widgets' &&\n\t\t\t\t\twidgetArea.widgets.length > 0\n\t\t\t)\n\t\t\t.map( ( widgetArea ) => {\n\t\t\t\treturn {\n\t\t\t\t\tvalue: widgetArea.id,\n\t\t\t\t\tlabel: widgetArea.name,\n\t\t\t\t};\n\t\t\t} );\n\n\t\tif ( ! sidebarOptions.length ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn [\n\t\t\t{ value: '', label: __( 'Select widget area' ) },\n\t\t\t...sidebarOptions,\n\t\t];\n\t}, [ sidebars ] );\n\n\t// Render an empty node while data is loading to avoid SlotFill re-positioning bug.\n\t// See: https://github.com/WordPress/gutenberg/issues/15641.\n\tif ( ! hasResolved ) {\n\t\treturn <Spacer marginBottom=\"0\" />;\n\t}\n\n\tif ( hasResolved && ! options.length ) {\n\t\treturn null;\n\t}\n\n\tasync function createFromWidgets( event ) {\n\t\tevent.preventDefault();\n\n\t\tif ( isBusy || ! selectedSidebar ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsBusy( true );\n\n\t\tconst sidebar = options.find(\n\t\t\t( { value } ) => value === selectedSidebar\n\t\t);\n\t\tconst { getWidgets } = registry.resolveSelect( coreStore );\n\n\t\t// The widgets API always returns a successful response.\n\t\tconst widgets = await getWidgets( {\n\t\t\tsidebar: sidebar.value,\n\t\t\t_embed: 'about',\n\t\t} );\n\n\t\tconst skippedWidgets = new Set();\n\t\tconst blocks = widgets.flatMap( ( widget ) => {\n\t\t\tconst block = transformWidgetToBlock( widget );\n\n\t\t\t// Skip the block if we have no matching transformations.\n\t\t\tif ( ! block ) {\n\t\t\t\tskippedWidgets.add( widget.id_base );\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\treturn block;\n\t\t} );\n\n\t\tawait createFromBlocks(\n\t\t\tblocks,\n\t\t\t/* translators: %s: name of the widget area */\n\t\t\tsprintf( __( 'Widget area: %s' ), sidebar.label )\n\t\t);\n\n\t\tif ( skippedWidgets.size ) {\n\t\t\tcreateErrorNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: the list of widgets */\n\t\t\t\t\t__( 'Unable to import the following widgets: %s.' ),\n\t\t\t\t\tArray.from( skippedWidgets ).join( ', ' )\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tsetIsBusy( false );\n\t}\n\n\treturn (\n\t\t<Spacer marginBottom=\"4\">\n\t\t\t<HStack as=\"form\" onSubmit={ createFromWidgets }>\n\t\t\t\t<FlexBlock>\n\t\t\t\t\t<
|
|
5
|
-
"mappings": ";AAAA,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,SAAS,gBAAgB;AAClC,SAAS,aAAa,WAAW,mBAAmB;AACpD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,
|
|
4
|
+
"sourcesContent": ["import { __, _x, sprintf } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport {\n\tButton,\n\tFlexBlock,\n\tFlexItem,\n\tSelectControl as WCSelectControl,\n\t__experimentalHStack as HStack,\n\t__experimentalSpacer as Spacer,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useCreateTemplatePartFromBlocks } from './utils/hooks';\nimport { transformWidgetToBlock } from './utils/transformers';\n\nconst SIDEBARS_QUERY = {\n\tper_page: -1,\n\t_fields: 'id,name,description,status,widgets',\n};\n\nexport function TemplatePartImportControls( { area, setAttributes } ) {\n\tconst [ selectedSidebar, setSelectedSidebar ] = useState( '' );\n\tconst [ isBusy, setIsBusy ] = useState( false );\n\n\tconst registry = useRegistry();\n\tconst { sidebars, hasResolved } = useSelect( ( select ) => {\n\t\tconst { getSidebars, hasFinishedResolution } = select( coreStore );\n\n\t\treturn {\n\t\t\tsidebars: getSidebars( SIDEBARS_QUERY ),\n\t\t\thasResolved: hasFinishedResolution( 'getSidebars', [\n\t\t\t\tSIDEBARS_QUERY,\n\t\t\t] ),\n\t\t};\n\t}, [] );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tconst createFromBlocks = useCreateTemplatePartFromBlocks(\n\t\tarea,\n\t\tsetAttributes\n\t);\n\n\tconst options = useMemo( () => {\n\t\tconst sidebarOptions = ( sidebars ?? [] )\n\t\t\t.filter(\n\t\t\t\t( widgetArea ) =>\n\t\t\t\t\twidgetArea.id !== 'wp_inactive_widgets' &&\n\t\t\t\t\twidgetArea.widgets.length > 0\n\t\t\t)\n\t\t\t.map( ( widgetArea ) => {\n\t\t\t\treturn {\n\t\t\t\t\tvalue: widgetArea.id,\n\t\t\t\t\tlabel: widgetArea.name,\n\t\t\t\t};\n\t\t\t} );\n\n\t\tif ( ! sidebarOptions.length ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn [\n\t\t\t{ value: '', label: __( 'Select widget area' ) },\n\t\t\t...sidebarOptions,\n\t\t];\n\t}, [ sidebars ] );\n\n\t// Render an empty node while data is loading to avoid SlotFill re-positioning bug.\n\t// See: https://github.com/WordPress/gutenberg/issues/15641.\n\tif ( ! hasResolved ) {\n\t\treturn <Spacer marginBottom=\"0\" />;\n\t}\n\n\tif ( hasResolved && ! options.length ) {\n\t\treturn null;\n\t}\n\n\tasync function createFromWidgets( event ) {\n\t\tevent.preventDefault();\n\n\t\tif ( isBusy || ! selectedSidebar ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsBusy( true );\n\n\t\tconst sidebar = options.find(\n\t\t\t( { value } ) => value === selectedSidebar\n\t\t);\n\t\tconst { getWidgets } = registry.resolveSelect( coreStore );\n\n\t\t// The widgets API always returns a successful response.\n\t\tconst widgets = await getWidgets( {\n\t\t\tsidebar: sidebar.value,\n\t\t\t_embed: 'about',\n\t\t} );\n\n\t\tconst skippedWidgets = new Set();\n\t\tconst blocks = widgets.flatMap( ( widget ) => {\n\t\t\tconst block = transformWidgetToBlock( widget );\n\n\t\t\t// Skip the block if we have no matching transformations.\n\t\t\tif ( ! block ) {\n\t\t\t\tskippedWidgets.add( widget.id_base );\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\treturn block;\n\t\t} );\n\n\t\tawait createFromBlocks(\n\t\t\tblocks,\n\t\t\t/* translators: %s: name of the widget area */\n\t\t\tsprintf( __( 'Widget area: %s' ), sidebar.label )\n\t\t);\n\n\t\tif ( skippedWidgets.size ) {\n\t\t\tcreateErrorNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: the list of widgets */\n\t\t\t\t\t__( 'Unable to import the following widgets: %s.' ),\n\t\t\t\t\tArray.from( skippedWidgets ).join( ', ' )\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tsetIsBusy( false );\n\t}\n\n\treturn (\n\t\t<Spacer marginBottom=\"4\">\n\t\t\t<HStack as=\"form\" onSubmit={ createFromWidgets }>\n\t\t\t\t<FlexBlock>\n\t\t\t\t\t<WCSelectControl\n\t\t\t\t\t\tlabel={ __( 'Import widget area' ) }\n\t\t\t\t\t\tvalue={ selectedSidebar }\n\t\t\t\t\t\toptions={ options }\n\t\t\t\t\t\tonChange={ ( value ) => setSelectedSidebar( value ) }\n\t\t\t\t\t\tdisabled={ ! options.length }\n\t\t\t\t\t/>\n\t\t\t\t</FlexBlock>\n\t\t\t\t<FlexItem\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\tmarginBottom: '8px',\n\t\t\t\t\t\tmarginTop: 'auto',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\taria-disabled={ isBusy || ! selectedSidebar }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ _x( 'Import', 'button label' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t</HStack>\n\t\t</Spacer>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,SAAS,gBAAgB;AAClC,SAAS,aAAa,WAAW,mBAAmB;AACpD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AACP,SAAS,SAA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