@wordpress/block-library 9.47.0 → 9.48.1
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 +8 -0
- package/build/columns/transforms.cjs +65 -0
- package/build/columns/transforms.cjs.map +2 -2
- package/build/comments/edit/placeholder.cjs +1 -1
- package/build/comments/edit/placeholder.cjs.map +2 -2
- package/build/cover/edit/inspector-controls.cjs +16 -4
- package/build/cover/edit/inspector-controls.cjs.map +2 -2
- package/build/gallery/edit.cjs +212 -331
- package/build/gallery/edit.cjs.map +2 -2
- package/build/gallery/transforms.cjs +43 -0
- package/build/gallery/transforms.cjs.map +2 -2
- package/build/heading/edit.cjs +0 -1
- package/build/heading/edit.cjs.map +2 -2
- package/build/image/image.cjs +14 -3
- package/build/image/image.cjs.map +2 -2
- package/build/image/use-open-image-media-editor-modal.cjs +8 -2
- package/build/image/use-open-image-media-editor-modal.cjs.map +2 -2
- package/build/list/edit.cjs +1 -8
- package/build/list/edit.cjs.map +2 -2
- package/build/list/ordered-list-settings.cjs +1 -44
- package/build/list/ordered-list-settings.cjs.map +2 -2
- package/build/list-item/hooks/use-merge.cjs +47 -24
- package/build/list-item/hooks/use-merge.cjs.map +2 -2
- package/build/navigation/edit/index.cjs +15 -26
- package/build/navigation/edit/index.cjs.map +2 -2
- package/build/navigation-link/edit.cjs +0 -1
- package/build/navigation-link/edit.cjs.map +2 -2
- package/build/navigation-submenu/edit.cjs +2 -1
- package/build/navigation-submenu/edit.cjs.map +2 -2
- package/build/paragraph/deprecated.cjs +1 -0
- package/build/paragraph/deprecated.cjs.map +2 -2
- package/build/paragraph/edit.cjs +10 -1
- package/build/paragraph/edit.cjs.map +3 -3
- package/build/playlist/block.json +12 -0
- package/build/playlist/edit.cjs +27 -1
- package/build/playlist/edit.cjs.map +2 -2
- package/build/playlist/save.cjs +8 -1
- package/build/playlist/save.cjs.map +2 -2
- package/build/playlist/view.cjs +1 -0
- package/build/playlist/view.cjs.map +2 -2
- package/build/post-featured-image/edit.cjs +6 -4
- package/build/post-featured-image/edit.cjs.map +2 -2
- package/build/post-time-to-read/index.cjs +1 -1
- package/build/post-time-to-read/index.cjs.map +2 -2
- package/build/post-time-to-read/variations.cjs +1 -1
- package/build/post-time-to-read/variations.cjs.map +2 -2
- package/build/pullquote/edit.cjs +2 -7
- package/build/pullquote/edit.cjs.map +2 -2
- package/build/quote/edit.cjs +4 -9
- package/build/quote/edit.cjs.map +2 -2
- package/build/shortcode/transforms.cjs +2 -2
- package/build/shortcode/transforms.cjs.map +2 -2
- package/build/site-logo/edit.cjs +4 -1
- package/build/site-logo/edit.cjs.map +2 -2
- package/build/utils/waveform-player.cjs +42 -9
- package/build/utils/waveform-player.cjs.map +2 -2
- package/build/utils/waveform-utils.cjs +6 -4
- package/build/utils/waveform-utils.cjs.map +2 -2
- package/build/video/edit-common-settings.cjs +3 -6
- package/build/video/edit-common-settings.cjs.map +2 -2
- package/build-module/columns/transforms.mjs +65 -0
- package/build-module/columns/transforms.mjs.map +2 -2
- package/build-module/comments/edit/placeholder.mjs +1 -1
- package/build-module/comments/edit/placeholder.mjs.map +2 -2
- package/build-module/cover/edit/inspector-controls.mjs +16 -4
- package/build-module/cover/edit/inspector-controls.mjs.map +2 -2
- package/build-module/gallery/edit.mjs +214 -334
- package/build-module/gallery/edit.mjs.map +2 -2
- package/build-module/gallery/transforms.mjs +43 -0
- package/build-module/gallery/transforms.mjs.map +2 -2
- package/build-module/heading/edit.mjs +1 -2
- package/build-module/heading/edit.mjs.map +2 -2
- package/build-module/image/image.mjs +15 -3
- package/build-module/image/image.mjs.map +2 -2
- package/build-module/image/use-open-image-media-editor-modal.mjs +8 -2
- package/build-module/image/use-open-image-media-editor-modal.mjs.map +2 -2
- package/build-module/list/edit.mjs +2 -9
- package/build-module/list/edit.mjs.map +2 -2
- package/build-module/list/ordered-list-settings.mjs +1 -45
- package/build-module/list/ordered-list-settings.mjs.map +2 -2
- package/build-module/list-item/hooks/use-merge.mjs +48 -25
- package/build-module/list-item/hooks/use-merge.mjs.map +2 -2
- package/build-module/navigation/edit/index.mjs +16 -33
- package/build-module/navigation/edit/index.mjs.map +2 -2
- package/build-module/navigation-link/edit.mjs +0 -1
- package/build-module/navigation-link/edit.mjs.map +2 -2
- package/build-module/navigation-submenu/edit.mjs +2 -1
- package/build-module/navigation-submenu/edit.mjs.map +2 -2
- package/build-module/paragraph/deprecated.mjs +1 -0
- package/build-module/paragraph/deprecated.mjs.map +2 -2
- package/build-module/paragraph/edit.mjs +12 -2
- package/build-module/paragraph/edit.mjs.map +2 -2
- package/build-module/playlist/block.json +12 -0
- package/build-module/playlist/edit.mjs +27 -1
- package/build-module/playlist/edit.mjs.map +2 -2
- package/build-module/playlist/save.mjs +8 -1
- package/build-module/playlist/save.mjs.map +2 -2
- package/build-module/playlist/view.mjs +1 -0
- package/build-module/playlist/view.mjs.map +2 -2
- package/build-module/post-featured-image/edit.mjs +6 -4
- package/build-module/post-featured-image/edit.mjs.map +2 -2
- package/build-module/post-time-to-read/index.mjs +1 -1
- package/build-module/post-time-to-read/index.mjs.map +2 -2
- package/build-module/post-time-to-read/variations.mjs +2 -2
- package/build-module/post-time-to-read/variations.mjs.map +2 -2
- package/build-module/pullquote/edit.mjs +2 -7
- package/build-module/pullquote/edit.mjs.map +2 -2
- package/build-module/quote/edit.mjs +5 -10
- package/build-module/quote/edit.mjs.map +2 -2
- package/build-module/shortcode/transforms.mjs +2 -2
- package/build-module/shortcode/transforms.mjs.map +2 -2
- package/build-module/site-logo/edit.mjs +5 -1
- package/build-module/site-logo/edit.mjs.map +2 -2
- package/build-module/utils/waveform-player.mjs +44 -11
- package/build-module/utils/waveform-player.mjs.map +2 -2
- package/build-module/utils/waveform-utils.mjs +6 -4
- package/build-module/utils/waveform-utils.mjs.map +2 -2
- package/build-module/video/edit-common-settings.mjs +4 -7
- package/build-module/video/edit-common-settings.mjs.map +2 -2
- package/build-style/comment-template/style-rtl.css +1 -0
- package/build-style/comment-template/style.css +1 -0
- package/build-style/common-rtl.css +30 -10
- package/build-style/common.css +30 -10
- package/build-style/cover/style-rtl.css +2 -1
- package/build-style/cover/style.css +2 -1
- package/build-style/editor-rtl.css +22 -11
- package/build-style/editor.css +22 -11
- package/build-style/form-input/style-rtl.css +2 -0
- package/build-style/form-input/style.css +2 -0
- package/build-style/gallery/style-rtl.css +4 -2
- package/build-style/gallery/style.css +4 -2
- package/build-style/media-text/style-rtl.css +2 -1
- package/build-style/media-text/style.css +2 -1
- package/build-style/playlist/style-rtl.css +3 -0
- package/build-style/playlist/style.css +3 -0
- package/build-style/query/editor-rtl.css +8 -4
- package/build-style/query/editor.css +8 -4
- package/build-style/read-more/style-rtl.css +1 -0
- package/build-style/read-more/style.css +1 -0
- package/build-style/reset-rtl.css +3 -1
- package/build-style/reset.css +3 -1
- package/build-style/search/style-rtl.css +3 -1
- package/build-style/search/style.css +3 -1
- package/build-style/site-logo/editor-rtl.css +2 -1
- package/build-style/site-logo/editor.css +2 -1
- package/build-style/style-rtl.css +53 -17
- package/build-style/style.css +53 -17
- package/build-style/tab/style-rtl.css +3 -1
- package/build-style/tab/style.css +3 -1
- package/build-style/template-part/editor-rtl.css +8 -4
- package/build-style/template-part/editor.css +8 -4
- package/build-style/video/style-rtl.css +2 -1
- package/build-style/video/style.css +2 -1
- package/package.json +51 -47
- package/src/accordion/README.md +97 -0
- package/src/accordion-heading/README.md +81 -0
- package/src/accordion-item/README.md +85 -0
- package/src/accordion-panel/README.md +74 -0
- package/src/archives/README.md +56 -0
- package/src/audio/README.md +55 -0
- package/src/avatar/README.md +74 -0
- package/src/block/README.md +56 -0
- package/src/breadcrumbs/README.md +67 -0
- package/src/button/README.md +93 -0
- package/src/buttons/README.md +80 -0
- package/src/calendar/README.md +51 -0
- package/src/categories/README.md +69 -0
- package/src/code/README.md +55 -0
- package/src/column/README.md +72 -0
- package/src/columns/README.md +90 -0
- package/src/columns/test/transforms.js +164 -0
- package/src/columns/transforms.js +74 -0
- package/src/comment-author-avatar/README.md +63 -0
- package/src/comment-author-name/README.md +67 -0
- package/src/comment-content/README.md +61 -0
- package/src/comment-date/README.md +67 -0
- package/src/comment-edit-link/README.md +67 -0
- package/src/comment-reply-link/README.md +63 -0
- package/src/comment-template/README.md +60 -0
- package/src/comments/README.md +88 -0
- package/src/comments/edit/placeholder.js +1 -1
- package/src/comments-pagination/README.md +77 -0
- package/src/comments-pagination-next/README.md +64 -0
- package/src/comments-pagination-numbers/README.md +64 -0
- package/src/comments-pagination-previous/README.md +64 -0
- package/src/comments-title/README.md +70 -0
- package/src/common.scss +63 -10
- package/src/cover/README.md +111 -0
- package/src/cover/edit/inspector-controls.js +61 -45
- package/src/cover/test/edit.js +38 -0
- package/src/details/README.md +65 -0
- package/src/embed/README.md +56 -0
- package/src/file/README.md +60 -0
- package/src/footnotes/README.md +64 -0
- package/src/form/README.md +90 -0
- package/src/form-input/README.md +74 -0
- package/src/form-submission-notification/README.md +50 -0
- package/src/form-submit-button/README.md +54 -0
- package/src/freeform/README.md +49 -0
- package/src/gallery/README.md +115 -0
- package/src/gallery/edit.js +213 -350
- package/src/gallery/test/transforms.js +155 -0
- package/src/gallery/transforms.js +47 -0
- package/src/group/README.md +80 -0
- package/src/heading/README.md +60 -0
- package/src/heading/edit.js +1 -2
- package/src/home-link/README.md +66 -0
- package/src/home-link/index.php +3 -15
- package/src/html/README.md +48 -0
- package/src/icon/README.md +63 -0
- package/src/image/README.md +102 -0
- package/src/image/image.js +50 -35
- package/src/image/index.php +4 -4
- package/src/image/test/use-open-image-media-editor-modal.js +41 -0
- package/src/image/use-open-image-media-editor-modal.js +7 -1
- package/src/latest-comments/README.md +57 -0
- package/src/latest-posts/README.md +71 -0
- package/src/list/README.md +70 -0
- package/src/list/edit.js +2 -9
- package/src/list/ordered-list-settings.js +46 -92
- package/src/list-item/README.md +71 -0
- package/src/list-item/hooks/use-merge.js +53 -46
- package/src/loginout/README.md +56 -0
- package/src/math/README.md +50 -0
- package/src/media-text/README.md +92 -0
- package/src/missing/README.md +55 -0
- package/src/more/README.md +49 -0
- package/src/navigation/README.md +115 -0
- package/src/navigation/edit/index.js +10 -30
- package/src/navigation-link/README.md +93 -0
- package/src/navigation-link/edit.js +0 -1
- package/src/navigation-link/index.php +1 -15
- package/src/navigation-link/test/__snapshots__/hooks.js.snap +45 -134
- package/src/navigation-overlay-close/README.md +48 -0
- package/src/navigation-submenu/README.md +84 -0
- package/src/navigation-submenu/edit.js +1 -0
- package/src/navigation-submenu/index.php +1 -17
- package/src/nextpage/README.md +50 -0
- package/src/page-list/README.md +84 -0
- package/src/page-list/index.php +3 -15
- package/src/page-list-item/README.md +77 -0
- package/src/paragraph/README.md +70 -0
- package/src/paragraph/deprecated.js +1 -0
- package/src/paragraph/edit.js +13 -1
- package/src/pattern/README.md +45 -0
- package/src/playlist/README.md +86 -0
- package/src/playlist/block.json +12 -0
- package/src/playlist/edit.js +27 -0
- package/src/playlist/index.php +10 -3
- package/src/playlist/save.js +9 -1
- package/src/playlist/style.scss +7 -0
- package/src/playlist/view.js +1 -0
- package/src/playlist-track/README.md +69 -0
- package/src/post-author/README.md +78 -0
- package/src/post-author-biography/README.md +59 -0
- package/src/post-author-name/README.md +63 -0
- package/src/post-author-name/index.php +1 -1
- package/src/post-comment/README.md +61 -0
- package/src/post-comments-count/README.md +58 -0
- package/src/post-comments-form/README.md +59 -0
- package/src/post-comments-link/README.md +60 -0
- package/src/post-content/README.md +71 -0
- package/src/post-date/README.md +65 -0
- package/src/post-date/index.php +1 -1
- package/src/post-excerpt/README.md +66 -0
- package/src/post-featured-image/README.md +85 -0
- package/src/post-featured-image/edit.js +15 -10
- package/src/post-featured-image/index.php +1 -1
- package/src/post-navigation-link/README.md +63 -0
- package/src/post-template/README.md +71 -0
- package/src/post-terms/README.md +65 -0
- package/src/post-time-to-read/README.md +63 -0
- package/src/post-time-to-read/index.js +1 -1
- package/src/post-time-to-read/variations.js +2 -2
- package/src/post-title/README.md +69 -0
- package/src/preformatted/README.md +50 -0
- package/src/pullquote/README.md +64 -0
- package/src/pullquote/edit.js +1 -7
- package/src/query/README.md +64 -0
- package/src/query-no-results/README.md +65 -0
- package/src/query-pagination/README.md +79 -0
- package/src/query-pagination-next/README.md +67 -0
- package/src/query-pagination-numbers/README.md +65 -0
- package/src/query-pagination-previous/README.md +67 -0
- package/src/query-title/README.md +65 -0
- package/src/query-total/README.md +66 -0
- package/src/quote/README.md +75 -0
- package/src/quote/edit.js +3 -9
- package/src/read-more/README.md +61 -0
- package/src/read-more/index.php +2 -2
- package/src/rss/README.md +62 -0
- package/src/search/README.md +66 -0
- package/src/separator/README.md +62 -0
- package/src/shortcode/README.md +44 -0
- package/src/shortcode/transforms.js +2 -2
- package/src/site-logo/README.md +72 -0
- package/src/site-logo/edit.js +5 -0
- package/src/site-tagline/README.md +56 -0
- package/src/site-title/README.md +57 -0
- package/src/social-link/README.md +64 -0
- package/src/social-links/README.md +98 -0
- package/src/spacer/README.md +53 -0
- package/src/tab/README.md +69 -0
- package/src/tab-list/README.md +79 -0
- package/src/tab-panel/README.md +75 -0
- package/src/tab-panels/README.md +75 -0
- package/src/table/README.md +71 -0
- package/src/table-of-contents/README.md +61 -0
- package/src/tabs/README.md +83 -0
- package/src/tag-cloud/README.md +62 -0
- package/src/template-part/README.md +48 -0
- package/src/term-count/README.md +59 -0
- package/src/term-description/README.md +60 -0
- package/src/term-name/README.md +65 -0
- package/src/term-template/README.md +65 -0
- package/src/terms-query/README.md +58 -0
- package/src/text-columns/README.md +51 -0
- package/src/utils/test/waveform-player.js +254 -0
- package/src/utils/waveform-player.js +90 -18
- package/src/utils/waveform-utils.js +15 -11
- package/src/verse/README.md +58 -0
- package/src/video/README.md +58 -0
- package/src/video/edit-common-settings.js +4 -7
- package/src/audio/edit.native.js +0 -250
- package/src/audio/style.native.scss +0 -13
- package/src/audio/test/__snapshots__/edit.native.js.snap +0 -546
- package/src/audio/test/__snapshots__/transforms.native.js.snap +0 -25
- package/src/audio/test/edit.native.js +0 -132
- package/src/audio/test/transforms.native.js +0 -43
- package/src/audio/transforms.native.js +0 -12
- package/src/block/edit-title.native.js +0 -67
- package/src/block/edit.native.js +0 -247
- package/src/block/editor.native.scss +0 -125
- package/src/block/test/__snapshots__/transforms.native.js.snap +0 -15
- package/src/block/test/edit.native.js +0 -262
- package/src/block/test/transforms.native.js +0 -40
- package/src/button/color-background.native.js +0 -41
- package/src/button/edit.native.js +0 -567
- package/src/button/editor.native.scss +0 -70
- package/src/button/rich-text.android.scss +0 -6
- package/src/button/rich-text.ios.scss +0 -6
- package/src/buttons/edit.native.js +0 -157
- package/src/buttons/editor.native.scss +0 -11
- package/src/buttons/test/__snapshots__/edit.native.js.snap +0 -99
- package/src/buttons/test/__snapshots__/transforms.native.js.snap +0 -31
- package/src/buttons/test/edit.native.js +0 -485
- package/src/buttons/test/transforms.native.js +0 -48
- package/src/buttons/transforms.native.js +0 -12
- package/src/code/edit.native.js +0 -70
- package/src/code/test/__snapshots__/edit.native.js.snap +0 -13
- package/src/code/test/edit.native.js +0 -65
- package/src/code/theme.native.scss +0 -22
- package/src/code/transforms.native.js +0 -12
- package/src/column/column-preview.native.js +0 -58
- package/src/column/edit.native.js +0 -273
- package/src/column/editor.native.scss +0 -75
- package/src/columns/columnCalculations.native.js +0 -178
- package/src/columns/edit.native.js +0 -507
- package/src/columns/editor.native.scss +0 -17
- package/src/columns/test/__snapshots__/edit.native.js.snap +0 -305
- package/src/columns/test/__snapshots__/transforms.native.js.snap +0 -61
- package/src/columns/test/edit.native.js +0 -496
- package/src/columns/test/transforms.native.js +0 -89
- package/src/columns/transforms.native.js +0 -12
- package/src/cover/controls.native.js +0 -307
- package/src/cover/edit.native.js +0 -708
- package/src/cover/focal-point-settings-button.native.js +0 -53
- package/src/cover/overlay-color-settings.native.js +0 -106
- package/src/cover/style.native.scss +0 -220
- package/src/cover/test/__snapshots__/edit.native.js.snap +0 -105
- package/src/cover/test/__snapshots__/transforms.native.js.snap +0 -73
- package/src/cover/test/edit.native.js +0 -701
- package/src/cover/test/transforms.native.js +0 -116
- package/src/cover/transforms.native.js +0 -12
- package/src/cover/use-cover-is-dark.native.js +0 -51
- package/src/embed/edit.native.js +0 -345
- package/src/embed/embed-controls.native.js +0 -65
- package/src/embed/embed-link-settings.native.js +0 -99
- package/src/embed/embed-loading.native.js +0 -29
- package/src/embed/embed-no-preview.native.js +0 -230
- package/src/embed/embed-placeholder.native.js +0 -178
- package/src/embed/embed-preview.native.js +0 -157
- package/src/embed/styles.native.scss +0 -196
- package/src/embed/test/__snapshots__/index.native.js.snap +0 -191
- package/src/embed/test/__snapshots__/transforms.native.js.snap +0 -23
- package/src/embed/test/index.native.js +0 -1125
- package/src/embed/test/transforms.native.js +0 -44
- package/src/embed/transforms.native.js +0 -12
- package/src/embed/wp-embed-preview.native.js +0 -80
- package/src/file/edit.native.js +0 -605
- package/src/file/style.native.scss +0 -79
- package/src/file/test/__snapshots__/edit.native.js.snap +0 -580
- package/src/file/test/__snapshots__/transforms.native.js.snap +0 -19
- package/src/file/test/edit.native.js +0 -93
- package/src/file/test/transforms.native.js +0 -43
- package/src/file/transforms.native.js +0 -12
- package/src/freeform/edit.native.js +0 -13
- package/src/freeform/test/__snapshots__/index.native.js.snap +0 -7
- package/src/freeform/test/__snapshots__/transforms.native.js.snap +0 -19
- package/src/freeform/test/index.native.js +0 -57
- package/src/freeform/test/transforms.native.js +0 -39
- package/src/gallery/gallery-styles.native.scss +0 -8
- package/src/gallery/gallery.native.js +0 -124
- package/src/gallery/styles.native.scss +0 -7
- package/src/gallery/test/__snapshots__/index.native.js.snap +0 -177
- package/src/gallery/test/__snapshots__/transforms.native.js.snap +0 -53
- package/src/gallery/test/helpers.native.js +0 -106
- package/src/gallery/test/index.native.js +0 -700
- package/src/gallery/test/transforms.native.js +0 -53
- package/src/gallery/test/use-get-media.native.js +0 -24
- package/src/gallery/transforms.native.js +0 -12
- package/src/gallery/use-get-media.native.js +0 -49
- package/src/group/edit.native.js +0 -137
- package/src/group/editor.native.scss +0 -56
- package/src/group/test/__snapshots__/edit.native.js.snap +0 -19
- package/src/group/test/__snapshots__/transforms.native.js.snap +0 -35
- package/src/group/test/edit.native.js +0 -100
- package/src/group/test/transforms.native.js +0 -73
- package/src/heading/edit.native.js +0 -159
- package/src/heading/test/__snapshots__/index.native.js.snap +0 -43
- package/src/heading/test/__snapshots__/transforms.native.js.snap +0 -47
- package/src/heading/test/index.native.js +0 -257
- package/src/heading/test/transforms.native.js +0 -46
- package/src/heading/transforms.native.js +0 -12
- package/src/html/transforms.native.js +0 -11
- package/src/image/edit.native.js +0 -959
- package/src/image/styles.native.scss +0 -70
- package/src/image/test/__snapshots__/transforms.native.js.snap +0 -49
- package/src/image/test/edit.native.js +0 -459
- package/src/image/test/transforms.native.js +0 -49
- package/src/image/transforms.native.js +0 -12
- package/src/index.native.js +0 -274
- package/src/latest-posts/edit.native.js +0 -294
- package/src/latest-posts/style.native.scss +0 -47
- package/src/latest-posts/test/__snapshots__/edit.native.js.snap +0 -3
- package/src/latest-posts/test/__snapshots__/transforms.native.js.snap +0 -15
- package/src/latest-posts/test/edit.native.js +0 -49
- package/src/latest-posts/test/transforms.native.js +0 -61
- package/src/list/tag-name.native.js +0 -12
- package/src/list/test/__snapshots__/edit.native.js.snap +0 -121
- package/src/list/test/__snapshots__/transforms.native.js.snap +0 -85
- package/src/list/test/edit.native.js +0 -602
- package/src/list/test/transforms.native.js +0 -56
- package/src/list/transforms.native.js +0 -12
- package/src/list-item/edit.native.js +0 -175
- package/src/list-item/hooks/use-enter.native.js +0 -81
- package/src/list-item/icons.native.js +0 -34
- package/src/list-item/list-style-type.native.js +0 -146
- package/src/list-item/style.native.scss +0 -57
- package/src/media-text/edit.native.js +0 -417
- package/src/media-text/icon-retry.native.js +0 -11
- package/src/media-text/media-container.native.js +0 -393
- package/src/media-text/style.native.scss +0 -191
- package/src/media-text/test/__snapshots__/transforms.native.js.snap +0 -73
- package/src/media-text/test/edit.native.js +0 -58
- package/src/media-text/test/transforms.native.js +0 -116
- package/src/media-text/transforms.native.js +0 -12
- package/src/missing/edit.native.js +0 -294
- package/src/missing/style.native.scss +0 -79
- package/src/missing/test/__snapshots__/edit.native.js.snap +0 -110
- package/src/missing/test/edit-integration.native.js +0 -168
- package/src/missing/test/edit.native.js +0 -81
- package/src/more/edit.native.js +0 -36
- package/src/more/editor.native.scss +0 -21
- package/src/more/test/__snapshots__/edit.native.js.snap +0 -7
- package/src/more/test/__snapshots__/transforms.native.js.snap +0 -19
- package/src/more/test/edit.native.js +0 -41
- package/src/more/test/transforms.native.js +0 -42
- package/src/more/transforms.native.js +0 -12
- package/src/navigation-link/shared/build-css-font-sizes.php +0 -43
- package/src/nextpage/edit.native.js +0 -58
- package/src/nextpage/editor.native.scss +0 -21
- package/src/nextpage/test/__snapshots__/transforms.native.js.snap +0 -19
- package/src/nextpage/test/transforms.native.js +0 -42
- package/src/nextpage/transforms.native.js +0 -12
- package/src/paragraph/edit.native.js +0 -116
- package/src/paragraph/test/__snapshots__/edit.native.js.snap +0 -88
- package/src/paragraph/test/__snapshots__/transforms.native.js.snap +0 -65
- package/src/paragraph/test/edit.native.js +0 -999
- package/src/paragraph/test/transforms.native.js +0 -51
- package/src/paragraph/transforms.native.js +0 -12
- package/src/preformatted/edit.native.js +0 -48
- package/src/preformatted/styles.native.scss +0 -30
- package/src/preformatted/test/__snapshots__/edit.native.js.snap +0 -95
- package/src/preformatted/test/__snapshots__/transforms.native.js.snap +0 -37
- package/src/preformatted/test/edit.native.js +0 -111
- package/src/preformatted/test/transforms.native.js +0 -47
- package/src/preformatted/transforms.native.js +0 -12
- package/src/pullquote/blockquote.native.js +0 -39
- package/src/pullquote/blockquote.native.scss +0 -8
- package/src/pullquote/edit.native.js +0 -128
- package/src/pullquote/figure.native.js +0 -33
- package/src/pullquote/figure.native.scss +0 -16
- package/src/pullquote/test/__snapshots__/transforms.native.js.snap +0 -47
- package/src/pullquote/test/edit.native.js +0 -73
- package/src/pullquote/test/transforms.native.js +0 -46
- package/src/pullquote/transforms.native.js +0 -12
- package/src/quote/test/__snapshots__/transforms.native.js.snap +0 -49
- package/src/quote/test/edit.native.js +0 -94
- package/src/quote/test/transforms.native.js +0 -69
- package/src/quote/transforms.native.js +0 -12
- package/src/search/edit.native.js +0 -486
- package/src/search/style.native.scss +0 -99
- package/src/search/test/__snapshots__/edit.native.js.snap +0 -827
- package/src/search/test/__snapshots__/transforms.native.js.snap +0 -15
- package/src/search/test/edit.native.js +0 -170
- package/src/search/test/transforms.native.js +0 -40
- package/src/separator/separator-settings.native.js +0 -3
- package/src/separator/test/__snapshots__/edit.native.js.snap +0 -7
- package/src/separator/test/__snapshots__/transforms.native.js.snap +0 -25
- package/src/separator/test/edit.native.js +0 -41
- package/src/separator/test/transforms.native.js +0 -42
- package/src/separator/transforms.native.js +0 -12
- package/src/shortcode/edit.native.js +0 -77
- package/src/shortcode/style.native.scss +0 -44
- package/src/shortcode/test/__snapshots__/edit.native.js.snap +0 -9
- package/src/shortcode/test/__snapshots__/transforms.native.js.snap +0 -19
- package/src/shortcode/test/edit.native.js +0 -70
- package/src/shortcode/test/transforms.native.js +0 -42
- package/src/shortcode/transforms.native.js +0 -12
- package/src/social-link/edit.native.js +0 -219
- package/src/social-link/editor.native.scss +0 -18
- package/src/social-links/edit.native.js +0 -147
- package/src/social-links/editor.native.scss +0 -25
- package/src/social-links/test/__snapshots__/edit.native.js.snap +0 -57
- package/src/social-links/test/__snapshots__/transforms.native.js.snap +0 -31
- package/src/social-links/test/edit.native.js +0 -266
- package/src/social-links/test/transforms.native.js +0 -53
- package/src/spacer/controls.native.js +0 -86
- package/src/spacer/edit.native.js +0 -110
- package/src/spacer/editor.native.scss +0 -18
- package/src/spacer/save.native.js +0 -18
- package/src/spacer/test/__snapshots__/index.native.js.snap +0 -43
- package/src/spacer/test/__snapshots__/transforms.native.js.snap +0 -25
- package/src/spacer/test/index.native.js +0 -257
- package/src/spacer/test/transforms.native.js +0 -42
- package/src/table/transforms.native.js +0 -11
- package/src/text-columns/transforms.native.js +0 -12
- package/src/utils/init-block.native.js +0 -40
- package/src/utils/transformation-categories.native.js +0 -47
- package/src/verse/test/__snapshots__/edit.native.js.snap +0 -13
- package/src/verse/test/__snapshots__/transforms.native.js.snap +0 -31
- package/src/verse/test/edit.native.js +0 -118
- package/src/verse/test/transforms.native.js +0 -46
- package/src/verse/transforms.native.js +0 -12
- package/src/video/edit.native.js +0 -406
- package/src/video/icon-retry.native.js +0 -11
- package/src/video/style.native.scss +0 -81
- package/src/video/test/__snapshots__/transforms.native.js.snap +0 -41
- package/src/video/test/edit.native.js +0 -53
- package/src/video/test/transforms.native.js +0 -49
- package/src/video/transforms.native.js +0 -12
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/navigation-link/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n\tuseInnerBlocksProps,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP } from '@wordpress/url';\nimport { useState, useEffect, useRef, useCallback } from '@wordpress/element';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport { link as linkIcon, addSubmenu } from '@wordpress/icons';\nimport { useMergeRefs, useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getColors } from '../navigation/edit/utils';\nimport {\n\tControls,\n\tLinkUI,\n\tuseEntityBinding,\n\tgetInvalidLinkHelpText,\n\tuseHandleLinkChange,\n\tuseIsInvalidLink,\n\tInvalidDraftDisplay,\n\tuseEnableLinkStatusValidation,\n\tuseIsDraggingWithin,\n\tselectLabelText,\n} from './shared';\n\nconst DEFAULT_BLOCK = { name: 'core/navigation-link' };\nconst NESTING_BLOCK_NAMES = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n];\n\nfunction getMissingText( type ) {\n\tlet missingText = '';\n\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\t\t/* translators: label for missing post in navigation link block */\n\t\t\tmissingText = __( 'Select post' );\n\t\t\tbreak;\n\t\tcase 'page':\n\t\t\t/* translators: label for missing page in navigation link block */\n\t\t\tmissingText = __( 'Select page' );\n\t\t\tbreak;\n\t\tcase 'category':\n\t\t\t/* translators: label for missing category in navigation link block */\n\t\t\tmissingText = __( 'Select category' );\n\t\t\tbreak;\n\t\tcase 'tag':\n\t\t\t/* translators: label for missing tag in navigation link block */\n\t\t\tmissingText = __( 'Select tag' );\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t/* translators: label for missing values in navigation link block */\n\t\t\tmissingText = __( 'Add link' );\n\t}\n\n\treturn missingText;\n}\n\nexport default function NavigationLinkEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tinsertBlocksAfter,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst { id, label, type, url, description, kind, metadata } = attributes;\n\tconst { maxNestingLevel } = context;\n\n\tconst {\n\t\treplaceBlock,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tselectBlock,\n\t} = useDispatch( blockEditorStore );\n\t// Have the link editing ui open on mount when lacking a url and selected.\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( isSelected && ! url );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst listItemRef = useRef( null );\n\tconst isDraggingWithin = useIsDraggingWithin( listItemRef );\n\tconst itemLabelPlaceholder = __( 'Add label\u2026' );\n\tconst ref = useRef();\n\tconst linkUIref = useRef();\n\t// A link is \"new\" only if it has an undefined label\n\t// After the link is created, even if no label is provided, it's set to an empty string.\n\tconst isNewLink = useRef( label === undefined );\n\t// Track whether we should focus the submenu appender when closing the link UI\n\tconst shouldSelectSubmenuAppenderOnClose = useRef( false );\n\n\tconst {\n\t\tisAtMaxNesting,\n\t\tisTopLevelLink,\n\t\tisParentOfSelectedBlock,\n\t\thasChildren,\n\t\tparentBlockClientId,\n\t\tisSubmenu,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst parentBlockName = getBlockName( rootClientId );\n\t\t\tconst isTopLevel = parentBlockName === 'core/navigation';\n\t\t\tconst rootNavigationClientId = isTopLevel\n\t\t\t\t? rootClientId\n\t\t\t\t: getBlockParentsByBlockName(\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t'core/navigation'\n\t\t\t\t )[ 0 ];\n\n\t\t\t// Get the immediate parent - if it's a submenu, use it; otherwise use the navigation block\n\t\t\tconst parentBlockId =\n\t\t\t\tparentBlockName === 'core/navigation-submenu'\n\t\t\t\t\t? rootClientId\n\t\t\t\t\t: rootNavigationClientId;\n\n\t\t\treturn {\n\t\t\t\tisAtMaxNesting:\n\t\t\t\t\tgetBlockParentsByBlockName( clientId, NESTING_BLOCK_NAMES )\n\t\t\t\t\t\t.length >= maxNestingLevel,\n\t\t\t\tisTopLevelLink: isTopLevel,\n\t\t\t\tisParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\ttrue\n\t\t\t\t),\n\t\t\t\thasChildren: !! getBlockCount( clientId ),\n\t\t\t\tparentBlockClientId: parentBlockId,\n\t\t\t\tisSubmenu: parentBlockName === 'core/navigation-submenu',\n\t\t\t};\n\t\t},\n\t\t[ clientId, maxNestingLevel ]\n\t);\n\n\tconst validateLinkStatus = useEnableLinkStatusValidation( clientId );\n\tconst { getBlocks } = useSelect( blockEditorStore );\n\n\t// URL binding logic\n\tconst { hasUrlBinding, isBoundEntityAvailable, entityRecord } =\n\t\tuseEntityBinding( {\n\t\t\tclientId,\n\t\t\tattributes,\n\t\t} );\n\n\tconst handleLinkChange = useHandleLinkChange( {\n\t\tclientId,\n\t\tattributes,\n\t\tsetAttributes,\n\t\tallowTextUpdate: true,\n\t} );\n\n\tconst [ isInvalid, isDraft ] = useIsInvalidLink(\n\t\tkind,\n\t\ttype,\n\t\tid,\n\t\tvalidateLinkStatus\n\t);\n\n\t/**\n\t * Transform to submenu block.\n\t */\n\tconst transformToSubmenu = useCallback( () => {\n\t\tlet innerBlocks = getBlocks( clientId );\n\t\tif ( innerBlocks.length === 0 ) {\n\t\t\tinnerBlocks = [ createBlock( 'core/navigation-link' ) ];\n\t\t\tselectBlock( innerBlocks[ 0 ].clientId );\n\t\t}\n\t\tconst newSubmenu = createBlock(\n\t\t\t'core/navigation-submenu',\n\t\t\tattributes,\n\t\t\tinnerBlocks\n\t\t);\n\t\treplaceBlock( clientId, newSubmenu );\n\t}, [ getBlocks, clientId, selectBlock, replaceBlock, attributes ] );\n\n\t// On mount, if this is a new link without a URL and it's selected,\n\t// select the parent block (submenu or navigation) instead to keep the appender visible.\n\t// This helps us return focus to the appender if the user closes the link ui without creating a link.\n\t// If we leave focus on this block, then when we close the link without creating a link, focus will\n\t// be lost during the new block selection process.\n\tuseEffect( () => {\n\t\tif ( isNewLink.current && isSelected ) {\n\t\t\tselectBlock( parentBlockClientId );\n\t\t}\n\t}, [] ); // eslint-disable-line react-hooks/exhaustive-deps\n\n\tuseEffect( () => {\n\t\t// If block has inner blocks, transform to Submenu.\n\t\tif ( hasChildren ) {\n\t\t\t// This side-effect should not create an undo level as those should\n\t\t\t// only be created via user interactions.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\ttransformToSubmenu();\n\t\t}\n\t}, [\n\t\thasChildren,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\ttransformToSubmenu,\n\t] );\n\n\t// Handle link UI when a new link is created\n\tuseEffect( () => {\n\t\t// We know if a link was just created from our link UI if\n\t\t// 1. isNewLink.current is true\n\t\t// 2. url has a value\n\t\t// 3. isLinkOpen is true\n\t\tif ( ! isNewLink.current || ! url || ! isLinkOpen ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Ensure this only runs once\n\t\tisNewLink.current = false;\n\n\t\t// We just created a link and the block is now selected.\n\t\t// If the label looks like a URL, focus and select the label text.\n\t\tif ( isURL( prependHTTP( label ) ) && /^.+\\.[a-z]+/.test( label ) ) {\n\t\t\t// Focus and select the label text.\n\t\t\tselectLabelText( ref );\n\t\t} else {\n\t\t\t// If the link was just created, we want to select the block so the inspector controls\n\t\t\t// are accurate.\n\t\t\tselectBlock( clientId, null );\n\n\t\t\t// Edge case: When the created link is the first child of a submenu, the focus will have\n\t\t\t// originated from the add submenu toolbar button. In this case, we need to return focus\n\t\t\t// to the submenu appender if the user closes the link ui using the keyboard.\n\t\t\t// Check if this is the first and only child of a newly created submenu.\n\t\t\tif ( isSubmenu ) {\n\t\t\t\tconst parentBlocks = getBlocks( parentBlockClientId );\n\t\t\t\t// If this is the only child, then this is a new submenu.\n\t\t\t\t// Set the flag to select the submenu appender when the link ui is closed.\n\t\t\t\tif (\n\t\t\t\t\tparentBlocks.length === 1 &&\n\t\t\t\t\tparentBlocks[ 0 ].clientId === clientId\n\t\t\t\t) {\n\t\t\t\t\tshouldSelectSubmenuAppenderOnClose.current = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ url, isLinkOpen, isNewLink, label ] );\n\n\t/**\n\t * Removes the current link if set.\n\t */\n\tfunction removeLink() {\n\t\t// Reset all attributes that comprise the link.\n\t\t// It is critical that all attributes are reset\n\t\t// to their default values otherwise this may\n\t\t// in advertently trigger side effects because\n\t\t// the values will have \"changed\".\n\t\tsetAttributes( {\n\t\t\turl: undefined,\n\t\t\tlabel: undefined,\n\t\t\tid: undefined,\n\t\t\tkind: undefined,\n\t\t\ttype: undefined,\n\t\t\topensInNewTab: false,\n\t\t} );\n\n\t\t// Close the link editing UI.\n\t\tsetIsLinkOpen( false );\n\t}\n\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, ! isTopLevelLink );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\t// Required to prevent the command center from opening,\n\t\t\t// as it shares the CMD+K shortcut.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/59845.\n\t\t\tevent.preventDefault();\n\t\t\t// If this link is a child of a parent submenu item, the parent submenu item event will also open, closing this popover\n\t\t\tevent.stopPropagation();\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}\n\n\tconst instanceId = useInstanceId( NavigationLinkEdit );\n\tconst hasMissingEntity = hasUrlBinding && ! isBoundEntityAvailable;\n\tconst missingEntityDescriptionId = hasMissingEntity\n\t\t? sprintf( 'navigation-link-edit-%d-desc', instanceId )\n\t\t: undefined;\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: clsx( 'wp-block-navigation-item', {\n\t\t\t'is-editing': isSelected || isParentOfSelectedBlock,\n\t\t\t'is-dragging-within': isDraggingWithin,\n\t\t\t'has-link': !! url,\n\t\t\t'has-child': hasChildren,\n\t\t\t'has-text-color': !! textColor || !! customTextColor,\n\t\t\t[ getColorClassName( 'color', textColor ) ]: !! textColor,\n\t\t\t'has-background': !! backgroundColor || customBackgroundColor,\n\t\t\t[ getColorClassName( 'background-color', backgroundColor ) ]:\n\t\t\t\t!! backgroundColor,\n\t\t} ),\n\t\t'aria-describedby': missingEntityDescriptionId,\n\t\t'aria-invalid': hasMissingEntity,\n\t\tstyle: {\n\t\t\tcolor: ! textColor && customTextColor,\n\t\t\tbackgroundColor: ! backgroundColor && customBackgroundColor,\n\t\t},\n\t\tonKeyDown,\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\t...blockProps,\n\t\t\tclassName: 'remove-outline', // Remove the outline from the inner blocks container.\n\t\t},\n\t\t{\n\t\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\t\tdirectInsert: true,\n\t\t\trenderAppender: false,\n\t\t}\n\t);\n\n\tconst needsValidLink =\n\t\t( ! url && ! ( hasUrlBinding && isBoundEntityAvailable ) ) ||\n\t\tisInvalid ||\n\t\tisDraft ||\n\t\t( hasUrlBinding && ! isBoundEntityAvailable );\n\n\tif ( needsValidLink ) {\n\t\tblockProps.onClick = () => {\n\t\t\tsetIsLinkOpen( true );\n\t\t};\n\t}\n\n\tconst classes = clsx( 'wp-block-navigation-item__content', {\n\t\t'wp-block-navigation-link__placeholder': needsValidLink,\n\t} );\n\n\tconst missingText = getMissingText( type );\n\tconst invalidLinkHelpText = getInvalidLinkHelpText();\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\tname=\"link\"\n\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! isAtMaxNesting && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tname=\"submenu\"\n\t\t\t\t\t\t\ticon={ addSubmenu }\n\t\t\t\t\t\t\ttitle={ __( 'Add submenu' ) }\n\t\t\t\t\t\t\tonClick={ transformToSubmenu }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls group=\"content\">\n\t\t\t\t<Controls\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ hasMissingEntity && (\n\t\t\t\t\t<VisuallyHidden id={ missingEntityDescriptionId }>\n\t\t\t\t\t\t{ invalidLinkHelpText }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t) }\n\t\t\t\t{ /* eslint-disable jsx-a11y/anchor-is-valid */ }\n\t\t\t\t<a className={ classes }>\n\t\t\t\t\t{ /* eslint-enable */ }\n\t\t\t\t\t{ ! url && ! metadata?.bindings?.url ? (\n\t\t\t\t\t\t<div className=\"wp-block-navigation-link__placeholder-text\">\n\t\t\t\t\t\t\t<span>{ missingText }</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ ! isInvalid && ! isDraft && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: labelValue,\n\t\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'core/navigation-link'\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t\t\t\t'Navigation link text'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ description && (\n\t\t\t\t\t\t\t\t\t\t<span className=\"wp-block-navigation-item__description\">\n\t\t\t\t\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ( isInvalid || isDraft ) && (\n\t\t\t\t\t\t\t\t<InvalidDraftDisplay\n\t\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\t\tisInvalid={ isInvalid }\n\t\t\t\t\t\t\t\t\tisDraft={ isDraft }\n\t\t\t\t\t\t\t\t\tclassName=\"wp-block-navigation-link__label\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isLinkOpen && (\n\t\t\t\t\t\t<LinkUI\n\t\t\t\t\t\t\tref={ linkUIref }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tlink={ attributes }\n\t\t\t\t\t\t\tentity={ {\n\t\t\t\t\t\t\t\tentityRecord,\n\t\t\t\t\t\t\t\thasBinding: hasUrlBinding,\n\t\t\t\t\t\t\t\tisEntityAvailable: isBoundEntityAvailable,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( false );\n\t\t\t\t\t\t\t\t// If there is no link and no binding, remove the auto-inserted block.\n\t\t\t\t\t\t\t\t// This avoids empty blocks which can provided a poor UX.\n\t\t\t\t\t\t\t\t// Don't remove if binding exists (even if entity is unavailable) so user can fix it.\n\t\t\t\t\t\t\t\tif ( ! url && ! hasUrlBinding ) {\n\t\t\t\t\t\t\t\t\tonReplace( [] );\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// Edge case: If this is the first child of a new submenu, focus the submenu's appender\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tshouldSelectSubmenuAppenderOnClose.current\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tshouldSelectSubmenuAppenderOnClose.current = false;\n\n\t\t\t\t\t\t\t\t\t// The appender is the next sibling in the DOM after the current block\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tlistItemRef.current?.nextElementSibling\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tconst appenderButton =\n\t\t\t\t\t\t\t\t\t\t\tlistItemRef.current.nextElementSibling.querySelector(\n\t\t\t\t\t\t\t\t\t\t\t\t'.block-editor-button-block-appender'\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\tif ( appenderButton ) {\n\t\t\t\t\t\t\t\t\t\t\tappenderButton.focus();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\t\tonRemove={ removeLink }\n\t\t\t\t\t\t\tonChange={ handleLinkChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</a>\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,oBAA4B;AAC5B,kBAAuC;AACvC,wBAA4C;AAC5C,sBAAiD;AACjD,kBAA4B;AAC5B,0BAQO;AACP,iBAAmC;AACnC,qBAAyD;AACzD,gBAA+B;AAC/B,mBAA6C;AAC7C,qBAA4C;AAK5C,mBAA0B;AAC1B,oBAWO;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n\tuseInnerBlocksProps,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP } from '@wordpress/url';\nimport { useState, useEffect, useRef, useCallback } from '@wordpress/element';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport { link as linkIcon, addSubmenu } from '@wordpress/icons';\nimport { useMergeRefs, useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getColors } from '../navigation/edit/utils';\nimport {\n\tControls,\n\tLinkUI,\n\tuseEntityBinding,\n\tgetInvalidLinkHelpText,\n\tuseHandleLinkChange,\n\tuseIsInvalidLink,\n\tInvalidDraftDisplay,\n\tuseEnableLinkStatusValidation,\n\tuseIsDraggingWithin,\n\tselectLabelText,\n} from './shared';\n\nconst DEFAULT_BLOCK = { name: 'core/navigation-link' };\nconst NESTING_BLOCK_NAMES = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n];\n\nfunction getMissingText( type ) {\n\tlet missingText = '';\n\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\t\t/* translators: label for missing post in navigation link block */\n\t\t\tmissingText = __( 'Select post' );\n\t\t\tbreak;\n\t\tcase 'page':\n\t\t\t/* translators: label for missing page in navigation link block */\n\t\t\tmissingText = __( 'Select page' );\n\t\t\tbreak;\n\t\tcase 'category':\n\t\t\t/* translators: label for missing category in navigation link block */\n\t\t\tmissingText = __( 'Select category' );\n\t\t\tbreak;\n\t\tcase 'tag':\n\t\t\t/* translators: label for missing tag in navigation link block */\n\t\t\tmissingText = __( 'Select tag' );\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t/* translators: label for missing values in navigation link block */\n\t\t\tmissingText = __( 'Add link' );\n\t}\n\n\treturn missingText;\n}\n\nexport default function NavigationLinkEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tinsertBlocksAfter,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst { id, label, type, url, description, kind, metadata } = attributes;\n\tconst { maxNestingLevel } = context;\n\n\tconst {\n\t\treplaceBlock,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tselectBlock,\n\t} = useDispatch( blockEditorStore );\n\t// Have the link editing ui open on mount when lacking a url and selected.\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( isSelected && ! url );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst listItemRef = useRef( null );\n\tconst isDraggingWithin = useIsDraggingWithin( listItemRef );\n\tconst itemLabelPlaceholder = __( 'Add label\u2026' );\n\tconst ref = useRef();\n\tconst linkUIref = useRef();\n\t// A link is \"new\" only if it has an undefined label\n\t// After the link is created, even if no label is provided, it's set to an empty string.\n\tconst isNewLink = useRef( label === undefined );\n\t// Track whether we should focus the submenu appender when closing the link UI\n\tconst shouldSelectSubmenuAppenderOnClose = useRef( false );\n\n\tconst {\n\t\tisAtMaxNesting,\n\t\tisTopLevelLink,\n\t\tisParentOfSelectedBlock,\n\t\thasChildren,\n\t\tparentBlockClientId,\n\t\tisSubmenu,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst parentBlockName = getBlockName( rootClientId );\n\t\t\tconst isTopLevel = parentBlockName === 'core/navigation';\n\t\t\tconst rootNavigationClientId = isTopLevel\n\t\t\t\t? rootClientId\n\t\t\t\t: getBlockParentsByBlockName(\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t'core/navigation'\n\t\t\t\t )[ 0 ];\n\n\t\t\t// Get the immediate parent - if it's a submenu, use it; otherwise use the navigation block\n\t\t\tconst parentBlockId =\n\t\t\t\tparentBlockName === 'core/navigation-submenu'\n\t\t\t\t\t? rootClientId\n\t\t\t\t\t: rootNavigationClientId;\n\n\t\t\treturn {\n\t\t\t\tisAtMaxNesting:\n\t\t\t\t\tgetBlockParentsByBlockName( clientId, NESTING_BLOCK_NAMES )\n\t\t\t\t\t\t.length >= maxNestingLevel,\n\t\t\t\tisTopLevelLink: isTopLevel,\n\t\t\t\tisParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\ttrue\n\t\t\t\t),\n\t\t\t\thasChildren: !! getBlockCount( clientId ),\n\t\t\t\tparentBlockClientId: parentBlockId,\n\t\t\t\tisSubmenu: parentBlockName === 'core/navigation-submenu',\n\t\t\t};\n\t\t},\n\t\t[ clientId, maxNestingLevel ]\n\t);\n\n\tconst validateLinkStatus = useEnableLinkStatusValidation( clientId );\n\tconst { getBlocks } = useSelect( blockEditorStore );\n\n\t// URL binding logic\n\tconst { hasUrlBinding, isBoundEntityAvailable, entityRecord } =\n\t\tuseEntityBinding( {\n\t\t\tclientId,\n\t\t\tattributes,\n\t\t} );\n\n\tconst handleLinkChange = useHandleLinkChange( {\n\t\tclientId,\n\t\tattributes,\n\t\tsetAttributes,\n\t\tallowTextUpdate: true,\n\t} );\n\n\tconst [ isInvalid, isDraft ] = useIsInvalidLink(\n\t\tkind,\n\t\ttype,\n\t\tid,\n\t\tvalidateLinkStatus\n\t);\n\n\t/**\n\t * Transform to submenu block.\n\t */\n\tconst transformToSubmenu = useCallback( () => {\n\t\tlet innerBlocks = getBlocks( clientId );\n\t\tif ( innerBlocks.length === 0 ) {\n\t\t\tinnerBlocks = [ createBlock( 'core/navigation-link' ) ];\n\t\t\tselectBlock( innerBlocks[ 0 ].clientId );\n\t\t}\n\t\tconst newSubmenu = createBlock(\n\t\t\t'core/navigation-submenu',\n\t\t\tattributes,\n\t\t\tinnerBlocks\n\t\t);\n\t\treplaceBlock( clientId, newSubmenu );\n\t}, [ getBlocks, clientId, selectBlock, replaceBlock, attributes ] );\n\n\t// On mount, if this is a new link without a URL and it's selected,\n\t// select the parent block (submenu or navigation) instead to keep the appender visible.\n\t// This helps us return focus to the appender if the user closes the link ui without creating a link.\n\t// If we leave focus on this block, then when we close the link without creating a link, focus will\n\t// be lost during the new block selection process.\n\tuseEffect( () => {\n\t\tif ( isNewLink.current && isSelected ) {\n\t\t\tselectBlock( parentBlockClientId );\n\t\t}\n\t}, [] ); // eslint-disable-line react-hooks/exhaustive-deps\n\n\tuseEffect( () => {\n\t\t// If block has inner blocks, transform to Submenu.\n\t\tif ( hasChildren ) {\n\t\t\t// This side-effect should not create an undo level as those should\n\t\t\t// only be created via user interactions.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\ttransformToSubmenu();\n\t\t}\n\t}, [\n\t\thasChildren,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\ttransformToSubmenu,\n\t] );\n\n\t// Handle link UI when a new link is created\n\tuseEffect( () => {\n\t\t// We know if a link was just created from our link UI if\n\t\t// 1. isNewLink.current is true\n\t\t// 2. url has a value\n\t\t// 3. isLinkOpen is true\n\t\tif ( ! isNewLink.current || ! url || ! isLinkOpen ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Ensure this only runs once\n\t\tisNewLink.current = false;\n\n\t\t// We just created a link and the block is now selected.\n\t\t// If the label looks like a URL, focus and select the label text.\n\t\tif ( isURL( prependHTTP( label ) ) && /^.+\\.[a-z]+/.test( label ) ) {\n\t\t\t// Focus and select the label text.\n\t\t\tselectLabelText( ref );\n\t\t} else {\n\t\t\t// If the link was just created, we want to select the block so the inspector controls\n\t\t\t// are accurate.\n\t\t\tselectBlock( clientId, null );\n\n\t\t\t// Edge case: When the created link is the first child of a submenu, the focus will have\n\t\t\t// originated from the add submenu toolbar button. In this case, we need to return focus\n\t\t\t// to the submenu appender if the user closes the link ui using the keyboard.\n\t\t\t// Check if this is the first and only child of a newly created submenu.\n\t\t\tif ( isSubmenu ) {\n\t\t\t\tconst parentBlocks = getBlocks( parentBlockClientId );\n\t\t\t\t// If this is the only child, then this is a new submenu.\n\t\t\t\t// Set the flag to select the submenu appender when the link ui is closed.\n\t\t\t\tif (\n\t\t\t\t\tparentBlocks.length === 1 &&\n\t\t\t\t\tparentBlocks[ 0 ].clientId === clientId\n\t\t\t\t) {\n\t\t\t\t\tshouldSelectSubmenuAppenderOnClose.current = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ url, isLinkOpen, isNewLink, label ] );\n\n\t/**\n\t * Removes the current link if set.\n\t */\n\tfunction removeLink() {\n\t\t// Reset all attributes that comprise the link.\n\t\t// It is critical that all attributes are reset\n\t\t// to their default values otherwise this may\n\t\t// in advertently trigger side effects because\n\t\t// the values will have \"changed\".\n\t\tsetAttributes( {\n\t\t\turl: undefined,\n\t\t\tlabel: undefined,\n\t\t\tid: undefined,\n\t\t\tkind: undefined,\n\t\t\ttype: undefined,\n\t\t\topensInNewTab: false,\n\t\t} );\n\n\t\t// Close the link editing UI.\n\t\tsetIsLinkOpen( false );\n\t}\n\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, ! isTopLevelLink );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\t// Required to prevent the command center from opening,\n\t\t\t// as it shares the CMD+K shortcut.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/59845.\n\t\t\tevent.preventDefault();\n\t\t\t// If this link is a child of a parent submenu item, the parent submenu item event will also open, closing this popover\n\t\t\tevent.stopPropagation();\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}\n\n\tconst instanceId = useInstanceId( NavigationLinkEdit );\n\tconst hasMissingEntity = hasUrlBinding && ! isBoundEntityAvailable;\n\tconst missingEntityDescriptionId = hasMissingEntity\n\t\t? sprintf( 'navigation-link-edit-%d-desc', instanceId )\n\t\t: undefined;\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: clsx( 'wp-block-navigation-item', {\n\t\t\t'is-editing': isSelected || isParentOfSelectedBlock,\n\t\t\t'is-dragging-within': isDraggingWithin,\n\t\t\t'has-link': !! url,\n\t\t\t'has-child': hasChildren,\n\t\t\t'has-text-color': !! textColor || !! customTextColor,\n\t\t\t[ getColorClassName( 'color', textColor ) ]: !! textColor,\n\t\t\t'has-background': !! backgroundColor || customBackgroundColor,\n\t\t\t[ getColorClassName( 'background-color', backgroundColor ) ]:\n\t\t\t\t!! backgroundColor,\n\t\t} ),\n\t\t'aria-describedby': missingEntityDescriptionId,\n\t\t'aria-invalid': hasMissingEntity,\n\t\tstyle: {\n\t\t\tcolor: ! textColor && customTextColor,\n\t\t\tbackgroundColor: ! backgroundColor && customBackgroundColor,\n\t\t},\n\t\tonKeyDown,\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\tclassName: 'remove-outline', // Remove the outline from the inner blocks container.\n\t\t},\n\t\t{\n\t\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\t\tdirectInsert: true,\n\t\t\trenderAppender: false,\n\t\t}\n\t);\n\n\tconst needsValidLink =\n\t\t( ! url && ! ( hasUrlBinding && isBoundEntityAvailable ) ) ||\n\t\tisInvalid ||\n\t\tisDraft ||\n\t\t( hasUrlBinding && ! isBoundEntityAvailable );\n\n\tif ( needsValidLink ) {\n\t\tblockProps.onClick = () => {\n\t\t\tsetIsLinkOpen( true );\n\t\t};\n\t}\n\n\tconst classes = clsx( 'wp-block-navigation-item__content', {\n\t\t'wp-block-navigation-link__placeholder': needsValidLink,\n\t} );\n\n\tconst missingText = getMissingText( type );\n\tconst invalidLinkHelpText = getInvalidLinkHelpText();\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\tname=\"link\"\n\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! isAtMaxNesting && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tname=\"submenu\"\n\t\t\t\t\t\t\ticon={ addSubmenu }\n\t\t\t\t\t\t\ttitle={ __( 'Add submenu' ) }\n\t\t\t\t\t\t\tonClick={ transformToSubmenu }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls group=\"content\">\n\t\t\t\t<Controls\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ hasMissingEntity && (\n\t\t\t\t\t<VisuallyHidden id={ missingEntityDescriptionId }>\n\t\t\t\t\t\t{ invalidLinkHelpText }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t) }\n\t\t\t\t{ /* eslint-disable jsx-a11y/anchor-is-valid */ }\n\t\t\t\t<a className={ classes }>\n\t\t\t\t\t{ /* eslint-enable */ }\n\t\t\t\t\t{ ! url && ! metadata?.bindings?.url ? (\n\t\t\t\t\t\t<div className=\"wp-block-navigation-link__placeholder-text\">\n\t\t\t\t\t\t\t<span>{ missingText }</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ ! isInvalid && ! isDraft && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: labelValue,\n\t\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'core/navigation-link'\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t\t\t\t'Navigation link text'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ description && (\n\t\t\t\t\t\t\t\t\t\t<span className=\"wp-block-navigation-item__description\">\n\t\t\t\t\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ( isInvalid || isDraft ) && (\n\t\t\t\t\t\t\t\t<InvalidDraftDisplay\n\t\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\t\tisInvalid={ isInvalid }\n\t\t\t\t\t\t\t\t\tisDraft={ isDraft }\n\t\t\t\t\t\t\t\t\tclassName=\"wp-block-navigation-link__label\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isLinkOpen && (\n\t\t\t\t\t\t<LinkUI\n\t\t\t\t\t\t\tref={ linkUIref }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tlink={ attributes }\n\t\t\t\t\t\t\tentity={ {\n\t\t\t\t\t\t\t\tentityRecord,\n\t\t\t\t\t\t\t\thasBinding: hasUrlBinding,\n\t\t\t\t\t\t\t\tisEntityAvailable: isBoundEntityAvailable,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( false );\n\t\t\t\t\t\t\t\t// If there is no link and no binding, remove the auto-inserted block.\n\t\t\t\t\t\t\t\t// This avoids empty blocks which can provided a poor UX.\n\t\t\t\t\t\t\t\t// Don't remove if binding exists (even if entity is unavailable) so user can fix it.\n\t\t\t\t\t\t\t\tif ( ! url && ! hasUrlBinding ) {\n\t\t\t\t\t\t\t\t\tonReplace( [] );\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// Edge case: If this is the first child of a new submenu, focus the submenu's appender\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tshouldSelectSubmenuAppenderOnClose.current\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tshouldSelectSubmenuAppenderOnClose.current = false;\n\n\t\t\t\t\t\t\t\t\t// The appender is the next sibling in the DOM after the current block\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tlistItemRef.current?.nextElementSibling\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tconst appenderButton =\n\t\t\t\t\t\t\t\t\t\t\tlistItemRef.current.nextElementSibling.querySelector(\n\t\t\t\t\t\t\t\t\t\t\t\t'.block-editor-button-block-appender'\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\tif ( appenderButton ) {\n\t\t\t\t\t\t\t\t\t\t\tappenderButton.focus();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\t\tonRemove={ removeLink }\n\t\t\t\t\t\t\tonChange={ handleLinkChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</a>\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AA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,gBACD;AAAA,gBAED,kBAAa;AAAA,kBACZ;AAAA,gBACD;AAAA,gBACA,aAAc;AAAA,gBACd,8BAA4B;AAAA;AAAA,YAC7B;AAAA,YACE,eACD,4CAAC,UAAK,WAAU,yCACb,uBACH;AAAA,aAEF;AAAA,WAEG,aAAa,YAChB;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA,WAAU;AAAA;AAAA,UACX;AAAA,WAEF;AAAA,QAEC,cACD;AAAA,UAAC;AAAA;AAAA,YACA,KAAM;AAAA,YACN;AAAA,YACA,MAAO;AAAA,YACP,QAAS;AAAA,cACR;AAAA,cACA,YAAY;AAAA,cACZ,mBAAmB;AAAA,YACpB;AAAA,YACA,SAAU,MAAM;AACf,4BAAe,KAAM;AAIrB,kBAAK,CAAE,OAAO,CAAE,eAAgB;AAC/B,0BAAW,CAAC,CAAE;AACd;AAAA,cACD;AAGA,kBACC,mCAAmC,SAClC;AACD,mDAAmC,UAAU;AAG7C,oBACC,YAAY,SAAS,oBACpB;AACD,wBAAM,iBACL,YAAY,QAAQ,mBAAmB;AAAA,oBACtC;AAAA,kBACD;AACD,sBAAK,gBAAiB;AACrB,mCAAe,MAAM;AAAA,kBACtB;AAAA,gBACD;AAAA,cACD;AAAA,YACD;AAAA,YACA,QAAS;AAAA,YACT,UAAW;AAAA,YACX,UAAW;AAAA;AAAA,QACZ;AAAA,SAEF;AAAA,MACA,4CAAC,SAAM,GAAG,kBAAmB;AAAA,OAC9B;AAAA,KACD;AAEF;",
|
|
6
6
|
"names": ["blockEditorStore", "clsx", "linkIcon"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/navigation-submenu/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInnerBlocks,\n\tInspectorControls,\n\tuseInnerBlocksProps,\n\tRichText,\n\tuseBlockProps,\n\tuseBlockEditingMode,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP } from '@wordpress/url';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { link as linkIcon, removeSubmenu } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\nimport { createBlock } from '@wordpress/blocks';\nimport { useMergeRefs, usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ItemSubmenuIcon } from './icons';\nimport {\n\tControls,\n\tLinkUI,\n\tuseEntityBinding,\n\tuseHandleLinkChange,\n\tuseIsInvalidLink,\n\tInvalidDraftDisplay,\n\tuseEnableLinkStatusValidation,\n\tuseIsDraggingWithin,\n\tselectLabelText,\n} from '../navigation-link/shared';\nimport {\n\tgetColors,\n\tgetNavigationChildBlockProps,\n} from '../navigation/edit/utils';\nimport { DEFAULT_BLOCK } from '../navigation/constants';\n\nconst ALLOWED_BLOCKS = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n\t'core/page-list',\n];\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\n */\n\n/**\n * Navigation Link Block Attributes\n *\n * @typedef {Object} WPNavigationLinkBlockAttributes\n *\n * @property {string} [label] Link text.\n * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.\n * @property {string} [type] The type such as post, page, tag, category and other custom types.\n * @property {string} [rel] The relationship of the linked URL.\n * @property {number} [id] A post or term id.\n * @property {boolean} [opensInNewTab] Sets link target to _blank when true.\n * @property {string} [url] Link href.\n */\n\nexport default function NavigationSubmenuEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst { label, url, description, kind, type, id } = attributes;\n\n\tconst { showSubmenuIcon, maxNestingLevel, submenuVisibility } = context;\n\tconst blockEditingMode = useBlockEditingMode();\n\n\t// Force click-only behavior in contentOnly mode to prevent hover dropdowns\n\tconst openSubmenusOnClick =\n\t\tblockEditingMode !== 'default' ? true : submenuVisibility === 'click';\n\n\t// URL binding logic\n\tconst { hasUrlBinding, isBoundEntityAvailable, entityRecord } =\n\t\tuseEntityBinding( {\n\t\t\tclientId,\n\t\t\tattributes,\n\t\t} );\n\n\tconst handleLinkChange = useHandleLinkChange( {\n\t\tclientId,\n\t\tattributes,\n\t\tsetAttributes,\n\t\tallowTextUpdate: true,\n\t} );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent, replaceBlock } =\n\t\tuseDispatch( blockEditorStore );\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( false );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst listItemRef = useRef( null );\n\tconst isDraggingWithin = useIsDraggingWithin( listItemRef );\n\tconst itemLabelPlaceholder = __( 'Add text\u2026' );\n\tconst ref = useRef();\n\n\tconst {\n\t\tparentCount,\n\t\tisParentOfSelectedBlock,\n\t\tisImmediateParentOfSelectedBlock,\n\t\thasChildren,\n\t\tselectedBlockHasChildren,\n\t\tonlyDescendantIsEmptyLink,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetBlock,\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tlet _onlyDescendantIsEmptyLink;\n\n\t\t\tconst selectedBlockId = getSelectedBlockClientId();\n\n\t\t\tconst selectedBlockChildren = getBlockOrder( selectedBlockId );\n\n\t\t\t// Check for a single descendant in the submenu. If that block\n\t\t\t// is a link block in a \"placeholder\" state with no label then\n\t\t\t// we can consider as an \"empty\" link.\n\t\t\tif ( selectedBlockChildren?.length === 1 ) {\n\t\t\t\tconst singleBlock = getBlock( selectedBlockChildren[ 0 ] );\n\n\t\t\t\t_onlyDescendantIsEmptyLink =\n\t\t\t\t\tsingleBlock?.name === 'core/navigation-link' &&\n\t\t\t\t\t! singleBlock?.attributes?.label;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tparentCount: getBlockParentsByBlockName(\n\t\t\t\t\tclientId,\n\t\t\t\t\t'core/navigation-submenu'\n\t\t\t\t).length,\n\t\t\t\tisParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\ttrue\n\t\t\t\t),\n\t\t\t\tisImmediateParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasChildren: !! getBlockCount( clientId ),\n\t\t\t\tselectedBlockHasChildren: !! selectedBlockChildren?.length,\n\t\t\t\tonlyDescendantIsEmptyLink: _onlyDescendantIsEmptyLink,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst validateLinkStatus = useEnableLinkStatusValidation( clientId );\n\n\tconst prevHasChildren = usePrevious( hasChildren );\n\n\t// Check if the submenu's parent link is invalid or draft\n\tconst [ isInvalid, isDraft ] = useIsInvalidLink(\n\t\tkind,\n\t\ttype,\n\t\tid,\n\t\tvalidateLinkStatus\n\t);\n\n\t// Show the LinkControl on mount if the URL is empty\n\t// ( When adding a new menu item)\n\t// This can't be done in the useState call because it conflicts\n\t// with the autofocus behavior of the BlockListBlock component.\n\tuseEffect( () => {\n\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}, [] );\n\n\t/**\n\t * The hook shouldn't be necessary but due to a focus loss happening\n\t * when selecting a suggestion in the link popover, we force close on block unselection.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsLinkOpen( false );\n\t\t}\n\t}, [ isSelected ] );\n\n\t// If the LinkControl popover is open and the URL has changed, close the LinkControl and focus the label text.\n\tuseEffect( () => {\n\t\tif ( isLinkOpen && url ) {\n\t\t\t// Does this look like a URL and have something TLD-ish?\n\t\t\tif (\n\t\t\t\tisURL( prependHTTP( label ) ) &&\n\t\t\t\t/^.+\\.[a-z]+/.test( label )\n\t\t\t) {\n\t\t\t\t// Focus and select the label text.\n\t\t\t\tselectLabelText( ref );\n\t\t\t}\n\t\t}\n\t}, [ url ] );\n\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, parentCount > 0 );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\t// Required to prevent the command center from opening,\n\t\t\t// as it shares the CMD+K shortcut.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/59845.\n\t\t\tevent.preventDefault();\n\t\t\t// If we don't stop propagation, this event bubbles up to the parent submenu item\n\t\t\tevent.stopPropagation();\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: clsx( 'wp-block-navigation-item', {\n\t\t\t'is-editing': isSelected || isParentOfSelectedBlock,\n\t\t\t'is-dragging-within': isDraggingWithin,\n\t\t\t'has-link': !! url,\n\t\t\t'has-child': hasChildren,\n\t\t\t'has-text-color': !! textColor || !! customTextColor,\n\t\t\t[ getColorClassName( 'color', textColor ) ]: !! textColor,\n\t\t\t'has-background': !! backgroundColor || customBackgroundColor,\n\t\t\t[ getColorClassName( 'background-color', backgroundColor ) ]:\n\t\t\t\t!! backgroundColor,\n\t\t\t'open-on-click': openSubmenusOnClick,\n\t\t\t'open-always': submenuVisibility === 'always',\n\t\t} ),\n\t\tstyle: {\n\t\t\tcolor: ! textColor && customTextColor,\n\t\t\tbackgroundColor: ! backgroundColor && customBackgroundColor,\n\t\t},\n\t\tonKeyDown,\n\t} );\n\n\t// Always use overlay colors for submenus.\n\tconst innerBlocksColors = getColors( context, true );\n\n\tconst allowedBlocks =\n\t\tparentCount >= maxNestingLevel\n\t\t\t? ALLOWED_BLOCKS.filter(\n\t\t\t\t\t( blockName ) => blockName !== 'core/navigation-submenu'\n\t\t\t )\n\t\t\t: ALLOWED_BLOCKS;\n\n\tconst navigationChildBlockProps =\n\t\tgetNavigationChildBlockProps( innerBlocksColors );\n\tconst innerBlocksProps = useInnerBlocksProps( navigationChildBlockProps, {\n\t\tallowedBlocks,\n\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\tdirectInsert: true,\n\n\t\t// Ensure block toolbar is not too far removed from item\n\t\t// being edited.\n\t\t// see: https://github.com/WordPress/gutenberg/pull/34615.\n\t\t__experimentalCaptureToolbars: true,\n\n\t\trenderAppender:\n\t\t\tisSelected ||\n\t\t\t( isImmediateParentOfSelectedBlock &&\n\t\t\t\t! selectedBlockHasChildren ) ||\n\t\t\t// Show the appender while dragging to allow inserting element between item and the appender.\n\t\t\thasChildren\n\t\t\t\t? InnerBlocks.ButtonBlockAppender\n\t\t\t\t: false,\n\t} );\n\n\tconst ParentElement = openSubmenusOnClick ? 'button' : 'a';\n\n\tfunction transformToLink() {\n\t\tconst newLinkBlock = createBlock( 'core/navigation-link', attributes );\n\t\treplaceBlock( clientId, newLinkBlock );\n\t}\n\n\tuseEffect( () => {\n\t\t// If block becomes empty, transform to Navigation Link.\n\t\tif ( ! hasChildren && prevHasChildren ) {\n\t\t\t// This side-effect should not create an undo level as those should\n\t\t\t// only be created via user interactions.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\ttransformToLink();\n\t\t}\n\t}, [ hasChildren, prevHasChildren ] );\n\n\tconst canConvertToLink =\n\t\t! selectedBlockHasChildren || onlyDescendantIsEmptyLink;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t{ ! openSubmenusOnClick && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"revert\"\n\t\t\t\t\t\ticon={ removeSubmenu }\n\t\t\t\t\t\ttitle={ __( 'Convert to Link' ) }\n\t\t\t\t\t\tonClick={ transformToLink }\n\t\t\t\t\t\tclassName=\"wp-block-navigation__submenu__revert\"\n\t\t\t\t\t\tdisabled={ ! canConvertToLink }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls group=\"content\">\n\t\t\t\t<Controls\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisLinkEditable={ ! openSubmenusOnClick }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<ParentElement className=\"wp-block-navigation-item__content\">\n\t\t\t\t\t{ ! isInvalid && ! isDraft && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { label: labelValue } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\t\t\taria-label={ __( 'Navigation link text' ) }\n\t\t\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\t\t\t\t\t\t\t\tsetIsLinkOpen( 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/>\n\t\t\t\t\t\t\t{ description && (\n\t\t\t\t\t\t\t\t<span className=\"wp-block-navigation-item__description\">\n\t\t\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t\t\t</span>\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{ ( isInvalid || isDraft ) && (\n\t\t\t\t\t\t<InvalidDraftDisplay\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\tisInvalid={ isInvalid }\n\t\t\t\t\t\t\tisDraft={ isDraft }\n\t\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! openSubmenusOnClick && isLinkOpen && (\n\t\t\t\t\t\t<LinkUI\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tlink={ attributes }\n\t\t\t\t\t\t\tentity={ {\n\t\t\t\t\t\t\t\tentityRecord,\n\t\t\t\t\t\t\t\thasBinding: hasUrlBinding,\n\t\t\t\t\t\t\t\tisEntityAvailable: isBoundEntityAvailable,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( false );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( { url: '' } );\n\t\t\t\t\t\t\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonChange={ handleLinkChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</ParentElement>\n\t\t\t\t{ ( showSubmenuIcon || openSubmenusOnClick ) && (\n\t\t\t\t\t<span className=\"wp-block-navigation__submenu-icon\">\n\t\t\t\t\t\t<ItemSubmenuIcon />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAAuC;AACvC,wBAA4C;AAC5C,sBAAiD;AACjD,kBAAmB;AACnB,0BAUO;AACP,iBAAmC;AACnC,qBAA4C;AAC5C,mBAAgD;AAChD,kBAAsB;AACtB,oBAA4B;AAC5B,qBAA0C;AAK1C,IAAAA,gBAAgC;AAChC,oBAUO;AACP,mBAGO;AACP,uBAA8B;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInnerBlocks,\n\tInspectorControls,\n\tuseInnerBlocksProps,\n\tRichText,\n\tuseBlockProps,\n\tuseBlockEditingMode,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP } from '@wordpress/url';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { link as linkIcon, removeSubmenu } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\nimport { createBlock } from '@wordpress/blocks';\nimport { useMergeRefs, usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ItemSubmenuIcon } from './icons';\nimport {\n\tControls,\n\tLinkUI,\n\tuseEntityBinding,\n\tuseHandleLinkChange,\n\tuseIsInvalidLink,\n\tInvalidDraftDisplay,\n\tuseEnableLinkStatusValidation,\n\tuseIsDraggingWithin,\n\tselectLabelText,\n} from '../navigation-link/shared';\nimport {\n\tgetColors,\n\tgetNavigationChildBlockProps,\n} from '../navigation/edit/utils';\nimport { DEFAULT_BLOCK } from '../navigation/constants';\n\nconst ALLOWED_BLOCKS = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n\t'core/page-list',\n\t'core/loginout',\n];\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\n */\n\n/**\n * Navigation Link Block Attributes\n *\n * @typedef {Object} WPNavigationLinkBlockAttributes\n *\n * @property {string} [label] Link text.\n * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.\n * @property {string} [type] The type such as post, page, tag, category and other custom types.\n * @property {string} [rel] The relationship of the linked URL.\n * @property {number} [id] A post or term id.\n * @property {boolean} [opensInNewTab] Sets link target to _blank when true.\n * @property {string} [url] Link href.\n */\n\nexport default function NavigationSubmenuEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst { label, url, description, kind, type, id } = attributes;\n\n\tconst { showSubmenuIcon, maxNestingLevel, submenuVisibility } = context;\n\tconst blockEditingMode = useBlockEditingMode();\n\n\t// Force click-only behavior in contentOnly mode to prevent hover dropdowns\n\tconst openSubmenusOnClick =\n\t\tblockEditingMode !== 'default' ? true : submenuVisibility === 'click';\n\n\t// URL binding logic\n\tconst { hasUrlBinding, isBoundEntityAvailable, entityRecord } =\n\t\tuseEntityBinding( {\n\t\t\tclientId,\n\t\t\tattributes,\n\t\t} );\n\n\tconst handleLinkChange = useHandleLinkChange( {\n\t\tclientId,\n\t\tattributes,\n\t\tsetAttributes,\n\t\tallowTextUpdate: true,\n\t} );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent, replaceBlock } =\n\t\tuseDispatch( blockEditorStore );\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( false );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst listItemRef = useRef( null );\n\tconst isDraggingWithin = useIsDraggingWithin( listItemRef );\n\tconst itemLabelPlaceholder = __( 'Add text\u2026' );\n\tconst ref = useRef();\n\n\tconst {\n\t\tparentCount,\n\t\tisParentOfSelectedBlock,\n\t\tisImmediateParentOfSelectedBlock,\n\t\thasChildren,\n\t\tselectedBlockHasChildren,\n\t\tonlyDescendantIsEmptyLink,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetBlock,\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tlet _onlyDescendantIsEmptyLink;\n\n\t\t\tconst selectedBlockId = getSelectedBlockClientId();\n\n\t\t\tconst selectedBlockChildren = getBlockOrder( selectedBlockId );\n\n\t\t\t// Check for a single descendant in the submenu. If that block\n\t\t\t// is a link block in a \"placeholder\" state with no label then\n\t\t\t// we can consider as an \"empty\" link.\n\t\t\tif ( selectedBlockChildren?.length === 1 ) {\n\t\t\t\tconst singleBlock = getBlock( selectedBlockChildren[ 0 ] );\n\n\t\t\t\t_onlyDescendantIsEmptyLink =\n\t\t\t\t\tsingleBlock?.name === 'core/navigation-link' &&\n\t\t\t\t\t! singleBlock?.attributes?.label;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tparentCount: getBlockParentsByBlockName(\n\t\t\t\t\tclientId,\n\t\t\t\t\t'core/navigation-submenu'\n\t\t\t\t).length,\n\t\t\t\tisParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\ttrue\n\t\t\t\t),\n\t\t\t\tisImmediateParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasChildren: !! getBlockCount( clientId ),\n\t\t\t\tselectedBlockHasChildren: !! selectedBlockChildren?.length,\n\t\t\t\tonlyDescendantIsEmptyLink: _onlyDescendantIsEmptyLink,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst validateLinkStatus = useEnableLinkStatusValidation( clientId );\n\n\tconst prevHasChildren = usePrevious( hasChildren );\n\n\t// Check if the submenu's parent link is invalid or draft\n\tconst [ isInvalid, isDraft ] = useIsInvalidLink(\n\t\tkind,\n\t\ttype,\n\t\tid,\n\t\tvalidateLinkStatus\n\t);\n\n\t// Show the LinkControl on mount if the URL is empty\n\t// ( When adding a new menu item)\n\t// This can't be done in the useState call because it conflicts\n\t// with the autofocus behavior of the BlockListBlock component.\n\tuseEffect( () => {\n\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}, [] );\n\n\t/**\n\t * The hook shouldn't be necessary but due to a focus loss happening\n\t * when selecting a suggestion in the link popover, we force close on block unselection.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsLinkOpen( false );\n\t\t}\n\t}, [ isSelected ] );\n\n\t// If the LinkControl popover is open and the URL has changed, close the LinkControl and focus the label text.\n\tuseEffect( () => {\n\t\tif ( isLinkOpen && url ) {\n\t\t\t// Does this look like a URL and have something TLD-ish?\n\t\t\tif (\n\t\t\t\tisURL( prependHTTP( label ) ) &&\n\t\t\t\t/^.+\\.[a-z]+/.test( label )\n\t\t\t) {\n\t\t\t\t// Focus and select the label text.\n\t\t\t\tselectLabelText( ref );\n\t\t\t}\n\t\t}\n\t}, [ url ] );\n\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, parentCount > 0 );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\t// Required to prevent the command center from opening,\n\t\t\t// as it shares the CMD+K shortcut.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/59845.\n\t\t\tevent.preventDefault();\n\t\t\t// If we don't stop propagation, this event bubbles up to the parent submenu item\n\t\t\tevent.stopPropagation();\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: clsx( 'wp-block-navigation-item', {\n\t\t\t'is-editing': isSelected || isParentOfSelectedBlock,\n\t\t\t'is-dragging-within': isDraggingWithin,\n\t\t\t'has-link': !! url,\n\t\t\t'has-child': hasChildren,\n\t\t\t'has-text-color': !! textColor || !! customTextColor,\n\t\t\t[ getColorClassName( 'color', textColor ) ]: !! textColor,\n\t\t\t'has-background': !! backgroundColor || customBackgroundColor,\n\t\t\t[ getColorClassName( 'background-color', backgroundColor ) ]:\n\t\t\t\t!! backgroundColor,\n\t\t\t'open-on-click': openSubmenusOnClick,\n\t\t\t'open-always': submenuVisibility === 'always',\n\t\t} ),\n\t\tstyle: {\n\t\t\tcolor: ! textColor && customTextColor,\n\t\t\tbackgroundColor: ! backgroundColor && customBackgroundColor,\n\t\t},\n\t\tonKeyDown,\n\t} );\n\n\t// Always use overlay colors for submenus.\n\tconst innerBlocksColors = getColors( context, true );\n\n\tconst allowedBlocks =\n\t\tparentCount >= maxNestingLevel\n\t\t\t? ALLOWED_BLOCKS.filter(\n\t\t\t\t\t( blockName ) => blockName !== 'core/navigation-submenu'\n\t\t\t )\n\t\t\t: ALLOWED_BLOCKS;\n\n\tconst navigationChildBlockProps =\n\t\tgetNavigationChildBlockProps( innerBlocksColors );\n\tconst innerBlocksProps = useInnerBlocksProps( navigationChildBlockProps, {\n\t\tallowedBlocks,\n\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\tdirectInsert: true,\n\n\t\t// Ensure block toolbar is not too far removed from item\n\t\t// being edited.\n\t\t// see: https://github.com/WordPress/gutenberg/pull/34615.\n\t\t__experimentalCaptureToolbars: true,\n\n\t\trenderAppender:\n\t\t\tisSelected ||\n\t\t\t( isImmediateParentOfSelectedBlock &&\n\t\t\t\t! selectedBlockHasChildren ) ||\n\t\t\t// Show the appender while dragging to allow inserting element between item and the appender.\n\t\t\thasChildren\n\t\t\t\t? InnerBlocks.ButtonBlockAppender\n\t\t\t\t: false,\n\t} );\n\n\tconst ParentElement = openSubmenusOnClick ? 'button' : 'a';\n\n\tfunction transformToLink() {\n\t\tconst newLinkBlock = createBlock( 'core/navigation-link', attributes );\n\t\treplaceBlock( clientId, newLinkBlock );\n\t}\n\n\tuseEffect( () => {\n\t\t// If block becomes empty, transform to Navigation Link.\n\t\tif ( ! hasChildren && prevHasChildren ) {\n\t\t\t// This side-effect should not create an undo level as those should\n\t\t\t// only be created via user interactions.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\ttransformToLink();\n\t\t}\n\t}, [ hasChildren, prevHasChildren ] );\n\n\tconst canConvertToLink =\n\t\t! selectedBlockHasChildren || onlyDescendantIsEmptyLink;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t{ ! openSubmenusOnClick && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"revert\"\n\t\t\t\t\t\ticon={ removeSubmenu }\n\t\t\t\t\t\ttitle={ __( 'Convert to Link' ) }\n\t\t\t\t\t\tonClick={ transformToLink }\n\t\t\t\t\t\tclassName=\"wp-block-navigation__submenu__revert\"\n\t\t\t\t\t\tdisabled={ ! canConvertToLink }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls group=\"content\">\n\t\t\t\t<Controls\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisLinkEditable={ ! openSubmenusOnClick }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<ParentElement className=\"wp-block-navigation-item__content\">\n\t\t\t\t\t{ ! isInvalid && ! isDraft && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { label: labelValue } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\t\t\taria-label={ __( 'Navigation link text' ) }\n\t\t\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\t\t\t\t\t\t\t\tsetIsLinkOpen( 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/>\n\t\t\t\t\t\t\t{ description && (\n\t\t\t\t\t\t\t\t<span className=\"wp-block-navigation-item__description\">\n\t\t\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t\t\t</span>\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{ ( isInvalid || isDraft ) && (\n\t\t\t\t\t\t<InvalidDraftDisplay\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\tisInvalid={ isInvalid }\n\t\t\t\t\t\t\tisDraft={ isDraft }\n\t\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! openSubmenusOnClick && isLinkOpen && (\n\t\t\t\t\t\t<LinkUI\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tlink={ attributes }\n\t\t\t\t\t\t\tentity={ {\n\t\t\t\t\t\t\t\tentityRecord,\n\t\t\t\t\t\t\t\thasBinding: hasUrlBinding,\n\t\t\t\t\t\t\t\tisEntityAvailable: isBoundEntityAvailable,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( false );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( { url: '' } );\n\t\t\t\t\t\t\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonChange={ handleLinkChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</ParentElement>\n\t\t\t\t{ ( showSubmenuIcon || openSubmenusOnClick ) && (\n\t\t\t\t\t<span className=\"wp-block-navigation__submenu-icon\">\n\t\t\t\t\t\t<ItemSubmenuIcon />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAAuC;AACvC,wBAA4C;AAC5C,sBAAiD;AACjD,kBAAmB;AACnB,0BAUO;AACP,iBAAmC;AACnC,qBAA4C;AAC5C,mBAAgD;AAChD,kBAAsB;AACtB,oBAA4B;AAC5B,qBAA0C;AAK1C,IAAAA,gBAAgC;AAChC,oBAUO;AACP,mBAGO;AACP,uBAA8B;AA4Q1B;AA1QJ,IAAM,iBAAiB;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAoBe,SAAR,sBAAwC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,EAAE,OAAO,KAAK,aAAa,MAAM,MAAM,GAAG,IAAI;AAEpD,QAAM,EAAE,iBAAiB,iBAAiB,kBAAkB,IAAI;AAChE,QAAM,uBAAmB,yCAAoB;AAG7C,QAAM,sBACL,qBAAqB,YAAY,OAAO,sBAAsB;AAG/D,QAAM,EAAE,eAAe,wBAAwB,aAAa,QAC3D,gCAAkB;AAAA,IACjB;AAAA,IACA;AAAA,EACD,CAAE;AAEH,QAAM,uBAAmB,mCAAqB;AAAA,IAC7C;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB;AAAA,EAClB,CAAE;AAEF,QAA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G,kBAAmB;AAAA,OAC9B;AAAA,KACD;AAEF;",
|
|
6
6
|
"names": ["import_icons", "blockEditorStore", "clsx", "linkIcon"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/paragraph/deprecated.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { RawHTML } from '@wordpress/element';\nimport {\n\tgetColorClassName,\n\tgetFontSizeClass,\n\tRichText,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\n\nimport { isRTL } from '@wordpress/i18n';\n\nconst supports = {\n\tclassName: false,\n};\n\nconst blockAttributes = {\n\talign: {\n\t\ttype: 'string',\n\t},\n\tcontent: {\n\t\ttype: 'string',\n\t\tsource: 'html',\n\t\tselector: 'p',\n\t\tdefault: '',\n\t},\n\tdropCap: {\n\t\ttype: 'boolean',\n\t\tdefault: false,\n\t},\n\tplaceholder: {\n\t\ttype: 'string',\n\t},\n\ttextColor: {\n\t\ttype: 'string',\n\t},\n\tbackgroundColor: {\n\t\ttype: 'string',\n\t},\n\tfontSize: {\n\t\ttype: 'string',\n\t},\n\tdirection: {\n\t\ttype: 'string',\n\t\tenum: [ 'ltr', 'rtl' ],\n\t},\n\tstyle: {\n\t\ttype: 'object',\n\t},\n};\n\nconst migrateCustomColorsAndFontSizes = ( attributes ) => {\n\tif (\n\t\t! attributes.customTextColor &&\n\t\t! attributes.customBackgroundColor &&\n\t\t! attributes.customFontSize\n\t) {\n\t\treturn attributes;\n\t}\n\tconst style = {};\n\tif ( attributes.customTextColor || attributes.customBackgroundColor ) {\n\t\tstyle.color = {};\n\t}\n\tif ( attributes.customTextColor ) {\n\t\tstyle.color.text = attributes.customTextColor;\n\t}\n\tif ( attributes.customBackgroundColor ) {\n\t\tstyle.color.background = attributes.customBackgroundColor;\n\t}\n\tif ( attributes.customFontSize ) {\n\t\tstyle.typography = { fontSize: attributes.customFontSize };\n\t}\n\n\tconst {\n\t\tcustomTextColor,\n\t\tcustomBackgroundColor,\n\t\tcustomFontSize,\n\t\t...restAttributes\n\t} = attributes;\n\n\treturn {\n\t\t...restAttributes,\n\t\tstyle,\n\t};\n};\n\nconst migrateTextAlign = ( attributes ) => {\n\tconst { align, ...restAttributes } = attributes;\n\tif ( ! align ) {\n\t\treturn attributes;\n\t}\n\treturn {\n\t\t...restAttributes,\n\t\tstyle: {\n\t\t\t...attributes.style,\n\t\t\ttypography: {\n\t\t\t\t...attributes.style?.typography,\n\t\t\t\ttextAlign: align,\n\t\t\t},\n\t\t},\n\t};\n};\n\nconst { style, ...restBlockAttributes } = blockAttributes;\n\nconst deprecated = [\n\t// Version with `align` attribute.\n\t{\n\t\tsupports: {\n\t\t\tclassName: false,\n\t\t\ttypography: {\n\t\t\t\tfontSize: true,\n\t\t\t},\n\t\t},\n\t\tattributes: blockAttributes,\n\t\tisEligible( attributes ) {\n\t\t\treturn (\n\t\t\t\t!! attributes.align ||\n\t\t\t\t!! attributes.className?.match(\n\t\t\t\t\t/\\bhas-text-align-(left|center|right)\\b/\n\t\t\t\t)\n\t\t\t);\n\t\t},\n\t\tsave( { attributes } ) {\n\t\t\tconst { align, content, dropCap, direction } = attributes;\n\t\t\tconst className = clsx( {\n\t\t\t\t'has-drop-cap':\n\t\t\t\t\talign === ( isRTL() ? 'left' : 'right' ) ||\n\t\t\t\t\talign === 'center'\n\t\t\t\t\t\t? false\n\t\t\t\t\t\t: dropCap,\n\t\t\t\t[ `has-text-align-${ align }` ]: align,\n\t\t\t} );\n\n\t\t\treturn (\n\t\t\t\t<p { ...useBlockProps.save( { className, dir: direction } ) }>\n\t\t\t\t\t<RichText.Content value={ content } />\n\t\t\t\t</p>\n\t\t\t);\n\t\t},\n\t\tmigrate: migrateTextAlign,\n\t},\n\t// Version without drop cap on aligned text.\n\t{\n\t\tsupports,\n\t\tattributes: {\n\t\t\t...restBlockAttributes,\n\t\t\tcustomTextColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\tcustomBackgroundColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\tcustomFontSize: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t},\n\t\tmigrate: migrateTextAlign,\n\t\tsave( { attributes } ) {\n\t\t\tconst { align, content, dropCap, direction } = attributes;\n\t\t\tconst className = clsx( {\n\t\t\t\t'has-drop-cap':\n\t\t\t\t\talign === ( isRTL() ? 'left' : 'right' ) ||\n\t\t\t\t\talign === 'center'\n\t\t\t\t\t\t? false\n\t\t\t\t\t\t: dropCap,\n\t\t\t\t[ `has-text-align-${ align }` ]: align,\n\t\t\t} );\n\n\t\t\treturn (\n\t\t\t\t<p { ...useBlockProps.save( { className, dir: direction } ) }>\n\t\t\t\t\t<RichText.Content value={ content } />\n\t\t\t\t</p>\n\t\t\t);\n\t\t},\n\t},\n\t{\n\t\tsupports,\n\t\tattributes: {\n\t\t\t...restBlockAttributes,\n\t\t\tcustomTextColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\tcustomBackgroundColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\tcustomFontSize: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t},\n\t\tmigrate( attributes ) {\n\t\t\treturn migrateCustomColorsAndFontSizes(\n\t\t\t\tmigrateTextAlign( attributes )\n\t\t\t);\n\t\t},\n\t\tsave( { attributes } ) {\n\t\t\tconst {\n\t\t\t\talign,\n\t\t\t\tcontent,\n\t\t\t\tdropCap,\n\t\t\t\tbackgroundColor,\n\t\t\t\ttextColor,\n\t\t\t\tcustomBackgroundColor,\n\t\t\t\tcustomTextColor,\n\t\t\t\tfontSize,\n\t\t\t\tcustomFontSize,\n\t\t\t\tdirection,\n\t\t\t} = attributes;\n\n\t\t\tconst textClass = getColorClassName( 'color', textColor );\n\t\t\tconst backgroundClass = getColorClassName(\n\t\t\t\t'background-color',\n\t\t\t\tbackgroundColor\n\t\t\t);\n\t\t\tconst fontSizeClass = getFontSizeClass( fontSize );\n\n\t\t\tconst className = clsx( {\n\t\t\t\t'has-text-color': textColor || customTextColor,\n\t\t\t\t'has-background': backgroundColor || customBackgroundColor,\n\t\t\t\t'has-drop-cap': dropCap,\n\t\t\t\t[ `has-text-align-${ align }` ]: align,\n\t\t\t\t[ fontSizeClass ]: fontSizeClass,\n\t\t\t\t[ textClass ]: textClass,\n\t\t\t\t[ backgroundClass ]: backgroundClass,\n\t\t\t} );\n\n\t\t\tconst styles = {\n\t\t\t\tbackgroundColor: backgroundClass\n\t\t\t\t\t? undefined\n\t\t\t\t\t: customBackgroundColor,\n\t\t\t\tcolor: textClass ? undefined : customTextColor,\n\t\t\t\tfontSize: fontSizeClass ? undefined : customFontSize,\n\t\t\t};\n\n\t\t\treturn (\n\t\t\t\t<RichText.Content\n\t\t\t\t\ttagName=\"p\"\n\t\t\t\t\tstyle={ styles }\n\t\t\t\t\tclassName={ className ? className : undefined }\n\t\t\t\t\tvalue={ content }\n\t\t\t\t\tdir={ direction }\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t},\n\t{\n\t\tsupports,\n\t\tattributes: {\n\t\t\t...restBlockAttributes,\n\t\t\tcustomTextColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\tcustomBackgroundColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\tcustomFontSize: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t},\n\t\tmigrate( attributes ) {\n\t\t\treturn migrateCustomColorsAndFontSizes(\n\t\t\t\tmigrateTextAlign( attributes )\n\t\t\t);\n\t\t},\n\t\tsave( { attributes } ) {\n\t\t\tconst {\n\t\t\t\talign,\n\t\t\t\tcontent,\n\t\t\t\tdropCap,\n\t\t\t\tbackgroundColor,\n\t\t\t\ttextColor,\n\t\t\t\tcustomBackgroundColor,\n\t\t\t\tcustomTextColor,\n\t\t\t\tfontSize,\n\t\t\t\tcustomFontSize,\n\t\t\t\tdirection,\n\t\t\t} = attributes;\n\n\t\t\tconst textClass = getColorClassName( 'color', textColor );\n\t\t\tconst backgroundClass = getColorClassName(\n\t\t\t\t'background-color',\n\t\t\t\tbackgroundColor\n\t\t\t);\n\t\t\tconst fontSizeClass = getFontSizeClass( fontSize );\n\n\t\t\tconst className = clsx( {\n\t\t\t\t'has-text-color': textColor || customTextColor,\n\t\t\t\t'has-background': backgroundColor || customBackgroundColor,\n\t\t\t\t'has-drop-cap': dropCap,\n\t\t\t\t[ fontSizeClass ]: fontSizeClass,\n\t\t\t\t[ textClass ]: textClass,\n\t\t\t\t[ backgroundClass ]: backgroundClass,\n\t\t\t} );\n\n\t\t\tconst styles = {\n\t\t\t\tbackgroundColor: backgroundClass\n\t\t\t\t\t? undefined\n\t\t\t\t\t: customBackgroundColor,\n\t\t\t\tcolor: textClass ? undefined : customTextColor,\n\t\t\t\tfontSize: fontSizeClass ? undefined : customFontSize,\n\t\t\t\ttextAlign: align,\n\t\t\t};\n\n\t\t\treturn (\n\t\t\t\t<RichText.Content\n\t\t\t\t\ttagName=\"p\"\n\t\t\t\t\tstyle={ styles }\n\t\t\t\t\tclassName={ className ? className : undefined }\n\t\t\t\t\tvalue={ content }\n\t\t\t\t\tdir={ direction }\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t},\n\t{\n\t\tsupports,\n\t\tattributes: {\n\t\t\t...restBlockAttributes,\n\t\t\tcustomTextColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\tcustomBackgroundColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\tcustomFontSize: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\twidth: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t\tmigrate( attributes ) {\n\t\t\treturn migrateCustomColorsAndFontSizes(\n\t\t\t\tmigrateTextAlign( attributes )\n\t\t\t);\n\t\t},\n\t\tsave( { attributes } ) {\n\t\t\tconst {\n\t\t\t\twidth,\n\t\t\t\talign,\n\t\t\t\tcontent,\n\t\t\t\tdropCap,\n\t\t\t\tbackgroundColor,\n\t\t\t\ttextColor,\n\t\t\t\tcustomBackgroundColor,\n\t\t\t\tcustomTextColor,\n\t\t\t\tfontSize,\n\t\t\t\tcustomFontSize,\n\t\t\t} = attributes;\n\n\t\t\tconst textClass = getColorClassName( 'color', textColor );\n\t\t\tconst backgroundClass = getColorClassName(\n\t\t\t\t'background-color',\n\t\t\t\tbackgroundColor\n\t\t\t);\n\t\t\tconst fontSizeClass = fontSize && `is-${ fontSize }-text`;\n\n\t\t\tconst className = clsx( {\n\t\t\t\t[ `align${ width }` ]: width,\n\t\t\t\t'has-background': backgroundColor || customBackgroundColor,\n\t\t\t\t'has-drop-cap': dropCap,\n\t\t\t\t[ fontSizeClass ]: fontSizeClass,\n\t\t\t\t[ textClass ]: textClass,\n\t\t\t\t[ backgroundClass ]: backgroundClass,\n\t\t\t} );\n\n\t\t\tconst styles = {\n\t\t\t\tbackgroundColor: backgroundClass\n\t\t\t\t\t? undefined\n\t\t\t\t\t: customBackgroundColor,\n\t\t\t\tcolor: textClass ? undefined : customTextColor,\n\t\t\t\tfontSize: fontSizeClass ? undefined : customFontSize,\n\t\t\t\ttextAlign: align,\n\t\t\t};\n\n\t\t\treturn (\n\t\t\t\t<RichText.Content\n\t\t\t\t\ttagName=\"p\"\n\t\t\t\t\tstyle={ styles }\n\t\t\t\t\tclassName={ className ? className : undefined }\n\t\t\t\t\tvalue={ content }\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t},\n\t{\n\t\tsupports,\n\t\tattributes: {\n\t\t\t...restBlockAttributes,\n\t\t\tfontSize: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t},\n\t\tsave( { attributes } ) {\n\t\t\tconst {\n\t\t\t\twidth,\n\t\t\t\talign,\n\t\t\t\tcontent,\n\t\t\t\tdropCap,\n\t\t\t\tbackgroundColor,\n\t\t\t\ttextColor,\n\t\t\t\tfontSize,\n\t\t\t} = attributes;\n\t\t\tconst className = clsx( {\n\t\t\t\t[ `align${ width }` ]: width,\n\t\t\t\t'has-background': backgroundColor,\n\t\t\t\t'has-drop-cap': dropCap,\n\t\t\t} );\n\t\t\tconst styles = {\n\t\t\t\tbackgroundColor,\n\t\t\t\tcolor: textColor,\n\t\t\t\tfontSize,\n\t\t\t\ttextAlign: align,\n\t\t\t};\n\n\t\t\treturn (\n\t\t\t\t<p\n\t\t\t\t\tstyle={ styles }\n\t\t\t\t\tclassName={ className ? className : undefined }\n\t\t\t\t>\n\t\t\t\t\t{ content }\n\t\t\t\t</p>\n\t\t\t);\n\t\t},\n\t\tmigrate( attributes ) {\n\t\t\treturn migrateCustomColorsAndFontSizes(\n\t\t\t\tmigrateTextAlign( {\n\t\t\t\t\t...attributes,\n\t\t\t\t\tcustomFontSize: Number.isFinite( attributes.fontSize )\n\t\t\t\t\t\t? attributes.fontSize\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tcustomTextColor:\n\t\t\t\t\t\tattributes.textColor &&\n\t\t\t\t\t\t'#' === attributes.textColor[ 0 ]\n\t\t\t\t\t\t\t? attributes.textColor\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tcustomBackgroundColor:\n\t\t\t\t\t\tattributes.backgroundColor &&\n\t\t\t\t\t\t'#' === attributes.backgroundColor[ 0 ]\n\t\t\t\t\t\t\t? attributes.backgroundColor\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t},\n\t{\n\t\tsupports,\n\t\tattributes: {\n\t\t\t...blockAttributes,\n\t\t\tcontent: {\n\t\t\t\ttype: 'string',\n\t\t\t\tsource: 'html',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t},\n\t\tsave( { attributes } ) {\n\t\t\treturn <RawHTML>{ attributes.content }</RawHTML>;\n\t\t},\n\t\tmigrate: ( attributes ) => attributes,\n\t},\n];\n\nexport default deprecated;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,qBAAwB;AACxB,0BAKO;AAEP,kBAAsB;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { RawHTML } from '@wordpress/element';\nimport {\n\tgetColorClassName,\n\tgetFontSizeClass,\n\tRichText,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\n\nimport { isRTL } from '@wordpress/i18n';\n\nconst supports = {\n\tclassName: false,\n};\n\nconst blockAttributes = {\n\talign: {\n\t\ttype: 'string',\n\t},\n\tcontent: {\n\t\ttype: 'string',\n\t\tsource: 'html',\n\t\tselector: 'p',\n\t\tdefault: '',\n\t},\n\tdropCap: {\n\t\ttype: 'boolean',\n\t\tdefault: false,\n\t},\n\tplaceholder: {\n\t\ttype: 'string',\n\t},\n\ttextColor: {\n\t\ttype: 'string',\n\t},\n\tbackgroundColor: {\n\t\ttype: 'string',\n\t},\n\tfontSize: {\n\t\ttype: 'string',\n\t},\n\tdirection: {\n\t\ttype: 'string',\n\t\tenum: [ 'ltr', 'rtl' ],\n\t},\n\tstyle: {\n\t\ttype: 'object',\n\t},\n};\n\nconst migrateCustomColorsAndFontSizes = ( attributes ) => {\n\tif (\n\t\t! attributes.customTextColor &&\n\t\t! attributes.customBackgroundColor &&\n\t\t! attributes.customFontSize\n\t) {\n\t\treturn attributes;\n\t}\n\tconst style = {};\n\tif ( attributes.customTextColor || attributes.customBackgroundColor ) {\n\t\tstyle.color = {};\n\t}\n\tif ( attributes.customTextColor ) {\n\t\tstyle.color.text = attributes.customTextColor;\n\t}\n\tif ( attributes.customBackgroundColor ) {\n\t\tstyle.color.background = attributes.customBackgroundColor;\n\t}\n\tif ( attributes.customFontSize ) {\n\t\tstyle.typography = { fontSize: attributes.customFontSize };\n\t}\n\n\tconst {\n\t\tcustomTextColor,\n\t\tcustomBackgroundColor,\n\t\tcustomFontSize,\n\t\t...restAttributes\n\t} = attributes;\n\n\treturn {\n\t\t...restAttributes,\n\t\tstyle,\n\t};\n};\n\nconst migrateTextAlign = ( attributes ) => {\n\tconst { align, ...restAttributes } = attributes;\n\tif ( ! align ) {\n\t\treturn attributes;\n\t}\n\treturn {\n\t\t...restAttributes,\n\t\tstyle: {\n\t\t\t...attributes.style,\n\t\t\ttypography: {\n\t\t\t\t...attributes.style?.typography,\n\t\t\t\ttextAlign: align,\n\t\t\t},\n\t\t},\n\t};\n};\n\nconst { style, ...restBlockAttributes } = blockAttributes;\n\nconst deprecated = [\n\t// Version with `align` attribute.\n\t{\n\t\tsupports: {\n\t\t\tclassName: false,\n\t\t\tcolor: true,\n\t\t\ttypography: {\n\t\t\t\tfontSize: true,\n\t\t\t},\n\t\t},\n\t\tattributes: blockAttributes,\n\t\tisEligible( attributes ) {\n\t\t\treturn (\n\t\t\t\t!! attributes.align ||\n\t\t\t\t!! attributes.className?.match(\n\t\t\t\t\t/\\bhas-text-align-(left|center|right)\\b/\n\t\t\t\t)\n\t\t\t);\n\t\t},\n\t\tsave( { attributes } ) {\n\t\t\tconst { align, content, dropCap, direction } = attributes;\n\t\t\tconst className = clsx( {\n\t\t\t\t'has-drop-cap':\n\t\t\t\t\talign === ( isRTL() ? 'left' : 'right' ) ||\n\t\t\t\t\talign === 'center'\n\t\t\t\t\t\t? false\n\t\t\t\t\t\t: dropCap,\n\t\t\t\t[ `has-text-align-${ align }` ]: align,\n\t\t\t} );\n\n\t\t\treturn (\n\t\t\t\t<p { ...useBlockProps.save( { className, dir: direction } ) }>\n\t\t\t\t\t<RichText.Content value={ content } />\n\t\t\t\t</p>\n\t\t\t);\n\t\t},\n\t\tmigrate: migrateTextAlign,\n\t},\n\t// Version without drop cap on aligned text.\n\t{\n\t\tsupports,\n\t\tattributes: {\n\t\t\t...restBlockAttributes,\n\t\t\tcustomTextColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\tcustomBackgroundColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\tcustomFontSize: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t},\n\t\tmigrate: migrateTextAlign,\n\t\tsave( { attributes } ) {\n\t\t\tconst { align, content, dropCap, direction } = attributes;\n\t\t\tconst className = clsx( {\n\t\t\t\t'has-drop-cap':\n\t\t\t\t\talign === ( isRTL() ? 'left' : 'right' ) ||\n\t\t\t\t\talign === 'center'\n\t\t\t\t\t\t? false\n\t\t\t\t\t\t: dropCap,\n\t\t\t\t[ `has-text-align-${ align }` ]: align,\n\t\t\t} );\n\n\t\t\treturn (\n\t\t\t\t<p { ...useBlockProps.save( { className, dir: direction } ) }>\n\t\t\t\t\t<RichText.Content value={ content } />\n\t\t\t\t</p>\n\t\t\t);\n\t\t},\n\t},\n\t{\n\t\tsupports,\n\t\tattributes: {\n\t\t\t...restBlockAttributes,\n\t\t\tcustomTextColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\tcustomBackgroundColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\tcustomFontSize: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t},\n\t\tmigrate( attributes ) {\n\t\t\treturn migrateCustomColorsAndFontSizes(\n\t\t\t\tmigrateTextAlign( attributes )\n\t\t\t);\n\t\t},\n\t\tsave( { attributes } ) {\n\t\t\tconst {\n\t\t\t\talign,\n\t\t\t\tcontent,\n\t\t\t\tdropCap,\n\t\t\t\tbackgroundColor,\n\t\t\t\ttextColor,\n\t\t\t\tcustomBackgroundColor,\n\t\t\t\tcustomTextColor,\n\t\t\t\tfontSize,\n\t\t\t\tcustomFontSize,\n\t\t\t\tdirection,\n\t\t\t} = attributes;\n\n\t\t\tconst textClass = getColorClassName( 'color', textColor );\n\t\t\tconst backgroundClass = getColorClassName(\n\t\t\t\t'background-color',\n\t\t\t\tbackgroundColor\n\t\t\t);\n\t\t\tconst fontSizeClass = getFontSizeClass( fontSize );\n\n\t\t\tconst className = clsx( {\n\t\t\t\t'has-text-color': textColor || customTextColor,\n\t\t\t\t'has-background': backgroundColor || customBackgroundColor,\n\t\t\t\t'has-drop-cap': dropCap,\n\t\t\t\t[ `has-text-align-${ align }` ]: align,\n\t\t\t\t[ fontSizeClass ]: fontSizeClass,\n\t\t\t\t[ textClass ]: textClass,\n\t\t\t\t[ backgroundClass ]: backgroundClass,\n\t\t\t} );\n\n\t\t\tconst styles = {\n\t\t\t\tbackgroundColor: backgroundClass\n\t\t\t\t\t? undefined\n\t\t\t\t\t: customBackgroundColor,\n\t\t\t\tcolor: textClass ? undefined : customTextColor,\n\t\t\t\tfontSize: fontSizeClass ? undefined : customFontSize,\n\t\t\t};\n\n\t\t\treturn (\n\t\t\t\t<RichText.Content\n\t\t\t\t\ttagName=\"p\"\n\t\t\t\t\tstyle={ styles }\n\t\t\t\t\tclassName={ className ? className : undefined }\n\t\t\t\t\tvalue={ content }\n\t\t\t\t\tdir={ direction }\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t},\n\t{\n\t\tsupports,\n\t\tattributes: {\n\t\t\t...restBlockAttributes,\n\t\t\tcustomTextColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\tcustomBackgroundColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\tcustomFontSize: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t},\n\t\tmigrate( attributes ) {\n\t\t\treturn migrateCustomColorsAndFontSizes(\n\t\t\t\tmigrateTextAlign( attributes )\n\t\t\t);\n\t\t},\n\t\tsave( { attributes } ) {\n\t\t\tconst {\n\t\t\t\talign,\n\t\t\t\tcontent,\n\t\t\t\tdropCap,\n\t\t\t\tbackgroundColor,\n\t\t\t\ttextColor,\n\t\t\t\tcustomBackgroundColor,\n\t\t\t\tcustomTextColor,\n\t\t\t\tfontSize,\n\t\t\t\tcustomFontSize,\n\t\t\t\tdirection,\n\t\t\t} = attributes;\n\n\t\t\tconst textClass = getColorClassName( 'color', textColor );\n\t\t\tconst backgroundClass = getColorClassName(\n\t\t\t\t'background-color',\n\t\t\t\tbackgroundColor\n\t\t\t);\n\t\t\tconst fontSizeClass = getFontSizeClass( fontSize );\n\n\t\t\tconst className = clsx( {\n\t\t\t\t'has-text-color': textColor || customTextColor,\n\t\t\t\t'has-background': backgroundColor || customBackgroundColor,\n\t\t\t\t'has-drop-cap': dropCap,\n\t\t\t\t[ fontSizeClass ]: fontSizeClass,\n\t\t\t\t[ textClass ]: textClass,\n\t\t\t\t[ backgroundClass ]: backgroundClass,\n\t\t\t} );\n\n\t\t\tconst styles = {\n\t\t\t\tbackgroundColor: backgroundClass\n\t\t\t\t\t? undefined\n\t\t\t\t\t: customBackgroundColor,\n\t\t\t\tcolor: textClass ? undefined : customTextColor,\n\t\t\t\tfontSize: fontSizeClass ? undefined : customFontSize,\n\t\t\t\ttextAlign: align,\n\t\t\t};\n\n\t\t\treturn (\n\t\t\t\t<RichText.Content\n\t\t\t\t\ttagName=\"p\"\n\t\t\t\t\tstyle={ styles }\n\t\t\t\t\tclassName={ className ? className : undefined }\n\t\t\t\t\tvalue={ content }\n\t\t\t\t\tdir={ direction }\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t},\n\t{\n\t\tsupports,\n\t\tattributes: {\n\t\t\t...restBlockAttributes,\n\t\t\tcustomTextColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\tcustomBackgroundColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\tcustomFontSize: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\twidth: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t\tmigrate( attributes ) {\n\t\t\treturn migrateCustomColorsAndFontSizes(\n\t\t\t\tmigrateTextAlign( attributes )\n\t\t\t);\n\t\t},\n\t\tsave( { attributes } ) {\n\t\t\tconst {\n\t\t\t\twidth,\n\t\t\t\talign,\n\t\t\t\tcontent,\n\t\t\t\tdropCap,\n\t\t\t\tbackgroundColor,\n\t\t\t\ttextColor,\n\t\t\t\tcustomBackgroundColor,\n\t\t\t\tcustomTextColor,\n\t\t\t\tfontSize,\n\t\t\t\tcustomFontSize,\n\t\t\t} = attributes;\n\n\t\t\tconst textClass = getColorClassName( 'color', textColor );\n\t\t\tconst backgroundClass = getColorClassName(\n\t\t\t\t'background-color',\n\t\t\t\tbackgroundColor\n\t\t\t);\n\t\t\tconst fontSizeClass = fontSize && `is-${ fontSize }-text`;\n\n\t\t\tconst className = clsx( {\n\t\t\t\t[ `align${ width }` ]: width,\n\t\t\t\t'has-background': backgroundColor || customBackgroundColor,\n\t\t\t\t'has-drop-cap': dropCap,\n\t\t\t\t[ fontSizeClass ]: fontSizeClass,\n\t\t\t\t[ textClass ]: textClass,\n\t\t\t\t[ backgroundClass ]: backgroundClass,\n\t\t\t} );\n\n\t\t\tconst styles = {\n\t\t\t\tbackgroundColor: backgroundClass\n\t\t\t\t\t? undefined\n\t\t\t\t\t: customBackgroundColor,\n\t\t\t\tcolor: textClass ? undefined : customTextColor,\n\t\t\t\tfontSize: fontSizeClass ? undefined : customFontSize,\n\t\t\t\ttextAlign: align,\n\t\t\t};\n\n\t\t\treturn (\n\t\t\t\t<RichText.Content\n\t\t\t\t\ttagName=\"p\"\n\t\t\t\t\tstyle={ styles }\n\t\t\t\t\tclassName={ className ? className : undefined }\n\t\t\t\t\tvalue={ content }\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t},\n\t{\n\t\tsupports,\n\t\tattributes: {\n\t\t\t...restBlockAttributes,\n\t\t\tfontSize: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t},\n\t\tsave( { attributes } ) {\n\t\t\tconst {\n\t\t\t\twidth,\n\t\t\t\talign,\n\t\t\t\tcontent,\n\t\t\t\tdropCap,\n\t\t\t\tbackgroundColor,\n\t\t\t\ttextColor,\n\t\t\t\tfontSize,\n\t\t\t} = attributes;\n\t\t\tconst className = clsx( {\n\t\t\t\t[ `align${ width }` ]: width,\n\t\t\t\t'has-background': backgroundColor,\n\t\t\t\t'has-drop-cap': dropCap,\n\t\t\t} );\n\t\t\tconst styles = {\n\t\t\t\tbackgroundColor,\n\t\t\t\tcolor: textColor,\n\t\t\t\tfontSize,\n\t\t\t\ttextAlign: align,\n\t\t\t};\n\n\t\t\treturn (\n\t\t\t\t<p\n\t\t\t\t\tstyle={ styles }\n\t\t\t\t\tclassName={ className ? className : undefined }\n\t\t\t\t>\n\t\t\t\t\t{ content }\n\t\t\t\t</p>\n\t\t\t);\n\t\t},\n\t\tmigrate( attributes ) {\n\t\t\treturn migrateCustomColorsAndFontSizes(\n\t\t\t\tmigrateTextAlign( {\n\t\t\t\t\t...attributes,\n\t\t\t\t\tcustomFontSize: Number.isFinite( attributes.fontSize )\n\t\t\t\t\t\t? attributes.fontSize\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tcustomTextColor:\n\t\t\t\t\t\tattributes.textColor &&\n\t\t\t\t\t\t'#' === attributes.textColor[ 0 ]\n\t\t\t\t\t\t\t? attributes.textColor\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tcustomBackgroundColor:\n\t\t\t\t\t\tattributes.backgroundColor &&\n\t\t\t\t\t\t'#' === attributes.backgroundColor[ 0 ]\n\t\t\t\t\t\t\t? attributes.backgroundColor\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t},\n\t{\n\t\tsupports,\n\t\tattributes: {\n\t\t\t...blockAttributes,\n\t\t\tcontent: {\n\t\t\t\ttype: 'string',\n\t\t\t\tsource: 'html',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t},\n\t\tsave( { attributes } ) {\n\t\t\treturn <RawHTML>{ attributes.content }</RawHTML>;\n\t\t},\n\t\tmigrate: ( attributes ) => attributes,\n\t},\n];\n\nexport default deprecated;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kB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A,QACN,QAAQ;AAAA,QACR,SAAS;AAAA,MACV;AAAA,IACD;AAAA,IACA,KAAM,EAAE,WAAW,GAAI;AACtB,aAAO,4CAAC,0BAAU,qBAAW,SAAS;AAAA,IACvC;AAAA,IACA,SAAS,CAAE,eAAgB;AAAA,EAC5B;AACD;AAEA,IAAO,qBAAQ;",
|
|
6
6
|
"names": ["style", "clsx"]
|
|
7
7
|
}
|
package/build/paragraph/edit.cjs
CHANGED
|
@@ -37,10 +37,12 @@ var import_clsx = __toESM(require("clsx"));
|
|
|
37
37
|
var import_i18n = require("@wordpress/i18n");
|
|
38
38
|
var import_components = require("@wordpress/components");
|
|
39
39
|
var import_block_editor = require("@wordpress/block-editor");
|
|
40
|
+
var import_data = require("@wordpress/data");
|
|
40
41
|
var import_blocks = require("@wordpress/blocks");
|
|
41
42
|
var import_icons = require("@wordpress/icons");
|
|
42
43
|
var import_use_enter = require("./use-enter.cjs");
|
|
43
44
|
var import_deprecated_attributes = __toESM(require("./deprecated-attributes.cjs"));
|
|
45
|
+
var import_lock_unlock = require("../lock-unlock.cjs");
|
|
44
46
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
47
|
function ParagraphRTLControl({ direction, setDirection }) {
|
|
46
48
|
return (0, import_i18n.isRTL)() && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -60,7 +62,14 @@ function hasDropCapDisabled(align) {
|
|
|
60
62
|
}
|
|
61
63
|
function DropCapControl({ clientId, attributes, setAttributes, name }) {
|
|
62
64
|
const [isDropCapFeatureEnabled] = (0, import_block_editor.useSettings)("typography.dropCap");
|
|
63
|
-
|
|
65
|
+
const hasSelectedStyleState = (0, import_data.useSelect)(
|
|
66
|
+
(select) => {
|
|
67
|
+
const { hasSelectedStyleState: hasSelectedBlockStyleState } = (0, import_lock_unlock.unlock)(select(import_block_editor.store));
|
|
68
|
+
return hasSelectedBlockStyleState(clientId);
|
|
69
|
+
},
|
|
70
|
+
[clientId]
|
|
71
|
+
);
|
|
72
|
+
if (!isDropCapFeatureEnabled || hasSelectedStyleState) {
|
|
64
73
|
return null;
|
|
65
74
|
}
|
|
66
75
|
const { style, dropCap } = attributes;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/paragraph/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, isRTL } from '@wordpress/i18n';\nimport {\n\tToolbarButton,\n\tToggleControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tuseSettings,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { formatLTR } from '@wordpress/icons';\n/**\n * Internal dependencies\n */\nimport { useOnEnter } from './use-enter';\nimport useDeprecatedAlign from './deprecated-attributes';\n\nfunction ParagraphRTLControl( { direction, setDirection } ) {\n\treturn (\n\t\tisRTL() && (\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ formatLTR }\n\t\t\t\ttitle={ _x( 'Left to right', 'editor button' ) }\n\t\t\t\tisActive={ direction === 'ltr' }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetDirection( direction === 'ltr' ? undefined : 'ltr' );\n\t\t\t\t} }\n\t\t\t/>\n\t\t)\n\t);\n}\n\nfunction hasDropCapDisabled( align ) {\n\treturn align === ( isRTL() ? 'left' : 'right' ) || align === 'center';\n}\n\nfunction DropCapControl( { clientId, attributes, setAttributes, name } ) {\n\t// Please do not add a useSelect call to the paragraph block unconditionally.\n\t// Every useSelect added to a (frequently used) block will degrade load\n\t// and type performance. By moving it within InspectorControls, the subscription is\n\t// now only added for the selected block(s).\n\tconst [ isDropCapFeatureEnabled ] = useSettings( 'typography.dropCap' );\n\n\tif ( ! isDropCapFeatureEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst { style, dropCap } = attributes;\n\tconst textAlign = style?.typography?.textAlign;\n\n\tlet helpText;\n\tif ( hasDropCapDisabled( textAlign ) ) {\n\t\thelpText = __( 'Not available for aligned text.' );\n\t} else if ( dropCap ) {\n\t\thelpText = __( 'Showing large initial letter.' );\n\t} else {\n\t\thelpText = __( 'Show a large initial letter.' );\n\t}\n\n\tconst isDropCapControlEnabledByDefault = getBlockSupport(\n\t\tname,\n\t\t'typography.defaultControls.dropCap',\n\t\tfalse\n\t);\n\n\treturn (\n\t\t<InspectorControls group=\"typography\">\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! dropCap }\n\t\t\t\tlabel={ __( 'Drop cap' ) }\n\t\t\t\tisShownByDefault={ isDropCapControlEnabledByDefault }\n\t\t\t\tonDeselect={ () => setAttributes( { dropCap: false } ) }\n\t\t\t\tresetAllFilter={ () => ( { dropCap: false } ) }\n\t\t\t\tpanelId={ clientId }\n\t\t\t>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Drop cap' ) }\n\t\t\t\t\tchecked={ !! dropCap }\n\t\t\t\t\tonChange={ () => setAttributes( { dropCap: ! dropCap } ) }\n\t\t\t\t\thelp={ helpText }\n\t\t\t\t\tdisabled={ hasDropCapDisabled( textAlign ) }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\t\t</InspectorControls>\n\t);\n}\n\nfunction ParagraphBlock( {\n\tattributes,\n\tmergeBlocks,\n\tonReplace,\n\tonRemove,\n\tsetAttributes,\n\tclientId,\n\tisSelected: isSingleSelected,\n\tname,\n} ) {\n\tconst { content, direction, dropCap, placeholder, style } = attributes;\n\tconst textAlign = style?.typography?.textAlign;\n\tuseDeprecatedAlign( attributes.align, style, setAttributes );\n\tconst blockProps = useBlockProps( {\n\t\tref: useOnEnter( { clientId, content } ),\n\t\tclassName: clsx( {\n\t\t\t'has-drop-cap': hasDropCapDisabled( textAlign ) ? false : dropCap,\n\t\t} ),\n\t\tstyle: { direction },\n\t} );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\treturn (\n\t\t<>\n\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t<ParagraphRTLControl\n\t\t\t\t\t\tdirection={ direction }\n\t\t\t\t\t\tsetDirection={ ( newDirection ) =>\n\t\t\t\t\t\t\tsetAttributes( { direction: newDirection } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ isSingleSelected && (\n\t\t\t\t<DropCapControl\n\t\t\t\t\tname={ name }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<RichText\n\t\t\t\tidentifier=\"content\"\n\t\t\t\ttagName=\"p\"\n\t\t\t\t{ ...blockProps }\n\t\t\t\tvalue={ content }\n\t\t\t\tonChange={ ( newContent ) =>\n\t\t\t\t\tsetAttributes( { content: newContent } )\n\t\t\t\t}\n\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\tonReplace={ onReplace }\n\t\t\t\tonRemove={ onRemove }\n\t\t\t\taria-label={\n\t\t\t\t\tRichText.isEmpty( content )\n\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t'Empty block; start writing or type forward slash to choose a block'\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Block: Paragraph' )\n\t\t\t\t}\n\t\t\t\tdata-empty={ RichText.isEmpty( content ) }\n\t\t\t\tplaceholder={ placeholder || __( 'Type / to choose a block' ) }\n\t\t\t\tdata-custom-placeholder={ placeholder ? true : undefined }\n\t\t\t\t__unstableEmbedURLOnPaste\n\t\t\t\t__unstableAllowPrefixTransformations\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default ParagraphBlock;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAA8B;AAC9B,wBAIO;AACP,
|
|
6
|
-
"names": ["ToolsPanelItem", "useDeprecatedAlign", "clsx"]
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, isRTL } from '@wordpress/i18n';\nimport {\n\tToolbarButton,\n\tToggleControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tuseSettings,\n\tuseBlockEditingMode,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { formatLTR } from '@wordpress/icons';\n/**\n * Internal dependencies\n */\nimport { useOnEnter } from './use-enter';\nimport useDeprecatedAlign from './deprecated-attributes';\nimport { unlock } from '../lock-unlock';\n\nfunction ParagraphRTLControl( { direction, setDirection } ) {\n\treturn (\n\t\tisRTL() && (\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ formatLTR }\n\t\t\t\ttitle={ _x( 'Left to right', 'editor button' ) }\n\t\t\t\tisActive={ direction === 'ltr' }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetDirection( direction === 'ltr' ? undefined : 'ltr' );\n\t\t\t\t} }\n\t\t\t/>\n\t\t)\n\t);\n}\n\nfunction hasDropCapDisabled( align ) {\n\treturn align === ( isRTL() ? 'left' : 'right' ) || align === 'center';\n}\n\nfunction DropCapControl( { clientId, attributes, setAttributes, name } ) {\n\t// Please do not add a useSelect call to the paragraph block unconditionally.\n\t// Every useSelect added to a (frequently used) block will degrade load\n\t// and type performance. By moving it within InspectorControls, the subscription is\n\t// now only added for the selected block(s).\n\tconst [ isDropCapFeatureEnabled ] = useSettings( 'typography.dropCap' );\n\tconst hasSelectedStyleState = useSelect(\n\t\t( select ) => {\n\t\t\tconst { hasSelectedStyleState: hasSelectedBlockStyleState } =\n\t\t\t\tunlock( select( blockEditorStore ) );\n\n\t\t\treturn hasSelectedBlockStyleState( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tif ( ! isDropCapFeatureEnabled || hasSelectedStyleState ) {\n\t\treturn null;\n\t}\n\n\tconst { style, dropCap } = attributes;\n\tconst textAlign = style?.typography?.textAlign;\n\n\tlet helpText;\n\tif ( hasDropCapDisabled( textAlign ) ) {\n\t\thelpText = __( 'Not available for aligned text.' );\n\t} else if ( dropCap ) {\n\t\thelpText = __( 'Showing large initial letter.' );\n\t} else {\n\t\thelpText = __( 'Show a large initial letter.' );\n\t}\n\n\tconst isDropCapControlEnabledByDefault = getBlockSupport(\n\t\tname,\n\t\t'typography.defaultControls.dropCap',\n\t\tfalse\n\t);\n\n\treturn (\n\t\t<InspectorControls group=\"typography\">\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! dropCap }\n\t\t\t\tlabel={ __( 'Drop cap' ) }\n\t\t\t\tisShownByDefault={ isDropCapControlEnabledByDefault }\n\t\t\t\tonDeselect={ () => setAttributes( { dropCap: false } ) }\n\t\t\t\tresetAllFilter={ () => ( { dropCap: false } ) }\n\t\t\t\tpanelId={ clientId }\n\t\t\t>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Drop cap' ) }\n\t\t\t\t\tchecked={ !! dropCap }\n\t\t\t\t\tonChange={ () => setAttributes( { dropCap: ! dropCap } ) }\n\t\t\t\t\thelp={ helpText }\n\t\t\t\t\tdisabled={ hasDropCapDisabled( textAlign ) }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\t\t</InspectorControls>\n\t);\n}\n\nfunction ParagraphBlock( {\n\tattributes,\n\tmergeBlocks,\n\tonReplace,\n\tonRemove,\n\tsetAttributes,\n\tclientId,\n\tisSelected: isSingleSelected,\n\tname,\n} ) {\n\tconst { content, direction, dropCap, placeholder, style } = attributes;\n\tconst textAlign = style?.typography?.textAlign;\n\tuseDeprecatedAlign( attributes.align, style, setAttributes );\n\tconst blockProps = useBlockProps( {\n\t\tref: useOnEnter( { clientId, content } ),\n\t\tclassName: clsx( {\n\t\t\t'has-drop-cap': hasDropCapDisabled( textAlign ) ? false : dropCap,\n\t\t} ),\n\t\tstyle: { direction },\n\t} );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\treturn (\n\t\t<>\n\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t<ParagraphRTLControl\n\t\t\t\t\t\tdirection={ direction }\n\t\t\t\t\t\tsetDirection={ ( newDirection ) =>\n\t\t\t\t\t\t\tsetAttributes( { direction: newDirection } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ isSingleSelected && (\n\t\t\t\t<DropCapControl\n\t\t\t\t\tname={ name }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<RichText\n\t\t\t\tidentifier=\"content\"\n\t\t\t\ttagName=\"p\"\n\t\t\t\t{ ...blockProps }\n\t\t\t\tvalue={ content }\n\t\t\t\tonChange={ ( newContent ) =>\n\t\t\t\t\tsetAttributes( { content: newContent } )\n\t\t\t\t}\n\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\tonReplace={ onReplace }\n\t\t\t\tonRemove={ onRemove }\n\t\t\t\taria-label={\n\t\t\t\t\tRichText.isEmpty( content )\n\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t'Empty block; start writing or type forward slash to choose a block'\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Block: Paragraph' )\n\t\t\t\t}\n\t\t\t\tdata-empty={ RichText.isEmpty( content ) }\n\t\t\t\tplaceholder={ placeholder || __( 'Type / to choose a block' ) }\n\t\t\t\tdata-custom-placeholder={ placeholder ? true : undefined }\n\t\t\t\t__unstableEmbedURLOnPaste\n\t\t\t\t__unstableAllowPrefixTransformations\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default ParagraphBlock;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAA8B;AAC9B,wBAIO;AACP,0BAQO;AACP,kBAA0B;AAC1B,oBAAgC;AAChC,mBAA0B;AAI1B,uBAA2B;AAC3B,mCAA+B;AAC/B,yBAAuB;AAKpB;AAHH,SAAS,oBAAqB,EAAE,WAAW,aAAa,GAAI;AAC3D,aACC,mBAAM,KACL;AAAA,IAAC;AAAA;AAAA,MACA,MAAO;AAAA,MACP,WAAQ,gBAAI,iBAAiB,eAAgB;AAAA,MAC7C,UAAW,cAAc;AAAA,MACzB,SAAU,MAAM;AACf,qBAAc,cAAc,QAAQ,SAAY,KAAM;AAAA,MACvD;AAAA;AAAA,EACD;AAGH;AAEA,SAAS,mBAAoB,OAAQ;AACpC,SAAO,eAAY,mBAAM,IAAI,SAAS,YAAa,UAAU;AAC9D;AAEA,SAAS,eAAgB,EAAE,UAAU,YAAY,eAAe,KAAK,GAAI;AAKxE,QAAM,CAAE,uBAAwB,QAAI,iCAAa,oBAAqB;AACtE,QAAM,4BAAwB;AAAA,IAC7B,CAAE,WAAY;AACb,YAAM,EAAE,uBAAuB,2BAA2B,QACzD,2BAAQ,OAAQ,oBAAAA,KAAiB,CAAE;AAEpC,aAAO,2BAA4B,QAAS;AAAA,IAC7C;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,MAAK,CAAE,2BAA2B,uBAAwB;AACzD,WAAO;AAAA,EACR;AAEA,QAAM,EAAE,OAAO,QAAQ,IAAI;AAC3B,QAAM,YAAY,OAAO,YAAY;AAErC,MAAI;AACJ,MAAK,mBAAoB,SAAU,GAAI;AACtC,mBAAW,gBAAI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EACG;AAAA,yBAAqB,aACtB,4CAAC,qCAAc,OAAM,SACpB;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA,cAAe,CAAE,iBAChB,cAAe,EAAE,WAAW,aAAa,CAAE;AAAA;AAAA,IAE7C,GACD;AAAA,IAEC,oBACD;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,IAED;AAAA,MAAC;AAAA;AAAA,QACA,YAAW;AAAA,QACX,SAAQ;AAAA,QACN,GAAG;AAAA,QACL,OAAQ;AAAA,QACR,UAAW,CAAE,eACZ,cAAe,EAAE,SAAS,WAAW,CAAE;AAAA,QAExC,SAAU;AAAA,QACV;AAAA,QACA;AAAA,QACA,cACC,6BAAS,QAAS,OAAQ,QACvB;AAAA,UACA;AAAA,QACA,QACA,gBAAI,kBAAmB;AAAA,QAE3B,cAAa,6BAAS,QAAS,OAAQ;AAAA,QACvC,aAAc,mBAAe,gBAAI,0BAA2B;AAAA,QAC5D,2BAA0B,cAAc,OAAO;AAAA,QAC/C,2BAAyB;AAAA,QACzB,sCAAoC;AAAA;AAAA,IACrC;AAAA,KACD;AAEF;AAEA,IAAO,eAAQ;",
|
|
6
|
+
"names": ["blockEditorStore", "ToolsPanelItem", "useDeprecatedAlign", "clsx"]
|
|
7
7
|
}
|
|
@@ -37,6 +37,10 @@
|
|
|
37
37
|
"type": "boolean",
|
|
38
38
|
"default": true
|
|
39
39
|
},
|
|
40
|
+
"showTrackLength": {
|
|
41
|
+
"type": "boolean",
|
|
42
|
+
"default": true
|
|
43
|
+
},
|
|
40
44
|
"caption": {
|
|
41
45
|
"type": "string"
|
|
42
46
|
}
|
|
@@ -74,6 +78,14 @@
|
|
|
74
78
|
"padding": true
|
|
75
79
|
}
|
|
76
80
|
},
|
|
81
|
+
"styles": [
|
|
82
|
+
{ "name": "bars", "label": "Bars", "isDefault": true },
|
|
83
|
+
{ "name": "mirror", "label": "Mirror" },
|
|
84
|
+
{ "name": "line", "label": "Line" },
|
|
85
|
+
{ "name": "blocks", "label": "Blocks" },
|
|
86
|
+
{ "name": "dots", "label": "Dots" },
|
|
87
|
+
{ "name": "seekbar", "label": "Seekbar" }
|
|
88
|
+
],
|
|
77
89
|
"editorStyle": "wp-block-playlist-editor",
|
|
78
90
|
"style": "wp-block-playlist"
|
|
79
91
|
}
|
package/build/playlist/edit.cjs
CHANGED
|
@@ -62,8 +62,10 @@ var PlaylistEdit = ({
|
|
|
62
62
|
showNumbers,
|
|
63
63
|
showImages,
|
|
64
64
|
showArtists,
|
|
65
|
+
showTrackLength,
|
|
65
66
|
currentTrack
|
|
66
67
|
} = attributes;
|
|
68
|
+
const waveformStyle = attributes.className?.match(/is-style-([\w-]+)/)?.[1] || "bars";
|
|
67
69
|
const blockProps = (0, import_block_editor.useBlockProps)();
|
|
68
70
|
const { replaceInnerBlocks, __unstableMarkNextChangeAsNotPersistent } = (0, import_data.useDispatch)(import_block_editor.store);
|
|
69
71
|
const { createErrorNotice } = (0, import_data.useDispatch)(import_notices.store);
|
|
@@ -249,6 +251,7 @@ var PlaylistEdit = ({
|
|
|
249
251
|
showTracklist: true,
|
|
250
252
|
showArtists: true,
|
|
251
253
|
showNumbers: true,
|
|
254
|
+
showTrackLength: true,
|
|
252
255
|
showImages: true,
|
|
253
256
|
order: "asc"
|
|
254
257
|
});
|
|
@@ -312,6 +315,27 @@ var PlaylistEdit = ({
|
|
|
312
315
|
}
|
|
313
316
|
)
|
|
314
317
|
}
|
|
318
|
+
),
|
|
319
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
320
|
+
import_components.__experimentalToolsPanelItem,
|
|
321
|
+
{
|
|
322
|
+
label: (0, import_i18n.__)("Show track length in Tracklist"),
|
|
323
|
+
isShownByDefault: true,
|
|
324
|
+
hasValue: () => showTrackLength !== true,
|
|
325
|
+
onDeselect: () => setAttributes({ showTrackLength: true }),
|
|
326
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
327
|
+
import_components.ToggleControl,
|
|
328
|
+
{
|
|
329
|
+
label: (0, import_i18n.__)(
|
|
330
|
+
"Show track length in Tracklist"
|
|
331
|
+
),
|
|
332
|
+
onChange: toggleAttribute(
|
|
333
|
+
"showTrackLength"
|
|
334
|
+
),
|
|
335
|
+
checked: showTrackLength
|
|
336
|
+
}
|
|
337
|
+
)
|
|
338
|
+
}
|
|
315
339
|
)
|
|
316
340
|
] }),
|
|
317
341
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -364,6 +388,7 @@ var PlaylistEdit = ({
|
|
|
364
388
|
title: currentTrackData?.title,
|
|
365
389
|
artist: currentTrackData?.artist,
|
|
366
390
|
image: currentTrackData?.image,
|
|
391
|
+
waveformStyle,
|
|
367
392
|
onEnded: onTrackEnded
|
|
368
393
|
}
|
|
369
394
|
) }),
|
|
@@ -371,7 +396,8 @@ var PlaylistEdit = ({
|
|
|
371
396
|
"ol",
|
|
372
397
|
{
|
|
373
398
|
className: (0, import_clsx.default)("wp-block-playlist__tracklist", {
|
|
374
|
-
"wp-block-playlist__tracklist-show-numbers": showNumbers
|
|
399
|
+
"wp-block-playlist__tracklist-show-numbers": showNumbers,
|
|
400
|
+
"wp-block-playlist__tracklist-length-is-hidden": !showTrackLength
|
|
375
401
|
}),
|
|
376
402
|
children: innerBlocksProps.children
|
|
377
403
|
}
|