@wordpress/block-library 7.18.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/build/audio/edit.native.js +1 -3
- package/build/audio/edit.native.js.map +1 -1
- package/build/audio/index.js +2 -1
- package/build/audio/index.js.map +1 -1
- package/build/avatar/edit.js +1 -0
- package/build/avatar/edit.js.map +1 -1
- package/build/avatar/user-control.js +1 -0
- package/build/avatar/user-control.js.map +1 -1
- package/build/block/edit.js +14 -2
- package/build/block/edit.js.map +1 -1
- package/build/block/edit.native.js +14 -6
- package/build/block/edit.native.js.map +1 -1
- package/build/block/index.js +1 -2
- package/build/block/index.js.map +1 -1
- package/build/button/deprecated.js +16 -2
- package/build/button/deprecated.js.map +1 -1
- package/build/button/edit.js +13 -7
- package/build/button/edit.js.map +1 -1
- package/build/button/edit.native.js.map +1 -1
- package/build/button/index.js +4 -1
- package/build/button/index.js.map +1 -1
- package/build/button/save.js +2 -0
- package/build/button/save.js.map +1 -1
- package/build/code/transforms.js +1 -1
- package/build/code/transforms.js.map +1 -1
- package/build/columns/edit.js +1 -0
- package/build/columns/edit.js.map +1 -1
- package/build/columns/edit.native.js +13 -30
- package/build/columns/edit.native.js.map +1 -1
- package/build/columns/transforms.js +5 -0
- package/build/columns/transforms.js.map +1 -1
- package/build/comment-author-avatar/edit.js +1 -0
- package/build/comment-author-avatar/edit.js.map +1 -1
- package/build/cover/edit/index.js +3 -1
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +2 -0
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/edit.native.js +24 -16
- package/build/cover/edit.native.js.map +1 -1
- package/build/embed/embed-controls.native.js +1 -0
- package/build/embed/embed-controls.native.js.map +1 -1
- package/build/embed/embed-preview.native.js +1 -3
- package/build/embed/embed-preview.native.js.map +1 -1
- package/build/file/inspector.js +1 -0
- package/build/file/inspector.js.map +1 -1
- package/build/gallery/edit.js +25 -13
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/gallery.native.js +1 -3
- package/build/gallery/gallery.native.js.map +1 -1
- package/build/gallery/shared.js +4 -10
- package/build/gallery/shared.js.map +1 -1
- package/build/gallery/transforms.js +1 -7
- package/build/gallery/transforms.js.map +1 -1
- package/build/gallery/use-get-media.js +1 -1
- package/build/gallery/use-get-media.js.map +1 -1
- package/build/gallery/use-get-media.native.js +3 -1
- package/build/gallery/use-get-media.native.js.map +1 -1
- package/build/gallery/v1/edit.js +26 -17
- package/build/gallery/v1/edit.js.map +1 -1
- package/build/gallery/v1/gallery.native.js +1 -3
- package/build/gallery/v1/gallery.native.js.map +1 -1
- package/build/gallery/v1/shared.js +4 -1
- package/build/gallery/v1/shared.js.map +1 -1
- package/build/group/edit.js +97 -45
- package/build/group/edit.js.map +1 -1
- package/build/group/index.js +6 -1
- package/build/group/index.js.map +1 -1
- package/build/group/placeholder.js +147 -0
- package/build/group/placeholder.js.map +1 -0
- package/build/group/variations.js +3 -3
- package/build/group/variations.js.map +1 -1
- package/build/heading/deprecated.js +152 -69
- package/build/heading/deprecated.js.map +1 -1
- package/build/heading/index.js +1 -2
- package/build/heading/index.js.map +1 -1
- package/build/heading/transforms.js +1 -2
- package/build/heading/transforms.js.map +1 -1
- package/build/html/index.js +1 -1
- package/build/image/edit.js +8 -5
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js +3 -2
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +12 -8
- package/build/image/image.js.map +1 -1
- package/build/index.js +3 -1
- package/build/index.js.map +1 -1
- package/build/latest-comments/edit.js +3 -1
- package/build/latest-comments/edit.js.map +1 -1
- package/build/latest-comments/index.js +5 -1
- package/build/latest-comments/index.js.map +1 -1
- package/build/latest-posts/deprecated.js +13 -0
- package/build/latest-posts/deprecated.js.map +1 -1
- package/build/latest-posts/edit.js +2 -0
- package/build/latest-posts/edit.js.map +1 -1
- package/build/latest-posts/index.js +13 -0
- package/build/latest-posts/index.js.map +1 -1
- package/build/list/transforms.js +1 -9
- package/build/list/transforms.js.map +1 -1
- package/build/list/utils.js +5 -2
- package/build/list/utils.js.map +1 -1
- package/build/list-item/edit.js +2 -1
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/index.js +4 -1
- package/build/list-item/index.js.map +1 -1
- package/build/list-item/transforms.js +22 -0
- package/build/list-item/transforms.js.map +1 -0
- package/build/list-item/utils.js +77 -1
- package/build/list-item/utils.js.map +1 -1
- package/build/media-text/edit.js +4 -2
- package/build/media-text/edit.js.map +1 -1
- package/build/navigation/edit/are-blocks-dirty.js +52 -0
- package/build/navigation/edit/are-blocks-dirty.js.map +1 -0
- package/build/navigation/edit/index.js +112 -143
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/manage-menus-button.js +36 -0
- package/build/navigation/edit/manage-menus-button.js.map +1 -0
- package/build/navigation/edit/menu-inspector-controls.js +72 -0
- package/build/navigation/edit/menu-inspector-controls.js.map +1 -0
- package/build/navigation/edit/navigation-menu-selector.js +3 -1
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/responsive-wrapper.js +2 -6
- package/build/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +15 -25
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/view-modal.js +6 -2
- package/build/navigation/view-modal.js.map +1 -1
- package/build/navigation-link/edit.js +52 -299
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/link-ui.js +222 -0
- package/build/navigation-link/link-ui.js.map +1 -0
- package/build/navigation-link/transforms.js +12 -0
- package/build/navigation-link/transforms.js.map +1 -1
- package/build/navigation-link/update-attributes.js +108 -0
- package/build/navigation-link/update-attributes.js.map +1 -0
- package/build/navigation-submenu/edit.js +42 -173
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/page-list/constants.js +15 -0
- package/build/page-list/constants.js.map +1 -0
- package/build/page-list/convert-to-links-modal.js +22 -86
- package/build/page-list/convert-to-links-modal.js.map +1 -1
- package/build/page-list/convert-to-navigation-links.js +76 -0
- package/build/page-list/convert-to-navigation-links.js.map +1 -0
- package/build/page-list/edit.js +142 -78
- package/build/page-list/edit.js.map +1 -1
- package/build/page-list/index.js +6 -1
- package/build/page-list/index.js.map +1 -1
- package/build/page-list-item/edit.js +87 -0
- package/build/page-list-item/edit.js.map +1 -0
- package/build/page-list-item/index.js +85 -0
- package/build/page-list-item/index.js.map +1 -0
- package/build/page-list-item/init.js +16 -0
- package/build/page-list-item/init.js.map +1 -0
- package/build/paragraph/index.js +1 -7
- package/build/paragraph/index.js.map +1 -1
- package/build/post-author/edit.js +38 -22
- package/build/post-author/edit.js.map +1 -1
- package/build/post-content/index.js +3 -0
- package/build/post-content/index.js.map +1 -1
- package/build/post-featured-image/overlay.js +1 -0
- package/build/post-featured-image/overlay.js.map +1 -1
- package/build/post-template/index.js +8 -0
- package/build/post-template/index.js.map +1 -1
- package/build/preformatted/transforms.js +3 -1
- package/build/preformatted/transforms.js.map +1 -1
- package/build/query/deprecated.js +192 -21
- package/build/query/deprecated.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +1 -0
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/query-placeholder.js +3 -19
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/query/index.js +0 -8
- package/build/query/index.js.map +1 -1
- package/build/query/utils.js +0 -8
- package/build/query/utils.js.map +1 -1
- package/build/rss/edit.js +3 -0
- package/build/rss/edit.js.map +1 -1
- package/build/search/edit.native.js +22 -22
- package/build/search/edit.native.js.map +1 -1
- package/build/search/index.js +9 -1
- package/build/search/index.js.map +1 -1
- package/build/site-logo/edit.js +18 -10
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-logo/index.js +1 -0
- package/build/site-logo/index.js.map +1 -1
- package/build/site-title/index.js +1 -0
- package/build/site-title/index.js.map +1 -1
- package/build/social-link/social-list.js +4 -12
- package/build/social-link/social-list.js.map +1 -1
- package/build/table/edit.js +3 -1
- package/build/table/edit.js.map +1 -1
- package/build/table/index.js +17 -1
- package/build/table/index.js.map +1 -1
- package/build/table/save.js +4 -2
- package/build/table/save.js.map +1 -1
- package/build/table/state.js +24 -12
- package/build/table/state.js.map +1 -1
- package/build/table/transforms.js +3 -2
- package/build/table/transforms.js.map +1 -1
- package/build/table-of-contents/edit.js +2 -2
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/tag-cloud/edit.js +2 -1
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/template-part/edit/selection-modal.js +5 -2
- package/build/template-part/edit/selection-modal.js.map +1 -1
- package/build/template-part/edit/utils/hooks.js +2 -6
- package/build/template-part/edit/utils/hooks.js.map +1 -1
- package/build/template-part/variations.js +5 -0
- package/build/template-part/variations.js.map +1 -1
- package/build/text-columns/edit.js +1 -0
- package/build/text-columns/edit.js.map +1 -1
- package/build/utils/transformation-categories.native.js +1 -1
- package/build/utils/transformation-categories.native.js.map +1 -1
- package/build/video/edit.js +1 -1
- package/build/video/edit.js.map +1 -1
- package/build/video/edit.native.js +1 -3
- package/build/video/edit.native.js.map +1 -1
- package/build-module/audio/edit.native.js +1 -2
- package/build-module/audio/edit.native.js.map +1 -1
- package/build-module/audio/index.js +2 -1
- package/build-module/audio/index.js.map +1 -1
- package/build-module/avatar/edit.js +1 -0
- package/build-module/avatar/edit.js.map +1 -1
- package/build-module/avatar/user-control.js +1 -0
- package/build-module/avatar/user-control.js.map +1 -1
- package/build-module/block/edit.js +14 -2
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/edit.native.js +14 -6
- package/build-module/block/edit.native.js.map +1 -1
- package/build-module/block/index.js +1 -2
- package/build-module/block/index.js.map +1 -1
- package/build-module/button/deprecated.js +16 -2
- package/build-module/button/deprecated.js.map +1 -1
- package/build-module/button/edit.js +15 -9
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/edit.native.js +2 -1
- package/build-module/button/edit.native.js.map +1 -1
- package/build-module/button/index.js +4 -1
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/save.js +2 -0
- package/build-module/button/save.js.map +1 -1
- package/build-module/code/transforms.js +1 -1
- package/build-module/code/transforms.js.map +1 -1
- package/build-module/columns/edit.js +1 -0
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/columns/edit.native.js +13 -29
- package/build-module/columns/edit.native.js.map +1 -1
- package/build-module/columns/transforms.js +5 -0
- package/build-module/columns/transforms.js.map +1 -1
- package/build-module/comment-author-avatar/edit.js +1 -0
- package/build-module/comment-author-avatar/edit.js.map +1 -1
- package/build-module/cover/edit/index.js +3 -1
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +2 -0
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/edit.native.js +22 -14
- package/build-module/cover/edit.native.js.map +1 -1
- package/build-module/embed/embed-controls.native.js +2 -1
- package/build-module/embed/embed-controls.native.js.map +1 -1
- package/build-module/embed/embed-preview.native.js +1 -2
- package/build-module/embed/embed-preview.native.js.map +1 -1
- package/build-module/file/inspector.js +1 -0
- package/build-module/file/inspector.js.map +1 -1
- package/build-module/gallery/edit.js +25 -12
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/gallery.native.js +1 -2
- package/build-module/gallery/gallery.native.js.map +1 -1
- package/build-module/gallery/shared.js +5 -11
- package/build-module/gallery/shared.js.map +1 -1
- package/build-module/gallery/transforms.js +1 -6
- package/build-module/gallery/transforms.js.map +1 -1
- package/build-module/gallery/use-get-media.js +1 -1
- package/build-module/gallery/use-get-media.js.map +1 -1
- package/build-module/gallery/use-get-media.native.js +3 -1
- package/build-module/gallery/use-get-media.native.js.map +1 -1
- package/build-module/gallery/v1/edit.js +27 -18
- package/build-module/gallery/v1/edit.js.map +1 -1
- package/build-module/gallery/v1/gallery.native.js +1 -2
- package/build-module/gallery/v1/gallery.native.js.map +1 -1
- package/build-module/gallery/v1/shared.js +5 -2
- package/build-module/gallery/v1/shared.js.map +1 -1
- package/build-module/group/edit.js +92 -45
- package/build-module/group/edit.js.map +1 -1
- package/build-module/group/index.js +6 -1
- package/build-module/group/index.js.map +1 -1
- package/build-module/group/placeholder.js +133 -0
- package/build-module/group/placeholder.js.map +1 -0
- package/build-module/group/variations.js +3 -3
- package/build-module/group/variations.js.map +1 -1
- package/build-module/heading/deprecated.js +152 -69
- package/build-module/heading/deprecated.js.map +1 -1
- package/build-module/heading/index.js +1 -2
- package/build-module/heading/index.js.map +1 -1
- package/build-module/heading/transforms.js +1 -2
- package/build-module/heading/transforms.js.map +1 -1
- package/build-module/html/index.js +1 -1
- package/build-module/image/edit.js +9 -6
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js +2 -1
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +13 -9
- package/build-module/image/image.js.map +1 -1
- package/build-module/index.js +2 -1
- package/build-module/index.js.map +1 -1
- package/build-module/latest-comments/edit.js +3 -1
- package/build-module/latest-comments/edit.js.map +1 -1
- package/build-module/latest-comments/index.js +5 -1
- package/build-module/latest-comments/index.js.map +1 -1
- package/build-module/latest-posts/deprecated.js +13 -0
- package/build-module/latest-posts/deprecated.js.map +1 -1
- package/build-module/latest-posts/edit.js +2 -0
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/latest-posts/index.js +13 -0
- package/build-module/latest-posts/index.js.map +1 -1
- package/build-module/list/transforms.js +1 -9
- package/build-module/list/transforms.js.map +1 -1
- package/build-module/list/utils.js +5 -2
- package/build-module/list/utils.js.map +1 -1
- package/build-module/list-item/edit.js +2 -1
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/index.js +3 -1
- package/build-module/list-item/index.js.map +1 -1
- package/build-module/list-item/transforms.js +13 -0
- package/build-module/list-item/transforms.js.map +1 -0
- package/build-module/list-item/utils.js +78 -1
- package/build-module/list-item/utils.js.map +1 -1
- package/build-module/media-text/edit.js +5 -3
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/navigation/edit/are-blocks-dirty.js +44 -0
- package/build-module/navigation/edit/are-blocks-dirty.js.map +1 -0
- package/build-module/navigation/edit/index.js +111 -143
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/manage-menus-button.js +26 -0
- package/build-module/navigation/edit/manage-menus-button.js.map +1 -0
- package/build-module/navigation/edit/menu-inspector-controls.js +59 -0
- package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -0
- package/build-module/navigation/edit/navigation-menu-selector.js +3 -1
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/responsive-wrapper.js +2 -6
- package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +16 -26
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/view-modal.js +6 -2
- package/build-module/navigation/view-modal.js.map +1 -1
- package/build-module/navigation-link/edit.js +56 -300
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/link-ui.js +206 -0
- package/build-module/navigation-link/link-ui.js.map +1 -0
- package/build-module/navigation-link/transforms.js +12 -0
- package/build-module/navigation-link/transforms.js.map +1 -1
- package/build-module/navigation-link/update-attributes.js +97 -0
- package/build-module/navigation-link/update-attributes.js.map +1 -0
- package/build-module/navigation-submenu/edit.js +47 -175
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/page-list/constants.js +6 -0
- package/build-module/page-list/constants.js.map +1 -0
- package/build-module/page-list/convert-to-links-modal.js +20 -81
- package/build-module/page-list/convert-to-links-modal.js.map +1 -1
- package/build-module/page-list/convert-to-navigation-links.js +66 -0
- package/build-module/page-list/convert-to-navigation-links.js.map +1 -0
- package/build-module/page-list/edit.js +144 -82
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/page-list/index.js +6 -1
- package/build-module/page-list/index.js.map +1 -1
- package/build-module/page-list-item/edit.js +74 -0
- package/build-module/page-list-item/edit.js.map +1 -0
- package/build-module/page-list-item/index.js +68 -0
- package/build-module/page-list-item/index.js.map +1 -0
- package/build-module/page-list-item/init.js +6 -0
- package/build-module/page-list-item/init.js.map +1 -0
- package/build-module/paragraph/index.js +1 -7
- package/build-module/paragraph/index.js.map +1 -1
- package/build-module/post-author/edit.js +38 -23
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-content/index.js +3 -0
- package/build-module/post-content/index.js.map +1 -1
- package/build-module/post-featured-image/overlay.js +1 -0
- package/build-module/post-featured-image/overlay.js.map +1 -1
- package/build-module/post-template/index.js +8 -0
- package/build-module/post-template/index.js.map +1 -1
- package/build-module/preformatted/transforms.js +3 -1
- package/build-module/preformatted/transforms.js.map +1 -1
- package/build-module/query/deprecated.js +185 -21
- package/build-module/query/deprecated.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +1 -0
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +3 -19
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/query/index.js +0 -8
- package/build-module/query/index.js.map +1 -1
- package/build-module/query/utils.js +0 -8
- package/build-module/query/utils.js.map +1 -1
- package/build-module/rss/edit.js +3 -0
- package/build-module/rss/edit.js.map +1 -1
- package/build-module/search/edit.native.js +20 -20
- package/build-module/search/edit.native.js.map +1 -1
- package/build-module/search/index.js +8 -1
- package/build-module/search/index.js.map +1 -1
- package/build-module/site-logo/edit.js +18 -9
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-logo/index.js +1 -0
- package/build-module/site-logo/index.js.map +1 -1
- package/build-module/site-title/index.js +1 -0
- package/build-module/site-title/index.js.map +1 -1
- package/build-module/social-link/social-list.js +2 -11
- package/build-module/social-link/social-list.js.map +1 -1
- package/build-module/table/edit.js +3 -1
- package/build-module/table/edit.js.map +1 -1
- package/build-module/table/index.js +17 -1
- package/build-module/table/index.js.map +1 -1
- package/build-module/table/save.js +4 -2
- package/build-module/table/save.js.map +1 -1
- package/build-module/table/state.js +25 -13
- package/build-module/table/state.js.map +1 -1
- package/build-module/table/transforms.js +3 -2
- package/build-module/table/transforms.js.map +1 -1
- package/build-module/table-of-contents/edit.js +2 -2
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/tag-cloud/edit.js +3 -2
- package/build-module/tag-cloud/edit.js.map +1 -1
- package/build-module/template-part/edit/selection-modal.js +6 -3
- package/build-module/template-part/edit/selection-modal.js.map +1 -1
- package/build-module/template-part/edit/utils/hooks.js +3 -7
- package/build-module/template-part/edit/utils/hooks.js.map +1 -1
- package/build-module/template-part/variations.js +5 -0
- package/build-module/template-part/variations.js.map +1 -1
- package/build-module/text-columns/edit.js +1 -0
- package/build-module/text-columns/edit.js.map +1 -1
- package/build-module/utils/transformation-categories.native.js +1 -1
- package/build-module/utils/transformation-categories.native.js.map +1 -1
- package/build-module/video/edit.js +1 -1
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/edit.native.js +1 -2
- package/build-module/video/edit.native.js.map +1 -1
- package/build-style/archives/editor-rtl.css +12 -0
- package/build-style/archives/editor.css +12 -0
- package/build-style/archives/style-rtl.css +12 -0
- package/build-style/archives/style.css +12 -0
- package/build-style/audio/editor-rtl.css +12 -0
- package/build-style/audio/editor.css +12 -0
- package/build-style/audio/style-rtl.css +12 -0
- package/build-style/audio/style.css +12 -0
- package/build-style/audio/theme-rtl.css +12 -0
- package/build-style/audio/theme.css +12 -0
- package/build-style/avatar/editor-rtl.css +12 -0
- package/build-style/avatar/editor.css +12 -0
- package/build-style/avatar/style-rtl.css +12 -0
- package/build-style/avatar/style.css +12 -0
- package/build-style/block/editor-rtl.css +22 -0
- package/build-style/block/editor.css +22 -0
- package/build-style/button/editor-rtl.css +12 -0
- package/build-style/button/editor.css +12 -0
- package/build-style/button/style-rtl.css +12 -0
- package/build-style/button/style.css +12 -0
- package/build-style/buttons/editor-rtl.css +12 -0
- package/build-style/buttons/editor.css +12 -0
- package/build-style/buttons/style-rtl.css +12 -0
- package/build-style/buttons/style.css +12 -0
- package/build-style/calendar/style-rtl.css +12 -0
- package/build-style/calendar/style.css +12 -0
- package/build-style/categories/editor-rtl.css +12 -0
- package/build-style/categories/editor.css +12 -0
- package/build-style/categories/style-rtl.css +12 -0
- package/build-style/categories/style.css +12 -0
- package/build-style/classic-rtl.css +12 -0
- package/build-style/classic.css +12 -0
- package/build-style/code/editor-rtl.css +12 -0
- package/build-style/code/editor.css +12 -0
- package/build-style/code/style-rtl.css +12 -0
- package/build-style/code/style.css +12 -0
- package/build-style/code/theme-rtl.css +12 -0
- package/build-style/code/theme.css +12 -0
- package/build-style/columns/editor-rtl.css +12 -0
- package/build-style/columns/editor.css +12 -0
- package/build-style/columns/style-rtl.css +12 -0
- package/build-style/columns/style.css +12 -0
- package/build-style/comment-author-avatar/editor-rtl.css +12 -0
- package/build-style/comment-author-avatar/editor.css +12 -0
- package/build-style/comment-content/style-rtl.css +12 -0
- package/build-style/comment-content/style.css +12 -0
- package/build-style/comment-template/style-rtl.css +12 -0
- package/build-style/comment-template/style.css +12 -0
- package/build-style/comments/editor-rtl.css +12 -0
- package/build-style/comments/editor.css +12 -0
- package/build-style/comments/style-rtl.css +12 -0
- package/build-style/comments/style.css +12 -0
- package/build-style/comments-pagination/editor-rtl.css +12 -0
- package/build-style/comments-pagination/editor.css +12 -0
- package/build-style/comments-pagination/style-rtl.css +12 -0
- package/build-style/comments-pagination/style.css +12 -0
- package/build-style/comments-pagination-numbers/editor-rtl.css +12 -0
- package/build-style/comments-pagination-numbers/editor.css +12 -0
- package/build-style/comments-title/editor-rtl.css +12 -0
- package/build-style/comments-title/editor.css +12 -0
- package/build-style/common-rtl.css +17 -1
- package/build-style/common.css +17 -1
- package/build-style/cover/editor-rtl.css +12 -0
- package/build-style/cover/editor.css +12 -0
- package/build-style/cover/style-rtl.css +14 -1
- package/build-style/cover/style.css +14 -1
- package/build-style/editor-elements-rtl.css +12 -0
- package/build-style/editor-elements.css +12 -0
- package/build-style/editor-rtl.css +115 -21
- package/build-style/editor.css +115 -21
- package/build-style/elements-rtl.css +12 -0
- package/build-style/elements.css +12 -0
- package/build-style/embed/editor-rtl.css +12 -0
- package/build-style/embed/editor.css +12 -0
- package/build-style/embed/style-rtl.css +12 -0
- package/build-style/embed/style.css +12 -0
- package/build-style/embed/theme-rtl.css +12 -0
- package/build-style/embed/theme.css +12 -0
- package/build-style/file/editor-rtl.css +12 -0
- package/build-style/file/editor.css +12 -0
- package/build-style/file/style-rtl.css +12 -0
- package/build-style/file/style.css +12 -0
- package/build-style/freeform/editor-rtl.css +12 -0
- package/build-style/freeform/editor.css +12 -0
- package/build-style/gallery/editor-rtl.css +13 -1
- package/build-style/gallery/editor.css +13 -1
- package/build-style/gallery/style-rtl.css +16 -2
- package/build-style/gallery/style.css +16 -2
- package/build-style/gallery/theme-rtl.css +12 -0
- package/build-style/gallery/theme.css +12 -0
- package/build-style/group/editor-rtl.css +56 -0
- package/build-style/group/editor.css +56 -0
- package/build-style/group/style-rtl.css +12 -0
- package/build-style/group/style.css +12 -0
- package/build-style/group/theme-rtl.css +12 -0
- package/build-style/group/theme.css +12 -0
- package/build-style/heading/style-rtl.css +12 -0
- package/build-style/heading/style.css +12 -0
- package/build-style/html/editor-rtl.css +12 -0
- package/build-style/html/editor.css +12 -0
- package/build-style/image/editor-rtl.css +12 -9
- package/build-style/image/editor.css +12 -9
- package/build-style/image/style-rtl.css +12 -0
- package/build-style/image/style.css +12 -0
- package/build-style/image/theme-rtl.css +12 -0
- package/build-style/image/theme.css +12 -0
- package/build-style/latest-comments/style-rtl.css +13 -0
- package/build-style/latest-comments/style.css +13 -0
- package/build-style/latest-posts/editor-rtl.css +12 -0
- package/build-style/latest-posts/editor.css +12 -0
- package/build-style/latest-posts/style-rtl.css +15 -0
- package/build-style/latest-posts/style.css +15 -0
- package/build-style/list/style-rtl.css +12 -0
- package/build-style/list/style.css +12 -0
- package/build-style/media-text/editor-rtl.css +12 -0
- package/build-style/media-text/editor.css +12 -0
- package/build-style/media-text/style-rtl.css +12 -0
- package/build-style/media-text/style.css +12 -0
- package/build-style/more/editor-rtl.css +12 -0
- package/build-style/more/editor.css +12 -0
- package/build-style/navigation/editor-rtl.css +35 -0
- package/build-style/navigation/editor.css +35 -0
- package/build-style/navigation/style-rtl.css +22 -0
- package/build-style/navigation/style.css +22 -0
- package/build-style/navigation-link/editor-rtl.css +20 -1
- package/build-style/navigation-link/editor.css +20 -1
- package/build-style/navigation-link/style-rtl.css +12 -0
- package/build-style/navigation-link/style.css +12 -0
- package/build-style/navigation-submenu/editor-rtl.css +12 -0
- package/build-style/navigation-submenu/editor.css +12 -0
- package/build-style/nextpage/editor-rtl.css +12 -0
- package/build-style/nextpage/editor.css +12 -0
- package/build-style/page-list/editor-rtl.css +12 -0
- package/build-style/page-list/editor.css +12 -0
- package/build-style/page-list/style-rtl.css +12 -0
- package/build-style/page-list/style.css +12 -0
- package/build-style/paragraph/editor-rtl.css +12 -0
- package/build-style/paragraph/editor.css +12 -0
- package/build-style/paragraph/style-rtl.css +12 -0
- package/build-style/paragraph/style.css +12 -0
- package/build-style/post-author/style-rtl.css +12 -0
- package/build-style/post-author/style.css +12 -0
- package/build-style/post-comments-form/editor-rtl.css +12 -0
- package/build-style/post-comments-form/editor.css +12 -0
- package/build-style/post-comments-form/style-rtl.css +12 -0
- package/build-style/post-comments-form/style.css +12 -0
- package/build-style/post-date/style-rtl.css +12 -0
- package/build-style/post-date/style.css +12 -0
- package/build-style/post-excerpt/editor-rtl.css +12 -0
- package/build-style/post-excerpt/editor.css +12 -0
- package/build-style/post-excerpt/style-rtl.css +12 -0
- package/build-style/post-excerpt/style.css +12 -0
- package/build-style/post-featured-image/editor-rtl.css +12 -0
- package/build-style/post-featured-image/editor.css +12 -0
- package/build-style/post-featured-image/style-rtl.css +12 -0
- package/build-style/post-featured-image/style.css +12 -0
- package/build-style/post-navigation-link/style-rtl.css +12 -0
- package/build-style/post-navigation-link/style.css +12 -0
- package/build-style/post-template/editor-rtl.css +12 -0
- package/build-style/post-template/editor.css +12 -0
- package/build-style/post-template/style-rtl.css +12 -0
- package/build-style/post-template/style.css +12 -0
- package/build-style/post-terms/style-rtl.css +12 -0
- package/build-style/post-terms/style.css +12 -0
- package/build-style/post-title/style-rtl.css +12 -0
- package/build-style/post-title/style.css +12 -0
- package/build-style/preformatted/style-rtl.css +12 -0
- package/build-style/preformatted/style.css +12 -0
- package/build-style/pullquote/editor-rtl.css +12 -0
- package/build-style/pullquote/editor.css +12 -0
- package/build-style/pullquote/style-rtl.css +12 -0
- package/build-style/pullquote/style.css +12 -0
- package/build-style/pullquote/theme-rtl.css +12 -0
- package/build-style/pullquote/theme.css +12 -0
- package/build-style/query/editor-rtl.css +13 -1
- package/build-style/query/editor.css +13 -1
- package/build-style/query-pagination/editor-rtl.css +12 -0
- package/build-style/query-pagination/editor.css +12 -0
- package/build-style/query-pagination/style-rtl.css +13 -1
- package/build-style/query-pagination/style.css +13 -1
- package/build-style/query-pagination-numbers/editor-rtl.css +12 -0
- package/build-style/query-pagination-numbers/editor.css +12 -0
- package/build-style/query-title/style-rtl.css +12 -0
- package/build-style/query-title/style.css +12 -0
- package/build-style/quote/style-rtl.css +12 -0
- package/build-style/quote/style.css +12 -0
- package/build-style/quote/theme-rtl.css +12 -0
- package/build-style/quote/theme.css +12 -0
- package/build-style/read-more/style-rtl.css +12 -0
- package/build-style/read-more/style.css +12 -0
- package/build-style/reset-rtl.css +12 -0
- package/build-style/reset.css +12 -0
- package/build-style/rss/editor-rtl.css +12 -0
- package/build-style/rss/editor.css +12 -0
- package/build-style/rss/style-rtl.css +12 -0
- package/build-style/rss/style.css +12 -0
- package/build-style/search/editor-rtl.css +12 -0
- package/build-style/search/editor.css +12 -0
- package/build-style/search/style-rtl.css +12 -0
- package/build-style/search/style.css +12 -0
- package/build-style/search/theme-rtl.css +12 -0
- package/build-style/search/theme.css +12 -0
- package/build-style/separator/editor-rtl.css +12 -0
- package/build-style/separator/editor.css +12 -0
- package/build-style/separator/style-rtl.css +12 -0
- package/build-style/separator/style.css +12 -0
- package/build-style/separator/theme-rtl.css +12 -0
- package/build-style/separator/theme.css +12 -0
- package/build-style/shortcode/editor-rtl.css +13 -1
- package/build-style/shortcode/editor.css +13 -1
- package/build-style/site-logo/editor-rtl.css +12 -0
- package/build-style/site-logo/editor.css +12 -0
- package/build-style/site-logo/style-rtl.css +12 -0
- package/build-style/site-logo/style.css +12 -0
- package/build-style/site-tagline/editor-rtl.css +12 -0
- package/build-style/site-tagline/editor.css +12 -0
- package/build-style/site-title/editor-rtl.css +12 -0
- package/build-style/site-title/editor.css +12 -0
- package/build-style/site-title/style-rtl.css +12 -0
- package/build-style/site-title/style.css +12 -0
- package/build-style/social-link/editor-rtl.css +12 -0
- package/build-style/social-link/editor.css +12 -0
- package/build-style/social-links/editor-rtl.css +12 -0
- package/build-style/social-links/editor.css +12 -0
- package/build-style/social-links/style-rtl.css +12 -0
- package/build-style/social-links/style.css +12 -0
- package/build-style/spacer/editor-rtl.css +12 -0
- package/build-style/spacer/editor.css +12 -0
- package/build-style/spacer/style-rtl.css +12 -0
- package/build-style/spacer/style.css +12 -0
- package/build-style/style-rtl.css +43 -6
- package/build-style/style.css +43 -6
- package/build-style/table/editor-rtl.css +13 -8
- package/build-style/table/editor.css +13 -8
- package/build-style/table/style-rtl.css +17 -0
- package/build-style/table/style.css +17 -0
- package/build-style/table/theme-rtl.css +13 -3
- package/build-style/table/theme.css +13 -3
- package/build-style/tag-cloud/style-rtl.css +12 -0
- package/build-style/tag-cloud/style.css +12 -0
- package/build-style/template-part/editor-rtl.css +27 -1
- package/build-style/template-part/editor.css +27 -1
- package/build-style/template-part/theme-rtl.css +12 -0
- package/build-style/template-part/theme.css +12 -0
- package/build-style/text-columns/editor-rtl.css +12 -0
- package/build-style/text-columns/editor.css +12 -0
- package/build-style/text-columns/style-rtl.css +12 -0
- package/build-style/text-columns/style.css +12 -0
- package/build-style/theme-rtl.css +13 -3
- package/build-style/theme.css +13 -3
- package/build-style/verse/style-rtl.css +12 -0
- package/build-style/verse/style.css +12 -0
- package/build-style/video/editor-rtl.css +12 -0
- package/build-style/video/editor.css +12 -0
- package/build-style/video/style-rtl.css +14 -1
- package/build-style/video/style.css +14 -1
- package/build-style/video/theme-rtl.css +12 -0
- package/build-style/video/theme.css +12 -0
- package/package.json +32 -30
- package/src/audio/edit.native.js +1 -2
- package/src/audio/index.js +1 -0
- package/src/avatar/edit.js +1 -0
- package/src/avatar/index.php +1 -1
- package/src/avatar/user-control.js +1 -0
- package/src/block/block.json +1 -2
- package/src/block/edit.js +14 -3
- package/src/block/edit.native.js +24 -12
- package/src/block/editor.scss +17 -0
- package/src/block/index.php +1 -2
- package/src/block/test/edit.native.js +28 -32
- package/src/button/block.json +4 -1
- package/src/button/deprecated.js +18 -2
- package/src/button/edit.js +11 -9
- package/src/button/edit.native.js +1 -0
- package/src/button/save.js +12 -2
- package/src/buttons/test/edit.native.js +41 -52
- package/src/code/transforms.js +3 -1
- package/src/columns/edit.js +1 -0
- package/src/columns/edit.native.js +18 -26
- package/src/columns/test/edit.native.js +32 -32
- package/src/columns/transforms.js +8 -0
- package/src/comment-author-avatar/edit.js +1 -0
- package/src/cover/edit/index.js +3 -1
- package/src/cover/edit/inspector-controls.js +2 -0
- package/src/cover/edit.native.js +32 -19
- package/src/cover/test/edit.native.js +77 -130
- package/src/embed/embed-controls.native.js +1 -0
- package/src/embed/embed-preview.native.js +1 -2
- package/src/embed/test/index.native.js +251 -245
- package/src/file/inspector.js +1 -0
- package/src/file/test/__snapshots__/edit.native.js.snap +2 -6
- package/src/gallery/edit.js +15 -5
- package/src/gallery/gallery.native.js +1 -2
- package/src/gallery/shared.js +7 -11
- package/src/gallery/test/index.native.js +11 -11
- package/src/gallery/transforms.js +1 -6
- package/src/gallery/use-get-media.js +1 -1
- package/src/gallery/use-get-media.native.js +2 -1
- package/src/gallery/v1/edit.js +26 -30
- package/src/gallery/v1/gallery.native.js +1 -2
- package/src/gallery/v1/shared.js +7 -2
- package/src/group/block.json +6 -1
- package/src/group/edit.js +91 -44
- package/src/group/editor.scss +48 -0
- package/src/group/placeholder.js +168 -0
- package/src/group/test/__snapshots__/edit.native.js.snap +1 -1
- package/src/group/test/edit.native.js +3 -3
- package/src/group/test/placeholder.js +78 -0
- package/src/group/variations.js +3 -3
- package/src/heading/block.json +1 -2
- package/src/heading/deprecated.js +209 -136
- package/src/heading/index.php +52 -0
- package/src/heading/test/__snapshots__/index.native.js.snap +7 -0
- package/src/heading/test/index.native.js +44 -0
- package/src/home-link/index.php +1 -1
- package/src/html/block.json +1 -1
- package/src/image/edit.js +7 -2
- package/src/image/edit.native.js +2 -1
- package/src/image/editor.scss +0 -11
- package/src/image/image.js +13 -8
- package/src/image/test/edit.native.js +24 -20
- package/src/index.js +2 -0
- package/src/latest-comments/block.json +5 -1
- package/src/latest-comments/edit.js +2 -0
- package/src/latest-comments/style.scss +3 -0
- package/src/latest-posts/block.json +13 -0
- package/src/latest-posts/edit.js +2 -0
- package/src/latest-posts/style.scss +3 -0
- package/src/list/test/edit.native.js +55 -47
- package/src/list/transforms.js +0 -11
- package/src/list/utils.js +6 -2
- package/src/list-item/edit.js +1 -0
- package/src/list-item/index.js +2 -0
- package/src/list-item/transforms.js +17 -0
- package/src/list-item/utils.js +10 -1
- package/src/media-text/edit.js +5 -3
- package/src/missing/test/edit-integration.native.js +10 -12
- package/src/navigation/edit/are-blocks-dirty.js +51 -0
- package/src/navigation/edit/index.js +269 -310
- package/src/navigation/edit/manage-menus-button.js +21 -0
- package/src/navigation/edit/menu-inspector-controls.js +78 -0
- package/src/navigation/edit/navigation-menu-selector.js +5 -1
- package/src/navigation/edit/responsive-wrapper.js +2 -10
- package/src/navigation/edit/test/are-blocks-dirty.js +121 -0
- package/src/navigation/edit/unsaved-inner-blocks.js +17 -36
- package/src/navigation/editor.scss +25 -0
- package/src/navigation/index.php +57 -10
- package/src/navigation/style.scss +16 -0
- package/src/navigation/view-modal.js +11 -1
- package/src/navigation-link/edit.js +66 -329
- package/src/navigation-link/editor.scss +8 -0
- package/src/navigation-link/index.php +32 -0
- package/src/navigation-link/link-ui.js +213 -0
- package/src/navigation-link/test/edit.js +23 -82
- package/src/navigation-link/transforms.js +14 -0
- package/src/navigation-link/update-attributes.js +99 -0
- package/src/navigation-submenu/edit.js +57 -177
- package/src/navigation-submenu/index.php +40 -0
- package/src/page-list/block.json +6 -1
- package/src/page-list/constants.js +8 -0
- package/src/page-list/convert-to-links-modal.js +19 -76
- package/src/page-list/convert-to-navigation-links.js +60 -0
- package/src/page-list/edit.js +179 -118
- package/src/page-list/index.php +9 -0
- package/src/page-list/test/convert-to-links-modal.js +28 -34
- package/src/page-list-item/block.json +51 -0
- package/src/page-list-item/edit.js +94 -0
- package/src/page-list-item/index.js +24 -0
- package/src/page-list-item/init.js +6 -0
- package/src/paragraph/index.js +0 -6
- package/src/post-author/edit.js +47 -22
- package/src/post-content/block.json +3 -0
- package/src/post-content/index.php +1 -2
- package/src/post-featured-image/index.php +7 -2
- package/src/post-featured-image/overlay.js +1 -0
- package/src/post-template/block.json +8 -0
- package/src/preformatted/transforms.js +4 -1
- package/src/query/block.json +0 -8
- package/src/query/deprecated.js +257 -86
- package/src/query/edit/inspector-controls/index.js +1 -0
- package/src/query/edit/query-placeholder.js +4 -16
- package/src/query/editor.scss +1 -1
- package/src/query-pagination/style.scss +1 -1
- package/src/read-more/index.php +9 -2
- package/src/rss/edit.js +3 -0
- package/src/search/edit.native.js +31 -27
- package/src/search/index.js +5 -1
- package/src/shortcode/test/edit.native.js +15 -18
- package/src/site-logo/edit.js +14 -6
- package/src/site-logo/index.js +1 -0
- package/src/site-title/index.js +1 -0
- package/src/social-link/social-list.js +2 -7
- package/src/social-link/test/index.native.js +16 -22
- package/src/social-links/test/edit.native.js +8 -7
- package/src/spacer/test/index.native.js +39 -36
- package/src/table/block.json +15 -0
- package/src/table/edit.js +2 -1
- package/src/table/editor.scss +1 -4
- package/src/table/index.js +1 -0
- package/src/table/save.js +5 -1
- package/src/table/state.js +22 -7
- package/src/table/style.scss +7 -0
- package/src/table/theme.scss +1 -3
- package/src/table/transforms.js +2 -1
- package/src/table-of-contents/edit.js +2 -2
- package/src/tag-cloud/edit.js +3 -2
- package/src/template-part/edit/selection-modal.js +4 -3
- package/src/template-part/edit/utils/hooks.js +7 -3
- package/src/template-part/editor.scss +20 -2
- package/src/template-part/index.php +6 -2
- package/src/template-part/variations.js +4 -0
- package/src/text-columns/edit.js +1 -0
- package/src/utils/transformation-categories.native.js +1 -0
- package/src/video/edit.js +1 -1
- package/src/video/edit.native.js +1 -2
- package/test/babel-plugin.js +35 -35
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
|
|
5
|
+
import { Popover, Button } from '@wordpress/components';
|
|
6
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
7
|
+
import {
|
|
8
|
+
__experimentalLinkControl as LinkControl,
|
|
9
|
+
BlockIcon,
|
|
10
|
+
store as blockEditorStore,
|
|
11
|
+
} from '@wordpress/block-editor';
|
|
12
|
+
import { createInterpolateElement } from '@wordpress/element';
|
|
13
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
14
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
15
|
+
import { switchToBlockType } from '@wordpress/blocks';
|
|
16
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Given the Link block's type attribute, return the query params to give to
|
|
20
|
+
* /wp/v2/search.
|
|
21
|
+
*
|
|
22
|
+
* @param {string} type Link block's type attribute.
|
|
23
|
+
* @param {string} kind Link block's entity of kind (post-type|taxonomy)
|
|
24
|
+
* @return {{ type?: string, subtype?: string }} Search query params.
|
|
25
|
+
*/
|
|
26
|
+
export function getSuggestionsQuery( type, kind ) {
|
|
27
|
+
switch ( type ) {
|
|
28
|
+
case 'post':
|
|
29
|
+
case 'page':
|
|
30
|
+
return { type: 'post', subtype: type };
|
|
31
|
+
case 'category':
|
|
32
|
+
return { type: 'term', subtype: 'category' };
|
|
33
|
+
case 'tag':
|
|
34
|
+
return { type: 'term', subtype: 'post_tag' };
|
|
35
|
+
case 'post_format':
|
|
36
|
+
return { type: 'post-format' };
|
|
37
|
+
default:
|
|
38
|
+
if ( kind === 'taxonomy' ) {
|
|
39
|
+
return { type: 'term', subtype: type };
|
|
40
|
+
}
|
|
41
|
+
if ( kind === 'post-type' ) {
|
|
42
|
+
return { type: 'post', subtype: type };
|
|
43
|
+
}
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Add transforms to Link Control
|
|
50
|
+
*
|
|
51
|
+
* @param {Object} props Component props.
|
|
52
|
+
* @param {string} props.clientId Block client ID.
|
|
53
|
+
*/
|
|
54
|
+
function LinkControlTransforms( { clientId } ) {
|
|
55
|
+
const { getBlock, blockTransforms } = useSelect(
|
|
56
|
+
( select ) => {
|
|
57
|
+
const {
|
|
58
|
+
getBlock: _getBlock,
|
|
59
|
+
getBlockRootClientId,
|
|
60
|
+
getBlockTransformItems,
|
|
61
|
+
} = select( blockEditorStore );
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
getBlock: _getBlock,
|
|
65
|
+
blockTransforms: getBlockTransformItems(
|
|
66
|
+
_getBlock( clientId ),
|
|
67
|
+
getBlockRootClientId( clientId )
|
|
68
|
+
),
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
[ clientId ]
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const { replaceBlock } = useDispatch( blockEditorStore );
|
|
75
|
+
|
|
76
|
+
const featuredBlocks = [
|
|
77
|
+
'core/page-list',
|
|
78
|
+
'core/site-logo',
|
|
79
|
+
'core/social-links',
|
|
80
|
+
'core/search',
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
const transforms = blockTransforms.filter( ( item ) => {
|
|
84
|
+
return featuredBlocks.includes( item.name );
|
|
85
|
+
} );
|
|
86
|
+
|
|
87
|
+
if ( ! transforms?.length ) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if ( ! clientId ) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<div className="link-control-transform">
|
|
97
|
+
<h3 className="link-control-transform__subheading">
|
|
98
|
+
{ __( 'Transform' ) }
|
|
99
|
+
</h3>
|
|
100
|
+
<div className="link-control-transform__items">
|
|
101
|
+
{ transforms.map( ( item, index ) => {
|
|
102
|
+
return (
|
|
103
|
+
<Button
|
|
104
|
+
key={ `transform-${ index }` }
|
|
105
|
+
onClick={ () =>
|
|
106
|
+
replaceBlock(
|
|
107
|
+
clientId,
|
|
108
|
+
switchToBlockType(
|
|
109
|
+
getBlock( clientId ),
|
|
110
|
+
item.name
|
|
111
|
+
)
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
className="link-control-transform__item"
|
|
115
|
+
>
|
|
116
|
+
<BlockIcon icon={ item.icon } />
|
|
117
|
+
{ item.title }
|
|
118
|
+
</Button>
|
|
119
|
+
);
|
|
120
|
+
} ) }
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function LinkUI( props ) {
|
|
127
|
+
const { saveEntityRecord } = useDispatch( coreStore );
|
|
128
|
+
|
|
129
|
+
async function handleCreate( pageTitle ) {
|
|
130
|
+
const postType = props.link.type || 'page';
|
|
131
|
+
|
|
132
|
+
const page = await saveEntityRecord( 'postType', postType, {
|
|
133
|
+
title: pageTitle,
|
|
134
|
+
status: 'draft',
|
|
135
|
+
} );
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
id: page.id,
|
|
139
|
+
type: postType,
|
|
140
|
+
// Make `title` property consistent with that in `fetchLinkSuggestions` where the `rendered` title (containing HTML entities)
|
|
141
|
+
// is also being decoded. By being consistent in both locations we avoid having to branch in the rendering output code.
|
|
142
|
+
// Ideally in the future we will update both APIs to utilise the "raw" form of the title which is better suited to edit contexts.
|
|
143
|
+
// e.g.
|
|
144
|
+
// - title.raw = "Yes & No"
|
|
145
|
+
// - title.rendered = "Yes & No"
|
|
146
|
+
// - decodeEntities( title.rendered ) = "Yes & No"
|
|
147
|
+
// See:
|
|
148
|
+
// - https://github.com/WordPress/gutenberg/pull/41063
|
|
149
|
+
// - https://github.com/WordPress/gutenberg/blob/a1e1fdc0e6278457e9f4fc0b31ac6d2095f5450b/packages/core-data/src/fetch/__experimental-fetch-link-suggestions.js#L212-L218
|
|
150
|
+
title: decodeEntities( page.title.rendered ),
|
|
151
|
+
url: page.link,
|
|
152
|
+
kind: 'post-type',
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const { label, url, opensInNewTab, type, kind } = props.link;
|
|
157
|
+
const link = {
|
|
158
|
+
url,
|
|
159
|
+
opensInNewTab,
|
|
160
|
+
title: label && stripHTML( label ),
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
<Popover
|
|
165
|
+
placement="bottom"
|
|
166
|
+
onClose={ props.onClose }
|
|
167
|
+
anchor={ props.anchor }
|
|
168
|
+
shift
|
|
169
|
+
>
|
|
170
|
+
<LinkControl
|
|
171
|
+
hasTextControl
|
|
172
|
+
hasRichPreviews
|
|
173
|
+
className={ props.className }
|
|
174
|
+
value={ link }
|
|
175
|
+
showInitialSuggestions={ true }
|
|
176
|
+
withCreateSuggestion={ props.hasCreateSuggestion }
|
|
177
|
+
createSuggestion={ handleCreate }
|
|
178
|
+
createSuggestionButtonText={ ( searchTerm ) => {
|
|
179
|
+
let format;
|
|
180
|
+
|
|
181
|
+
if ( type === 'post' ) {
|
|
182
|
+
/* translators: %s: search term. */
|
|
183
|
+
format = __( 'Create draft post: <mark>%s</mark>' );
|
|
184
|
+
} else {
|
|
185
|
+
/* translators: %s: search term. */
|
|
186
|
+
format = __( 'Create draft page: <mark>%s</mark>' );
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return createInterpolateElement(
|
|
190
|
+
sprintf( format, searchTerm ),
|
|
191
|
+
{
|
|
192
|
+
mark: <mark />,
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
} }
|
|
196
|
+
noDirectEntry={ !! type }
|
|
197
|
+
noURLSuggestion={ !! type }
|
|
198
|
+
suggestionsQuery={ getSuggestionsQuery( type, kind ) }
|
|
199
|
+
onChange={ props.onChange }
|
|
200
|
+
onRemove={ props.onRemove }
|
|
201
|
+
renderControlBottom={
|
|
202
|
+
! url
|
|
203
|
+
? () => (
|
|
204
|
+
<LinkControlTransforms
|
|
205
|
+
clientId={ props.clientId }
|
|
206
|
+
/>
|
|
207
|
+
)
|
|
208
|
+
: null
|
|
209
|
+
}
|
|
210
|
+
/>
|
|
211
|
+
</Popover>
|
|
212
|
+
);
|
|
213
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { updateAttributes } from '../update-attributes';
|
|
5
5
|
|
|
6
6
|
describe( 'edit', () => {
|
|
7
|
-
describe( '
|
|
7
|
+
describe( 'updateAttributes', () => {
|
|
8
8
|
// Data shapes are linked to fetchLinkSuggestions from
|
|
9
9
|
// core-data/src/fetch/__experimental-fetch-link-suggestions.js.
|
|
10
10
|
it( 'can update a post link', () => {
|
|
@@ -18,10 +18,7 @@ describe( 'edit', () => {
|
|
|
18
18
|
type: 'post',
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
linkSuggestion,
|
|
23
|
-
setAttributes
|
|
24
|
-
);
|
|
21
|
+
updateAttributes( linkSuggestion, setAttributes );
|
|
25
22
|
expect( setAttributes ).toHaveBeenCalledWith( {
|
|
26
23
|
id: 1337,
|
|
27
24
|
label: 'Menu Test',
|
|
@@ -42,10 +39,7 @@ describe( 'edit', () => {
|
|
|
42
39
|
type: 'page',
|
|
43
40
|
url: 'http://wordpress.local/sample-page/',
|
|
44
41
|
};
|
|
45
|
-
|
|
46
|
-
linkSuggestion,
|
|
47
|
-
setAttributes
|
|
48
|
-
);
|
|
42
|
+
updateAttributes( linkSuggestion, setAttributes );
|
|
49
43
|
expect( setAttributes ).toHaveBeenCalledWith( {
|
|
50
44
|
id: 2,
|
|
51
45
|
kind: 'post-type',
|
|
@@ -66,10 +60,7 @@ describe( 'edit', () => {
|
|
|
66
60
|
type: 'post_tag',
|
|
67
61
|
url: 'http://wordpress.local/tag/bar/',
|
|
68
62
|
};
|
|
69
|
-
|
|
70
|
-
linkSuggestion,
|
|
71
|
-
setAttributes
|
|
72
|
-
);
|
|
63
|
+
updateAttributes( linkSuggestion, setAttributes );
|
|
73
64
|
expect( setAttributes ).toHaveBeenCalledWith( {
|
|
74
65
|
id: 15,
|
|
75
66
|
kind: 'taxonomy',
|
|
@@ -90,10 +81,7 @@ describe( 'edit', () => {
|
|
|
90
81
|
type: 'category',
|
|
91
82
|
url: 'http://wordpress.local/category/cats/',
|
|
92
83
|
};
|
|
93
|
-
|
|
94
|
-
linkSuggestion,
|
|
95
|
-
setAttributes
|
|
96
|
-
);
|
|
84
|
+
updateAttributes( linkSuggestion, setAttributes );
|
|
97
85
|
expect( setAttributes ).toHaveBeenCalledWith( {
|
|
98
86
|
id: 9,
|
|
99
87
|
kind: 'taxonomy',
|
|
@@ -114,10 +102,7 @@ describe( 'edit', () => {
|
|
|
114
102
|
type: 'portfolio',
|
|
115
103
|
url: 'http://wordpress.local/portfolio/fall/',
|
|
116
104
|
};
|
|
117
|
-
|
|
118
|
-
linkSuggestion,
|
|
119
|
-
setAttributes
|
|
120
|
-
);
|
|
105
|
+
updateAttributes( linkSuggestion, setAttributes );
|
|
121
106
|
expect( setAttributes ).toHaveBeenCalledWith( {
|
|
122
107
|
id: 131,
|
|
123
108
|
kind: 'post-type',
|
|
@@ -138,10 +123,7 @@ describe( 'edit', () => {
|
|
|
138
123
|
type: 'portfolio_tag',
|
|
139
124
|
url: 'http://wordpress.local/portfolio_tag/PortfolioTag/',
|
|
140
125
|
};
|
|
141
|
-
|
|
142
|
-
linkSuggestion,
|
|
143
|
-
setAttributes
|
|
144
|
-
);
|
|
126
|
+
updateAttributes( linkSuggestion, setAttributes );
|
|
145
127
|
expect( setAttributes ).toHaveBeenCalledWith( {
|
|
146
128
|
id: 4,
|
|
147
129
|
kind: 'taxonomy',
|
|
@@ -162,10 +144,7 @@ describe( 'edit', () => {
|
|
|
162
144
|
type: 'portfolio_category',
|
|
163
145
|
url: 'http://wordpress.local/portfolio_category/Portfolio-category/',
|
|
164
146
|
};
|
|
165
|
-
|
|
166
|
-
linkSuggestion,
|
|
167
|
-
setAttributes
|
|
168
|
-
);
|
|
147
|
+
updateAttributes( linkSuggestion, setAttributes );
|
|
169
148
|
expect( setAttributes ).toHaveBeenCalledWith( {
|
|
170
149
|
id: 2,
|
|
171
150
|
kind: 'taxonomy',
|
|
@@ -186,10 +165,7 @@ describe( 'edit', () => {
|
|
|
186
165
|
type: 'post-format',
|
|
187
166
|
url: 'http://wordpress.local/type/video/',
|
|
188
167
|
};
|
|
189
|
-
|
|
190
|
-
linkSuggestion,
|
|
191
|
-
setAttributes
|
|
192
|
-
);
|
|
168
|
+
updateAttributes( linkSuggestion, setAttributes );
|
|
193
169
|
// post_format returns a slug ID value from the Search API
|
|
194
170
|
// we do not persist this ID since we expect this value to be a post or term ID.
|
|
195
171
|
expect( setAttributes ).toHaveBeenCalledWith( {
|
|
@@ -208,10 +184,7 @@ describe( 'edit', () => {
|
|
|
208
184
|
opensInNewTab: false,
|
|
209
185
|
url: 'www.wordpress.org',
|
|
210
186
|
};
|
|
211
|
-
|
|
212
|
-
linkSuggestion,
|
|
213
|
-
setAttributes
|
|
214
|
-
);
|
|
187
|
+
updateAttributes( linkSuggestion, setAttributes );
|
|
215
188
|
expect( setAttributes ).toHaveBeenCalledWith( {
|
|
216
189
|
opensInNewTab: false,
|
|
217
190
|
url: 'www.wordpress.org',
|
|
@@ -229,10 +202,7 @@ describe( 'edit', () => {
|
|
|
229
202
|
type: 'URL',
|
|
230
203
|
url: 'http://www.wordpress.org',
|
|
231
204
|
};
|
|
232
|
-
|
|
233
|
-
linkSuggestion,
|
|
234
|
-
setAttributes
|
|
235
|
-
);
|
|
205
|
+
updateAttributes( linkSuggestion, setAttributes );
|
|
236
206
|
expect( setAttributes ).toHaveBeenCalledWith( {
|
|
237
207
|
opensInNewTab: false,
|
|
238
208
|
label: 'www.wordpress.org',
|
|
@@ -250,10 +220,7 @@ describe( 'edit', () => {
|
|
|
250
220
|
type: 'mailto',
|
|
251
221
|
url: 'mailto:foo@example.com',
|
|
252
222
|
};
|
|
253
|
-
|
|
254
|
-
linkSuggestion,
|
|
255
|
-
setAttributes
|
|
256
|
-
);
|
|
223
|
+
updateAttributes( linkSuggestion, setAttributes );
|
|
257
224
|
expect( setAttributes ).toHaveBeenCalledWith( {
|
|
258
225
|
opensInNewTab: false,
|
|
259
226
|
label: 'mailto:foo@example.com',
|
|
@@ -272,10 +239,7 @@ describe( 'edit', () => {
|
|
|
272
239
|
type: 'internal',
|
|
273
240
|
url: '#foo',
|
|
274
241
|
};
|
|
275
|
-
|
|
276
|
-
linkSuggestion,
|
|
277
|
-
setAttributes
|
|
278
|
-
);
|
|
242
|
+
updateAttributes( linkSuggestion, setAttributes );
|
|
279
243
|
expect( setAttributes ).toHaveBeenCalledWith( {
|
|
280
244
|
opensInNewTab: false,
|
|
281
245
|
label: '#foo',
|
|
@@ -294,10 +258,7 @@ describe( 'edit', () => {
|
|
|
294
258
|
type: 'tel',
|
|
295
259
|
url: 'tel:5555555',
|
|
296
260
|
};
|
|
297
|
-
|
|
298
|
-
linkSuggestion,
|
|
299
|
-
setAttributes
|
|
300
|
-
);
|
|
261
|
+
updateAttributes( linkSuggestion, setAttributes );
|
|
301
262
|
expect( setAttributes ).toHaveBeenCalledWith( {
|
|
302
263
|
opensInNewTab: false,
|
|
303
264
|
label: 'tel:5555555',
|
|
@@ -319,10 +280,7 @@ describe( 'edit', () => {
|
|
|
319
280
|
type: 'URL',
|
|
320
281
|
url: 'https://www.wordpress.org',
|
|
321
282
|
};
|
|
322
|
-
|
|
323
|
-
linkSuggestion,
|
|
324
|
-
setAttributes
|
|
325
|
-
);
|
|
283
|
+
updateAttributes( linkSuggestion, setAttributes );
|
|
326
284
|
expect( setAttributes ).toHaveBeenCalledWith( {
|
|
327
285
|
opensInNewTab: false,
|
|
328
286
|
label: 'www.wordpress.org',
|
|
@@ -339,10 +297,7 @@ describe( 'edit', () => {
|
|
|
339
297
|
type: 'URL',
|
|
340
298
|
url: 'wordpress.org',
|
|
341
299
|
};
|
|
342
|
-
|
|
343
|
-
linkSuggestion,
|
|
344
|
-
setAttributes
|
|
345
|
-
);
|
|
300
|
+
updateAttributes( linkSuggestion, setAttributes );
|
|
346
301
|
expect( setAttributes ).toHaveBeenCalledWith( {
|
|
347
302
|
opensInNewTab: false,
|
|
348
303
|
label: 'Custom Title',
|
|
@@ -359,10 +314,7 @@ describe( 'edit', () => {
|
|
|
359
314
|
type: 'URL',
|
|
360
315
|
url: 'https://wordpress.org',
|
|
361
316
|
};
|
|
362
|
-
|
|
363
|
-
linkSuggestion,
|
|
364
|
-
setAttributes
|
|
365
|
-
);
|
|
317
|
+
updateAttributes( linkSuggestion, setAttributes );
|
|
366
318
|
expect( setAttributes ).toHaveBeenCalledWith( {
|
|
367
319
|
opensInNewTab: false,
|
|
368
320
|
label: 'Custom Title',
|
|
@@ -380,10 +332,7 @@ describe( 'edit', () => {
|
|
|
380
332
|
type: 'URL',
|
|
381
333
|
url: 'http://wordpress.org/?s=<>',
|
|
382
334
|
};
|
|
383
|
-
|
|
384
|
-
linkSuggestion,
|
|
385
|
-
setAttributes
|
|
386
|
-
);
|
|
335
|
+
updateAttributes( linkSuggestion, setAttributes );
|
|
387
336
|
expect( setAttributes ).toHaveBeenCalledWith( {
|
|
388
337
|
opensInNewTab: false,
|
|
389
338
|
label: 'Custom Title',
|
|
@@ -408,11 +357,7 @@ describe( 'edit', () => {
|
|
|
408
357
|
type: 'post',
|
|
409
358
|
};
|
|
410
359
|
|
|
411
|
-
|
|
412
|
-
linkSuggestion,
|
|
413
|
-
setAttributes,
|
|
414
|
-
mockState
|
|
415
|
-
);
|
|
360
|
+
updateAttributes( linkSuggestion, setAttributes, mockState );
|
|
416
361
|
expect( mockState ).toEqual( {
|
|
417
362
|
id: 1337,
|
|
418
363
|
label: 'Menu Test',
|
|
@@ -422,7 +367,7 @@ describe( 'edit', () => {
|
|
|
422
367
|
url: 'https://wordpress.local/menu-test/',
|
|
423
368
|
} );
|
|
424
369
|
// Click on the existing link control, and toggle opens new tab.
|
|
425
|
-
|
|
370
|
+
updateAttributes(
|
|
426
371
|
{
|
|
427
372
|
url: 'https://wordpress.local/menu-test/',
|
|
428
373
|
opensInNewTab: true,
|
|
@@ -453,11 +398,7 @@ describe( 'edit', () => {
|
|
|
453
398
|
type: 'post',
|
|
454
399
|
};
|
|
455
400
|
|
|
456
|
-
|
|
457
|
-
linkSuggestion,
|
|
458
|
-
setAttributes,
|
|
459
|
-
mockState
|
|
460
|
-
);
|
|
401
|
+
updateAttributes( linkSuggestion, setAttributes, mockState );
|
|
461
402
|
expect( mockState ).toEqual( {
|
|
462
403
|
id: 1337,
|
|
463
404
|
label: 'Menu Test',
|
|
@@ -467,7 +408,7 @@ describe( 'edit', () => {
|
|
|
467
408
|
url: 'https://wordpress.local/menu-test/',
|
|
468
409
|
} );
|
|
469
410
|
// Click on the existing link control, and toggle opens new tab.
|
|
470
|
-
|
|
411
|
+
updateAttributes(
|
|
471
412
|
{
|
|
472
413
|
url: 'https://wordpress.local/foo/',
|
|
473
414
|
opensInNewTab: false,
|
|
@@ -40,6 +40,13 @@ const transforms = {
|
|
|
40
40
|
return createBlock( 'core/navigation-link' );
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
|
+
{
|
|
44
|
+
type: 'block',
|
|
45
|
+
blocks: [ 'core/page-list' ],
|
|
46
|
+
transform: () => {
|
|
47
|
+
return createBlock( 'core/navigation-link' );
|
|
48
|
+
},
|
|
49
|
+
},
|
|
43
50
|
],
|
|
44
51
|
to: [
|
|
45
52
|
{
|
|
@@ -91,6 +98,13 @@ const transforms = {
|
|
|
91
98
|
} );
|
|
92
99
|
},
|
|
93
100
|
},
|
|
101
|
+
{
|
|
102
|
+
type: 'block',
|
|
103
|
+
blocks: [ 'core/page-list' ],
|
|
104
|
+
transform: () => {
|
|
105
|
+
return createBlock( 'core/page-list' );
|
|
106
|
+
},
|
|
107
|
+
},
|
|
94
108
|
],
|
|
95
109
|
};
|
|
96
110
|
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { safeDecodeURI } from '@wordpress/url';
|
|
5
|
+
import { escapeHTML } from '@wordpress/escape-html';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Navigation Link Block Attributes
|
|
12
|
+
*
|
|
13
|
+
* @typedef {Object} WPNavigationLinkBlockAttributes
|
|
14
|
+
*
|
|
15
|
+
* @property {string} [label] Link text.
|
|
16
|
+
* @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.
|
|
17
|
+
* @property {string} [type] The type such as post, page, tag, category and other custom types.
|
|
18
|
+
* @property {string} [rel] The relationship of the linked URL.
|
|
19
|
+
* @property {number} [id] A post or term id.
|
|
20
|
+
* @property {boolean} [opensInNewTab] Sets link target to _blank when true.
|
|
21
|
+
* @property {string} [url] Link href.
|
|
22
|
+
* @property {string} [title] Link title attribute.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Link Control onChange handler that updates block attributes when a setting is changed.
|
|
26
|
+
*
|
|
27
|
+
* @param {Object} updatedValue New block attributes to update.
|
|
28
|
+
* @param {Function} setAttributes Block attribute update function.
|
|
29
|
+
* @param {WPNavigationLinkBlockAttributes} blockAttributes Current block attributes.
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
export const updateAttributes = (
|
|
34
|
+
updatedValue = {},
|
|
35
|
+
setAttributes,
|
|
36
|
+
blockAttributes = {}
|
|
37
|
+
) => {
|
|
38
|
+
const {
|
|
39
|
+
label: originalLabel = '',
|
|
40
|
+
kind: originalKind = '',
|
|
41
|
+
type: originalType = '',
|
|
42
|
+
} = blockAttributes;
|
|
43
|
+
|
|
44
|
+
const {
|
|
45
|
+
title: newLabel = '', // the title of any provided Post.
|
|
46
|
+
url: newUrl = '',
|
|
47
|
+
opensInNewTab,
|
|
48
|
+
id,
|
|
49
|
+
kind: newKind = originalKind,
|
|
50
|
+
type: newType = originalType,
|
|
51
|
+
} = updatedValue;
|
|
52
|
+
|
|
53
|
+
const newLabelWithoutHttp = newLabel.replace( /http(s?):\/\//gi, '' );
|
|
54
|
+
const newUrlWithoutHttp = newUrl.replace( /http(s?):\/\//gi, '' );
|
|
55
|
+
|
|
56
|
+
const useNewLabel =
|
|
57
|
+
newLabel &&
|
|
58
|
+
newLabel !== originalLabel &&
|
|
59
|
+
// LinkControl without the title field relies
|
|
60
|
+
// on the check below. Specifically, it assumes that
|
|
61
|
+
// the URL is the same as a title.
|
|
62
|
+
// This logic a) looks suspicious and b) should really
|
|
63
|
+
// live in the LinkControl and not here. It's a great
|
|
64
|
+
// candidate for future refactoring.
|
|
65
|
+
newLabelWithoutHttp !== newUrlWithoutHttp;
|
|
66
|
+
|
|
67
|
+
// Unfortunately this causes the escaping model to be inverted.
|
|
68
|
+
// The escaped content is stored in the block attributes (and ultimately in the database),
|
|
69
|
+
// and then the raw data is "recovered" when outputting into the DOM.
|
|
70
|
+
// It would be preferable to store the **raw** data in the block attributes and escape it in JS.
|
|
71
|
+
// Why? Because there isn't one way to escape data. Depending on the context, you need to do
|
|
72
|
+
// different transforms. It doesn't make sense to me to choose one of them for the purposes of storage.
|
|
73
|
+
// See also:
|
|
74
|
+
// - https://github.com/WordPress/gutenberg/pull/41063
|
|
75
|
+
// - https://github.com/WordPress/gutenberg/pull/18617.
|
|
76
|
+
const label = useNewLabel
|
|
77
|
+
? escapeHTML( newLabel )
|
|
78
|
+
: originalLabel || escapeHTML( newUrlWithoutHttp );
|
|
79
|
+
|
|
80
|
+
// In https://github.com/WordPress/gutenberg/pull/24670 we decided to use "tag" in favor of "post_tag"
|
|
81
|
+
const type = newType === 'post_tag' ? 'tag' : newType.replace( '-', '_' );
|
|
82
|
+
|
|
83
|
+
const isBuiltInType =
|
|
84
|
+
[ 'post', 'page', 'tag', 'category' ].indexOf( type ) > -1;
|
|
85
|
+
|
|
86
|
+
const isCustomLink =
|
|
87
|
+
( ! newKind && ! isBuiltInType ) || newKind === 'custom';
|
|
88
|
+
const kind = isCustomLink ? 'custom' : newKind;
|
|
89
|
+
|
|
90
|
+
setAttributes( {
|
|
91
|
+
// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.
|
|
92
|
+
...( newUrl && { url: encodeURI( safeDecodeURI( newUrl ) ) } ),
|
|
93
|
+
...( label && { label } ),
|
|
94
|
+
...( undefined !== opensInNewTab && { opensInNewTab } ),
|
|
95
|
+
...( id && Number.isInteger( id ) && { id } ),
|
|
96
|
+
...( kind && { kind } ),
|
|
97
|
+
...( type && type !== 'URL' && { type } ),
|
|
98
|
+
} );
|
|
99
|
+
};
|