@wordpress/block-library 10.1.1-next.v.202607070741.0 → 10.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/build/accordion/block.json +1 -0
- package/build/accordion-panel/block.json +1 -0
- package/build/button/edit.cjs +18 -8
- package/build/button/edit.cjs.map +2 -2
- package/build/code/edit.cjs +3 -1
- package/build/code/edit.cjs.map +2 -2
- package/build/cover/block.json +12 -0
- package/build/cover/edit/block-controls.cjs +14 -5
- package/build/cover/edit/block-controls.cjs.map +2 -2
- package/build/cover/edit/embed-video-url-input.cjs +5 -3
- package/build/cover/edit/embed-video-url-input.cjs.map +3 -3
- package/build/cover/edit/index.cjs +76 -32
- package/build/cover/edit/index.cjs.map +2 -2
- package/build/cover/embed-video-utils.cjs +17 -7
- package/build/cover/embed-video-utils.cjs.map +2 -2
- package/build/details/transforms.cjs +1 -3
- package/build/details/transforms.cjs.map +2 -2
- package/build/embed/edit.cjs +1 -1
- package/build/embed/edit.cjs.map +2 -2
- package/build/embed/embed-placeholder.cjs +1 -2
- package/build/embed/embed-placeholder.cjs.map +2 -2
- package/build/file/edit.cjs +4 -3
- package/build/file/edit.cjs.map +2 -2
- package/build/file/transforms.cjs +25 -60
- package/build/file/transforms.cjs.map +2 -2
- package/build/gallery/block.json +4 -2
- package/build/gallery/dynamic-gallery.cjs +104 -61
- package/build/gallery/dynamic-gallery.cjs.map +3 -3
- package/build/gallery/edit.cjs +1 -1
- package/build/gallery/edit.cjs.map +3 -3
- package/build/gallery/gap-styles.cjs +49 -13
- package/build/gallery/gap-styles.cjs.map +3 -3
- package/build/gallery/use-dynamic-gallery.cjs +15 -8
- package/build/gallery/use-dynamic-gallery.cjs.map +2 -2
- package/build/group/transforms.cjs +1 -1
- package/build/group/transforms.cjs.map +2 -2
- package/build/heading/edit.cjs +1 -1
- package/build/heading/edit.cjs.map +2 -2
- package/build/html/modal.cjs +63 -54
- package/build/html/modal.cjs.map +3 -3
- package/build/icon/block.json +5 -3
- package/build/icon/components/custom-inserter/icon-grid.cjs +25 -12
- package/build/icon/components/custom-inserter/icon-grid.cjs.map +2 -2
- package/build/icon/components/custom-inserter/index.cjs +100 -31
- package/build/icon/components/custom-inserter/index.cjs.map +3 -3
- package/build/icon/edit.cjs +11 -12
- package/build/icon/edit.cjs.map +2 -2
- package/build/image/block.json +1 -1
- package/build/image/edit.cjs +1 -35
- package/build/image/edit.cjs.map +2 -2
- package/build/image/image.cjs +23 -18
- package/build/image/image.cjs.map +3 -3
- package/build/image/transforms.cjs +78 -0
- package/build/image/transforms.cjs.map +3 -3
- package/build/image/use-open-image-media-editor-modal.cjs +6 -2
- package/build/image/use-open-image-media-editor-modal.cjs.map +2 -2
- package/build/index.cjs +18 -8
- package/build/index.cjs.map +2 -2
- package/build/latest-posts/edit.cjs +5 -8
- package/build/latest-posts/edit.cjs.map +2 -2
- package/build/list-item/edit.cjs +1 -1
- package/build/list-item/edit.cjs.map +2 -2
- package/build/list-item/hooks/use-enter.cjs +14 -17
- package/build/list-item/hooks/use-enter.cjs.map +3 -3
- package/build/list-item/hooks/use-indent-list-item.cjs +10 -2
- package/build/list-item/hooks/use-indent-list-item.cjs.map +2 -2
- package/build/list-item/hooks/use-space.cjs +3 -2
- package/build/list-item/hooks/use-space.cjs.map +3 -3
- package/build/math/edit.cjs +39 -56
- package/build/math/edit.cjs.map +3 -3
- package/build/media-text/edit.cjs +2 -1
- package/build/media-text/edit.cjs.map +2 -2
- package/build/more/edit.cjs +2 -2
- package/build/more/edit.cjs.map +2 -2
- package/build/navigation/edit/index.cjs +30 -16
- package/build/navigation/edit/index.cjs.map +3 -3
- package/build/navigation/edit/use-layout-custom-properties.cjs +72 -0
- package/build/navigation/edit/use-layout-custom-properties.cjs.map +7 -0
- package/build/navigation/view.cjs +9 -6
- package/build/navigation/view.cjs.map +2 -2
- package/build/navigation-link/edit.cjs +3 -3
- package/build/navigation-link/edit.cjs.map +2 -2
- package/build/navigation-link/link-ui/index.cjs +2 -2
- package/build/navigation-link/link-ui/index.cjs.map +2 -2
- package/build/paragraph/edit.cjs +5 -2
- package/build/paragraph/edit.cjs.map +3 -3
- package/build/paragraph/index.cjs +4 -1
- package/build/paragraph/index.cjs.map +2 -2
- package/build/paragraph/use-enter.cjs +3 -7
- package/build/paragraph/use-enter.cjs.map +3 -3
- package/build/playlist/block.json +29 -10
- package/build/playlist/context.cjs +2 -1
- package/build/playlist/context.cjs.map +2 -2
- package/build/playlist/edit.cjs +328 -39
- package/build/playlist/edit.cjs.map +3 -3
- package/build/playlist/index.cjs +1 -1
- package/build/playlist/index.cjs.map +2 -2
- package/build/playlist/utils.cjs +37 -8
- package/build/playlist/utils.cjs.map +2 -2
- package/build/playlist/view.cjs +83 -13
- package/build/playlist/view.cjs.map +2 -2
- package/build/playlist-track/block.json +4 -2
- package/build/playlist-track/edit.cjs +115 -70
- package/build/playlist-track/edit.cjs.map +2 -2
- package/build/post-content/block.json +1 -0
- package/build/post-content/edit.cjs +36 -15
- package/build/post-content/edit.cjs.map +2 -2
- package/build/post-featured-image/edit.cjs +3 -2
- package/build/post-featured-image/edit.cjs.map +2 -2
- package/build/post-template/block.json +2 -1
- package/build/post-template/edit.cjs +10 -1
- package/build/post-template/edit.cjs.map +2 -2
- package/build/post-terms/edit.cjs +2 -2
- package/build/post-terms/edit.cjs.map +2 -2
- package/build/post-title/edit.cjs +2 -2
- package/build/post-title/edit.cjs.map +2 -2
- package/build/preformatted/edit.cjs +3 -1
- package/build/preformatted/edit.cjs.map +2 -2
- package/build/pullquote/block.json +3 -1
- package/build/pullquote/edit.cjs +5 -3
- package/build/pullquote/edit.cjs.map +2 -2
- package/build/query/block.json +3 -2
- package/build/query/edit/inspector-controls/index.cjs +42 -5
- package/build/query/edit/inspector-controls/index.cjs.map +2 -2
- package/build/query/edit/inspector-controls/offset-controls.cjs +1 -2
- package/build/query/edit/inspector-controls/offset-controls.cjs.map +2 -2
- package/build/query/edit/inspector-controls/pages-control.cjs +0 -1
- package/build/query/edit/inspector-controls/pages-control.cjs.map +2 -2
- package/build/query/edit/query-content.cjs +10 -3
- package/build/query/edit/query-content.cjs.map +2 -2
- package/build/query/index.cjs +2 -1
- package/build/query/index.cjs.map +2 -2
- package/build/quote/block.json +3 -1
- package/build/quote/transforms.cjs +1 -3
- package/build/quote/transforms.cjs.map +2 -2
- package/build/read-more/edit.cjs +3 -1
- package/build/read-more/edit.cjs.map +2 -2
- package/build/rss/edit.cjs +0 -1
- package/build/rss/edit.cjs.map +2 -2
- package/build/site-tagline/edit.cjs +3 -1
- package/build/site-tagline/edit.cjs.map +2 -2
- package/build/site-title/edit.cjs +3 -1
- package/build/site-title/edit.cjs.map +2 -2
- package/build/social-links/edit.cjs +11 -4
- package/build/social-links/edit.cjs.map +2 -2
- package/build/tab-list/block.json +4 -3
- package/build/tab-list/edit.cjs +67 -11
- package/build/tab-list/edit.cjs.map +3 -3
- package/build/tab-list/tab-movers.cjs +87 -0
- package/build/tab-list/tab-movers.cjs.map +7 -0
- package/build/tab-panel/block.json +1 -6
- package/build/tab-panel/edit.cjs +16 -24
- package/build/tab-panel/edit.cjs.map +2 -2
- package/build/tab-panels/block.json +0 -1
- package/build/table/edit.cjs +1 -1
- package/build/table/edit.cjs.map +2 -2
- package/build/tabs/block.json +0 -5
- package/build/tabs/edit.cjs +4 -39
- package/build/tabs/edit.cjs.map +3 -3
- package/build/tabs/use-tab-actions.cjs +23 -1
- package/build/tabs/use-tab-actions.cjs.map +2 -2
- package/build/tabs/use-tab-list-items-sync.cjs +19 -1
- package/build/tabs/use-tab-list-items-sync.cjs.map +2 -2
- package/build/term-name/block.json +1 -3
- package/build/term-name/deprecated.cjs +105 -0
- package/build/term-name/deprecated.cjs.map +7 -0
- package/build/term-name/edit.cjs +11 -37
- package/build/term-name/edit.cjs.map +3 -3
- package/build/term-name/index.cjs +3 -1
- package/build/term-name/index.cjs.map +3 -3
- package/build/utils/caption.cjs +2 -2
- package/build/utils/caption.cjs.map +2 -2
- package/build/utils/waveform-player.cjs +138 -22
- package/build/utils/waveform-player.cjs.map +2 -2
- package/build/utils/waveform-utils.cjs +315 -17
- package/build/utils/waveform-utils.cjs.map +2 -2
- package/build/verse/edit.cjs +3 -1
- package/build/verse/edit.cjs.map +2 -2
- package/build/video/edit.cjs +2 -11
- package/build/video/edit.cjs.map +3 -3
- package/build/video/tracks-editor.cjs +0 -1
- package/build/video/tracks-editor.cjs.map +2 -2
- package/build-module/accordion/block.json +1 -0
- package/build-module/accordion-panel/block.json +1 -0
- package/build-module/button/edit.mjs +19 -14
- package/build-module/button/edit.mjs.map +2 -2
- package/build-module/code/edit.mjs +3 -1
- package/build-module/code/edit.mjs.map +2 -2
- package/build-module/cover/block.json +12 -0
- package/build-module/cover/edit/block-controls.mjs +14 -5
- package/build-module/cover/edit/block-controls.mjs.map +2 -2
- package/build-module/cover/edit/embed-video-url-input.mjs +5 -4
- package/build-module/cover/edit/embed-video-url-input.mjs.map +2 -2
- package/build-module/cover/edit/index.mjs +79 -35
- package/build-module/cover/edit/index.mjs.map +2 -2
- package/build-module/cover/embed-video-utils.mjs +16 -7
- package/build-module/cover/embed-video-utils.mjs.map +2 -2
- package/build-module/details/transforms.mjs +2 -7
- package/build-module/details/transforms.mjs.map +2 -2
- package/build-module/embed/edit.mjs +1 -1
- package/build-module/embed/edit.mjs.map +2 -2
- package/build-module/embed/embed-placeholder.mjs +1 -2
- package/build-module/embed/embed-placeholder.mjs.map +2 -2
- package/build-module/file/edit.mjs +4 -3
- package/build-module/file/edit.mjs.map +2 -2
- package/build-module/file/transforms.mjs +25 -60
- package/build-module/file/transforms.mjs.map +2 -2
- package/build-module/gallery/block.json +4 -2
- package/build-module/gallery/dynamic-gallery.mjs +104 -61
- package/build-module/gallery/dynamic-gallery.mjs.map +2 -2
- package/build-module/gallery/edit.mjs +3 -3
- package/build-module/gallery/edit.mjs.map +2 -2
- package/build-module/gallery/gap-styles.mjs +53 -14
- package/build-module/gallery/gap-styles.mjs.map +2 -2
- package/build-module/gallery/use-dynamic-gallery.mjs +16 -9
- package/build-module/gallery/use-dynamic-gallery.mjs.map +2 -2
- package/build-module/group/transforms.mjs +2 -5
- package/build-module/group/transforms.mjs.map +2 -2
- package/build-module/heading/edit.mjs +1 -1
- package/build-module/heading/edit.mjs.map +2 -2
- package/build-module/html/modal.mjs +68 -55
- package/build-module/html/modal.mjs.map +2 -2
- package/build-module/icon/block.json +5 -3
- package/build-module/icon/components/custom-inserter/icon-grid.mjs +25 -12
- package/build-module/icon/components/custom-inserter/icon-grid.mjs.map +2 -2
- package/build-module/icon/components/custom-inserter/index.mjs +102 -33
- package/build-module/icon/components/custom-inserter/index.mjs.map +2 -2
- package/build-module/icon/edit.mjs +11 -12
- package/build-module/icon/edit.mjs.map +2 -2
- package/build-module/image/block.json +1 -1
- package/build-module/image/edit.mjs +1 -35
- package/build-module/image/edit.mjs.map +2 -2
- package/build-module/image/image.mjs +23 -18
- package/build-module/image/image.mjs.map +2 -2
- package/build-module/image/transforms.mjs +78 -0
- package/build-module/image/transforms.mjs.map +2 -2
- package/build-module/image/use-open-image-media-editor-modal.mjs +6 -2
- package/build-module/image/use-open-image-media-editor-modal.mjs.map +2 -2
- package/build-module/index.mjs +18 -8
- package/build-module/index.mjs.map +2 -2
- package/build-module/latest-posts/edit.mjs +5 -8
- package/build-module/latest-posts/edit.mjs.map +2 -2
- package/build-module/list-item/edit.mjs +1 -1
- package/build-module/list-item/edit.mjs.map +2 -2
- package/build-module/list-item/hooks/use-enter.mjs +15 -21
- package/build-module/list-item/hooks/use-enter.mjs.map +2 -2
- package/build-module/list-item/hooks/use-indent-list-item.mjs +10 -2
- package/build-module/list-item/hooks/use-indent-list-item.mjs.map +2 -2
- package/build-module/list-item/hooks/use-space.mjs +4 -6
- package/build-module/list-item/hooks/use-space.mjs.map +2 -2
- package/build-module/math/edit.mjs +41 -60
- package/build-module/math/edit.mjs.map +2 -2
- package/build-module/media-text/edit.mjs +2 -1
- package/build-module/media-text/edit.mjs.map +2 -2
- package/build-module/more/edit.mjs +2 -2
- package/build-module/more/edit.mjs.map +2 -2
- package/build-module/navigation/edit/index.mjs +30 -16
- package/build-module/navigation/edit/index.mjs.map +2 -2
- package/build-module/navigation/edit/use-layout-custom-properties.mjs +51 -0
- package/build-module/navigation/edit/use-layout-custom-properties.mjs.map +7 -0
- package/build-module/navigation/view.mjs +9 -6
- package/build-module/navigation/view.mjs.map +2 -2
- package/build-module/navigation-link/edit.mjs +3 -3
- package/build-module/navigation-link/edit.mjs.map +2 -2
- package/build-module/navigation-link/link-ui/index.mjs +2 -2
- package/build-module/navigation-link/link-ui/index.mjs.map +2 -2
- package/build-module/paragraph/edit.mjs +6 -2
- package/build-module/paragraph/edit.mjs.map +2 -2
- package/build-module/paragraph/index.mjs +4 -1
- package/build-module/paragraph/index.mjs.map +2 -2
- package/build-module/paragraph/use-enter.mjs +4 -11
- package/build-module/paragraph/use-enter.mjs.map +2 -2
- package/build-module/playlist/block.json +29 -10
- package/build-module/playlist/context.mjs +2 -1
- package/build-module/playlist/context.mjs.map +2 -2
- package/build-module/playlist/edit.mjs +331 -41
- package/build-module/playlist/edit.mjs.map +2 -2
- package/build-module/playlist/index.mjs +1 -1
- package/build-module/playlist/index.mjs.map +2 -2
- package/build-module/playlist/utils.mjs +35 -7
- package/build-module/playlist/utils.mjs.map +2 -2
- package/build-module/playlist/view.mjs +89 -14
- package/build-module/playlist/view.mjs.map +2 -2
- package/build-module/playlist-track/block.json +4 -2
- package/build-module/playlist-track/edit.mjs +117 -71
- package/build-module/playlist-track/edit.mjs.map +2 -2
- package/build-module/post-content/block.json +1 -0
- package/build-module/post-content/edit.mjs +37 -15
- package/build-module/post-content/edit.mjs.map +2 -2
- package/build-module/post-featured-image/edit.mjs +3 -2
- package/build-module/post-featured-image/edit.mjs.map +2 -2
- package/build-module/post-template/block.json +2 -1
- package/build-module/post-template/edit.mjs +10 -1
- package/build-module/post-template/edit.mjs.map +2 -2
- package/build-module/post-terms/edit.mjs +2 -2
- package/build-module/post-terms/edit.mjs.map +2 -2
- package/build-module/post-title/edit.mjs +2 -2
- package/build-module/post-title/edit.mjs.map +2 -2
- package/build-module/preformatted/edit.mjs +3 -1
- package/build-module/preformatted/edit.mjs.map +2 -2
- package/build-module/pullquote/block.json +3 -1
- package/build-module/pullquote/edit.mjs +5 -3
- package/build-module/pullquote/edit.mjs.map +2 -2
- package/build-module/query/block.json +3 -2
- package/build-module/query/edit/inspector-controls/index.mjs +44 -6
- package/build-module/query/edit/inspector-controls/index.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/offset-controls.mjs +2 -3
- package/build-module/query/edit/inspector-controls/offset-controls.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/pages-control.mjs +0 -1
- package/build-module/query/edit/inspector-controls/pages-control.mjs.map +2 -2
- package/build-module/query/edit/query-content.mjs +10 -3
- package/build-module/query/edit/query-content.mjs.map +2 -2
- package/build-module/query/index.mjs +2 -1
- package/build-module/query/index.mjs.map +2 -2
- package/build-module/quote/block.json +3 -1
- package/build-module/quote/transforms.mjs +2 -4
- package/build-module/quote/transforms.mjs.map +2 -2
- package/build-module/read-more/edit.mjs +3 -1
- package/build-module/read-more/edit.mjs.map +2 -2
- package/build-module/rss/edit.mjs +0 -1
- package/build-module/rss/edit.mjs.map +2 -2
- package/build-module/site-tagline/edit.mjs +3 -1
- package/build-module/site-tagline/edit.mjs.map +2 -2
- package/build-module/site-title/edit.mjs +3 -1
- package/build-module/site-title/edit.mjs.map +2 -2
- package/build-module/social-links/edit.mjs +11 -4
- package/build-module/social-links/edit.mjs.map +2 -2
- package/build-module/tab-list/block.json +4 -3
- package/build-module/tab-list/edit.mjs +74 -13
- package/build-module/tab-list/edit.mjs.map +2 -2
- package/build-module/tab-list/tab-movers.mjs +59 -0
- package/build-module/tab-list/tab-movers.mjs.map +7 -0
- package/build-module/tab-panel/block.json +1 -6
- package/build-module/tab-panel/edit.mjs +17 -25
- package/build-module/tab-panel/edit.mjs.map +2 -2
- package/build-module/tab-panels/block.json +0 -1
- package/build-module/table/edit.mjs +1 -1
- package/build-module/table/edit.mjs.map +2 -2
- package/build-module/tabs/block.json +0 -5
- package/build-module/tabs/edit.mjs +5 -45
- package/build-module/tabs/edit.mjs.map +2 -2
- package/build-module/tabs/use-tab-actions.mjs +23 -1
- package/build-module/tabs/use-tab-actions.mjs.map +2 -2
- package/build-module/tabs/use-tab-list-items-sync.mjs +19 -1
- package/build-module/tabs/use-tab-list-items-sync.mjs.map +2 -2
- package/build-module/term-name/block.json +1 -3
- package/build-module/term-name/deprecated.mjs +74 -0
- package/build-module/term-name/deprecated.mjs.map +7 -0
- package/build-module/term-name/edit.mjs +11 -28
- package/build-module/term-name/edit.mjs.map +2 -2
- package/build-module/term-name/index.mjs +3 -1
- package/build-module/term-name/index.mjs.map +2 -2
- package/build-module/utils/caption.mjs +2 -2
- package/build-module/utils/caption.mjs.map +2 -2
- package/build-module/utils/waveform-player.mjs +144 -23
- package/build-module/utils/waveform-player.mjs.map +2 -2
- package/build-module/utils/waveform-utils.mjs +310 -16
- package/build-module/utils/waveform-utils.mjs.map +2 -2
- package/build-module/verse/edit.mjs +3 -1
- package/build-module/verse/edit.mjs.map +2 -2
- package/build-module/video/edit.mjs +2 -11
- package/build-module/video/edit.mjs.map +2 -2
- package/build-module/video/tracks-editor.mjs +0 -1
- package/build-module/video/tracks-editor.mjs.map +2 -2
- package/build-style/cover/editor-rtl.css +3 -0
- package/build-style/cover/editor.css +3 -0
- package/build-style/editor-rtl.css +61 -59
- package/build-style/editor.css +61 -59
- package/build-style/icon/editor-rtl.css +80 -10
- package/build-style/icon/editor.css +80 -10
- package/build-style/image/editor-rtl.css +3 -32
- package/build-style/image/editor.css +3 -32
- package/build-style/more/editor-rtl.css +2 -2
- package/build-style/more/editor.css +2 -2
- package/build-style/navigation/editor-rtl.css +3 -4
- package/build-style/navigation/editor.css +3 -4
- package/build-style/navigation-link/editor-rtl.css +1 -1
- package/build-style/navigation-link/editor.css +1 -1
- package/build-style/nextpage/editor-rtl.css +2 -2
- package/build-style/nextpage/editor.css +2 -2
- package/build-style/playlist/editor-rtl.css +4 -3
- package/build-style/playlist/editor.css +4 -3
- package/build-style/playlist/style-rtl.css +81 -5
- package/build-style/playlist/style.css +81 -5
- package/build-style/playlist-track/style-rtl.css +10 -0
- package/build-style/playlist-track/style.css +10 -0
- package/build-style/pullquote/editor-rtl.css +4 -0
- package/build-style/pullquote/editor.css +4 -0
- package/build-style/style-rtl.css +91 -5
- package/build-style/style.css +91 -5
- package/build-style/tab-list/editor-rtl.css +101 -0
- package/build-style/tab-list/editor.css +101 -0
- package/build-style/video/editor-rtl.css +1 -1
- package/build-style/video/editor.css +1 -1
- package/build-types/table-of-contents/list.d.ts +1 -1
- package/build-types/table-of-contents/list.d.ts.map +1 -1
- package/package.json +47 -45
- package/src/accordion/README.md +1 -0
- package/src/accordion/block.json +1 -0
- package/src/accordion-panel/block.json +1 -0
- package/src/breadcrumbs/index.php +3 -1
- package/src/button/edit.js +21 -15
- package/src/button/index.php +1 -1
- package/src/code/edit.js +7 -2
- package/src/cover/README.md +60 -0
- package/src/cover/block.json +12 -0
- package/src/cover/edit/block-controls.js +26 -11
- package/src/cover/edit/embed-video-url-input.js +5 -4
- package/src/cover/edit/index.js +109 -46
- package/src/cover/editor.scss +6 -0
- package/src/cover/embed-video-utils.js +38 -13
- package/src/cover/index.php +9 -2
- package/src/details/transforms.js +2 -7
- package/src/editor.scss +1 -0
- package/src/embed/edit.js +3 -1
- package/src/embed/embed-placeholder.js +9 -8
- package/src/file/edit.js +8 -8
- package/src/file/transforms.js +28 -60
- package/src/form/index.php +6 -4
- package/src/gallery/README.md +1 -1
- package/src/gallery/block.json +4 -2
- package/src/gallery/dynamic-gallery.js +133 -74
- package/src/gallery/edit.js +3 -3
- package/src/gallery/gap-styles.js +79 -20
- package/src/gallery/index.php +103 -43
- package/src/gallery/use-dynamic-gallery.js +27 -12
- package/src/group/transforms.js +2 -5
- package/src/heading/edit.js +1 -1
- package/src/html/modal.js +13 -2
- package/src/icon/README.md +1 -3
- package/src/icon/block.json +5 -3
- package/src/icon/components/custom-inserter/icon-grid.js +40 -11
- package/src/icon/components/custom-inserter/index.js +98 -25
- package/src/icon/edit.js +11 -17
- package/src/icon/editor.scss +33 -11
- package/src/image/README.md +1 -1
- package/src/image/block.json +1 -1
- package/src/image/edit.js +1 -57
- package/src/image/editor.scss +6 -44
- package/src/image/image.js +56 -27
- package/src/image/test/use-open-image-media-editor-modal.js +37 -1
- package/src/image/transforms.js +128 -0
- package/src/image/use-open-image-media-editor-modal.js +8 -1
- package/src/index.js +19 -7
- package/src/latest-posts/edit.js +5 -8
- package/src/latest-posts/index.php +49 -18
- package/src/list-item/edit.js +1 -1
- package/src/list-item/hooks/use-enter.js +15 -22
- package/src/list-item/hooks/use-indent-list-item.js +10 -1
- package/src/list-item/hooks/use-space.js +4 -6
- package/src/math/edit.js +42 -59
- package/src/media-text/edit.js +1 -0
- package/src/media-text/editor.scss +1 -0
- package/src/media-text/index.php +11 -2
- package/src/more/edit.js +7 -4
- package/src/more/editor.scss +1 -1
- package/src/navigation/edit/index.js +52 -36
- package/src/navigation/edit/test/layout-custom-properties.js +138 -0
- package/src/navigation/edit/use-layout-custom-properties.js +84 -0
- package/src/navigation/editor.scss +1 -2
- package/src/navigation/index.php +123 -12
- package/src/navigation/test/view.js +51 -0
- package/src/navigation/view.js +15 -14
- package/src/navigation-link/edit.js +11 -7
- package/src/navigation-link/editor.scss +1 -1
- package/src/navigation-link/index.php +70 -3
- package/src/navigation-link/link-ui/index.js +2 -1
- package/src/navigation-link/test/__snapshots__/hooks.js.snap +1 -1
- package/src/navigation-submenu/index.php +6 -3
- package/src/nextpage/editor.scss +1 -1
- package/src/page-list/index.php +4 -3
- package/src/paragraph/edit.js +9 -2
- package/src/paragraph/index.js +4 -1
- package/src/paragraph/use-enter.js +4 -11
- package/src/pattern/index.php +5 -5
- package/src/playlist/README.md +17 -18
- package/src/playlist/block.json +29 -10
- package/src/playlist/context.js +1 -0
- package/src/playlist/edit.js +395 -59
- package/src/playlist/editor.scss +4 -5
- package/src/playlist/index.js +1 -1
- package/src/playlist/index.php +71 -22
- package/src/playlist/style.scss +54 -1
- package/src/playlist/test/edit-component.js +139 -0
- package/src/playlist/test/edit.js +43 -2
- package/src/playlist/utils.js +49 -10
- package/src/playlist/view.js +97 -16
- package/src/playlist-track/README.md +3 -3
- package/src/playlist-track/block.json +4 -2
- package/src/playlist-track/edit.js +116 -75
- package/src/playlist-track/index.php +26 -11
- package/src/playlist-track/style.scss +10 -0
- package/src/playlist-track/test/edit.js +253 -0
- package/src/post-content/README.md +1 -0
- package/src/post-content/block.json +1 -0
- package/src/post-content/edit.js +45 -16
- package/src/post-excerpt/index.php +4 -1
- package/src/post-featured-image/edit.js +3 -2
- package/src/post-featured-image/index.php +4 -1
- package/src/post-template/README.md +1 -0
- package/src/post-template/block.json +2 -1
- package/src/post-template/edit.js +9 -0
- package/src/post-terms/edit.js +7 -4
- package/src/post-title/edit.js +5 -3
- package/src/preformatted/edit.js +7 -2
- package/src/pullquote/README.md +1 -0
- package/src/pullquote/block.json +3 -1
- package/src/pullquote/edit.js +9 -4
- package/src/pullquote/editor.scss +6 -0
- package/src/query/README.md +2 -1
- package/src/query/block.json +3 -2
- package/src/query/edit/inspector-controls/index.js +47 -4
- package/src/query/edit/inspector-controls/offset-controls.js +2 -3
- package/src/query/edit/inspector-controls/pages-control.js +0 -1
- package/src/query/edit/query-content.js +19 -3
- package/src/query/index.js +1 -0
- package/src/quote/README.md +1 -0
- package/src/quote/block.json +3 -1
- package/src/quote/transforms.js +2 -4
- package/src/read-more/edit.js +7 -2
- package/src/rss/edit.js +0 -1
- package/src/rss/index.php +10 -4
- package/src/site-tagline/edit.js +7 -2
- package/src/site-title/edit.js +7 -2
- package/src/social-link/index.php +19 -9
- package/src/social-links/edit.js +21 -12
- package/src/tab-list/README.md +4 -5
- package/src/tab-list/block.json +4 -3
- package/src/tab-list/edit.js +92 -28
- package/src/tab-list/editor.scss +9 -0
- package/src/tab-list/index.php +9 -4
- package/src/tab-list/tab-movers.js +72 -0
- package/src/tab-panel/README.md +4 -6
- package/src/tab-panel/block.json +1 -6
- package/src/tab-panel/edit.js +20 -33
- package/src/tab-panels/README.md +5 -3
- package/src/tab-panels/block.json +0 -1
- package/src/table/edit.js +1 -1
- package/src/table-of-contents/index.php +386 -1
- package/src/tabs/README.md +18 -9
- package/src/tabs/block.json +0 -5
- package/src/tabs/edit.js +7 -64
- package/src/tabs/use-tab-actions.js +32 -3
- package/src/tabs/use-tab-list-items-sync.js +24 -4
- package/src/tag-cloud/index.php +3 -2
- package/src/template-part/index.php +3 -17
- package/src/term-name/README.md +1 -1
- package/src/term-name/block.json +1 -3
- package/src/term-name/deprecated.js +74 -0
- package/src/term-name/edit.js +2 -18
- package/src/term-name/index.js +2 -0
- package/src/utils/caption.js +7 -4
- package/src/utils/media-control.scss +1 -5
- package/src/utils/test/waveform-player.js +297 -34
- package/src/utils/test/waveform-utils.js +473 -5
- package/src/utils/waveform-player.js +189 -59
- package/src/utils/waveform-utils.js +443 -40
- package/src/verse/edit.js +7 -2
- package/src/video/edit.js +0 -8
- package/src/video/editor.scss +1 -1
- package/src/video/index.php +2 -2
- package/src/video/tracks-editor.js +0 -1
- package/build/image/animated-gif-convert-control.cjs +0 -105
- package/build/image/animated-gif-convert-control.cjs.map +0 -7
- package/build/utils/gif-conversion-attributes.cjs +0 -40
- package/build/utils/gif-conversion-attributes.cjs.map +0 -7
- package/build/video/gif-restore-control.cjs +0 -73
- package/build/video/gif-restore-control.cjs.map +0 -7
- package/build-module/image/animated-gif-convert-control.mjs +0 -87
- package/build-module/image/animated-gif-convert-control.mjs.map +0 -7
- package/build-module/utils/gif-conversion-attributes.mjs +0 -15
- package/build-module/utils/gif-conversion-attributes.mjs.map +0 -7
- package/build-module/video/gif-restore-control.mjs +0 -55
- package/build-module/video/gif-restore-control.mjs.map +0 -7
- package/src/image/animated-gif-convert-control.js +0 -135
- package/src/image/test/animated-gif-convert-control.js +0 -276
- package/src/utils/gif-conversion-attributes.js +0 -30
- package/src/utils/test/gif-conversion-attributes.js +0 -60
- package/src/video/gif-restore-control.js +0 -92
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
// packages/block-library/src/group/transforms.js
|
|
2
|
-
import {
|
|
3
|
-
createBlock,
|
|
4
|
-
__experimentalCloneSanitizedBlock
|
|
5
|
-
} from "@wordpress/blocks";
|
|
2
|
+
import { createBlock, cloneSanitizedBlock } from "@wordpress/blocks";
|
|
6
3
|
var transforms = {
|
|
7
4
|
from: [
|
|
8
5
|
{
|
|
@@ -19,7 +16,7 @@ var transforms = {
|
|
|
19
16
|
void 0
|
|
20
17
|
);
|
|
21
18
|
const groupInnerBlocks = blocks.map(
|
|
22
|
-
(block) =>
|
|
19
|
+
(block) => cloneSanitizedBlock(block)
|
|
23
20
|
);
|
|
24
21
|
return createBlock(
|
|
25
22
|
"core/group",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/group/transforms.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {
|
|
5
|
-
"mappings": ";AAGA
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock, cloneSanitizedBlock } from '@wordpress/blocks';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ '*' ],\n\t\t\t__experimentalConvert( blocks ) {\n\t\t\t\tconst alignments = [ 'wide', 'full' ];\n\n\t\t\t\t// Determine the widest setting of all the blocks to be grouped\n\t\t\t\tconst widestAlignment = blocks.reduce(\n\t\t\t\t\t( accumulator, block ) => {\n\t\t\t\t\t\tconst { align } = block.attributes;\n\t\t\t\t\t\treturn alignments.indexOf( align ) >\n\t\t\t\t\t\t\talignments.indexOf( accumulator )\n\t\t\t\t\t\t\t? align\n\t\t\t\t\t\t\t: accumulator;\n\t\t\t\t\t},\n\t\t\t\t\tundefined\n\t\t\t\t);\n\n\t\t\t\t// Clone the Blocks to be Grouped\n\t\t\t\t// Failing to create new block references causes the original blocks\n\t\t\t\t// to be replaced in the switchToBlockType call thereby meaning they\n\t\t\t\t// are removed both from their original location and within the\n\t\t\t\t// new group block.\n\t\t\t\tconst groupInnerBlocks = blocks.map( ( block ) =>\n\t\t\t\t\tcloneSanitizedBlock( block )\n\t\t\t\t);\n\n\t\t\t\treturn createBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\talign: widestAlignment,\n\t\t\t\t\t\tlayout: { type: 'constrained' },\n\t\t\t\t\t},\n\t\t\t\t\tgroupInnerBlocks\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,aAAa,2BAA2B;AAEjD,IAAM,aAAa;AAAA,EAClB,MAAM;AAAA,IACL;AAAA,MACC,MAAM;AAAA,MACN,cAAc;AAAA,MACd,QAAQ,CAAE,GAAI;AAAA,MACd,sBAAuB,QAAS;AAC/B,cAAM,aAAa,CAAE,QAAQ,MAAO;AAGpC,cAAM,kBAAkB,OAAO;AAAA,UAC9B,CAAE,aAAa,UAAW;AACzB,kBAAM,EAAE,MAAM,IAAI,MAAM;AACxB,mBAAO,WAAW,QAAS,KAAM,IAChC,WAAW,QAAS,WAAY,IAC9B,QACA;AAAA,UACJ;AAAA,UACA;AAAA,QACD;AAOA,cAAM,mBAAmB,OAAO;AAAA,UAAK,CAAE,UACtC,oBAAqB,KAAM;AAAA,QAC5B;AAEA,eAAO;AAAA,UACN;AAAA,UACA;AAAA,YACC,OAAO;AAAA,YACP,QAAQ,EAAE,MAAM,cAAc;AAAA,UAC/B;AAAA,UACA;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;AAEA,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/heading/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { generateAnchor, setAnchor } from './autogenerate-anchors';\nimport useDeprecatedTextAlign from '../utils/deprecated-text-align-attributes';\n\nfunction HeadingEdit( props ) {\n\tconst {\n\t\tattributes,\n\t\tsetAttributes,\n\t\tmergeBlocks,\n\t\tonReplace,\n\t\tstyle,\n\t\tclientId,\n\t} = props;\n\tuseDeprecatedTextAlign( props );\n\tconst { content, level, placeholder, anchor } = attributes;\n\tconst tagName = 'h' + level;\n\tconst blockProps = useBlockProps( {\n\t\tstyle,\n\t} );\n\n\tconst { canGenerateAnchors } = useSelect( ( select ) => {\n\t\tconst { getGlobalBlockCount, getSettings } = select( blockEditorStore );\n\t\tconst settings = getSettings();\n\n\t\treturn {\n\t\t\tcanGenerateAnchors:\n\t\t\t\t!! settings.generateAnchors ||\n\t\t\t\tgetGlobalBlockCount( 'core/table-of-contents' ) > 0,\n\t\t};\n\t}, [] );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Initially set anchor for headings that have content but no anchor set.\n\t// This is used when transforming a block to heading, or for legacy anchors.\n\tuseEffect( () => {\n\t\tif ( ! canGenerateAnchors ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! anchor && content ) {\n\t\t\t// This side-effect should not create an undo level.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\tanchor: generateAnchor( clientId, content ),\n\t\t\t} );\n\t\t}\n\t\tsetAnchor( clientId, anchor );\n\n\t\t// Remove anchor map when block unmounts.\n\t\treturn () => setAnchor( clientId, null );\n\t}, [\n\t\tanchor,\n\t\tcontent,\n\t\tclientId,\n\t\tcanGenerateAnchors,\n\t\tsetAttributes,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t] );\n\n\tconst onContentChange = ( value ) => {\n\t\tconst newAttrs = { content: value };\n\t\tif (\n\t\t\tcanGenerateAnchors &&\n\t\t\t( ! anchor ||\n\t\t\t\t! value ||\n\t\t\t\tgenerateAnchor( clientId, content ) === anchor )\n\t\t) {\n\t\t\tnewAttrs.anchor = generateAnchor( clientId, value );\n\t\t}\n\t\tsetAttributes( newAttrs );\n\t};\n\n\treturn (\n\t\t<RichText\n\t\t\tidentifier=\"content\"\n\t\t\ttagName={ tagName }\n\t\t\tvalue={ content }\n\t\t\tonChange={ onContentChange }\n\t\t\tonMerge={ mergeBlocks }\n\t\t\tonReplace={ onReplace }\n\t\t\tonRemove={ () => onReplace( [] ) }\n\t\t\tplaceholder={ placeholder || __( 'Heading' ) }\n\t\t\t{ ...blockProps }\n\t\t/>\n\t);\n}\n\nexport default HeadingEdit;\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,aAAa,iBAAiB;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AAKP,SAAS,gBAAgB,iBAAiB;AAC1C,OAAO,4BAA4B;AAyEjC;AAvEF,SAAS,YAAa,OAAQ;AAC7B,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AACJ,yBAAwB,KAAM;AAC9B,QAAM,EAAE,SAAS,OAAO,aAAa,OAAO,IAAI;AAChD,QAAM,UAAU,MAAM;AACtB,QAAM,aAAa,cAAe;AAAA,IACjC;AAAA,EACD,CAAE;AAEF,QAAM,EAAE,mBAAmB,IAAI,UAAW,CAAE,WAAY;AACvD,UAAM,EAAE,qBAAqB,YAAY,IAAI,OAAQ,gBAAiB;AACtE,UAAM,WAAW,YAAY;AAE7B,WAAO;AAAA,MACN,oBACC,CAAC,CAAE,SAAS,mBACZ,oBAAqB,wBAAyB,IAAI;AAAA,IACpD;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,QAAM,EAAE,wCAAwC,IAC/C,YAAa,gBAAiB;AAI/B,YAAW,MAAM;AAChB,QAAK,CAAE,oBAAqB;AAC3B;AAAA,IACD;AAEA,QAAK,CAAE,UAAU,SAAU;AAE1B,8CAAwC;AACxC,oBAAe;AAAA,QACd,QAAQ,eAAgB,UAAU,OAAQ;AAAA,MAC3C,CAAE;AAAA,IACH;AACA,cAAW,UAAU,MAAO;AAG5B,WAAO,MAAM,UAAW,UAAU,IAAK;AAAA,EACxC,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AAEF,QAAM,kBAAkB,CAAE,UAAW;AACpC,UAAM,WAAW,EAAE,SAAS,MAAM;AAClC,QACC,uBACE,CAAE,UACH,CAAE,SACF,eAAgB,UAAU,OAAQ,MAAM,SACxC;AACD,eAAS,SAAS,eAAgB,UAAU,KAAM;AAAA,IACnD;AACA,kBAAe,QAAS;AAAA,EACzB;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,YAAW;AAAA,MACX;AAAA,MACA,OAAQ;AAAA,MACR,UAAW;AAAA,MACX,SAAU;AAAA,MACV;AAAA,MACA,UAAW,MAAM,UAAW,CAAC,CAAE;AAAA,MAC/
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { generateAnchor, setAnchor } from './autogenerate-anchors';\nimport useDeprecatedTextAlign from '../utils/deprecated-text-align-attributes';\n\nfunction HeadingEdit( props ) {\n\tconst {\n\t\tattributes,\n\t\tsetAttributes,\n\t\tmergeBlocks,\n\t\tonReplace,\n\t\tstyle,\n\t\tclientId,\n\t} = props;\n\tuseDeprecatedTextAlign( props );\n\tconst { content, level, placeholder, anchor } = attributes;\n\tconst tagName = 'h' + level;\n\tconst blockProps = useBlockProps( {\n\t\tstyle,\n\t} );\n\n\tconst { canGenerateAnchors } = useSelect( ( select ) => {\n\t\tconst { getGlobalBlockCount, getSettings } = select( blockEditorStore );\n\t\tconst settings = getSettings();\n\n\t\treturn {\n\t\t\tcanGenerateAnchors:\n\t\t\t\t!! settings.generateAnchors ||\n\t\t\t\tgetGlobalBlockCount( 'core/table-of-contents' ) > 0,\n\t\t};\n\t}, [] );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Initially set anchor for headings that have content but no anchor set.\n\t// This is used when transforming a block to heading, or for legacy anchors.\n\tuseEffect( () => {\n\t\tif ( ! canGenerateAnchors ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! anchor && content ) {\n\t\t\t// This side-effect should not create an undo level.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\tanchor: generateAnchor( clientId, content ),\n\t\t\t} );\n\t\t}\n\t\tsetAnchor( clientId, anchor );\n\n\t\t// Remove anchor map when block unmounts.\n\t\treturn () => setAnchor( clientId, null );\n\t}, [\n\t\tanchor,\n\t\tcontent,\n\t\tclientId,\n\t\tcanGenerateAnchors,\n\t\tsetAttributes,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t] );\n\n\tconst onContentChange = ( value ) => {\n\t\tconst newAttrs = { content: value };\n\t\tif (\n\t\t\tcanGenerateAnchors &&\n\t\t\t( ! anchor ||\n\t\t\t\t! value ||\n\t\t\t\tgenerateAnchor( clientId, content ) === anchor )\n\t\t) {\n\t\t\tnewAttrs.anchor = generateAnchor( clientId, value );\n\t\t}\n\t\tsetAttributes( newAttrs );\n\t};\n\n\treturn (\n\t\t<RichText\n\t\t\tidentifier=\"content\"\n\t\t\ttagName={ tagName }\n\t\t\tvalue={ content }\n\t\t\tonChange={ onContentChange }\n\t\t\tonMerge={ mergeBlocks }\n\t\t\tonReplace={ onReplace }\n\t\t\tonRemove={ onReplace ? () => onReplace( [] ) : undefined }\n\t\t\tplaceholder={ placeholder || __( 'Heading' ) }\n\t\t\t{ ...blockProps }\n\t\t/>\n\t);\n}\n\nexport default HeadingEdit;\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,aAAa,iBAAiB;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AAKP,SAAS,gBAAgB,iBAAiB;AAC1C,OAAO,4BAA4B;AAyEjC;AAvEF,SAAS,YAAa,OAAQ;AAC7B,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AACJ,yBAAwB,KAAM;AAC9B,QAAM,EAAE,SAAS,OAAO,aAAa,OAAO,IAAI;AAChD,QAAM,UAAU,MAAM;AACtB,QAAM,aAAa,cAAe;AAAA,IACjC;AAAA,EACD,CAAE;AAEF,QAAM,EAAE,mBAAmB,IAAI,UAAW,CAAE,WAAY;AACvD,UAAM,EAAE,qBAAqB,YAAY,IAAI,OAAQ,gBAAiB;AACtE,UAAM,WAAW,YAAY;AAE7B,WAAO;AAAA,MACN,oBACC,CAAC,CAAE,SAAS,mBACZ,oBAAqB,wBAAyB,IAAI;AAAA,IACpD;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,QAAM,EAAE,wCAAwC,IAC/C,YAAa,gBAAiB;AAI/B,YAAW,MAAM;AAChB,QAAK,CAAE,oBAAqB;AAC3B;AAAA,IACD;AAEA,QAAK,CAAE,UAAU,SAAU;AAE1B,8CAAwC;AACxC,oBAAe;AAAA,QACd,QAAQ,eAAgB,UAAU,OAAQ;AAAA,MAC3C,CAAE;AAAA,IACH;AACA,cAAW,UAAU,MAAO;AAG5B,WAAO,MAAM,UAAW,UAAU,IAAK;AAAA,EACxC,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AAEF,QAAM,kBAAkB,CAAE,UAAW;AACpC,UAAM,WAAW,EAAE,SAAS,MAAM;AAClC,QACC,uBACE,CAAE,UACH,CAAE,SACF,eAAgB,UAAU,OAAQ,MAAM,SACxC;AACD,eAAS,SAAS,eAAgB,UAAU,KAAM;AAAA,IACnD;AACA,kBAAe,QAAS;AAAA,EACzB;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,YAAW;AAAA,MACX;AAAA,MACA,OAAQ;AAAA,MACR,UAAW;AAAA,MACX,SAAU;AAAA,MACV;AAAA,MACA,UAAW,YAAY,MAAM,UAAW,CAAC,CAAE,IAAI;AAAA,MAC/C,aAAc,eAAe,GAAI,SAAU;AAAA,MACzC,GAAG;AAAA;AAAA,EACN;AAEF;AAEA,IAAO,eAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -11,7 +11,11 @@ import {
|
|
|
11
11
|
__experimentalVStack as VStack,
|
|
12
12
|
__experimentalHStack as HStack
|
|
13
13
|
} from "@wordpress/components";
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
PlainText,
|
|
16
|
+
store as blockEditorStore,
|
|
17
|
+
privateApis as blockEditorPrivateApis
|
|
18
|
+
} from "@wordpress/block-editor";
|
|
15
19
|
import { fullscreen, square } from "@wordpress/icons";
|
|
16
20
|
import { useViewportMatch } from "@wordpress/compose";
|
|
17
21
|
import { unlock } from "../lock-unlock.mjs";
|
|
@@ -19,12 +23,14 @@ import Preview from "./preview.mjs";
|
|
|
19
23
|
import { parseContent, serializeContent } from "./utils.mjs";
|
|
20
24
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
21
25
|
var { Tabs } = unlock(componentsPrivateApis);
|
|
26
|
+
var { useNativeUndo } = unlock(blockEditorPrivateApis);
|
|
22
27
|
function HTMLEditModal({ onRequestClose, content, onUpdate }) {
|
|
23
28
|
const { html, css, js } = parseContent(content);
|
|
24
29
|
const [editedHtml, setEditedHtml] = useState(html);
|
|
25
30
|
const [editedCss, setEditedCss] = useState(css);
|
|
26
31
|
const [editedJs, setEditedJs] = useState(js);
|
|
27
32
|
const [isFullscreen, setIsFullscreen] = useState(false);
|
|
33
|
+
const nativeUndoRef = useNativeUndo();
|
|
28
34
|
const isMobileViewport = useViewportMatch("small", "<");
|
|
29
35
|
const { canUserUseUnfilteredHTML } = useSelect((select) => {
|
|
30
36
|
const settings = select(blockEditorStore).getSettings();
|
|
@@ -106,67 +112,74 @@ function HTMLEditModal({ onRequestClose, content, onUpdate }) {
|
|
|
106
112
|
align: "stretch",
|
|
107
113
|
gap: 8,
|
|
108
114
|
children: [
|
|
109
|
-
/* @__PURE__ */ jsxs(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
PlainText,
|
|
115
|
+
/* @__PURE__ */ jsxs(
|
|
116
|
+
"div",
|
|
117
|
+
{
|
|
118
|
+
ref: nativeUndoRef,
|
|
119
|
+
className: "block-library-html__modal-content",
|
|
120
|
+
children: [
|
|
121
|
+
/* @__PURE__ */ jsx(
|
|
122
|
+
Tabs.TabPanel,
|
|
118
123
|
{
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
tabId: "html",
|
|
125
|
+
focusable: false,
|
|
126
|
+
className: "block-library-html__modal-tab",
|
|
127
|
+
children: /* @__PURE__ */ jsx(
|
|
128
|
+
PlainText,
|
|
129
|
+
{
|
|
130
|
+
value: editedHtml,
|
|
131
|
+
onChange: setEditedHtml,
|
|
132
|
+
placeholder: __("Write HTML…"),
|
|
133
|
+
"aria-label": __("HTML"),
|
|
134
|
+
className: "block-library-html__modal-editor",
|
|
135
|
+
async: true
|
|
136
|
+
}
|
|
137
|
+
)
|
|
125
138
|
}
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
canUserUseUnfilteredHTML && /* @__PURE__ */ jsx(
|
|
130
|
-
Tabs.TabPanel,
|
|
131
|
-
{
|
|
132
|
-
tabId: "css",
|
|
133
|
-
focusable: false,
|
|
134
|
-
className: "block-library-html__modal-tab",
|
|
135
|
-
children: /* @__PURE__ */ jsx(
|
|
136
|
-
PlainText,
|
|
139
|
+
),
|
|
140
|
+
canUserUseUnfilteredHTML && /* @__PURE__ */ jsx(
|
|
141
|
+
Tabs.TabPanel,
|
|
137
142
|
{
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
143
|
+
tabId: "css",
|
|
144
|
+
focusable: false,
|
|
145
|
+
className: "block-library-html__modal-tab",
|
|
146
|
+
children: /* @__PURE__ */ jsx(
|
|
147
|
+
PlainText,
|
|
148
|
+
{
|
|
149
|
+
value: editedCss,
|
|
150
|
+
onChange: setEditedCss,
|
|
151
|
+
placeholder: __("Write CSS…"),
|
|
152
|
+
"aria-label": __("CSS"),
|
|
153
|
+
className: "block-library-html__modal-editor",
|
|
154
|
+
async: true
|
|
155
|
+
}
|
|
156
|
+
)
|
|
144
157
|
}
|
|
145
|
-
)
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
canUserUseUnfilteredHTML && /* @__PURE__ */ jsx(
|
|
149
|
-
Tabs.TabPanel,
|
|
150
|
-
{
|
|
151
|
-
tabId: "js",
|
|
152
|
-
focusable: false,
|
|
153
|
-
className: "block-library-html__modal-tab",
|
|
154
|
-
children: /* @__PURE__ */ jsx(
|
|
155
|
-
PlainText,
|
|
158
|
+
),
|
|
159
|
+
canUserUseUnfilteredHTML && /* @__PURE__ */ jsx(
|
|
160
|
+
Tabs.TabPanel,
|
|
156
161
|
{
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
tabId: "js",
|
|
163
|
+
focusable: false,
|
|
164
|
+
className: "block-library-html__modal-tab",
|
|
165
|
+
children: /* @__PURE__ */ jsx(
|
|
166
|
+
PlainText,
|
|
167
|
+
{
|
|
168
|
+
value: editedJs,
|
|
169
|
+
onChange: setEditedJs,
|
|
170
|
+
placeholder: __(
|
|
171
|
+
"Write JavaScript…"
|
|
172
|
+
),
|
|
173
|
+
"aria-label": __("JavaScript"),
|
|
174
|
+
className: "block-library-html__modal-editor",
|
|
175
|
+
async: true
|
|
176
|
+
}
|
|
177
|
+
)
|
|
165
178
|
}
|
|
166
179
|
)
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
180
|
+
]
|
|
181
|
+
}
|
|
182
|
+
),
|
|
170
183
|
/* @__PURE__ */ jsx("div", { className: "block-library-html__preview", children: /* @__PURE__ */ jsx(
|
|
171
184
|
Preview,
|
|
172
185
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/html/modal.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tModal,\n\tButton,\n\tFlex,\n\tNotice,\n\tprivateApis as componentsPrivateApis,\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport {
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AACP,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tModal,\n\tButton,\n\tFlex,\n\tNotice,\n\tprivateApis as componentsPrivateApis,\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport {\n\tPlainText,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { fullscreen, square } from '@wordpress/icons';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport Preview from './preview';\nimport { parseContent, serializeContent } from './utils';\n\nconst { Tabs } = unlock( componentsPrivateApis );\nconst { useNativeUndo } = unlock( blockEditorPrivateApis );\n\nexport default function HTMLEditModal( { onRequestClose, content, onUpdate } ) {\n\t// Parse content into separate sections and use as initial state\n\tconst { html, css, js } = parseContent( content );\n\tconst [ editedHtml, setEditedHtml ] = useState( html );\n\tconst [ editedCss, setEditedCss ] = useState( css );\n\tconst [ editedJs, setEditedJs ] = useState( js );\n\tconst [ isFullscreen, setIsFullscreen ] = useState( false );\n\t// The fields hold local state that is only committed when the dialog is\n\t// saved, so undo and redo within them must remain the browser's own.\n\tconst nativeUndoRef = useNativeUndo();\n\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\n\t// Check if user has permission to save scripts and get editor styles\n\tconst { canUserUseUnfilteredHTML } = useSelect( ( select ) => {\n\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tcanUserUseUnfilteredHTML:\n\t\t\t\tsettings.__experimentalCanUserUseUnfilteredHTML,\n\t\t};\n\t}, [] );\n\n\t// Determine if we should show a warning about CSS/JS content being stripped\n\tconst hasRestrictedContent =\n\t\t! canUserUseUnfilteredHTML && ( css.trim() || js.trim() );\n\n\tconst handleUpdate = () => {\n\t\t// For users without unfiltered_html capability, strip CSS and JS content\n\t\t// to prevent kses from leaving broken content\n\t\tonUpdate(\n\t\t\tserializeContent( {\n\t\t\t\thtml: editedHtml,\n\t\t\t\tcss: canUserUseUnfilteredHTML ? editedCss : '',\n\t\t\t\tjs: canUserUseUnfilteredHTML ? editedJs : '',\n\t\t\t} )\n\t\t);\n\t};\n\tconst handleUpdateAndClose = () => {\n\t\thandleUpdate();\n\t\tonRequestClose();\n\t};\n\tconst toggleFullscreen = () => {\n\t\tsetIsFullscreen( ( prevState ) => ! prevState );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<Modal\n\t\t\t\ttitle={ __( 'Edit HTML' ) }\n\t\t\t\tonRequestClose={ onRequestClose }\n\t\t\t\tclassName=\"block-library-html__modal\"\n\t\t\t\tsize=\"large\"\n\t\t\t\tisDismissible={ false }\n\t\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\t\tisFullScreen={ isFullscreen }\n\t\t\t\t__experimentalHideHeader\n\t\t\t>\n\t\t\t\t<Tabs orientation=\"horizontal\" defaultTabId=\"html\">\n\t\t\t\t\t<VStack expanded>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\tjustify=\"space-between\"\n\t\t\t\t\t\t\tclassName=\"block-library-html__modal-header\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<Tabs.TabList>\n\t\t\t\t\t\t\t\t\t<Tabs.Tab tabId=\"html\">HTML</Tabs.Tab>\n\t\t\t\t\t\t\t\t\t{ canUserUseUnfilteredHTML && (\n\t\t\t\t\t\t\t\t\t\t<Tabs.Tab tabId=\"css\">CSS</Tabs.Tab>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ canUserUseUnfilteredHTML && (\n\t\t\t\t\t\t\t\t\t\t<Tabs.Tab tabId=\"js\">\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'JavaScript' ) }\n\t\t\t\t\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Tabs.TabList>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{ ! isMobileViewport && (\n\t\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\tisFullscreen ? square : fullscreen\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t\t\t'Enable/disable fullscreen'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tonClick={ toggleFullscreen }\n\t\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t{ hasRestrictedContent && (\n\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-notice\"\n\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'This block contains CSS or JavaScript that will be removed when you save because you do not have permission to use unfiltered HTML.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\tdirection={ isMobileViewport ? 'column' : 'row' }\n\t\t\t\t\t\t\tclassName=\"block-library-html__modal-tabs\"\n\t\t\t\t\t\t\talign=\"stretch\"\n\t\t\t\t\t\t\tgap={ 8 }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tref={ nativeUndoRef }\n\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-content\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\t\t\t\ttabId=\"html\"\n\t\t\t\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-tab\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<PlainText\n\t\t\t\t\t\t\t\t\t\tvalue={ editedHtml }\n\t\t\t\t\t\t\t\t\t\tonChange={ setEditedHtml }\n\t\t\t\t\t\t\t\t\t\tplaceholder={ __( 'Write HTML…' ) }\n\t\t\t\t\t\t\t\t\t\taria-label={ __( 'HTML' ) }\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-editor\"\n\t\t\t\t\t\t\t\t\t\tasync\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t\t\t\t\t{ canUserUseUnfilteredHTML && (\n\t\t\t\t\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\t\t\t\t\ttabId=\"css\"\n\t\t\t\t\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-tab\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<PlainText\n\t\t\t\t\t\t\t\t\t\t\tvalue={ editedCss }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ setEditedCss }\n\t\t\t\t\t\t\t\t\t\t\tplaceholder={ __( 'Write CSS…' ) }\n\t\t\t\t\t\t\t\t\t\t\taria-label={ __( 'CSS' ) }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-editor\"\n\t\t\t\t\t\t\t\t\t\t\tasync\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ canUserUseUnfilteredHTML && (\n\t\t\t\t\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\t\t\t\t\ttabId=\"js\"\n\t\t\t\t\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-tab\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<PlainText\n\t\t\t\t\t\t\t\t\t\t\tvalue={ editedJs }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ setEditedJs }\n\t\t\t\t\t\t\t\t\t\t\tplaceholder={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Write JavaScript…'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\taria-label={ __( 'JavaScript' ) }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-editor\"\n\t\t\t\t\t\t\t\t\t\t\tasync\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div className=\"block-library-html__preview\">\n\t\t\t\t\t\t\t\t<Preview\n\t\t\t\t\t\t\t\t\tcontent={ serializeContent( {\n\t\t\t\t\t\t\t\t\t\thtml: editedHtml,\n\t\t\t\t\t\t\t\t\t\tcss: editedCss,\n\t\t\t\t\t\t\t\t\t\tjs: editedJs,\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</div>\n\t\t\t\t\t\t</Flex>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\talignment=\"center\"\n\t\t\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\t\t\tspacing={ 4 }\n\t\t\t\t\t\t\tclassName=\"block-library-html__modal-footer\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\tonClick={ onRequestClose }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\tonClick={ handleUpdateAndClose }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Update' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</VStack>\n\t\t\t\t</Tabs>\n\t\t\t</Modal>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -33,9 +33,11 @@
|
|
|
33
33
|
"align": [ "left", "center", "right" ],
|
|
34
34
|
"html": false,
|
|
35
35
|
"color": {
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
36
|
+
"__experimentalSkipSerialization": true,
|
|
37
|
+
"__experimentalDefaultControls": {
|
|
38
|
+
"background": true,
|
|
39
|
+
"text": true
|
|
40
|
+
}
|
|
39
41
|
},
|
|
40
42
|
"interactivity": {
|
|
41
43
|
"clientNavigation": true
|
|
@@ -1,32 +1,45 @@
|
|
|
1
1
|
// packages/block-library/src/icon/components/custom-inserter/icon-grid.js
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
3
|
import { Button } from "@wordpress/components";
|
|
4
|
+
import { useAsyncList } from "@wordpress/compose";
|
|
5
|
+
import { useRef, useLayoutEffect } from "@wordpress/element";
|
|
6
|
+
import { getScrollContainer } from "@wordpress/dom";
|
|
4
7
|
import HtmlRenderer from "../../../utils/html-renderer.mjs";
|
|
5
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
|
|
9
|
+
var BATCH_SIZE = 20;
|
|
10
|
+
function IconGrid({ icons, onChange, value }) {
|
|
11
|
+
const shownIcons = useAsyncList(icons, {
|
|
12
|
+
step: BATCH_SIZE
|
|
13
|
+
});
|
|
14
|
+
const selectedIconRef = useRef();
|
|
15
|
+
const selectedIndex = icons?.findIndex((icon) => icon.name === value) ?? -1;
|
|
16
|
+
const isReadyToScroll = selectedIndex >= 0 && (shownIcons.length >= selectedIndex + BATCH_SIZE || shownIcons.length === icons.length);
|
|
17
|
+
useLayoutEffect(() => {
|
|
18
|
+
const node = selectedIconRef.current;
|
|
19
|
+
if (!isReadyToScroll || !node) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (getScrollContainer(node)?.scrollTop) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
node.scrollIntoView({ block: "center" });
|
|
26
|
+
}, [isReadyToScroll]);
|
|
7
27
|
return /* @__PURE__ */ jsx("div", { className: "wp-block-icon__inserter-grid", children: !icons?.length ? /* @__PURE__ */ jsx("div", { className: "wp-block-icon__inserter-grid-no-results", children: /* @__PURE__ */ jsx("p", { children: __("No results found.") }) }) : /* @__PURE__ */ jsx(
|
|
8
28
|
"div",
|
|
9
29
|
{
|
|
10
30
|
className: "wp-block-icon__inserter-grid-icons-list",
|
|
11
31
|
"aria-label": __("Icon library"),
|
|
12
|
-
children:
|
|
32
|
+
children: shownIcons.map((icon) => {
|
|
13
33
|
return /* @__PURE__ */ jsxs(
|
|
14
34
|
Button,
|
|
15
35
|
{
|
|
36
|
+
ref: icon.name === value ? selectedIconRef : void 0,
|
|
16
37
|
className: "wp-block-icon__inserter-grid-icons-list-item",
|
|
17
38
|
onClick: () => onChange(icon.name),
|
|
18
|
-
variant: icon.name ===
|
|
39
|
+
variant: icon.name === value ? "primary" : void 0,
|
|
19
40
|
__next40pxDefaultSize: true,
|
|
20
41
|
children: [
|
|
21
|
-
/* @__PURE__ */ jsx("span", { className: "wp-block-icon__inserter-grid-icons-list-item-icon", children: /* @__PURE__ */ jsx(
|
|
22
|
-
HtmlRenderer,
|
|
23
|
-
{
|
|
24
|
-
html: icon.content,
|
|
25
|
-
wrapperProps: {
|
|
26
|
-
style: { width: "24px" }
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
) }),
|
|
42
|
+
/* @__PURE__ */ jsx("span", { className: "wp-block-icon__inserter-grid-icons-list-item-icon", children: /* @__PURE__ */ jsx(HtmlRenderer, { html: icon.content }) }),
|
|
30
43
|
/* @__PURE__ */ jsx("span", { className: "wp-block-icon__inserter-grid-icons-list-item-title", children: icon.label })
|
|
31
44
|
]
|
|
32
45
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/icon/components/custom-inserter/icon-grid.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport HtmlRenderer from '../../../utils/html-renderer';\n\nexport default function IconGrid( { icons, onChange,
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,cAAc;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { useAsyncList } from '@wordpress/compose';\nimport { useRef, useLayoutEffect } from '@wordpress/element';\nimport { getScrollContainer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport HtmlRenderer from '../../../utils/html-renderer';\n\nconst BATCH_SIZE = 20;\n\nexport default function IconGrid( { icons, onChange, value } ) {\n\tconst shownIcons = useAsyncList( icons, {\n\t\tstep: BATCH_SIZE,\n\t} );\n\n\t// Scroll the selected icon into view, but wait until enough icons render\n\t// below it so it can be centered rather than stuck at the bottom. Skip it\n\t// if the user has already scrolled the list.\n\tconst selectedIconRef = useRef();\n\tconst selectedIndex =\n\t\ticons?.findIndex( ( icon ) => icon.name === value ) ?? -1;\n\tconst isReadyToScroll =\n\t\tselectedIndex >= 0 &&\n\t\t( shownIcons.length >= selectedIndex + BATCH_SIZE ||\n\t\t\tshownIcons.length === icons.length );\n\n\tuseLayoutEffect( () => {\n\t\tconst node = selectedIconRef.current;\n\t\tif ( ! isReadyToScroll || ! node ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( getScrollContainer( node )?.scrollTop ) {\n\t\t\treturn;\n\t\t}\n\t\tnode.scrollIntoView( { block: 'center' } );\n\t}, [ isReadyToScroll ] );\n\n\treturn (\n\t\t<div className=\"wp-block-icon__inserter-grid\">\n\t\t\t{ ! icons?.length ? (\n\t\t\t\t<div className=\"wp-block-icon__inserter-grid-no-results\">\n\t\t\t\t\t<p>{ __( 'No results found.' ) }</p>\n\t\t\t\t</div>\n\t\t\t) : (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"wp-block-icon__inserter-grid-icons-list\"\n\t\t\t\t\taria-label={ __( 'Icon library' ) }\n\t\t\t\t>\n\t\t\t\t\t{ shownIcons.map( ( icon ) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tkey={ icon.name }\n\t\t\t\t\t\t\t\tref={\n\t\t\t\t\t\t\t\t\ticon.name === value\n\t\t\t\t\t\t\t\t\t\t? selectedIconRef\n\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tclassName=\"wp-block-icon__inserter-grid-icons-list-item\"\n\t\t\t\t\t\t\t\tonClick={ () => onChange( icon.name ) }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\ticon.name === value ? 'primary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<span className=\"wp-block-icon__inserter-grid-icons-list-item-icon\">\n\t\t\t\t\t\t\t\t\t<HtmlRenderer html={ icon.content } />\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t<span className=\"wp-block-icon__inserter-grid-icons-list-item-title\">\n\t\t\t\t\t\t\t\t\t{ icon.label }\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAC7B,SAAS,QAAQ,uBAAuB;AACxC,SAAS,0BAA0B;AAKnC,OAAO,kBAAkB;AAmCpB,cASE,YATF;AAjCL,IAAM,aAAa;AAEJ,SAAR,SAA2B,EAAE,OAAO,UAAU,MAAM,GAAI;AAC9D,QAAM,aAAa,aAAc,OAAO;AAAA,IACvC,MAAM;AAAA,EACP,CAAE;AAKF,QAAM,kBAAkB,OAAO;AAC/B,QAAM,gBACL,OAAO,UAAW,CAAE,SAAU,KAAK,SAAS,KAAM,KAAK;AACxD,QAAM,kBACL,iBAAiB,MACf,WAAW,UAAU,gBAAgB,cACtC,WAAW,WAAW,MAAM;AAE9B,kBAAiB,MAAM;AACtB,UAAM,OAAO,gBAAgB;AAC7B,QAAK,CAAE,mBAAmB,CAAE,MAAO;AAClC;AAAA,IACD;AACA,QAAK,mBAAoB,IAAK,GAAG,WAAY;AAC5C;AAAA,IACD;AACA,SAAK,eAAgB,EAAE,OAAO,SAAS,CAAE;AAAA,EAC1C,GAAG,CAAE,eAAgB,CAAE;AAEvB,SACC,oBAAC,SAAI,WAAU,gCACZ,WAAE,OAAO,SACV,oBAAC,SAAI,WAAU,2CACd,8BAAC,OAAI,aAAI,mBAAoB,GAAG,GACjC,IAEA;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,cAAa,GAAI,cAAe;AAAA,MAE9B,qBAAW,IAAK,CAAE,SAAU;AAC7B,eACC;AAAA,UAAC;AAAA;AAAA,YAEA,KACC,KAAK,SAAS,QACX,kBACA;AAAA,YAEJ,WAAU;AAAA,YACV,SAAU,MAAM,SAAU,KAAK,IAAK;AAAA,YACpC,SACC,KAAK,SAAS,QAAQ,YAAY;AAAA,YAEnC,uBAAqB;AAAA,YAErB;AAAA,kCAAC,UAAK,WAAU,qDACf,8BAAC,gBAAa,MAAO,KAAK,SAAU,GACrC;AAAA,cACA,oBAAC,UAAK,WAAU,sDACb,eAAK,OACR;AAAA;AAAA;AAAA,UAlBM,KAAK;AAAA,QAmBZ;AAAA,MAEF,CAAE;AAAA;AAAA,EACH,GAEF;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,29 +1,49 @@
|
|
|
1
1
|
// packages/block-library/src/icon/components/custom-inserter/index.js
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
|
-
import { Modal, SearchControl } from "@wordpress/components";
|
|
4
|
-
import {
|
|
3
|
+
import { Modal, SearchControl, Spinner } from "@wordpress/components";
|
|
4
|
+
import { Stack, Tabs } from "@wordpress/ui";
|
|
5
|
+
import { useState, useMemo } from "@wordpress/element";
|
|
5
6
|
import { useDebounce } from "@wordpress/compose";
|
|
7
|
+
import { useSelect } from "@wordpress/data";
|
|
8
|
+
import { store as coreDataStore } from "@wordpress/core-data";
|
|
6
9
|
import IconGrid from "./icon-grid.mjs";
|
|
7
10
|
import { normalizeSearchInput } from "../../../utils/search-patterns.mjs";
|
|
8
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
function CustomInserterModal({
|
|
10
|
-
icons = [],
|
|
11
|
-
setInserterOpen,
|
|
12
|
-
attributes,
|
|
13
|
-
setAttributes
|
|
14
|
-
}) {
|
|
12
|
+
function CustomInserterModal({ onClose, value, onChange }) {
|
|
15
13
|
const [searchInput, setSearchInput] = useState("");
|
|
14
|
+
const [currentCollection, setCurrentCollection] = useState(null);
|
|
16
15
|
const debouncedSetSearchInput = useDebounce(setSearchInput, 300);
|
|
17
|
-
const
|
|
18
|
-
(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
const collections = useSelect(
|
|
17
|
+
(select) => select(coreDataStore).getEntityRecords(
|
|
18
|
+
"root",
|
|
19
|
+
"iconCollection"
|
|
20
|
+
),
|
|
21
|
+
[]
|
|
22
|
+
);
|
|
23
|
+
const selectedCollection = value?.split("/")[0];
|
|
24
|
+
const collectionSlug = currentCollection ?? (collections?.some(({ slug }) => slug === selectedCollection) ? selectedCollection : collections?.[0]?.slug) ?? null;
|
|
25
|
+
const { icons, hasResolvedIcons } = useSelect(
|
|
26
|
+
(select) => {
|
|
27
|
+
if (collectionSlug === null) {
|
|
28
|
+
return { icons: null, hasResolvedIcons: false };
|
|
29
|
+
}
|
|
30
|
+
const query = collectionSlug === "" ? {} : { collection: collectionSlug };
|
|
31
|
+
const { getEntityRecords, hasFinishedResolution } = select(coreDataStore);
|
|
32
|
+
return {
|
|
33
|
+
icons: getEntityRecords("root", "icon", query),
|
|
34
|
+
hasResolvedIcons: hasFinishedResolution("getEntityRecords", [
|
|
35
|
+
"root",
|
|
36
|
+
"icon",
|
|
37
|
+
query
|
|
38
|
+
])
|
|
39
|
+
};
|
|
23
40
|
},
|
|
24
|
-
[
|
|
41
|
+
[collectionSlug]
|
|
25
42
|
);
|
|
26
43
|
const filteredIcons = useMemo(() => {
|
|
44
|
+
if (!icons) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
27
47
|
if (searchInput) {
|
|
28
48
|
const input = normalizeSearchInput(searchInput);
|
|
29
49
|
return icons.filter((icon) => {
|
|
@@ -39,25 +59,74 @@ function CustomInserterModal({
|
|
|
39
59
|
{
|
|
40
60
|
className: "wp-block-icon__inserter-modal",
|
|
41
61
|
title: __("Icon library"),
|
|
42
|
-
onRequestClose:
|
|
62
|
+
onRequestClose: onClose,
|
|
43
63
|
isFullScreen: true,
|
|
44
|
-
children: /* @__PURE__ */ jsxs(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
children: /* @__PURE__ */ jsxs(
|
|
65
|
+
Tabs.Root,
|
|
66
|
+
{
|
|
67
|
+
className: "wp-block-icon__inserter",
|
|
68
|
+
orientation: "vertical",
|
|
69
|
+
value: collectionSlug,
|
|
70
|
+
onValueChange: setCurrentCollection,
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ jsxs(
|
|
73
|
+
Stack,
|
|
74
|
+
{
|
|
75
|
+
direction: "column",
|
|
76
|
+
gap: "lg",
|
|
77
|
+
className: "wp-block-icon__inserter-sidebar",
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ jsx(
|
|
80
|
+
SearchControl,
|
|
81
|
+
{
|
|
82
|
+
value: searchInput,
|
|
83
|
+
onChange: debouncedSetSearchInput
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
/* @__PURE__ */ jsxs(Tabs.List, { children: [
|
|
87
|
+
/* @__PURE__ */ jsx(Tabs.Tab, { value: "", children: __("All") }),
|
|
88
|
+
collections?.map((collection) => /* @__PURE__ */ jsx(
|
|
89
|
+
Tabs.Tab,
|
|
90
|
+
{
|
|
91
|
+
value: collection.slug,
|
|
92
|
+
children: collection.label
|
|
93
|
+
},
|
|
94
|
+
collection.slug
|
|
95
|
+
))
|
|
96
|
+
] })
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
),
|
|
100
|
+
[{ slug: "" }, ...collections ?? []].map(
|
|
101
|
+
(collection) => /* @__PURE__ */ jsx(
|
|
102
|
+
Tabs.Panel,
|
|
103
|
+
{
|
|
104
|
+
tabIndex: -1,
|
|
105
|
+
value: collection.slug,
|
|
106
|
+
className: "wp-block-icon__inserter-panel",
|
|
107
|
+
children: !hasResolvedIcons ? /* @__PURE__ */ jsx(
|
|
108
|
+
"div",
|
|
109
|
+
{
|
|
110
|
+
className: "wp-block-icon__inserter-loading",
|
|
111
|
+
role: "status",
|
|
112
|
+
"aria-label": __("Loading…"),
|
|
113
|
+
children: /* @__PURE__ */ jsx(Spinner, {})
|
|
114
|
+
}
|
|
115
|
+
) : /* @__PURE__ */ jsx(
|
|
116
|
+
IconGrid,
|
|
117
|
+
{
|
|
118
|
+
icons: filteredIcons,
|
|
119
|
+
onChange,
|
|
120
|
+
value
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
},
|
|
124
|
+
collection.slug
|
|
125
|
+
)
|
|
126
|
+
)
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
)
|
|
61
130
|
}
|
|
62
131
|
);
|
|
63
132
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/icon/components/custom-inserter/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Modal, SearchControl } from '@wordpress/components';\nimport { useState, useMemo
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,OAAO,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Modal, SearchControl, Spinner } from '@wordpress/components';\nimport { Stack, Tabs } from '@wordpress/ui';\nimport { useState, useMemo } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport IconGrid from './icon-grid';\nimport { normalizeSearchInput } from '../../../utils/search-patterns';\n\nexport default function CustomInserterModal( { onClose, value, onChange } ) {\n\tconst [ searchInput, setSearchInput ] = useState( '' );\n\tconst [ currentCollection, setCurrentCollection ] = useState( null );\n\n\tconst debouncedSetSearchInput = useDebounce( setSearchInput, 300 );\n\n\tconst collections = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreDataStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'iconCollection'\n\t\t\t),\n\t\t[]\n\t);\n\n\t// Default to the collection the selected icon belongs to, otherwise the\n\t// first collection.\n\tconst selectedCollection = value?.split( '/' )[ 0 ];\n\tconst collectionSlug =\n\t\tcurrentCollection ??\n\t\t( collections?.some( ( { slug } ) => slug === selectedCollection )\n\t\t\t? selectedCollection\n\t\t\t: collections?.[ 0 ]?.slug ) ??\n\t\tnull;\n\n\tconst { icons, hasResolvedIcons } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( collectionSlug === null ) {\n\t\t\t\treturn { icons: null, hasResolvedIcons: false };\n\t\t\t}\n\t\t\tconst query =\n\t\t\t\tcollectionSlug === '' ? {} : { collection: collectionSlug };\n\t\t\tconst { getEntityRecords, hasFinishedResolution } =\n\t\t\t\tselect( coreDataStore );\n\t\t\treturn {\n\t\t\t\ticons: getEntityRecords( 'root', 'icon', query ),\n\t\t\t\thasResolvedIcons: hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'root',\n\t\t\t\t\t'icon',\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t};\n\t\t},\n\t\t[ collectionSlug ]\n\t);\n\n\tconst filteredIcons = useMemo( () => {\n\t\tif ( ! icons ) {\n\t\t\treturn [];\n\t\t}\n\t\tif ( searchInput ) {\n\t\t\tconst input = normalizeSearchInput( searchInput );\n\t\t\treturn icons.filter( ( icon ) => {\n\t\t\t\tconst iconName = normalizeSearchInput( icon.name );\n\t\t\t\tconst iconLabel = normalizeSearchInput( icon.label );\n\n\t\t\t\treturn (\n\t\t\t\t\ticonName.includes( input ) || iconLabel.includes( input )\n\t\t\t\t);\n\t\t\t} );\n\t\t}\n\n\t\treturn icons;\n\t}, [ searchInput, icons ] );\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"wp-block-icon__inserter-modal\"\n\t\t\ttitle={ __( 'Icon library' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t\tisFullScreen\n\t\t>\n\t\t\t<Tabs.Root\n\t\t\t\tclassName=\"wp-block-icon__inserter\"\n\t\t\t\torientation=\"vertical\"\n\t\t\t\tvalue={ collectionSlug }\n\t\t\t\tonValueChange={ setCurrentCollection }\n\t\t\t>\n\t\t\t\t<Stack\n\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\tgap=\"lg\"\n\t\t\t\t\tclassName=\"wp-block-icon__inserter-sidebar\"\n\t\t\t\t>\n\t\t\t\t\t<SearchControl\n\t\t\t\t\t\tvalue={ searchInput }\n\t\t\t\t\t\tonChange={ debouncedSetSearchInput }\n\t\t\t\t\t/>\n\t\t\t\t\t<Tabs.List>\n\t\t\t\t\t\t<Tabs.Tab value=\"\">{ __( 'All' ) }</Tabs.Tab>\n\t\t\t\t\t\t{ collections?.map( ( collection ) => (\n\t\t\t\t\t\t\t<Tabs.Tab\n\t\t\t\t\t\t\t\tkey={ collection.slug }\n\t\t\t\t\t\t\t\tvalue={ collection.slug }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ collection.label }\n\t\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</Tabs.List>\n\t\t\t\t</Stack>\n\t\t\t\t{ [ { slug: '' }, ...( collections ?? [] ) ].map(\n\t\t\t\t\t( collection ) => (\n\t\t\t\t\t\t<Tabs.Panel\n\t\t\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\t\t\tkey={ collection.slug }\n\t\t\t\t\t\t\tvalue={ collection.slug }\n\t\t\t\t\t\t\tclassName=\"wp-block-icon__inserter-panel\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ ! hasResolvedIcons ? (\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclassName=\"wp-block-icon__inserter-loading\"\n\t\t\t\t\t\t\t\t\trole=\"status\"\n\t\t\t\t\t\t\t\t\taria-label={ __( 'Loading…' ) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<IconGrid\n\t\t\t\t\t\t\t\t\ticons={ filteredIcons }\n\t\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Tabs.Panel>\n\t\t\t\t\t)\n\t\t\t\t) }\n\t\t\t</Tabs.Root>\n\t\t</Modal>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|