@wordpress/block-library 9.38.0 → 9.39.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 +2 -0
- package/build/block/block.json +2 -1
- package/build/breadcrumbs/edit.cjs +15 -5
- package/build/breadcrumbs/edit.cjs.map +2 -2
- package/build/breadcrumbs/index.cjs +1 -0
- package/build/breadcrumbs/index.cjs.map +2 -2
- package/build/button/index.cjs +3 -0
- package/build/button/index.cjs.map +2 -2
- package/build/comment-date/block.json +1 -0
- package/build/comment-edit-link/block.json +1 -3
- package/build/comment-edit-link/deprecated.cjs +91 -0
- package/build/comment-edit-link/deprecated.cjs.map +7 -0
- package/build/comment-edit-link/edit.cjs +6 -18
- package/build/comment-edit-link/edit.cjs.map +3 -3
- package/build/comment-edit-link/index.cjs +2 -0
- package/build/comment-edit-link/index.cjs.map +3 -3
- package/build/comment-reply-link/block.json +1 -5
- package/build/comment-reply-link/deprecated.cjs +84 -0
- package/build/comment-reply-link/deprecated.cjs.map +7 -0
- package/build/comment-reply-link/edit.cjs +10 -23
- package/build/comment-reply-link/edit.cjs.map +3 -3
- package/build/comment-reply-link/index.cjs +2 -0
- package/build/comment-reply-link/index.cjs.map +3 -3
- package/build/comments-title/block.json +1 -3
- package/build/comments-title/deprecated.cjs +148 -24
- package/build/comments-title/deprecated.cjs.map +3 -3
- package/build/comments-title/edit.cjs +17 -31
- package/build/comments-title/edit.cjs.map +3 -3
- package/build/cover/edit/block-controls.cjs +10 -2
- package/build/cover/edit/block-controls.cjs.map +2 -2
- package/build/cover/edit/embed-video-url-input.cjs +6 -2
- package/build/cover/edit/embed-video-url-input.cjs.map +2 -2
- package/build/cover/edit/inspector-controls.cjs +1 -1
- package/build/cover/edit/inspector-controls.cjs.map +2 -2
- package/build/details/index.cjs +3 -0
- package/build/details/index.cjs.map +2 -2
- package/build/embed/util.cjs +9 -0
- package/build/embed/util.cjs.map +2 -2
- package/build/freeform/block.json +2 -1
- package/build/heading/index.cjs +3 -0
- package/build/heading/index.cjs.map +2 -2
- package/build/html/block.json +2 -1
- package/build/image/image.cjs +43 -9
- package/build/image/image.cjs.map +2 -2
- package/build/image/index.cjs +1 -1
- package/build/image/index.cjs.map +2 -2
- package/build/index.cjs +6 -0
- package/build/index.cjs.map +2 -2
- package/build/list-item/index.cjs +12 -1
- package/build/list-item/index.cjs.map +2 -2
- package/build/missing/block.json +2 -1
- package/build/more/block.json +2 -1
- package/build/more/index.cjs +1 -1
- package/build/more/index.cjs.map +2 -2
- package/build/navigation/block.json +5 -4
- package/build/navigation/deprecated.cjs +133 -5
- package/build/navigation/deprecated.cjs.map +2 -2
- package/build/navigation/edit/deleted-overlay-warning.cjs +70 -0
- package/build/navigation/edit/deleted-overlay-warning.cjs.map +7 -0
- package/build/navigation/edit/index.cjs +143 -65
- package/build/navigation/edit/index.cjs.map +3 -3
- package/build/navigation/edit/overlay-panel.cjs +10 -1
- package/build/navigation/edit/overlay-panel.cjs.map +3 -3
- package/build/navigation/edit/overlay-preview.cjs +120 -0
- package/build/navigation/edit/overlay-preview.cjs.map +7 -0
- package/build/navigation/edit/overlay-template-part-selector.cjs +59 -24
- package/build/navigation/edit/overlay-template-part-selector.cjs.map +3 -3
- package/build/navigation/edit/responsive-wrapper.cjs +12 -1
- package/build/navigation/edit/responsive-wrapper.cjs.map +3 -3
- package/build/navigation/edit/use-create-overlay.cjs +19 -2
- package/build/navigation/edit/use-create-overlay.cjs.map +3 -3
- package/build/navigation/utils/get-submenu-visibility.cjs +37 -0
- package/build/navigation/utils/get-submenu-visibility.cjs.map +7 -0
- package/build/navigation-link/edit.cjs +2 -40
- package/build/navigation-link/edit.cjs.map +2 -2
- package/build/navigation-link/shared/index.cjs +6 -0
- package/build/navigation-link/shared/index.cjs.map +2 -2
- package/build/navigation-link/shared/select-label-text.cjs +40 -0
- package/build/navigation-link/shared/select-label-text.cjs.map +7 -0
- package/build/navigation-link/shared/use-is-dragging-within.cjs +59 -0
- package/build/navigation-link/shared/use-is-dragging-within.cjs.map +7 -0
- package/build/navigation-submenu/block.json +1 -1
- package/build/navigation-submenu/edit.cjs +8 -47
- package/build/navigation-submenu/edit.cjs.map +2 -2
- package/build/navigation-submenu/index.cjs +2 -2
- package/build/navigation-submenu/index.cjs.map +2 -2
- package/build/nextpage/block.json +2 -1
- package/build/paragraph/block.json +1 -0
- package/build/paragraph/index.cjs +1 -1
- package/build/paragraph/index.cjs.map +2 -2
- package/build/post-excerpt/edit.cjs +1 -1
- package/build/post-excerpt/edit.cjs.map +2 -2
- package/build/shortcode/block.json +2 -1
- package/build/tab/add-tab-toolbar-control.cjs +31 -9
- package/build/tab/add-tab-toolbar-control.cjs.map +2 -2
- package/build/tab/block.json +18 -4
- package/build/tab/controls.cjs +4 -8
- package/build/tab/controls.cjs.map +3 -3
- package/build/tab/edit.cjs +46 -118
- package/build/tab/edit.cjs.map +3 -3
- package/build/tab/remove-tab-toolbar-control.cjs +91 -0
- package/build/tab/remove-tab-toolbar-control.cjs.map +7 -0
- package/build/tab/save.cjs +2 -2
- package/build/tab/save.cjs.map +2 -2
- package/build/tab-panels/block.json +70 -0
- package/build/tab-panels/edit.cjs +63 -0
- package/build/tab-panels/edit.cjs.map +7 -0
- package/build/tab-panels/icon.cjs +29 -0
- package/build/tab-panels/icon.cjs.map +7 -0
- package/build/tab-panels/index.cjs +58 -0
- package/build/tab-panels/index.cjs.map +7 -0
- package/build/tab-panels/save.cjs +33 -0
- package/build/tab-panels/save.cjs.map +7 -0
- package/build/tabs/block.json +61 -90
- package/build/tabs/controls.cjs +19 -221
- package/build/tabs/controls.cjs.map +3 -3
- package/build/tabs/deprecated.cjs +179 -0
- package/build/tabs/deprecated.cjs.map +7 -0
- package/build/tabs/edit.cjs +84 -62
- package/build/tabs/edit.cjs.map +3 -3
- package/build/tabs/index.cjs +3 -1
- package/build/tabs/index.cjs.map +3 -3
- package/build/tabs/save.cjs +6 -9
- package/build/tabs/save.cjs.map +2 -2
- package/build/tabs-menu/block.json +77 -0
- package/build/tabs-menu/edit.cjs +204 -0
- package/build/tabs-menu/edit.cjs.map +7 -0
- package/build/tabs-menu/icon.cjs +29 -0
- package/build/tabs-menu/icon.cjs.map +7 -0
- package/build/tabs-menu/index.cjs +58 -0
- package/build/tabs-menu/index.cjs.map +7 -0
- package/build/tabs-menu/save.cjs +35 -0
- package/build/tabs-menu/save.cjs.map +7 -0
- package/build/tabs-menu-item/block.json +98 -0
- package/build/tabs-menu-item/controls.cjs +247 -0
- package/build/tabs-menu-item/controls.cjs.map +7 -0
- package/build/tabs-menu-item/edit.cjs +272 -0
- package/build/tabs-menu-item/edit.cjs.map +7 -0
- package/build/tabs-menu-item/icon.cjs +29 -0
- package/build/tabs-menu-item/icon.cjs.map +7 -0
- package/build/tabs-menu-item/index.cjs +58 -0
- package/build/tabs-menu-item/index.cjs.map +7 -0
- package/build/tabs-menu-item/save.cjs +50 -0
- package/build/tabs-menu-item/save.cjs.map +7 -0
- package/build/template-part/edit/index.cjs +2 -2
- package/build/template-part/edit/index.cjs.map +2 -2
- package/build/utils/caption.cjs +4 -6
- package/build/utils/caption.cjs.map +3 -3
- package/build/verse/block.json +1 -3
- package/build/verse/deprecated.cjs +74 -5
- package/build/verse/deprecated.cjs.map +3 -3
- package/build/verse/edit.cjs +33 -48
- package/build/verse/edit.cjs.map +3 -3
- package/build/verse/save.cjs +2 -16
- package/build/verse/save.cjs.map +3 -3
- package/build/video/edit.cjs +4 -2
- package/build/video/edit.cjs.map +2 -2
- package/build-module/block/block.json +2 -1
- package/build-module/breadcrumbs/edit.mjs +15 -5
- package/build-module/breadcrumbs/edit.mjs.map +2 -2
- package/build-module/breadcrumbs/index.mjs +1 -0
- package/build-module/breadcrumbs/index.mjs.map +2 -2
- package/build-module/button/index.mjs +3 -0
- package/build-module/button/index.mjs.map +2 -2
- package/build-module/comment-date/block.json +1 -0
- package/build-module/comment-edit-link/block.json +1 -3
- package/build-module/comment-edit-link/deprecated.mjs +60 -0
- package/build-module/comment-edit-link/deprecated.mjs.map +7 -0
- package/build-module/comment-edit-link/edit.mjs +7 -24
- package/build-module/comment-edit-link/edit.mjs.map +2 -2
- package/build-module/comment-edit-link/index.mjs +2 -0
- package/build-module/comment-edit-link/index.mjs.map +2 -2
- package/build-module/comment-reply-link/block.json +1 -5
- package/build-module/comment-reply-link/deprecated.mjs +53 -0
- package/build-module/comment-reply-link/deprecated.mjs.map +7 -0
- package/build-module/comment-reply-link/edit.mjs +12 -29
- package/build-module/comment-reply-link/edit.mjs.map +2 -2
- package/build-module/comment-reply-link/index.mjs +2 -0
- package/build-module/comment-reply-link/index.mjs.map +2 -2
- package/build-module/comments-title/block.json +1 -3
- package/build-module/comments-title/deprecated.mjs +148 -24
- package/build-module/comments-title/deprecated.mjs.map +2 -2
- package/build-module/comments-title/edit.mjs +17 -32
- package/build-module/comments-title/edit.mjs.map +2 -2
- package/build-module/cover/edit/block-controls.mjs +11 -3
- package/build-module/cover/edit/block-controls.mjs.map +2 -2
- package/build-module/cover/edit/embed-video-url-input.mjs +6 -2
- package/build-module/cover/edit/embed-video-url-input.mjs.map +2 -2
- package/build-module/cover/edit/inspector-controls.mjs +1 -1
- package/build-module/cover/edit/inspector-controls.mjs.map +2 -2
- package/build-module/details/index.mjs +3 -0
- package/build-module/details/index.mjs.map +2 -2
- package/build-module/embed/util.mjs +8 -0
- package/build-module/embed/util.mjs.map +2 -2
- package/build-module/freeform/block.json +2 -1
- package/build-module/heading/index.mjs +3 -0
- package/build-module/heading/index.mjs.map +2 -2
- package/build-module/html/block.json +2 -1
- package/build-module/image/image.mjs +43 -9
- package/build-module/image/image.mjs.map +2 -2
- package/build-module/image/index.mjs +1 -1
- package/build-module/image/index.mjs.map +2 -2
- package/build-module/index.mjs +6 -0
- package/build-module/index.mjs.map +2 -2
- package/build-module/list-item/index.mjs +12 -1
- package/build-module/list-item/index.mjs.map +2 -2
- package/build-module/missing/block.json +2 -1
- package/build-module/more/block.json +2 -1
- package/build-module/more/index.mjs +1 -1
- package/build-module/more/index.mjs.map +2 -2
- package/build-module/navigation/block.json +5 -4
- package/build-module/navigation/deprecated.mjs +133 -5
- package/build-module/navigation/deprecated.mjs.map +2 -2
- package/build-module/navigation/edit/deleted-overlay-warning.mjs +49 -0
- package/build-module/navigation/edit/deleted-overlay-warning.mjs.map +7 -0
- package/build-module/navigation/edit/index.mjs +145 -65
- package/build-module/navigation/edit/index.mjs.map +2 -2
- package/build-module/navigation/edit/overlay-panel.mjs +10 -1
- package/build-module/navigation/edit/overlay-panel.mjs.map +2 -2
- package/build-module/navigation/edit/overlay-preview.mjs +99 -0
- package/build-module/navigation/edit/overlay-preview.mjs.map +7 -0
- package/build-module/navigation/edit/overlay-template-part-selector.mjs +61 -26
- package/build-module/navigation/edit/overlay-template-part-selector.mjs.map +2 -2
- package/build-module/navigation/edit/responsive-wrapper.mjs +12 -1
- package/build-module/navigation/edit/responsive-wrapper.mjs.map +2 -2
- package/build-module/navigation/edit/use-create-overlay.mjs +21 -4
- package/build-module/navigation/edit/use-create-overlay.mjs.map +2 -2
- package/build-module/navigation/utils/get-submenu-visibility.mjs +12 -0
- package/build-module/navigation/utils/get-submenu-visibility.mjs.map +7 -0
- package/build-module/navigation-link/edit.mjs +4 -40
- package/build-module/navigation-link/edit.mjs.map +2 -2
- package/build-module/navigation-link/shared/index.mjs +4 -0
- package/build-module/navigation-link/shared/index.mjs.map +2 -2
- package/build-module/navigation-link/shared/select-label-text.mjs +15 -0
- package/build-module/navigation-link/shared/select-label-text.mjs.map +7 -0
- package/build-module/navigation-link/shared/use-is-dragging-within.mjs +34 -0
- package/build-module/navigation-link/shared/use-is-dragging-within.mjs.map +7 -0
- package/build-module/navigation-submenu/block.json +1 -1
- package/build-module/navigation-submenu/edit.mjs +10 -47
- package/build-module/navigation-submenu/edit.mjs.map +2 -2
- package/build-module/navigation-submenu/index.mjs +2 -2
- package/build-module/navigation-submenu/index.mjs.map +2 -2
- package/build-module/nextpage/block.json +2 -1
- package/build-module/paragraph/block.json +1 -0
- package/build-module/paragraph/index.mjs +1 -1
- package/build-module/paragraph/index.mjs.map +2 -2
- package/build-module/post-excerpt/edit.mjs +1 -1
- package/build-module/post-excerpt/edit.mjs.map +2 -2
- package/build-module/shortcode/block.json +2 -1
- package/build-module/tab/add-tab-toolbar-control.mjs +32 -10
- package/build-module/tab/add-tab-toolbar-control.mjs.map +2 -2
- package/build-module/tab/block.json +18 -4
- package/build-module/tab/controls.mjs +4 -8
- package/build-module/tab/controls.mjs.map +2 -2
- package/build-module/tab/edit.mjs +48 -128
- package/build-module/tab/edit.mjs.map +2 -2
- package/build-module/tab/remove-tab-toolbar-control.mjs +73 -0
- package/build-module/tab/remove-tab-toolbar-control.mjs.map +7 -0
- package/build-module/tab/save.mjs +2 -2
- package/build-module/tab/save.mjs.map +2 -2
- package/build-module/tab-panels/block.json +70 -0
- package/build-module/tab-panels/edit.mjs +36 -0
- package/build-module/tab-panels/edit.mjs.map +7 -0
- package/build-module/tab-panels/icon.mjs +8 -0
- package/build-module/tab-panels/icon.mjs.map +7 -0
- package/build-module/tab-panels/index.mjs +20 -0
- package/build-module/tab-panels/index.mjs.map +7 -0
- package/build-module/tab-panels/save.mjs +12 -0
- package/build-module/tab-panels/save.mjs.map +7 -0
- package/build-module/tabs/block.json +61 -90
- package/build-module/tabs/controls.mjs +21 -228
- package/build-module/tabs/controls.mjs.map +2 -2
- package/build-module/tabs/deprecated.mjs +158 -0
- package/build-module/tabs/deprecated.mjs.map +7 -0
- package/build-module/tabs/edit.mjs +87 -64
- package/build-module/tabs/edit.mjs.map +2 -2
- package/build-module/tabs/index.mjs +3 -1
- package/build-module/tabs/index.mjs.map +2 -2
- package/build-module/tabs/save.mjs +7 -10
- package/build-module/tabs/save.mjs.map +2 -2
- package/build-module/tabs-menu/block.json +77 -0
- package/build-module/tabs-menu/edit.mjs +186 -0
- package/build-module/tabs-menu/edit.mjs.map +7 -0
- package/build-module/tabs-menu/icon.mjs +8 -0
- package/build-module/tabs-menu/icon.mjs.map +7 -0
- package/build-module/tabs-menu/index.mjs +20 -0
- package/build-module/tabs-menu/index.mjs.map +7 -0
- package/build-module/tabs-menu/save.mjs +14 -0
- package/build-module/tabs-menu/save.mjs.map +7 -0
- package/build-module/tabs-menu-item/block.json +98 -0
- package/build-module/tabs-menu-item/controls.mjs +227 -0
- package/build-module/tabs-menu-item/controls.mjs.map +7 -0
- package/build-module/tabs-menu-item/edit.mjs +253 -0
- package/build-module/tabs-menu-item/edit.mjs.map +7 -0
- package/build-module/tabs-menu-item/icon.mjs +8 -0
- package/build-module/tabs-menu-item/icon.mjs.map +7 -0
- package/build-module/tabs-menu-item/index.mjs +20 -0
- package/build-module/tabs-menu-item/index.mjs.map +7 -0
- package/build-module/tabs-menu-item/save.mjs +29 -0
- package/build-module/tabs-menu-item/save.mjs.map +7 -0
- package/build-module/template-part/edit/index.mjs +2 -2
- package/build-module/template-part/edit/index.mjs.map +2 -2
- package/build-module/utils/caption.mjs +1 -3
- package/build-module/utils/caption.mjs.map +2 -2
- package/build-module/verse/block.json +1 -3
- package/build-module/verse/deprecated.mjs +74 -5
- package/build-module/verse/deprecated.mjs.map +2 -2
- package/build-module/verse/edit.mjs +35 -55
- package/build-module/verse/edit.mjs.map +2 -2
- package/build-module/verse/save.mjs +2 -6
- package/build-module/verse/save.mjs.map +2 -2
- package/build-module/video/edit.mjs +4 -2
- package/build-module/video/edit.mjs.map +2 -2
- package/build-style/editor-rtl.css +64 -21
- package/build-style/editor.css +64 -21
- package/build-style/gallery/style-rtl.css +1 -1
- package/build-style/gallery/style.css +1 -1
- package/build-style/media-text/style-rtl.css +2 -0
- package/build-style/media-text/style.css +2 -0
- package/build-style/navigation/editor-rtl.css +48 -0
- package/build-style/navigation/editor.css +48 -0
- package/build-style/navigation/style-rtl.css +64 -18
- package/build-style/navigation/style.css +64 -18
- package/build-style/style-rtl.css +109 -171
- package/build-style/style.css +109 -171
- package/build-style/tab/style-rtl.css +7 -1
- package/build-style/tab/style.css +7 -1
- package/build-style/tab-panels/style-rtl.css +4 -0
- package/build-style/tab-panels/style.css +4 -0
- package/build-style/tabs/style-rtl.css +1 -167
- package/build-style/tabs/style.css +1 -167
- package/build-style/tabs-menu/editor-rtl.css +4 -0
- package/build-style/tabs-menu/editor.css +4 -0
- package/build-style/tabs-menu/style-rtl.css +8 -0
- package/build-style/tabs-menu/style.css +8 -0
- package/build-style/tabs-menu-item/editor-rtl.css +16 -0
- package/build-style/tabs-menu-item/editor.css +16 -0
- package/build-style/tabs-menu-item/style-rtl.css +34 -0
- package/build-style/tabs-menu-item/style.css +34 -0
- package/build-style/verse/style-rtl.css +1 -0
- package/build-style/verse/style.css +1 -0
- package/package.json +37 -37
- package/src/block/block.json +2 -1
- package/src/breadcrumbs/edit.js +10 -2
- package/src/breadcrumbs/index.js +1 -0
- package/src/button/index.js +4 -0
- package/src/categories/index.php +5 -1
- package/src/comment-date/block.json +1 -0
- package/src/comment-edit-link/block.json +1 -3
- package/src/comment-edit-link/deprecated.js +63 -0
- package/src/comment-edit-link/edit.js +7 -31
- package/src/comment-edit-link/index.js +2 -0
- package/src/comment-reply-link/block.json +1 -5
- package/src/comment-reply-link/deprecated.js +56 -0
- package/src/comment-reply-link/edit.js +6 -35
- package/src/comment-reply-link/index.js +2 -0
- package/src/comments-title/block.json +1 -3
- package/src/comments-title/deprecated.js +153 -23
- package/src/comments-title/edit.js +9 -25
- package/src/cover/edit/block-controls.js +14 -3
- package/src/cover/edit/embed-video-url-input.js +6 -2
- package/src/cover/edit/inspector-controls.js +1 -3
- package/src/details/index.js +4 -0
- package/src/editor.scss +2 -1
- package/src/embed/test/index.js +49 -0
- package/src/embed/util.js +21 -0
- package/src/freeform/block.json +2 -1
- package/src/gallery/style.scss +1 -1
- package/src/heading/index.js +4 -0
- package/src/html/block.json +2 -1
- package/src/image/image.js +63 -11
- package/src/image/index.js +4 -1
- package/src/index.js +6 -0
- package/src/list-item/index.js +16 -0
- package/src/media-text/style.scss +2 -0
- package/src/missing/block.json +2 -1
- package/src/more/block.json +2 -1
- package/src/more/index.js +4 -1
- package/src/navigation/block.json +5 -4
- package/src/navigation/deprecated.js +144 -5
- package/src/navigation/edit/deleted-overlay-warning.js +56 -0
- package/src/navigation/edit/index.js +181 -70
- package/src/navigation/edit/overlay-panel.js +10 -0
- package/src/navigation/edit/overlay-preview.js +133 -0
- package/src/navigation/edit/overlay-template-part-selector.js +76 -26
- package/src/navigation/edit/responsive-wrapper.js +14 -1
- package/src/navigation/edit/test/overlay-template-part-selector.js +24 -16
- package/src/navigation/edit/test/responsive-wrapper.js +179 -0
- package/src/navigation/edit/test/use-create-overlay.js +129 -2
- package/src/navigation/edit/use-create-overlay.js +26 -4
- package/src/navigation/editor.scss +51 -0
- package/src/navigation/index.php +59 -11
- package/src/navigation/style.scss +140 -76
- package/src/navigation/utils/get-submenu-visibility.js +27 -0
- package/src/navigation/utils/test/get-submenu-visibility.js +47 -0
- package/src/navigation-link/edit.js +3 -67
- package/src/navigation-link/shared/index.js +2 -0
- package/src/navigation-link/shared/select-label-text.js +16 -0
- package/src/navigation-link/shared/use-is-dragging-within.js +55 -0
- package/src/navigation-submenu/block.json +1 -1
- package/src/navigation-submenu/edit.js +10 -73
- package/src/navigation-submenu/index.js +6 -3
- package/src/navigation-submenu/index.php +36 -5
- package/src/nextpage/block.json +2 -1
- package/src/paragraph/block.json +1 -0
- package/src/paragraph/index.js +4 -1
- package/src/post-excerpt/edit.js +1 -1
- package/src/post-excerpt/index.php +39 -16
- package/src/shortcode/block.json +2 -1
- package/src/style.scss +3 -0
- package/src/tab/add-tab-toolbar-control.js +36 -11
- package/src/tab/block.json +18 -4
- package/src/tab/controls.js +4 -5
- package/src/tab/edit.js +75 -150
- package/src/tab/index.php +5 -63
- package/src/tab/remove-tab-toolbar-control.js +103 -0
- package/src/tab/save.js +1 -3
- package/src/tab/style.scss +8 -1
- package/src/tab-panels/block.json +70 -0
- package/src/tab-panels/edit.js +44 -0
- package/src/tab-panels/icon.js +10 -0
- package/src/tab-panels/index.js +21 -0
- package/src/tab-panels/save.js +11 -0
- package/src/tab-panels/style.scss +4 -0
- package/src/tabs/block.json +61 -90
- package/src/tabs/controls.js +7 -221
- package/src/tabs/deprecated.js +214 -0
- package/src/tabs/edit.js +108 -68
- package/src/tabs/index.js +2 -0
- package/src/tabs/index.php +86 -191
- package/src/tabs/save.js +6 -13
- package/src/tabs/style.scss +1 -187
- package/src/tabs-menu/block.json +77 -0
- package/src/tabs-menu/edit.js +251 -0
- package/src/tabs-menu/editor.scss +6 -0
- package/src/tabs-menu/icon.js +10 -0
- package/src/tabs-menu/index.js +21 -0
- package/src/tabs-menu/index.php +74 -0
- package/src/tabs-menu/save.js +18 -0
- package/src/tabs-menu/style.scss +8 -0
- package/src/tabs-menu-item/block.json +98 -0
- package/src/tabs-menu-item/controls.js +262 -0
- package/src/tabs-menu-item/edit.js +322 -0
- package/src/tabs-menu-item/editor.scss +20 -0
- package/src/tabs-menu-item/icon.js +10 -0
- package/src/tabs-menu-item/index.js +21 -0
- package/src/tabs-menu-item/index.php +82 -0
- package/src/tabs-menu-item/save.js +44 -0
- package/src/tabs-menu-item/style.scss +42 -0
- package/src/template-part/edit/index.js +2 -4
- package/src/utils/caption.js +1 -7
- package/src/verse/block.json +1 -3
- package/src/verse/deprecated.js +83 -4
- package/src/verse/edit.js +37 -56
- package/src/verse/save.js +2 -11
- package/src/verse/style.scss +1 -0
- package/src/video/edit.js +4 -2
- package/build/tab/tabs-list.cjs +0 -132
- package/build/tab/tabs-list.cjs.map +0 -7
- package/build/tabs/style-engine.cjs +0 -119
- package/build/tabs/style-engine.cjs.map +0 -7
- package/build-module/tab/tabs-list.mjs +0 -101
- package/build-module/tab/tabs-list.mjs.map +0 -7
- package/build-module/tabs/style-engine.mjs +0 -101
- package/build-module/tabs/style-engine.mjs.map +0 -7
- package/build-style/tabs/editor-rtl.css +0 -26
- package/build-style/tabs/editor.css +0 -26
- package/src/tab/tabs-list.js +0 -122
- package/src/tabs/editor.scss +0 -30
- package/src/tabs/style-engine.js +0 -164
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/navigation/edit/overlay-panel.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport OverlayTemplatePartSelector from './overlay-template-part-selector';\nimport OverlayVisibilityControl from './overlay-visibility-control';\nimport OverlayMenuPreviewButton from './overlay-menu-preview-button';\n\n/**\n * Overlay Panel component for Navigation block.\n *\n * @param {Object} props Component props.\n * @param {string} props.overlayMenu Overlay menu setting ('never', 'mobile', 'always').\n * @param {string} props.overlay Currently selected overlay template part ID.\n * @param {Function} props.setAttributes Function to update block attributes.\n * @param {Function} props.onNavigateToEntityRecord Function to navigate to template part editor.\n * @param {boolean} props.overlayMenuPreview Whether overlay menu preview is open.\n * @param {Function} props.setOverlayMenuPreview Function to toggle overlay menu preview.\n * @param {boolean} props.hasIcon Whether the overlay menu has an icon.\n * @param {string} props.icon Icon type for overlay menu.\n * @param {string} props.overlayMenuPreviewClasses CSS classes for overlay menu preview button.\n * @param {string} props.overlayMenuPreviewId ID for overlay menu preview.\n * @param {boolean} props.isResponsive Whether overlay menu is responsive.\n * @return {JSX.Element|null} The overlay panel component or null if overlay is disabled.\n */\nexport default function OverlayPanel( {\n\toverlayMenu,\n\toverlay,\n\tsetAttributes,\n\tonNavigateToEntityRecord,\n\toverlayMenuPreview,\n\tsetOverlayMenuPreview,\n\thasIcon,\n\ticon,\n\toverlayMenuPreviewClasses,\n\toverlayMenuPreviewId,\n\tisResponsive,\n} ) {\n\treturn (\n\t\t<PanelBody title={ __( 'Overlay' ) } initialOpen>\n\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t<OverlayVisibilityControl\n\t\t\t\t\toverlayMenu={ overlayMenu }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\n\t\t\t\t{ overlayMenu !== 'never' && (\n\t\t\t\t\t<OverlayMenuPreviewButton\n\t\t\t\t\t\tisResponsive={ isResponsive }\n\t\t\t\t\t\toverlayMenuPreview={ overlayMenuPreview }\n\t\t\t\t\t\tsetOverlayMenuPreview={ setOverlayMenuPreview }\n\t\t\t\t\t\thasIcon={ hasIcon }\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\toverlayMenuPreviewClasses={ overlayMenuPreviewClasses }\n\t\t\t\t\t\toverlayMenuPreviewId={ overlayMenuPreviewId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ overlayMenu !== 'never' && (\n\t\t\t\t\t<OverlayTemplatePartSelector\n\t\t\t\t\t\toverlay={ overlay }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tonNavigateToEntityRecord={ onNavigateToEntityRecord }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</VStack>\n\t\t</PanelBody>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA,wBAAwB;AAAA,OAClB;AACP,SAAS,UAAU;AAKnB,OAAO,iCAAiC;AACxC,OAAO,8BAA8B;AACrC,OAAO,8BAA8B;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport OverlayTemplatePartSelector from './overlay-template-part-selector';\nimport OverlayVisibilityControl from './overlay-visibility-control';\nimport OverlayMenuPreviewButton from './overlay-menu-preview-button';\nimport OverlayPreview from './overlay-preview';\n\n/**\n * Overlay Panel component for Navigation block.\n *\n * @param {Object} props Component props.\n * @param {string} props.overlayMenu Overlay menu setting ('never', 'mobile', 'always').\n * @param {string} props.overlay Currently selected overlay template part ID.\n * @param {Function} props.setAttributes Function to update block attributes.\n * @param {Function} props.onNavigateToEntityRecord Function to navigate to template part editor.\n * @param {boolean} props.overlayMenuPreview Whether overlay menu preview is open.\n * @param {Function} props.setOverlayMenuPreview Function to toggle overlay menu preview.\n * @param {boolean} props.hasIcon Whether the overlay menu has an icon.\n * @param {string} props.icon Icon type for overlay menu.\n * @param {string} props.overlayMenuPreviewClasses CSS classes for overlay menu preview button.\n * @param {string} props.overlayMenuPreviewId ID for overlay menu preview.\n * @param {boolean} props.isResponsive Whether overlay menu is responsive.\n * @param {string} props.currentTheme Current theme stylesheet name.\n * @return {JSX.Element|null} The overlay panel component or null if overlay is disabled.\n */\nexport default function OverlayPanel( {\n\toverlayMenu,\n\toverlay,\n\tsetAttributes,\n\tonNavigateToEntityRecord,\n\toverlayMenuPreview,\n\tsetOverlayMenuPreview,\n\thasIcon,\n\ticon,\n\toverlayMenuPreviewClasses,\n\toverlayMenuPreviewId,\n\tisResponsive,\n\tcurrentTheme,\n} ) {\n\treturn (\n\t\t<PanelBody title={ __( 'Overlay' ) } initialOpen>\n\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t<OverlayVisibilityControl\n\t\t\t\t\toverlayMenu={ overlayMenu }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\n\t\t\t\t{ overlayMenu !== 'never' && (\n\t\t\t\t\t<OverlayMenuPreviewButton\n\t\t\t\t\t\tisResponsive={ isResponsive }\n\t\t\t\t\t\toverlayMenuPreview={ overlayMenuPreview }\n\t\t\t\t\t\tsetOverlayMenuPreview={ setOverlayMenuPreview }\n\t\t\t\t\t\thasIcon={ hasIcon }\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\toverlayMenuPreviewClasses={ overlayMenuPreviewClasses }\n\t\t\t\t\t\toverlayMenuPreviewId={ overlayMenuPreviewId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ overlayMenu !== 'never' && (\n\t\t\t\t\t<OverlayTemplatePartSelector\n\t\t\t\t\t\toverlay={ overlay }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tonNavigateToEntityRecord={ onNavigateToEntityRecord }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ overlayMenu !== 'never' && overlay && (\n\t\t\t\t\t<OverlayPreview\n\t\t\t\t\t\toverlay={ overlay }\n\t\t\t\t\t\tcurrentTheme={ currentTheme }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</VStack>\n\t\t</PanelBody>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA,wBAAwB;AAAA,OAClB;AACP,SAAS,UAAU;AAKnB,OAAO,iCAAiC;AACxC,OAAO,8BAA8B;AACrC,OAAO,8BAA8B;AACrC,OAAO,oBAAoB;AAoCxB,SACC,KADD;AAhBY,SAAR,aAA+B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,SACC,oBAAC,aAAU,OAAQ,GAAI,SAAU,GAAI,aAAW,MAC/C,+BAAC,UAAO,SAAU,GACjB;AAAA;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,IAEE,gBAAgB,WACjB;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,IAGC,gBAAgB,WACjB;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,IAGC,gBAAgB,WAAW,WAC5B;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,KAEF,GACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// packages/block-library/src/navigation/edit/overlay-preview.js
|
|
2
|
+
import { useSelect } from "@wordpress/data";
|
|
3
|
+
import { store as coreStore } from "@wordpress/core-data";
|
|
4
|
+
import { useMemo } from "@wordpress/element";
|
|
5
|
+
import { parse } from "@wordpress/blocks";
|
|
6
|
+
import { Spinner } from "@wordpress/components";
|
|
7
|
+
import { __ } from "@wordpress/i18n";
|
|
8
|
+
import { BlockPreview } from "@wordpress/block-editor";
|
|
9
|
+
import { createTemplatePartId } from "../../template-part/edit/utils/create-template-part-id.mjs";
|
|
10
|
+
import { jsx } from "react/jsx-runtime";
|
|
11
|
+
function OverlayPreview({ overlay, currentTheme }) {
|
|
12
|
+
const templatePartId = useMemo(() => {
|
|
13
|
+
if (!overlay || !currentTheme) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return createTemplatePartId(currentTheme, overlay);
|
|
17
|
+
}, [currentTheme, overlay]);
|
|
18
|
+
const { content, editedBlocks, hasResolved, recordExists } = useSelect(
|
|
19
|
+
(select) => {
|
|
20
|
+
if (!templatePartId) {
|
|
21
|
+
return {
|
|
22
|
+
content: null,
|
|
23
|
+
editedBlocks: null,
|
|
24
|
+
hasResolved: true,
|
|
25
|
+
recordExists: false
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const { getEditedEntityRecord, hasFinishedResolution } = select(coreStore);
|
|
29
|
+
const editedRecord = getEditedEntityRecord(
|
|
30
|
+
"postType",
|
|
31
|
+
"wp_template_part",
|
|
32
|
+
templatePartId,
|
|
33
|
+
{ context: "view" }
|
|
34
|
+
);
|
|
35
|
+
return {
|
|
36
|
+
content: editedRecord?.content,
|
|
37
|
+
editedBlocks: editedRecord?.blocks,
|
|
38
|
+
hasResolved: hasFinishedResolution("getEditedEntityRecord", [
|
|
39
|
+
"postType",
|
|
40
|
+
"wp_template_part",
|
|
41
|
+
templatePartId,
|
|
42
|
+
{ context: "view" }
|
|
43
|
+
]),
|
|
44
|
+
recordExists: !!editedRecord
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
[templatePartId]
|
|
48
|
+
);
|
|
49
|
+
const blocks = useMemo(() => {
|
|
50
|
+
if (!templatePartId) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
if (editedBlocks && editedBlocks.length > 0) {
|
|
54
|
+
return editedBlocks;
|
|
55
|
+
}
|
|
56
|
+
if (content && typeof content === "string") {
|
|
57
|
+
return parse(content);
|
|
58
|
+
}
|
|
59
|
+
return [];
|
|
60
|
+
}, [templatePartId, editedBlocks, content]);
|
|
61
|
+
if (!overlay) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
if (!hasResolved) {
|
|
65
|
+
return /* @__PURE__ */ jsx("div", { className: "wp-block-navigation__overlay-preview-loading", children: /* @__PURE__ */ jsx(Spinner, {}) });
|
|
66
|
+
}
|
|
67
|
+
if (hasResolved && !recordExists) {
|
|
68
|
+
return /* @__PURE__ */ jsx("div", { className: "wp-block-navigation__overlay-preview-empty", children: __("This overlay template part no longer exists.") });
|
|
69
|
+
}
|
|
70
|
+
if (!blocks || blocks.length === 0) {
|
|
71
|
+
return /* @__PURE__ */ jsx("div", { className: "wp-block-navigation__overlay-preview-empty", children: __("This overlay is empty.") });
|
|
72
|
+
}
|
|
73
|
+
return /* @__PURE__ */ jsx(
|
|
74
|
+
"div",
|
|
75
|
+
{
|
|
76
|
+
className: "wp-block-navigation__overlay-preview",
|
|
77
|
+
"aria-label": __("Navigation Overlay template part preview"),
|
|
78
|
+
role: "region",
|
|
79
|
+
children: /* @__PURE__ */ jsx(
|
|
80
|
+
BlockPreview.Async,
|
|
81
|
+
{
|
|
82
|
+
placeholder: /* @__PURE__ */ jsx("div", { className: "wp-block-navigation__overlay-preview-placeholder" }),
|
|
83
|
+
children: /* @__PURE__ */ jsx(
|
|
84
|
+
BlockPreview,
|
|
85
|
+
{
|
|
86
|
+
blocks,
|
|
87
|
+
viewportWidth: 400,
|
|
88
|
+
minHeight: 200
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
export {
|
|
97
|
+
OverlayPreview as default
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=overlay-preview.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/navigation/edit/overlay-preview.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport { parse } from '@wordpress/blocks';\nimport { Spinner } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { BlockPreview } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { createTemplatePartId } from '../../template-part/edit/utils/create-template-part-id';\n\n/**\n * Component that displays a read-only visual preview of the selected overlay template part.\n *\n * @param {Object} props Component props.\n * @param {string} props.overlay The overlay template part slug.\n * @param {string} props.currentTheme The current theme stylesheet name.\n * @return {JSX.Element|null} The overlay preview component or null if no overlay is selected.\n */\nexport default function OverlayPreview( { overlay, currentTheme } ) {\n\tconst templatePartId = useMemo( () => {\n\t\tif ( ! overlay || ! currentTheme ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn createTemplatePartId( currentTheme, overlay );\n\t}, [ currentTheme, overlay ] );\n\n\tconst { content, editedBlocks, hasResolved, recordExists } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! templatePartId ) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: null,\n\t\t\t\t\teditedBlocks: null,\n\t\t\t\t\thasResolved: true,\n\t\t\t\t\trecordExists: false,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst { getEditedEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst editedRecord = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\ttemplatePartId,\n\t\t\t\t{ context: 'view' }\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tcontent: editedRecord?.content,\n\t\t\t\teditedBlocks: editedRecord?.blocks,\n\t\t\t\thasResolved: hasFinishedResolution( 'getEditedEntityRecord', [\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template_part',\n\t\t\t\t\ttemplatePartId,\n\t\t\t\t\t{ context: 'view' },\n\t\t\t\t] ),\n\t\t\t\trecordExists: !! editedRecord,\n\t\t\t};\n\t\t},\n\t\t[ templatePartId ]\n\t);\n\n\tconst blocks = useMemo( () => {\n\t\tif ( ! templatePartId ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif ( editedBlocks && editedBlocks.length > 0 ) {\n\t\t\treturn editedBlocks;\n\t\t}\n\n\t\tif ( content && typeof content === 'string' ) {\n\t\t\treturn parse( content );\n\t\t}\n\n\t\treturn [];\n\t}, [ templatePartId, editedBlocks, content ] );\n\n\tif ( ! overlay ) {\n\t\treturn null;\n\t}\n\n\tif ( ! hasResolved ) {\n\t\treturn (\n\t\t\t<div className=\"wp-block-navigation__overlay-preview-loading\">\n\t\t\t\t<Spinner />\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Show message if the overlay template part has been deleted.\n\tif ( hasResolved && ! recordExists ) {\n\t\treturn (\n\t\t\t<div className=\"wp-block-navigation__overlay-preview-empty\">\n\t\t\t\t{ __( 'This overlay template part no longer exists.' ) }\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif ( ! blocks || blocks.length === 0 ) {\n\t\treturn (\n\t\t\t<div className=\"wp-block-navigation__overlay-preview-empty\">\n\t\t\t\t{ __( 'This overlay is empty.' ) }\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"wp-block-navigation__overlay-preview\"\n\t\t\taria-label={ __( 'Navigation Overlay template part preview' ) }\n\t\t\trole=\"region\"\n\t\t>\n\t\t\t<BlockPreview.Async\n\t\t\t\tplaceholder={\n\t\t\t\t\t<div className=\"wp-block-navigation__overlay-preview-placeholder\" />\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t<BlockPreview\n\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\tviewportWidth={ 400 }\n\t\t\t\t\tminHeight={ 200 }\n\t\t\t\t/>\n\t\t\t</BlockPreview.Async>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,SAAS,iBAAiB;AACnC,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAK7B,SAAS,4BAA4B;AA6EjC;AAnEW,SAAR,eAAiC,EAAE,SAAS,aAAa,GAAI;AACnE,QAAM,iBAAiB,QAAS,MAAM;AACrC,QAAK,CAAE,WAAW,CAAE,cAAe;AAClC,aAAO;AAAA,IACR;AACA,WAAO,qBAAsB,cAAc,OAAQ;AAAA,EACpD,GAAG,CAAE,cAAc,OAAQ,CAAE;AAE7B,QAAM,EAAE,SAAS,cAAc,aAAa,aAAa,IAAI;AAAA,IAC5D,CAAE,WAAY;AACb,UAAK,CAAE,gBAAiB;AACvB,eAAO;AAAA,UACN,SAAS;AAAA,UACT,cAAc;AAAA,UACd,aAAa;AAAA,UACb,cAAc;AAAA,QACf;AAAA,MACD;AAEA,YAAM,EAAE,uBAAuB,sBAAsB,IACpD,OAAQ,SAAU;AAEnB,YAAM,eAAe;AAAA,QACpB;AAAA,QACA;AAAA,QACA;AAAA,QACA,EAAE,SAAS,OAAO;AAAA,MACnB;AAEA,aAAO;AAAA,QACN,SAAS,cAAc;AAAA,QACvB,cAAc,cAAc;AAAA,QAC5B,aAAa,sBAAuB,yBAAyB;AAAA,UAC5D;AAAA,U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useState, useCallback } from "@wordpress/element";
|
|
3
|
-
import { useEntityRecords } from "@wordpress/core-data";
|
|
4
|
-
import { useDispatch } from "@wordpress/data";
|
|
3
|
+
import { useEntityRecords, store as coreStore } from "@wordpress/core-data";
|
|
4
|
+
import { useDispatch, useSelect } from "@wordpress/data";
|
|
5
5
|
import {
|
|
6
6
|
SelectControl,
|
|
7
7
|
Button,
|
|
@@ -15,6 +15,7 @@ import { store as noticesStore } from "@wordpress/notices";
|
|
|
15
15
|
import { plus } from "@wordpress/icons";
|
|
16
16
|
import { createTemplatePartId } from "../../template-part/edit/utils/create-template-part-id.mjs";
|
|
17
17
|
import useCreateOverlayTemplatePart from "./use-create-overlay.mjs";
|
|
18
|
+
import DeletedOverlayWarning from "./deleted-overlay-warning.mjs";
|
|
18
19
|
import { NAVIGATION_OVERLAY_TEMPLATE_PART_AREA } from "../constants.mjs";
|
|
19
20
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
20
21
|
function OverlayTemplatePartSelector({
|
|
@@ -30,6 +31,10 @@ function OverlayTemplatePartSelector({
|
|
|
30
31
|
per_page: -1
|
|
31
32
|
});
|
|
32
33
|
const { createErrorNotice } = useDispatch(noticesStore);
|
|
34
|
+
const currentTheme = useSelect(
|
|
35
|
+
(select) => select(coreStore).getCurrentTheme()?.stylesheet,
|
|
36
|
+
[]
|
|
37
|
+
);
|
|
33
38
|
const [isCreating, setIsCreating] = useState(false);
|
|
34
39
|
const overlayTemplateParts = useMemo(() => {
|
|
35
40
|
if (!templateParts) {
|
|
@@ -40,6 +45,14 @@ function OverlayTemplatePartSelector({
|
|
|
40
45
|
);
|
|
41
46
|
}, [templateParts]);
|
|
42
47
|
const createOverlayTemplatePart = useCreateOverlayTemplatePart(overlayTemplateParts);
|
|
48
|
+
const selectedTemplatePart = useMemo(() => {
|
|
49
|
+
if (!overlay || !overlayTemplateParts) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return overlayTemplateParts.find(
|
|
53
|
+
(templatePart) => templatePart.slug === overlay
|
|
54
|
+
);
|
|
55
|
+
}, [overlay, overlayTemplateParts]);
|
|
43
56
|
const options = useMemo(() => {
|
|
44
57
|
const baseOptions = [
|
|
45
58
|
{
|
|
@@ -52,42 +65,44 @@ function OverlayTemplatePartSelector({
|
|
|
52
65
|
}
|
|
53
66
|
const templatePartOptions = overlayTemplateParts.map(
|
|
54
67
|
(templatePart) => {
|
|
55
|
-
const templatePartId = createTemplatePartId(
|
|
56
|
-
templatePart.theme,
|
|
57
|
-
templatePart.slug
|
|
58
|
-
);
|
|
59
68
|
const label = templatePart.title?.rendered ? decodeEntities(templatePart.title.rendered) : templatePart.slug;
|
|
60
69
|
return {
|
|
61
70
|
label,
|
|
62
|
-
value:
|
|
71
|
+
value: templatePart.slug
|
|
63
72
|
};
|
|
64
73
|
}
|
|
65
74
|
);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
if (overlay && !selectedTemplatePart) {
|
|
76
|
+
templatePartOptions.unshift({
|
|
77
|
+
label: sprintf(
|
|
78
|
+
/* translators: %s: Overlay slug. */
|
|
79
|
+
__("%s (missing)"),
|
|
80
|
+
overlay
|
|
81
|
+
),
|
|
82
|
+
value: overlay
|
|
83
|
+
});
|
|
71
84
|
}
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
85
|
+
return [...baseOptions, ...templatePartOptions];
|
|
86
|
+
}, [
|
|
87
|
+
overlayTemplateParts,
|
|
88
|
+
hasResolved,
|
|
89
|
+
isResolving,
|
|
90
|
+
overlay,
|
|
91
|
+
selectedTemplatePart
|
|
92
|
+
]);
|
|
80
93
|
const handleSelectChange = (value) => {
|
|
81
94
|
setAttributes({
|
|
82
95
|
overlay: value || void 0
|
|
83
96
|
});
|
|
84
97
|
};
|
|
85
98
|
const handleEditClick = () => {
|
|
86
|
-
if (!overlay || !onNavigateToEntityRecord) {
|
|
99
|
+
if (!overlay || !selectedTemplatePart || !onNavigateToEntityRecord) {
|
|
87
100
|
return;
|
|
88
101
|
}
|
|
102
|
+
const theme = selectedTemplatePart.theme || currentTheme;
|
|
103
|
+
const templatePartId = createTemplatePartId(theme, overlay);
|
|
89
104
|
onNavigateToEntityRecord({
|
|
90
|
-
postId:
|
|
105
|
+
postId: templatePartId,
|
|
91
106
|
postType: "wp_template_part"
|
|
92
107
|
});
|
|
93
108
|
};
|
|
@@ -96,11 +111,16 @@ function OverlayTemplatePartSelector({
|
|
|
96
111
|
setIsCreating(true);
|
|
97
112
|
const templatePart = await createOverlayTemplatePart();
|
|
98
113
|
setAttributes({
|
|
99
|
-
overlay: templatePart.
|
|
114
|
+
overlay: templatePart.slug
|
|
100
115
|
});
|
|
101
116
|
if (onNavigateToEntityRecord) {
|
|
117
|
+
const theme = templatePart.theme || currentTheme;
|
|
118
|
+
const templatePartId = createTemplatePartId(
|
|
119
|
+
theme,
|
|
120
|
+
templatePart.slug
|
|
121
|
+
);
|
|
102
122
|
onNavigateToEntityRecord({
|
|
103
|
-
postId:
|
|
123
|
+
postId: templatePartId,
|
|
104
124
|
postType: "wp_template_part"
|
|
105
125
|
});
|
|
106
126
|
}
|
|
@@ -114,9 +134,16 @@ function OverlayTemplatePartSelector({
|
|
|
114
134
|
createOverlayTemplatePart,
|
|
115
135
|
setAttributes,
|
|
116
136
|
onNavigateToEntityRecord,
|
|
117
|
-
createErrorNotice
|
|
137
|
+
createErrorNotice,
|
|
138
|
+
currentTheme
|
|
118
139
|
]);
|
|
140
|
+
const handleClearOverlay = useCallback(() => {
|
|
141
|
+
setAttributes({ overlay: void 0 });
|
|
142
|
+
}, [setAttributes]);
|
|
119
143
|
const isCreateButtonDisabled = isResolving || isCreating;
|
|
144
|
+
const isOverlayMissing = useMemo(() => {
|
|
145
|
+
return overlay && hasResolved && !isResolving && !selectedTemplatePart;
|
|
146
|
+
}, [overlay, hasResolved, isResolving, selectedTemplatePart]);
|
|
120
147
|
const helpText = useMemo(() => {
|
|
121
148
|
if (overlayTemplateParts.length === 0 && hasResolved) {
|
|
122
149
|
return __("No overlays found.");
|
|
@@ -174,7 +201,15 @@ function OverlayTemplatePartSelector({
|
|
|
174
201
|
children: __("Edit")
|
|
175
202
|
}
|
|
176
203
|
) })
|
|
177
|
-
] })
|
|
204
|
+
] }),
|
|
205
|
+
isOverlayMissing && /* @__PURE__ */ jsx(
|
|
206
|
+
DeletedOverlayWarning,
|
|
207
|
+
{
|
|
208
|
+
onClear: handleClearOverlay,
|
|
209
|
+
onCreate: handleCreateOverlay,
|
|
210
|
+
isCreating
|
|
211
|
+
}
|
|
212
|
+
)
|
|
178
213
|
] });
|
|
179
214
|
}
|
|
180
215
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/navigation/edit/overlay-template-part-selector.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo, useState, useCallback } from '@wordpress/element';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { useDispatch } from '@wordpress/data';\nimport {\n\tSelectControl,\n\tButton,\n\tFlexBlock,\n\tFlexItem,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { createTemplatePartId } from '../../template-part/edit/utils/create-template-part-id';\nimport useCreateOverlayTemplatePart from './use-create-overlay';\nimport { NAVIGATION_OVERLAY_TEMPLATE_PART_AREA } from '../constants';\n\n/**\n * Overlay Template Part Selector component.\n *\n * @param {Object} props Component props.\n * @param {string} props.overlay Currently selected overlay template part ID.\n * @param {Function} props.setAttributes Function to update block attributes.\n * @param {Function} props.onNavigateToEntityRecord Function to navigate to template part editor.\n * @return {JSX.Element} The overlay template part selector component.\n */\nexport default function OverlayTemplatePartSelector( {\n\toverlay,\n\tsetAttributes,\n\tonNavigateToEntityRecord,\n} ) {\n\tconst {\n\t\trecords: templateParts,\n\t\tisResolving,\n\t\thasResolved,\n\t} = useEntityRecords( 'postType', 'wp_template_part', {\n\t\tper_page: -1,\n\t} );\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\t// Track if we're currently creating a new overlay\n\tconst [ isCreating, setIsCreating ] = useState( false );\n\n\t// Filter template parts by overlay area\n\tconst overlayTemplateParts = useMemo( () => {\n\t\tif ( ! templateParts ) {\n\t\t\treturn [];\n\t\t}\n\t\treturn templateParts.filter(\n\t\t\t( templatePart ) =>\n\t\t\t\ttemplatePart.area === NAVIGATION_OVERLAY_TEMPLATE_PART_AREA\n\t\t);\n\t}, [ templateParts ] );\n\n\t// Hook to create overlay template part\n\tconst createOverlayTemplatePart =\n\t\tuseCreateOverlayTemplatePart( overlayTemplateParts );\n\n\t// Build options for SelectControl\n\tconst options = useMemo( () => {\n\t\tconst baseOptions = [\n\t\t\t{\n\t\t\t\tlabel: __( 'None (default)' ),\n\t\t\t\tvalue: '',\n\t\t\t},\n\t\t];\n\n\t\tif ( ! hasResolved || isResolving ) {\n\t\t\treturn baseOptions;\n\t\t}\n\n\t\tconst templatePartOptions = overlayTemplateParts.map(\n\t\t\t( templatePart ) => {\n\t\t\t\tconst
|
|
5
|
-
"mappings": ";AAGA,SAAS,SAAS,UAAU,mBAAmB;AAC/C,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo, useState, useCallback } from '@wordpress/element';\nimport { useEntityRecords, store as coreStore } from '@wordpress/core-data';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tSelectControl,\n\tButton,\n\tFlexBlock,\n\tFlexItem,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { createTemplatePartId } from '../../template-part/edit/utils/create-template-part-id';\nimport useCreateOverlayTemplatePart from './use-create-overlay';\nimport DeletedOverlayWarning from './deleted-overlay-warning';\nimport { NAVIGATION_OVERLAY_TEMPLATE_PART_AREA } from '../constants';\n\n/**\n * Overlay Template Part Selector component.\n *\n * @param {Object} props Component props.\n * @param {string} props.overlay Currently selected overlay template part ID.\n * @param {Function} props.setAttributes Function to update block attributes.\n * @param {Function} props.onNavigateToEntityRecord Function to navigate to template part editor.\n * @return {JSX.Element} The overlay template part selector component.\n */\nexport default function OverlayTemplatePartSelector( {\n\toverlay,\n\tsetAttributes,\n\tonNavigateToEntityRecord,\n} ) {\n\tconst {\n\t\trecords: templateParts,\n\t\tisResolving,\n\t\thasResolved,\n\t} = useEntityRecords( 'postType', 'wp_template_part', {\n\t\tper_page: -1,\n\t} );\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tconst currentTheme = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.stylesheet,\n\t\t[]\n\t);\n\n\t// Track if we're currently creating a new overlay\n\tconst [ isCreating, setIsCreating ] = useState( false );\n\n\t// Filter template parts by overlay area\n\tconst overlayTemplateParts = useMemo( () => {\n\t\tif ( ! templateParts ) {\n\t\t\treturn [];\n\t\t}\n\t\treturn templateParts.filter(\n\t\t\t( templatePart ) =>\n\t\t\t\ttemplatePart.area === NAVIGATION_OVERLAY_TEMPLATE_PART_AREA\n\t\t);\n\t}, [ templateParts ] );\n\n\t// Hook to create overlay template part\n\tconst createOverlayTemplatePart =\n\t\tuseCreateOverlayTemplatePart( overlayTemplateParts );\n\n\t// Find the selected template part to get its title\n\tconst selectedTemplatePart = useMemo( () => {\n\t\tif ( ! overlay || ! overlayTemplateParts ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn overlayTemplateParts.find(\n\t\t\t( templatePart ) => templatePart.slug === overlay\n\t\t);\n\t}, [ overlay, overlayTemplateParts ] );\n\n\t// Build options for SelectControl\n\tconst options = useMemo( () => {\n\t\tconst baseOptions = [\n\t\t\t{\n\t\t\t\tlabel: __( 'None (default)' ),\n\t\t\t\tvalue: '',\n\t\t\t},\n\t\t];\n\n\t\tif ( ! hasResolved || isResolving ) {\n\t\t\treturn baseOptions;\n\t\t}\n\n\t\tconst templatePartOptions = overlayTemplateParts.map(\n\t\t\t( templatePart ) => {\n\t\t\t\tconst label = templatePart.title?.rendered\n\t\t\t\t\t? decodeEntities( templatePart.title.rendered )\n\t\t\t\t\t: templatePart.slug;\n\n\t\t\t\treturn {\n\t\t\t\t\tlabel,\n\t\t\t\t\tvalue: templatePart.slug,\n\t\t\t\t};\n\t\t\t}\n\t\t);\n\n\t\t// If an overlay is selected but not found in the list, add it as a \"missing\" option\n\t\tif ( overlay && ! selectedTemplatePart ) {\n\t\t\ttemplatePartOptions.unshift( {\n\t\t\t\tlabel: sprintf(\n\t\t\t\t\t/* translators: %s: Overlay slug. */\n\t\t\t\t\t__( '%s (missing)' ),\n\t\t\t\t\toverlay\n\t\t\t\t),\n\t\t\t\tvalue: overlay,\n\t\t\t} );\n\t\t}\n\n\t\treturn [ ...baseOptions, ...templatePartOptions ];\n\t}, [\n\t\toverlayTemplateParts,\n\t\thasResolved,\n\t\tisResolving,\n\t\toverlay,\n\t\tselectedTemplatePart,\n\t] );\n\n\tconst handleSelectChange = ( value ) => {\n\t\tsetAttributes( {\n\t\t\toverlay: value || undefined,\n\t\t} );\n\t};\n\n\tconst handleEditClick = () => {\n\t\tif (\n\t\t\t! overlay ||\n\t\t\t! selectedTemplatePart ||\n\t\t\t! onNavigateToEntityRecord\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Resolve the full template part ID using theme\n\t\t// Default to current theme if not set\n\t\tconst theme = selectedTemplatePart.theme || currentTheme;\n\t\tconst templatePartId = createTemplatePartId( theme, overlay );\n\n\t\tonNavigateToEntityRecord( {\n\t\t\tpostId: templatePartId,\n\t\t\tpostType: 'wp_template_part',\n\t\t} );\n\t};\n\n\tconst handleCreateOverlay = useCallback( async () => {\n\t\ttry {\n\t\t\tsetIsCreating( true );\n\n\t\t\tconst templatePart = await createOverlayTemplatePart();\n\n\t\t\tsetAttributes( {\n\t\t\t\toverlay: templatePart.slug,\n\t\t\t} );\n\n\t\t\t// Navigate to the new overlay for editing\n\t\t\t// Create the full ID using theme and slug\n\t\t\tif ( onNavigateToEntityRecord ) {\n\t\t\t\tconst theme = templatePart.theme || currentTheme;\n\t\t\t\tconst templatePartId = createTemplatePartId(\n\t\t\t\t\ttheme,\n\t\t\t\t\ttemplatePart.slug\n\t\t\t\t);\n\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\tpostId: templatePartId,\n\t\t\t\t\tpostType: 'wp_template_part',\n\t\t\t\t} );\n\t\t\t}\n\t\t} catch ( error ) {\n\t\t\t// Error handling pattern matches CreateTemplatePartModalContents.\n\t\t\t// See: packages/fields/src/components/create-template-part-modal/index.tsx\n\t\t\t// The 'unknown_error' code check ensures generic error codes don't show\n\t\t\t// potentially confusing technical messages, instead showing a user-friendly fallback.\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error &&\n\t\t\t\t'code' in error &&\n\t\t\t\terror.message &&\n\t\t\t\terror.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while creating the overlay.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t} finally {\n\t\t\tsetIsCreating( false );\n\t\t}\n\t}, [\n\t\tcreateOverlayTemplatePart,\n\t\tsetAttributes,\n\t\tonNavigateToEntityRecord,\n\t\tcreateErrorNotice,\n\t\tcurrentTheme,\n\t] );\n\n\tconst handleClearOverlay = useCallback( () => {\n\t\tsetAttributes( { overlay: undefined } );\n\t}, [ setAttributes ] );\n\n\tconst isCreateButtonDisabled = isResolving || isCreating;\n\n\t// Check if the selected overlay is missing (deleted)\n\tconst isOverlayMissing = useMemo( () => {\n\t\treturn (\n\t\t\toverlay && hasResolved && ! isResolving && ! selectedTemplatePart\n\t\t);\n\t}, [ overlay, hasResolved, isResolving, selectedTemplatePart ] );\n\n\t// Build help text\n\tconst helpText = useMemo( () => {\n\t\tif ( overlayTemplateParts.length === 0 && hasResolved ) {\n\t\t\treturn __( 'No overlays found.' );\n\t\t}\n\t\treturn __( 'Select an overlay for navigation.' );\n\t}, [ overlayTemplateParts.length, hasResolved ] );\n\n\t// Tooltip/aria-label text for the edit button\n\tconst editButtonLabel = useMemo( () => {\n\t\treturn selectedTemplatePart\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %s: Overlay title. */\n\t\t\t\t\t__( 'Edit overlay: %s' ),\n\t\t\t\t\tselectedTemplatePart.title?.rendered\n\t\t\t\t\t\t? decodeEntities( selectedTemplatePart.title.rendered )\n\t\t\t\t\t\t: selectedTemplatePart.slug\n\t\t\t )\n\t\t\t: __( 'Edit overlay' );\n\t}, [ selectedTemplatePart ] );\n\n\treturn (\n\t\t<div className=\"wp-block-navigation__overlay-selector\">\n\t\t\t<Button\n\t\t\t\tsize=\"small\"\n\t\t\t\ticon={ plus }\n\t\t\t\tonClick={ handleCreateOverlay }\n\t\t\t\tdisabled={ isCreateButtonDisabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tisBusy={ isCreating }\n\t\t\t\tlabel={ __( 'Create new overlay template' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tclassName=\"wp-block-navigation__overlay-create-button\"\n\t\t\t/>\n\t\t\t<HStack alignment=\"flex-start\">\n\t\t\t\t<FlexBlock>\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Overlay template' ) }\n\t\t\t\t\t\tvalue={ overlay || '' }\n\t\t\t\t\t\toptions={ options }\n\t\t\t\t\t\tonChange={ handleSelectChange }\n\t\t\t\t\t\tdisabled={ isResolving }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\thelp={ helpText }\n\t\t\t\t\t/>\n\t\t\t\t</FlexBlock>\n\t\t\t\t{ overlay && hasResolved && selectedTemplatePart && (\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tonClick={ handleEditClick }\n\t\t\t\t\t\t\tdisabled={ ! onNavigateToEntityRecord }\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\tlabel={ editButtonLabel }\n\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\tclassName=\"wp-block-navigation__overlay-edit-button\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t\t{ isOverlayMissing && (\n\t\t\t\t<DeletedOverlayWarning\n\t\t\t\t\tonClear={ handleClearOverlay }\n\t\t\t\t\tonCreate={ handleCreateOverlay }\n\t\t\t\t\tisCreating={ isCreating }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,SAAS,UAAU,mBAAmB;AAC/C,SAAS,kBAAkB,SAAS,iBAAiB;AACrD,SAAS,aAAa,iBAAiB;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,OAClB;AACP,SAAS,IAAI,eAAe;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,SAAS,oBAAoB;AACtC,SAAS,YAAY;AAKrB,SAAS,4BAA4B;AACrC,OAAO,kCAAkC;AACzC,OAAO,2BAA2B;AAClC,SAAS,6CAA6C;AAwNnD,cAWA,YAXA;AA7MY,SAAR,4BAA8C;AAAA,EACpD;AAAA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WAAW,eAAe,wBAC3B,oBAAC,YACA;AAAA,QAAC;AAAA;AAAA,UACA,uBAAqB;AAAA,UACrB,SAAQ;AAAA,UACR,SAAU;AAAA,UACV,UAAW,CAAE;AAAA,UACb,wBAAsB;AAAA,UACtB,OAAQ;AAAA,UACR,aAAW;AAAA,UACX,WAAU;AAAA,UAER,aAAI,MAAO;AAAA;AAAA,MACd,GACD;AAAA,OAEF;AAAA,IACE,oBACD;AAAA,MAAC;AAAA;AAAA,QACA,SAAU;AAAA,QACV,UAAW;AAAA,QACX;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,7 +4,10 @@ import { close, Icon } from "@wordpress/icons";
|
|
|
4
4
|
import { Button } from "@wordpress/components";
|
|
5
5
|
import { __ } from "@wordpress/i18n";
|
|
6
6
|
import { getColorClassName } from "@wordpress/block-editor";
|
|
7
|
+
import { useSelect } from "@wordpress/data";
|
|
8
|
+
import { store as coreStore } from "@wordpress/core-data";
|
|
7
9
|
import OverlayMenuIcon from "./overlay-menu-icon.mjs";
|
|
10
|
+
import { createTemplatePartId } from "../../template-part/edit/utils/create-template-part-id.mjs";
|
|
8
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
12
|
function ResponsiveWrapper({
|
|
10
13
|
children,
|
|
@@ -20,6 +23,10 @@ function ResponsiveWrapper({
|
|
|
20
23
|
overlay,
|
|
21
24
|
onNavigateToEntityRecord
|
|
22
25
|
}) {
|
|
26
|
+
const currentTheme = useSelect(
|
|
27
|
+
(select) => select(coreStore).getCurrentTheme()?.stylesheet,
|
|
28
|
+
[]
|
|
29
|
+
);
|
|
23
30
|
if (!isResponsive) {
|
|
24
31
|
return children;
|
|
25
32
|
}
|
|
@@ -59,8 +66,12 @@ function ResponsiveWrapper({
|
|
|
59
66
|
};
|
|
60
67
|
const handleToggleClick = () => {
|
|
61
68
|
if (overlay && onNavigateToEntityRecord) {
|
|
69
|
+
const templatePartId = createTemplatePartId(
|
|
70
|
+
currentTheme,
|
|
71
|
+
overlay
|
|
72
|
+
);
|
|
62
73
|
onNavigateToEntityRecord({
|
|
63
|
-
postId:
|
|
74
|
+
postId: templatePartId,
|
|
64
75
|
postType: "wp_template_part"
|
|
65
76
|
});
|
|
66
77
|
return;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/navigation/edit/responsive-wrapper.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { close, Icon } from '@wordpress/icons';\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { getColorClassName } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport OverlayMenuIcon from './overlay-menu-icon';\n\nexport default function ResponsiveWrapper( {\n\tchildren,\n\tid,\n\tisOpen,\n\tisResponsive,\n\tonToggle,\n\tisHiddenByDefault,\n\toverlayBackgroundColor,\n\toverlayTextColor,\n\thasIcon,\n\ticon,\n\toverlay,\n\tonNavigateToEntityRecord,\n} ) {\n\tif ( ! isResponsive ) {\n\t\treturn children;\n\t}\n\n\t// Only apply overlay colors if there's no custom overlay template part.\n\tconst hasCustomOverlay = !! overlay;\n\n\tconst responsiveContainerClasses = clsx(\n\t\t'wp-block-navigation__responsive-container',\n\t\t! hasCustomOverlay && {\n\t\t\t'has-text-color':\n\t\t\t\t!! overlayTextColor.color || !! overlayTextColor?.class,\n\t\t\t[ getColorClassName( 'color', overlayTextColor?.slug ) ]:\n\t\t\t\t!! overlayTextColor?.slug,\n\t\t\t'has-background':\n\t\t\t\t!! overlayBackgroundColor.color ||\n\t\t\t\toverlayBackgroundColor?.class,\n\t\t\t[ getColorClassName(\n\t\t\t\t'background-color',\n\t\t\t\toverlayBackgroundColor?.slug\n\t\t\t) ]: !! overlayBackgroundColor?.slug,\n\t\t},\n\t\t{\n\t\t\t'is-menu-open': isOpen,\n\t\t\t'hidden-by-default': isHiddenByDefault,\n\t\t}\n\t);\n\n\tconst styles = ! hasCustomOverlay\n\t\t? {\n\t\t\t\tcolor: ! overlayTextColor?.slug && overlayTextColor?.color,\n\t\t\t\tbackgroundColor:\n\t\t\t\t\t! overlayBackgroundColor?.slug &&\n\t\t\t\t\toverlayBackgroundColor?.color &&\n\t\t\t\t\toverlayBackgroundColor.color,\n\t\t }\n\t\t: {};\n\n\tconst openButtonClasses = clsx(\n\t\t'wp-block-navigation__responsive-container-open',\n\t\t{ 'always-shown': isHiddenByDefault }\n\t);\n\n\tconst modalId = `${ id }-modal`;\n\n\tconst dialogProps = {\n\t\tclassName: 'wp-block-navigation__responsive-dialog',\n\t\t...( isOpen && {\n\t\t\trole: 'dialog',\n\t\t\t'aria-modal': true,\n\t\t\t'aria-label': __( 'Menu' ),\n\t\t} ),\n\t};\n\n\tconst handleToggleClick = () => {\n\t\t// If an overlay template part is selected, navigate to it instead of toggling\n\t\tif ( overlay && onNavigateToEntityRecord ) {\n\t\t\tonNavigateToEntityRecord( {\n\t\t\t\tpostId:
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,OAAO,YAAY;AAC5B,SAAS,cAAc;AACvB,SAAS,UAAU;AACnB,SAAS,yBAAyB;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { close, Icon } from '@wordpress/icons';\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { getColorClassName } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport OverlayMenuIcon from './overlay-menu-icon';\nimport { createTemplatePartId } from '../../template-part/edit/utils/create-template-part-id';\n\nexport default function ResponsiveWrapper( {\n\tchildren,\n\tid,\n\tisOpen,\n\tisResponsive,\n\tonToggle,\n\tisHiddenByDefault,\n\toverlayBackgroundColor,\n\toverlayTextColor,\n\thasIcon,\n\ticon,\n\toverlay,\n\tonNavigateToEntityRecord,\n} ) {\n\tconst currentTheme = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.stylesheet,\n\t\t[]\n\t);\n\n\tif ( ! isResponsive ) {\n\t\treturn children;\n\t}\n\n\t// Only apply overlay colors if there's no custom overlay template part.\n\tconst hasCustomOverlay = !! overlay;\n\n\tconst responsiveContainerClasses = clsx(\n\t\t'wp-block-navigation__responsive-container',\n\t\t! hasCustomOverlay && {\n\t\t\t'has-text-color':\n\t\t\t\t!! overlayTextColor.color || !! overlayTextColor?.class,\n\t\t\t[ getColorClassName( 'color', overlayTextColor?.slug ) ]:\n\t\t\t\t!! overlayTextColor?.slug,\n\t\t\t'has-background':\n\t\t\t\t!! overlayBackgroundColor.color ||\n\t\t\t\toverlayBackgroundColor?.class,\n\t\t\t[ getColorClassName(\n\t\t\t\t'background-color',\n\t\t\t\toverlayBackgroundColor?.slug\n\t\t\t) ]: !! overlayBackgroundColor?.slug,\n\t\t},\n\t\t{\n\t\t\t'is-menu-open': isOpen,\n\t\t\t'hidden-by-default': isHiddenByDefault,\n\t\t}\n\t);\n\n\tconst styles = ! hasCustomOverlay\n\t\t? {\n\t\t\t\tcolor: ! overlayTextColor?.slug && overlayTextColor?.color,\n\t\t\t\tbackgroundColor:\n\t\t\t\t\t! overlayBackgroundColor?.slug &&\n\t\t\t\t\toverlayBackgroundColor?.color &&\n\t\t\t\t\toverlayBackgroundColor.color,\n\t\t }\n\t\t: {};\n\n\tconst openButtonClasses = clsx(\n\t\t'wp-block-navigation__responsive-container-open',\n\t\t{ 'always-shown': isHiddenByDefault }\n\t);\n\n\tconst modalId = `${ id }-modal`;\n\n\tconst dialogProps = {\n\t\tclassName: 'wp-block-navigation__responsive-dialog',\n\t\t...( isOpen && {\n\t\t\trole: 'dialog',\n\t\t\t'aria-modal': true,\n\t\t\t'aria-label': __( 'Menu' ),\n\t\t} ),\n\t};\n\n\tconst handleToggleClick = () => {\n\t\t// If an overlay template part is selected, navigate to it instead of toggling\n\t\tif ( overlay && onNavigateToEntityRecord ) {\n\t\t\tconst templatePartId = createTemplatePartId(\n\t\t\t\tcurrentTheme,\n\t\t\t\toverlay\n\t\t\t);\n\n\t\t\tonNavigateToEntityRecord( {\n\t\t\t\tpostId: templatePartId,\n\t\t\t\tpostType: 'wp_template_part',\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\t\t// Otherwise, use normal toggle behavior\n\t\tonToggle( true );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t{ ! isOpen && (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\taria-label={ hasIcon && __( 'Open menu' ) }\n\t\t\t\t\tclassName={ openButtonClasses }\n\t\t\t\t\tonClick={ handleToggleClick }\n\t\t\t\t>\n\t\t\t\t\t{ hasIcon && <OverlayMenuIcon icon={ icon } /> }\n\t\t\t\t\t{ ! hasIcon && __( 'Menu' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\n\t\t\t<div\n\t\t\t\tclassName={ responsiveContainerClasses }\n\t\t\t\tstyle={ styles }\n\t\t\t\tid={ modalId }\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"wp-block-navigation__responsive-close\"\n\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t>\n\t\t\t\t\t<div { ...dialogProps }>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tclassName=\"wp-block-navigation__responsive-container-close\"\n\t\t\t\t\t\t\taria-label={ hasIcon && __( 'Close menu' ) }\n\t\t\t\t\t\t\tonClick={ () => onToggle( false ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ hasIcon && <Icon icon={ close } /> }\n\t\t\t\t\t\t\t{ ! hasIcon && __( 'Close' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"wp-block-navigation__responsive-container-content\"\n\t\t\t\t\t\t\tid={ `${ modalId }-content` }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,OAAO,YAAY;AAC5B,SAAS,cAAc;AACvB,SAAS,UAAU;AACnB,SAAS,yBAAyB;AAClC,SAAS,iBAAiB;AAC1B,SAAS,SAAS,iBAAiB;AAKnC,OAAO,qBAAqB;AAC5B,SAAS,4BAA4B;AA8FnC,mBASgB,KAPd,YAFF;AA5Fa,SAAR,kBAAoC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,eAAe;AAAA,IACpB,CAAE,WAAY,OAAQ,SAAU,EAAE,gBAAgB,GAAG;AAAA,IACrD,CAAC;AAAA,EACF;AAEA,MAAK,CAAE,cAAe;AACrB,WAAO;AAAA,EACR;AAGA,QAAM,mBAAmB,CAAC,CAAE;AAE5B,QAAM,6BAA6B;AAAA,IAClC;AAAA,IACA,CAAE,oBAAoB;AAAA,MACrB,kBACC,CAAC,CAAE,iBAAiB,SAAS,CAAC,CAAE,kBAAkB;AAAA,MACnD,CAAE,kBAAmB,SAAS,kBAAkB,IAAK,CAAE,GACtD,CAAC,CAAE,kBAAkB;AAAA,MACtB,kBACC,CAAC,CAAE,uBAAuB,SAC1B,wBAAwB;AAAA,MACzB,CAAE;AAAA,QACD;AAAA,QACA,wBAAwB;AAAA,MACzB,CAAE,GAAG,CAAC,CAAE,wBAAwB;AAAA,IACjC;AAAA,IACA;AAAA,MACC,gBAAgB;AAAA,MACh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,kBACzC,SAAU,MAAM,SAAU,KAAM;AAAA,kBAE9B;AAAA,+BAAW,oBAAC,QAAK,MAAO,OAAQ;AAAA,oBAChC,CAAE,WAAW,GAAI,OAAQ;AAAA;AAAA;AAAA,cAC5B;AAAA,cACA;AAAA,gBAAC;AAAA;AAAA,kBACA,WAAU;AAAA,kBACV,IAAK,GAAI,OAAQ;AAAA,kBAEf;AAAA;AAAA,cACH;AAAA,eACD;AAAA;AAAA,QACD;AAAA;AAAA,IACD;AAAA,KACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
// packages/block-library/src/navigation/edit/use-create-overlay.js
|
|
2
2
|
import { useCallback } from "@wordpress/element";
|
|
3
|
-
import { useDispatch } from "@wordpress/data";
|
|
3
|
+
import { useDispatch, useSelect } from "@wordpress/data";
|
|
4
4
|
import { store as coreStore } from "@wordpress/core-data";
|
|
5
|
+
import { store as blockEditorStore } from "@wordpress/block-editor";
|
|
5
6
|
import { __ } from "@wordpress/i18n";
|
|
6
|
-
import { serialize, createBlock } from "@wordpress/blocks";
|
|
7
|
+
import { parse, serialize, createBlock } from "@wordpress/blocks";
|
|
7
8
|
import { getUniqueTemplatePartTitle, getCleanTemplatePartSlug } from "./utils.mjs";
|
|
8
9
|
import { NAVIGATION_OVERLAY_TEMPLATE_PART_AREA } from "../constants.mjs";
|
|
10
|
+
import { unlock } from "../../lock-unlock.mjs";
|
|
9
11
|
function useCreateOverlayTemplatePart(overlayTemplateParts) {
|
|
10
12
|
const { saveEntityRecord } = useDispatch(coreStore);
|
|
13
|
+
const pattern = useSelect(
|
|
14
|
+
(select) => unlock(select(blockEditorStore)).getPatternBySlug(
|
|
15
|
+
"gutenberg/navigation-overlay"
|
|
16
|
+
),
|
|
17
|
+
[]
|
|
18
|
+
);
|
|
11
19
|
const createOverlayTemplatePart = useCallback(async () => {
|
|
12
20
|
const templatePartsWithTitles = overlayTemplateParts.filter(
|
|
13
21
|
(templatePart2) => templatePart2.title?.rendered
|
|
@@ -17,19 +25,28 @@ function useCreateOverlayTemplatePart(overlayTemplateParts) {
|
|
|
17
25
|
templatePartsWithTitles
|
|
18
26
|
);
|
|
19
27
|
const cleanSlug = getCleanTemplatePartSlug(uniqueTitle);
|
|
28
|
+
let initialContent = "";
|
|
29
|
+
if (pattern?.content) {
|
|
30
|
+
const blocks = parse(pattern.content, {
|
|
31
|
+
__unstableSkipMigrationLogs: true
|
|
32
|
+
});
|
|
33
|
+
initialContent = serialize(blocks);
|
|
34
|
+
} else {
|
|
35
|
+
initialContent = serialize([createBlock("core/paragraph")]);
|
|
36
|
+
}
|
|
20
37
|
const templatePart = await saveEntityRecord(
|
|
21
38
|
"postType",
|
|
22
39
|
"wp_template_part",
|
|
23
40
|
{
|
|
24
41
|
slug: cleanSlug,
|
|
25
42
|
title: uniqueTitle,
|
|
26
|
-
content:
|
|
43
|
+
content: initialContent,
|
|
27
44
|
area: NAVIGATION_OVERLAY_TEMPLATE_PART_AREA
|
|
28
45
|
},
|
|
29
46
|
{ throwOnError: true }
|
|
30
47
|
);
|
|
31
48
|
return templatePart;
|
|
32
|
-
}, [overlayTemplateParts, saveEntityRecord]);
|
|
49
|
+
}, [overlayTemplateParts, saveEntityRecord, pattern]);
|
|
33
50
|
return createOverlayTemplatePart;
|
|
34
51
|
}
|
|
35
52
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/navigation/edit/use-create-overlay.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport { serialize, createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { getUniqueTemplatePartTitle, getCleanTemplatePartSlug } from './utils';\nimport { NAVIGATION_OVERLAY_TEMPLATE_PART_AREA } from '../constants';\n\n/**\n * Hook to create a new overlay template part.\n *\n * @param {Array} overlayTemplateParts Array of existing overlay template parts.\n * @return {function(): Promise<Object>} Function to create a new overlay template part.\n * The function returns a Promise that resolves to the created template part object.\n */\nexport default function useCreateOverlayTemplatePart( overlayTemplateParts ) {\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\tconst createOverlayTemplatePart = useCallback( async () => {\n\t\t// Generate unique name using only overlay area template parts\n\t\t// Filter to only include template parts with titles for uniqueness check\n\t\tconst templatePartsWithTitles = overlayTemplateParts.filter(\n\t\t\t( templatePart ) => templatePart.title?.rendered\n\t\t);\n\t\tconst uniqueTitle = getUniqueTemplatePartTitle(\n\t\t\t__( 'Overlay' ),\n\t\t\ttemplatePartsWithTitles\n\t\t);\n\t\tconst cleanSlug = getCleanTemplatePartSlug( uniqueTitle );\n\n\t\t// Create the template part\n\t\tconst templatePart = await saveEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\t{\n\t\t\t\tslug: cleanSlug,\n\t\t\t\ttitle: uniqueTitle,\n\t\t\t\tcontent:
|
|
5
|
-
"mappings": ";AAGA,SAAS,mBAAmB;AAC5B,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { parse, serialize, createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { getUniqueTemplatePartTitle, getCleanTemplatePartSlug } from './utils';\nimport { NAVIGATION_OVERLAY_TEMPLATE_PART_AREA } from '../constants';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Hook to create a new overlay template part.\n *\n * @param {Array} overlayTemplateParts Array of existing overlay template parts.\n * @return {function(): Promise<Object>} Function to create a new overlay template part.\n * The function returns a Promise that resolves to the created template part object.\n */\nexport default function useCreateOverlayTemplatePart( overlayTemplateParts ) {\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst pattern = useSelect(\n\t\t( select ) =>\n\t\t\tunlock( select( blockEditorStore ) ).getPatternBySlug(\n\t\t\t\t'gutenberg/navigation-overlay'\n\t\t\t),\n\t\t[]\n\t);\n\n\tconst createOverlayTemplatePart = useCallback( async () => {\n\t\t// Generate unique name using only overlay area template parts\n\t\t// Filter to only include template parts with titles for uniqueness check\n\t\tconst templatePartsWithTitles = overlayTemplateParts.filter(\n\t\t\t( templatePart ) => templatePart.title?.rendered\n\t\t);\n\t\tconst uniqueTitle = getUniqueTemplatePartTitle(\n\t\t\t__( 'Overlay' ),\n\t\t\ttemplatePartsWithTitles\n\t\t);\n\t\tconst cleanSlug = getCleanTemplatePartSlug( uniqueTitle );\n\n\t\tlet initialContent = '';\n\n\t\tif ( pattern?.content ) {\n\t\t\t// Parse the pattern content into blocks and serialize it\n\t\t\tconst blocks = parse( pattern.content, {\n\t\t\t\t__unstableSkipMigrationLogs: true,\n\t\t\t} );\n\t\t\tinitialContent = serialize( blocks );\n\t\t} else {\n\t\t\t// Fallback to empty paragraph if pattern is not found\n\t\t\tinitialContent = serialize( [ createBlock( 'core/paragraph' ) ] );\n\t\t}\n\n\t\t// Create the template part\n\t\tconst templatePart = await saveEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\t{\n\t\t\t\tslug: cleanSlug,\n\t\t\t\ttitle: uniqueTitle,\n\t\t\t\tcontent: initialContent,\n\t\t\t\tarea: NAVIGATION_OVERLAY_TEMPLATE_PART_AREA,\n\t\t\t},\n\t\t\t{ throwOnError: true }\n\t\t);\n\n\t\treturn templatePart;\n\t}, [ overlayTemplateParts, saveEntityRecord, pattern ] );\n\n\treturn createOverlayTemplatePart;\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,mBAAmB;AAC5B,SAAS,aAAa,iBAAiB;AACvC,SAAS,SAAS,iBAAiB;AACnC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,UAAU;AACnB,SAAS,OAAO,WAAW,mBAAmB;AAK9C,SAAS,4BAA4B,gCAAgC;AACrE,SAAS,6CAA6C;AACtD,SAAS,cAAc;AASR,SAAR,6BAA+C,sBAAuB;AAC5E,QAAM,EAAE,iBAAiB,IAAI,YAAa,SAAU;AACpD,QAAM,UAAU;AAAA,IACf,CAAE,WACD,OAAQ,OAAQ,gBAAiB,CAAE,EAAE;AAAA,MACpC;AAAA,IACD;AAAA,IACD,CAAC;AAAA,EACF;AAEA,QAAM,4BAA4B,YAAa,YAAY;AAG1D,UAAM,0BAA0B,qBAAqB;AAAA,MACpD,CAAEA,kBAAkBA,cAAa,OAAO;AAAA,IACzC;AACA,UAAM,cAAc;AAAA,MACnB,GAAI,SAAU;AAAA,MACd;AAAA,IACD;AACA,UAAM,YAAY,yBAA0B,WAAY;AAExD,QAAI,iBAAiB;AAErB,QAAK,SAAS,SAAU;AAEvB,YAAM,SAAS,MAAO,QAAQ,SAAS;AAAA,QACtC,6BAA6B;AAAA,MAC9B,CAAE;AACF,uBAAiB,UAAW,MAAO;AAAA,IACpC,OAAO;AAEN,uBAAiB,UAAW,CAAE,YAAa,gBAAiB,CAAE,CAAE;AAAA,IACjE;AAGA,UAAM,eAAe,MAAM;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,SAAS;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,EAAE,cAAc,KAAK;AAAA,IACtB;AAEA,WAAO;AAAA,EACR,GAAG,CAAE,sBAAsB,kBAAkB,OAAQ,CAAE;AAEvD,SAAO;AACR;",
|
|
6
6
|
"names": ["templatePart"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// packages/block-library/src/navigation/utils/get-submenu-visibility.js
|
|
2
|
+
function getSubmenuVisibility(attributes) {
|
|
3
|
+
const { submenuVisibility, openSubmenusOnClick } = attributes;
|
|
4
|
+
if (submenuVisibility) {
|
|
5
|
+
return submenuVisibility;
|
|
6
|
+
}
|
|
7
|
+
return openSubmenusOnClick ? "click" : "hover";
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
getSubmenuVisibility
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=get-submenu-visibility.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/navigation/utils/get-submenu-visibility.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Returns the submenu visibility value with backward compatibility\n * for the deprecated openSubmenusOnClick attribute.\n *\n * This function centralizes the migration logic from the boolean\n * openSubmenusOnClick to the new submenuVisibility enum.\n *\n * NOTE: Keep this function in sync with block_core_navigation_get_submenu_visibility\n * in packages/block-library/src/navigation/index.php\n *\n * @param {Object} attributes Block attributes containing submenuVisibility and/or openSubmenusOnClick.\n * @return {string} The visibility mode: 'hover', 'click', or 'always'.\n */\nexport function getSubmenuVisibility( attributes ) {\n\tconst { submenuVisibility, openSubmenusOnClick } = attributes;\n\n\t// If new attribute is set, use it\n\tif ( submenuVisibility ) {\n\t\treturn submenuVisibility;\n\t}\n\n\t// Fall back to old attribute for backward compatibility\n\t// openSubmenusOnClick: true -> 'click'\n\t// openSubmenusOnClick: false -> 'hover'\n\t// openSubmenusOnClick: undefined -> 'hover' (default)\n\treturn openSubmenusOnClick ? 'click' : 'hover';\n}\n"],
|
|
5
|
+
"mappings": ";AAaO,SAAS,qBAAsB,YAAa;AAClD,QAAM,EAAE,mBAAmB,oBAAoB,IAAI;AAGnD,MAAK,mBAAoB;AACxB,WAAO;AAAA,EACR;AAMA,SAAO,sBAAsB,UAAU;AACxC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -31,7 +31,9 @@ import {
|
|
|
31
31
|
useHandleLinkChange,
|
|
32
32
|
useIsInvalidLink,
|
|
33
33
|
InvalidDraftDisplay,
|
|
34
|
-
useEnableLinkStatusValidation
|
|
34
|
+
useEnableLinkStatusValidation,
|
|
35
|
+
useIsDraggingWithin,
|
|
36
|
+
selectLabelText
|
|
35
37
|
} from "./shared/index.mjs";
|
|
36
38
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
37
39
|
var DEFAULT_BLOCK = { name: "core/navigation-link" };
|
|
@@ -39,34 +41,6 @@ var NESTING_BLOCK_NAMES = [
|
|
|
39
41
|
"core/navigation-link",
|
|
40
42
|
"core/navigation-submenu"
|
|
41
43
|
];
|
|
42
|
-
var useIsDraggingWithin = (elementRef) => {
|
|
43
|
-
const [isDraggingWithin, setIsDraggingWithin] = useState(false);
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
const { ownerDocument } = elementRef.current;
|
|
46
|
-
function handleDragStart(event) {
|
|
47
|
-
handleDragEnter(event);
|
|
48
|
-
}
|
|
49
|
-
function handleDragEnd() {
|
|
50
|
-
setIsDraggingWithin(false);
|
|
51
|
-
}
|
|
52
|
-
function handleDragEnter(event) {
|
|
53
|
-
if (elementRef.current.contains(event.target)) {
|
|
54
|
-
setIsDraggingWithin(true);
|
|
55
|
-
} else {
|
|
56
|
-
setIsDraggingWithin(false);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
ownerDocument.addEventListener("dragstart", handleDragStart);
|
|
60
|
-
ownerDocument.addEventListener("dragend", handleDragEnd);
|
|
61
|
-
ownerDocument.addEventListener("dragenter", handleDragEnter);
|
|
62
|
-
return () => {
|
|
63
|
-
ownerDocument.removeEventListener("dragstart", handleDragStart);
|
|
64
|
-
ownerDocument.removeEventListener("dragend", handleDragEnd);
|
|
65
|
-
ownerDocument.removeEventListener("dragenter", handleDragEnter);
|
|
66
|
-
};
|
|
67
|
-
}, [elementRef]);
|
|
68
|
-
return isDraggingWithin;
|
|
69
|
-
};
|
|
70
44
|
function getMissingText(type) {
|
|
71
45
|
let missingText = "";
|
|
72
46
|
switch (type) {
|
|
@@ -202,7 +176,7 @@ function NavigationLinkEdit({
|
|
|
202
176
|
}
|
|
203
177
|
isNewLink.current = false;
|
|
204
178
|
if (isURL(prependHTTP(label)) && /^.+\.[a-z]+/.test(label)) {
|
|
205
|
-
selectLabelText();
|
|
179
|
+
selectLabelText(ref);
|
|
206
180
|
} else {
|
|
207
181
|
selectBlock(clientId, null);
|
|
208
182
|
if (isSubmenu) {
|
|
@@ -213,16 +187,6 @@ function NavigationLinkEdit({
|
|
|
213
187
|
}
|
|
214
188
|
}
|
|
215
189
|
}, [url, isLinkOpen, isNewLink, label]);
|
|
216
|
-
function selectLabelText() {
|
|
217
|
-
ref.current.focus();
|
|
218
|
-
const { ownerDocument } = ref.current;
|
|
219
|
-
const { defaultView } = ownerDocument;
|
|
220
|
-
const selection = defaultView.getSelection();
|
|
221
|
-
const range = ownerDocument.createRange();
|
|
222
|
-
range.selectNodeContents(ref.current);
|
|
223
|
-
selection.removeAllRanges();
|
|
224
|
-
selection.addRange(range);
|
|
225
|
-
}
|
|
226
190
|
function removeLink() {
|
|
227
191
|
setAttributes({
|
|
228
192
|
url: void 0,
|