@wordpress/block-library 8.19.4 → 8.19.6

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.
Files changed (43) hide show
  1. package/build/image/image.js +4 -1
  2. package/build/image/image.js.map +1 -1
  3. package/build/image/view.js +13 -4
  4. package/build/image/view.js.map +1 -1
  5. package/build/latest-posts/edit.js +2 -2
  6. package/build/latest-posts/edit.js.map +1 -1
  7. package/build/list-item/hooks/use-merge.js +15 -15
  8. package/build/list-item/hooks/use-merge.js.map +1 -1
  9. package/build/lock-unlock.js +1 -1
  10. package/build/lock-unlock.js.map +1 -1
  11. package/build/navigation/edit/index.js +0 -1
  12. package/build/navigation/edit/index.js.map +1 -1
  13. package/build/navigation/view.js +7 -0
  14. package/build/navigation/view.js.map +1 -1
  15. package/build-module/image/image.js +4 -1
  16. package/build-module/image/image.js.map +1 -1
  17. package/build-module/image/view.js +13 -4
  18. package/build-module/image/view.js.map +1 -1
  19. package/build-module/latest-posts/edit.js +2 -2
  20. package/build-module/latest-posts/edit.js.map +1 -1
  21. package/build-module/list-item/hooks/use-merge.js +15 -15
  22. package/build-module/list-item/hooks/use-merge.js.map +1 -1
  23. package/build-module/lock-unlock.js +1 -1
  24. package/build-module/lock-unlock.js.map +1 -1
  25. package/build-module/navigation/edit/index.js +0 -1
  26. package/build-module/navigation/edit/index.js.map +1 -1
  27. package/build-module/navigation/view.js +7 -0
  28. package/build-module/navigation/view.js.map +1 -1
  29. package/package.json +32 -32
  30. package/src/image/image.js +10 -0
  31. package/src/image/index.php +55 -37
  32. package/src/image/view.js +16 -5
  33. package/src/latest-posts/edit.js +4 -3
  34. package/src/latest-posts/index.php +2 -3
  35. package/src/list-item/hooks/use-merge.js +20 -23
  36. package/src/lock-unlock.js +1 -1
  37. package/src/navigation/edit/index.js +0 -1
  38. package/src/navigation/index.php +19 -6
  39. package/src/navigation/view.js +7 -0
  40. package/src/pattern/index.php +0 -3
  41. package/src/query/index.php +2 -1
  42. package/src/search/index.php +0 -4
  43. package/src/template-part/index.php +4 -7
@@ -1 +1 @@
1
- {"version":3,"names":["store","wpStore","focusableSelectors","openMenu","menuOpenedOn","context","ref","selectors","core","navigation","menuOpenedBy","previousFocus","type","document","documentElement","classList","add","closeMenu","menuClosedOn","isMenuOpen","modal","contains","window","activeElement","focus","remove","effects","initMenu","focusableElements","querySelectorAll","firstFocusableElement","lastFocusableElement","length","focusFirstElement","querySelector","roleAttribute","ariaModal","Object","values","filter","Boolean","actions","openMenuOnHover","overlayOpenedBy","closeMenuOnHover","openMenuOnClick","closeMenuOnClick","openMenuOnFocus","toggleMenuOnClick","click","handleMenuKeydown","event","key","shiftKey","preventDefault","handleMenuFocusout","relatedTarget","target"],"sources":["@wordpress/block-library/src/navigation/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as wpStore } from '@wordpress/interactivity';\n\nconst focusableSelectors = [\n\t'a[href]',\n\t'input:not([disabled]):not([type=\"hidden\"]):not([aria-hidden])',\n\t'select:not([disabled]):not([aria-hidden])',\n\t'textarea:not([disabled]):not([aria-hidden])',\n\t'button:not([disabled]):not([aria-hidden])',\n\t'[contenteditable]',\n\t'[tabindex]:not([tabindex^=\"-\"])',\n];\n\nconst openMenu = ( store, menuOpenedOn ) => {\n\tconst { context, ref, selectors } = store;\n\tselectors.core.navigation.menuOpenedBy( store )[ menuOpenedOn ] = true;\n\tcontext.core.navigation.previousFocus = ref;\n\tif ( context.core.navigation.type === 'overlay' ) {\n\t\t// Add a `has-modal-open` class to the <html> root.\n\t\tdocument.documentElement.classList.add( 'has-modal-open' );\n\t}\n};\n\nconst closeMenu = ( store, menuClosedOn ) => {\n\tconst { context, selectors } = store;\n\tselectors.core.navigation.menuOpenedBy( store )[ menuClosedOn ] = false;\n\t// Check if the menu is still open or not.\n\tif ( ! selectors.core.navigation.isMenuOpen( store ) ) {\n\t\tif (\n\t\t\tcontext.core.navigation.modal?.contains(\n\t\t\t\twindow.document.activeElement\n\t\t\t)\n\t\t) {\n\t\t\tcontext.core.navigation.previousFocus.focus();\n\t\t}\n\t\tcontext.core.navigation.modal = null;\n\t\tcontext.core.navigation.previousFocus = null;\n\t\tif ( context.core.navigation.type === 'overlay' ) {\n\t\t\tdocument.documentElement.classList.remove( 'has-modal-open' );\n\t\t}\n\t}\n};\n\nwpStore( {\n\teffects: {\n\t\tcore: {\n\t\t\tnavigation: {\n\t\t\t\tinitMenu: ( store ) => {\n\t\t\t\t\tconst { context, selectors, ref } = store;\n\t\t\t\t\tif ( selectors.core.navigation.isMenuOpen( store ) ) {\n\t\t\t\t\t\tconst focusableElements =\n\t\t\t\t\t\t\tref.querySelectorAll( focusableSelectors );\n\t\t\t\t\t\tcontext.core.navigation.modal = ref;\n\t\t\t\t\t\tcontext.core.navigation.firstFocusableElement =\n\t\t\t\t\t\t\tfocusableElements[ 0 ];\n\t\t\t\t\t\tcontext.core.navigation.lastFocusableElement =\n\t\t\t\t\t\t\tfocusableElements[ focusableElements.length - 1 ];\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tfocusFirstElement: ( store ) => {\n\t\t\t\t\tconst { selectors, ref } = store;\n\t\t\t\t\tif ( selectors.core.navigation.isMenuOpen( store ) ) {\n\t\t\t\t\t\tref.querySelector(\n\t\t\t\t\t\t\t'.wp-block-navigation-item > *:first-child'\n\t\t\t\t\t\t).focus();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\tselectors: {\n\t\tcore: {\n\t\t\tnavigation: {\n\t\t\t\troleAttribute: ( store ) => {\n\t\t\t\t\tconst { context, selectors } = store;\n\t\t\t\t\treturn context.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\tselectors.core.navigation.isMenuOpen( store )\n\t\t\t\t\t\t? 'dialog'\n\t\t\t\t\t\t: null;\n\t\t\t\t},\n\t\t\t\tariaModal: ( store ) => {\n\t\t\t\t\tconst { context, selectors } = store;\n\t\t\t\t\treturn context.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\tselectors.core.navigation.isMenuOpen( store )\n\t\t\t\t\t\t? 'true'\n\t\t\t\t\t\t: null;\n\t\t\t\t},\n\t\t\t\tisMenuOpen: ( { context } ) =>\n\t\t\t\t\t// The menu is opened if either `click`, `hover` or `focus` is true.\n\t\t\t\t\tObject.values(\n\t\t\t\t\t\tcontext.core.navigation[\n\t\t\t\t\t\t\tcontext.core.navigation.type === 'overlay'\n\t\t\t\t\t\t\t\t? 'overlayOpenedBy'\n\t\t\t\t\t\t\t\t: 'submenuOpenedBy'\n\t\t\t\t\t\t]\n\t\t\t\t\t).filter( Boolean ).length > 0,\n\t\t\t\tmenuOpenedBy: ( { context } ) =>\n\t\t\t\t\tcontext.core.navigation[\n\t\t\t\t\t\tcontext.core.navigation.type === 'overlay'\n\t\t\t\t\t\t\t? 'overlayOpenedBy'\n\t\t\t\t\t\t\t: 'submenuOpenedBy'\n\t\t\t\t\t],\n\t\t\t},\n\t\t},\n\t},\n\tactions: {\n\t\tcore: {\n\t\t\tnavigation: {\n\t\t\t\topenMenuOnHover( store ) {\n\t\t\t\t\tconst { navigation } = store.context.core;\n\t\t\t\t\tif (\n\t\t\t\t\t\tnavigation.type === 'submenu' &&\n\t\t\t\t\t\t// Only open on hover if the overlay is closed.\n\t\t\t\t\t\tObject.values(\n\t\t\t\t\t\t\tnavigation.overlayOpenedBy || {}\n\t\t\t\t\t\t).filter( Boolean ).length === 0\n\t\t\t\t\t)\n\t\t\t\t\t\topenMenu( store, 'hover' );\n\t\t\t\t},\n\t\t\t\tcloseMenuOnHover( store ) {\n\t\t\t\t\tcloseMenu( store, 'hover' );\n\t\t\t\t},\n\t\t\t\topenMenuOnClick( store ) {\n\t\t\t\t\topenMenu( store, 'click' );\n\t\t\t\t},\n\t\t\t\tcloseMenuOnClick( store ) {\n\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t},\n\t\t\t\topenMenuOnFocus( store ) {\n\t\t\t\t\topenMenu( store, 'focus' );\n\t\t\t\t},\n\t\t\t\ttoggleMenuOnClick: ( store ) => {\n\t\t\t\t\tconst { selectors } = store;\n\t\t\t\t\tconst menuOpenedBy =\n\t\t\t\t\t\tselectors.core.navigation.menuOpenedBy( store );\n\t\t\t\t\tif ( menuOpenedBy.click || menuOpenedBy.focus ) {\n\t\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t\t} else {\n\t\t\t\t\t\topenMenu( store, 'click' );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\thandleMenuKeydown: ( store ) => {\n\t\t\t\t\tconst { context, selectors, event } = store;\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectors.core.navigation.menuOpenedBy( store ).click\n\t\t\t\t\t) {\n\t\t\t\t\t\t// If Escape close the menu.\n\t\t\t\t\t\tif ( event?.key === 'Escape' ) {\n\t\t\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Trap focus if it is an overlay (main menu).\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tcontext.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\t\tevent.key === 'Tab'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// If shift + tab it change the direction.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tevent.shiftKey &&\n\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\tcontext.core.navigation\n\t\t\t\t\t\t\t\t\t\t.firstFocusableElement\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tcontext.core.navigation.lastFocusableElement.focus();\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t! event.shiftKey &&\n\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\tcontext.core.navigation.lastFocusableElement\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tcontext.core.navigation.firstFocusableElement.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\thandleMenuFocusout: ( store ) => {\n\t\t\t\t\tconst { context, event } = store;\n\t\t\t\t\t// If focus is outside modal, and in the document, close menu\n\t\t\t\t\t// event.target === The element losing focus\n\t\t\t\t\t// event.relatedTarget === The element receiving focus (if any)\n\t\t\t\t\t// When focusout is outsite the document,\n\t\t\t\t\t// `window.document.activeElement` doesn't change.\n\t\t\t\t\tif (\n\t\t\t\t\t\t! context.core.navigation.modal?.contains(\n\t\t\t\t\t\t\tevent.relatedTarget\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\tevent.target !== window.document.activeElement\n\t\t\t\t\t) {\n\t\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,OAAO,QAAQ,0BAA0B;AAE3D,MAAMC,kBAAkB,GAAG,CAC1B,SAAS,EACT,+DAA+D,EAC/D,2CAA2C,EAC3C,6CAA6C,EAC7C,2CAA2C,EAC3C,mBAAmB,EACnB,iCAAiC,CACjC;AAED,MAAMC,QAAQ,GAAGA,CAAEH,KAAK,EAAEI,YAAY,KAAM;EAC3C,MAAM;IAAEC,OAAO;IAAEC,GAAG;IAAEC;EAAU,CAAC,GAAGP,KAAK;EACzCO,SAAS,CAACC,IAAI,CAACC,UAAU,CAACC,YAAY,CAAEV,KAAM,CAAC,CAAEI,YAAY,CAAE,GAAG,IAAI;EACtEC,OAAO,CAACG,IAAI,CAACC,UAAU,CAACE,aAAa,GAAGL,GAAG;EAC3C,IAAK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,CAAC,MAAM,IACN,CAAE2B,KAAK,CAACE,QAAQ,IAChB/B,MAAM,CAACT,QAAQ,CAACU,aAAa,KAC5BlB,OAAO,CAACG,IAAI,CAACC,UAAU,CAACsB,oBAAoB,EAC5C;gBACDoB,KAAK,CAACG,cAAc,CAAC,CAAC;gBACtBjD,OAAO,CAACG,IAAI,CAACC,UAAU,CAACqB,qBAAqB,CAACN,KAAK,CAAC,CAAC;cACtD;YACD;UACD;QACD,CAAC;QACD+B,kBAAkB,EAAIvD,KAAK,IAAM;UAChC,MAAM;YAAEK,OAAO;YAAE8C;UAAM,CAAC,GAAGnD,KAAK;UAChC;UACA;UACA;UACA;UACA;UACA,IACC,CAAEK,OAAO,CAACG,IAAI,CAACC,UAAU,CAACW,KAAK,EAAEC,QAAQ,CACxC8B,KAAK,CAACK,aACP,CAAC,IACDL,KAAK,CAACM,MAAM,KAAKnC,MAAM,CAACT,QAAQ,CAACU,aAAa,EAC7C;YACDN,SAAS,CAAEjB,KAAK,EAAE,OAAQ,CAAC;YAC3BiB,SAAS,CAAEjB,KAAK,EAAE,OAAQ,CAAC;UAC5B;QACD;MACD;IACD;EACD;AACD,CAAE,CAAC"}
1
+ {"version":3,"names":["store","wpStore","focusableSelectors","openMenu","menuOpenedOn","context","ref","selectors","core","navigation","menuOpenedBy","previousFocus","type","document","documentElement","classList","add","closeMenu","menuClosedOn","isMenuOpen","modal","contains","window","activeElement","focus","remove","effects","initMenu","focusableElements","querySelectorAll","firstFocusableElement","lastFocusableElement","length","focusFirstElement","querySelector","roleAttribute","ariaModal","ariaLabel","Object","values","filter","Boolean","actions","openMenuOnHover","overlayOpenedBy","closeMenuOnHover","openMenuOnClick","closeMenuOnClick","openMenuOnFocus","toggleMenuOnClick","click","handleMenuKeydown","event","key","shiftKey","preventDefault","handleMenuFocusout","relatedTarget","target"],"sources":["@wordpress/block-library/src/navigation/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as wpStore } from '@wordpress/interactivity';\n\nconst focusableSelectors = [\n\t'a[href]',\n\t'input:not([disabled]):not([type=\"hidden\"]):not([aria-hidden])',\n\t'select:not([disabled]):not([aria-hidden])',\n\t'textarea:not([disabled]):not([aria-hidden])',\n\t'button:not([disabled]):not([aria-hidden])',\n\t'[contenteditable]',\n\t'[tabindex]:not([tabindex^=\"-\"])',\n];\n\nconst openMenu = ( store, menuOpenedOn ) => {\n\tconst { context, ref, selectors } = store;\n\tselectors.core.navigation.menuOpenedBy( store )[ menuOpenedOn ] = true;\n\tcontext.core.navigation.previousFocus = ref;\n\tif ( context.core.navigation.type === 'overlay' ) {\n\t\t// Add a `has-modal-open` class to the <html> root.\n\t\tdocument.documentElement.classList.add( 'has-modal-open' );\n\t}\n};\n\nconst closeMenu = ( store, menuClosedOn ) => {\n\tconst { context, selectors } = store;\n\tselectors.core.navigation.menuOpenedBy( store )[ menuClosedOn ] = false;\n\t// Check if the menu is still open or not.\n\tif ( ! selectors.core.navigation.isMenuOpen( store ) ) {\n\t\tif (\n\t\t\tcontext.core.navigation.modal?.contains(\n\t\t\t\twindow.document.activeElement\n\t\t\t)\n\t\t) {\n\t\t\tcontext.core.navigation.previousFocus.focus();\n\t\t}\n\t\tcontext.core.navigation.modal = null;\n\t\tcontext.core.navigation.previousFocus = null;\n\t\tif ( context.core.navigation.type === 'overlay' ) {\n\t\t\tdocument.documentElement.classList.remove( 'has-modal-open' );\n\t\t}\n\t}\n};\n\nwpStore( {\n\teffects: {\n\t\tcore: {\n\t\t\tnavigation: {\n\t\t\t\tinitMenu: ( store ) => {\n\t\t\t\t\tconst { context, selectors, ref } = store;\n\t\t\t\t\tif ( selectors.core.navigation.isMenuOpen( store ) ) {\n\t\t\t\t\t\tconst focusableElements =\n\t\t\t\t\t\t\tref.querySelectorAll( focusableSelectors );\n\t\t\t\t\t\tcontext.core.navigation.modal = ref;\n\t\t\t\t\t\tcontext.core.navigation.firstFocusableElement =\n\t\t\t\t\t\t\tfocusableElements[ 0 ];\n\t\t\t\t\t\tcontext.core.navigation.lastFocusableElement =\n\t\t\t\t\t\t\tfocusableElements[ focusableElements.length - 1 ];\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tfocusFirstElement: ( store ) => {\n\t\t\t\t\tconst { selectors, ref } = store;\n\t\t\t\t\tif ( selectors.core.navigation.isMenuOpen( store ) ) {\n\t\t\t\t\t\tref.querySelector(\n\t\t\t\t\t\t\t'.wp-block-navigation-item > *:first-child'\n\t\t\t\t\t\t).focus();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\tselectors: {\n\t\tcore: {\n\t\t\tnavigation: {\n\t\t\t\troleAttribute: ( store ) => {\n\t\t\t\t\tconst { context, selectors } = store;\n\t\t\t\t\treturn context.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\tselectors.core.navigation.isMenuOpen( store )\n\t\t\t\t\t\t? 'dialog'\n\t\t\t\t\t\t: null;\n\t\t\t\t},\n\t\t\t\tariaModal: ( store ) => {\n\t\t\t\t\tconst { context, selectors } = store;\n\t\t\t\t\treturn context.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\tselectors.core.navigation.isMenuOpen( store )\n\t\t\t\t\t\t? 'true'\n\t\t\t\t\t\t: null;\n\t\t\t\t},\n\t\t\t\tariaLabel: ( store ) => {\n\t\t\t\t\tconst { context, selectors } = store;\n\t\t\t\t\treturn context.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\tselectors.core.navigation.isMenuOpen( store )\n\t\t\t\t\t\t? context.core.navigation.ariaLabel\n\t\t\t\t\t\t: null;\n\t\t\t\t},\n\t\t\t\tisMenuOpen: ( { context } ) =>\n\t\t\t\t\t// The menu is opened if either `click`, `hover` or `focus` is true.\n\t\t\t\t\tObject.values(\n\t\t\t\t\t\tcontext.core.navigation[\n\t\t\t\t\t\t\tcontext.core.navigation.type === 'overlay'\n\t\t\t\t\t\t\t\t? 'overlayOpenedBy'\n\t\t\t\t\t\t\t\t: 'submenuOpenedBy'\n\t\t\t\t\t\t]\n\t\t\t\t\t).filter( Boolean ).length > 0,\n\t\t\t\tmenuOpenedBy: ( { context } ) =>\n\t\t\t\t\tcontext.core.navigation[\n\t\t\t\t\t\tcontext.core.navigation.type === 'overlay'\n\t\t\t\t\t\t\t? 'overlayOpenedBy'\n\t\t\t\t\t\t\t: 'submenuOpenedBy'\n\t\t\t\t\t],\n\t\t\t},\n\t\t},\n\t},\n\tactions: {\n\t\tcore: {\n\t\t\tnavigation: {\n\t\t\t\topenMenuOnHover( store ) {\n\t\t\t\t\tconst { navigation } = store.context.core;\n\t\t\t\t\tif (\n\t\t\t\t\t\tnavigation.type === 'submenu' &&\n\t\t\t\t\t\t// Only open on hover if the overlay is closed.\n\t\t\t\t\t\tObject.values(\n\t\t\t\t\t\t\tnavigation.overlayOpenedBy || {}\n\t\t\t\t\t\t).filter( Boolean ).length === 0\n\t\t\t\t\t)\n\t\t\t\t\t\topenMenu( store, 'hover' );\n\t\t\t\t},\n\t\t\t\tcloseMenuOnHover( store ) {\n\t\t\t\t\tcloseMenu( store, 'hover' );\n\t\t\t\t},\n\t\t\t\topenMenuOnClick( store ) {\n\t\t\t\t\topenMenu( store, 'click' );\n\t\t\t\t},\n\t\t\t\tcloseMenuOnClick( store ) {\n\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t},\n\t\t\t\topenMenuOnFocus( store ) {\n\t\t\t\t\topenMenu( store, 'focus' );\n\t\t\t\t},\n\t\t\t\ttoggleMenuOnClick: ( store ) => {\n\t\t\t\t\tconst { selectors } = store;\n\t\t\t\t\tconst menuOpenedBy =\n\t\t\t\t\t\tselectors.core.navigation.menuOpenedBy( store );\n\t\t\t\t\tif ( menuOpenedBy.click || menuOpenedBy.focus ) {\n\t\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t\t} else {\n\t\t\t\t\t\topenMenu( store, 'click' );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\thandleMenuKeydown: ( store ) => {\n\t\t\t\t\tconst { context, selectors, event } = store;\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectors.core.navigation.menuOpenedBy( store ).click\n\t\t\t\t\t) {\n\t\t\t\t\t\t// If Escape close the menu.\n\t\t\t\t\t\tif ( event?.key === 'Escape' ) {\n\t\t\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Trap focus if it is an overlay (main menu).\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tcontext.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\t\tevent.key === 'Tab'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// If shift + tab it change the direction.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tevent.shiftKey &&\n\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\tcontext.core.navigation\n\t\t\t\t\t\t\t\t\t\t.firstFocusableElement\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tcontext.core.navigation.lastFocusableElement.focus();\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t! event.shiftKey &&\n\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\tcontext.core.navigation.lastFocusableElement\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tcontext.core.navigation.firstFocusableElement.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\thandleMenuFocusout: ( store ) => {\n\t\t\t\t\tconst { context, event } = store;\n\t\t\t\t\t// If focus is outside modal, and in the document, close menu\n\t\t\t\t\t// event.target === The element losing focus\n\t\t\t\t\t// event.relatedTarget === The element receiving focus (if any)\n\t\t\t\t\t// When focusout is outsite the document,\n\t\t\t\t\t// `window.document.activeElement` doesn't change.\n\t\t\t\t\tif (\n\t\t\t\t\t\t! context.core.navigation.modal?.contains(\n\t\t\t\t\t\t\tevent.relatedTarget\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\tevent.target !== window.document.activeElement\n\t\t\t\t\t) {\n\t\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,OAAO,QAAQ,0BAA0B;AAE3D,MAAMC,kBAAkB,GAAG,CAC1B,SAAS,EACT,+DAA+D,EAC/D,2CAA2C,EAC3C,6CAA6C,EAC7C,2CAA2C,EAC3C,mBAAmB,EACnB,iCAAiC,CACjC;AAED,MAAMC,QAAQ,GAAGA,CAAEH,KAAK,EAAEI,YAAY,KAAM;EAC3C,MAAM;IAAEC,OAAO;IAAEC,GAAG;IAAEC;EAAU,CAAC,GAAGP,KAAK;EACzCO,SAAS,CAACC,IAAI,CAACC,UAAU,CAACC,YAAY,CAAEV,KAAM,CAAC,CAAEI,YAAY,CAAE,GAAG,IAAI;EACtEC,OAAO,CAACG,IAAI,CAACC,UAAU,CAACE,aAAa,GAAGL,GAAG;EAC3C,IAAKD,OAAO,CAACG,IAAI,CAACC,UAAU,CAACG,IAAI,KAAK,SAAS,EAAG;IACjD;IACAC,QAAQ,CAACC,eAAe,CAACC,SAAS,CAACC,GAAG,CAAE,gBAAiB,CAAC;EAC3D;AACD,CAAC;AAED,MAAMC,SAAS,GAAGA,CAAEjB,KAAK,EAAEkB,YAAY,KAAM;EAC5C,MAAM;IAAEb,OAAO;IAAEE;EAAU,CAAC,GAAGP,KAAK;EACpCO,SAAS,CAACC,IAAI,CAACC,UAAU,CAACC,YAAY,CAAEV,KAAM,CAAC,C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Q,IAChBhC,MAAM,CAACT,QAAQ,CAACU,aAAa,KAC5BlB,OAAO,CAACG,IAAI,CAACC,UAAU,CAACsB,oBAAoB,EAC5C;gBACDqB,KAAK,CAACG,cAAc,CAAC,CAAC;gBACtBlD,OAAO,CAACG,IAAI,CAACC,UAAU,CAACqB,qBAAqB,CAACN,KAAK,CAAC,CAAC;cACtD;YACD;UACD;QACD,CAAC;QACDgC,kBAAkB,EAAIxD,KAAK,IAAM;UAChC,MAAM;YAAEK,OAAO;YAAE+C;UAAM,CAAC,GAAGpD,KAAK;UAChC;UACA;UACA;UACA;UACA;UACA,IACC,CAAEK,OAAO,CAACG,IAAI,CAACC,UAAU,CAACW,KAAK,EAAEC,QAAQ,CACxC+B,KAAK,CAACK,aACP,CAAC,IACDL,KAAK,CAACM,MAAM,KAAKpC,MAAM,CAACT,QAAQ,CAACU,aAAa,EAC7C;YACDN,SAAS,CAAEjB,KAAK,EAAE,OAAQ,CAAC;YAC3BiB,SAAS,CAAEjB,KAAK,EAAE,OAAQ,CAAC;UAC5B;QACD;MACD;IACD;EACD;AACD,CAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-library",
3
- "version": "8.19.4",
3
+ "version": "8.19.6",
4
4
  "description": "Block library for the WordPress editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -31,36 +31,36 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.16.0",
34
- "@wordpress/a11y": "^3.42.4",
35
- "@wordpress/api-fetch": "^6.39.4",
36
- "@wordpress/autop": "^3.42.4",
37
- "@wordpress/blob": "^3.42.4",
38
- "@wordpress/block-editor": "^12.10.4",
39
- "@wordpress/blocks": "^12.19.4",
40
- "@wordpress/components": "^25.8.4",
41
- "@wordpress/compose": "^6.19.4",
42
- "@wordpress/core-data": "^6.19.4",
43
- "@wordpress/data": "^9.12.4",
44
- "@wordpress/date": "^4.42.4",
45
- "@wordpress/deprecated": "^3.42.4",
46
- "@wordpress/dom": "^3.42.4",
47
- "@wordpress/element": "^5.19.4",
48
- "@wordpress/escape-html": "^2.42.4",
49
- "@wordpress/hooks": "^3.42.4",
50
- "@wordpress/html-entities": "^3.42.4",
51
- "@wordpress/i18n": "^4.42.4",
52
- "@wordpress/icons": "^9.33.4",
53
- "@wordpress/interactivity": "^2.3.4",
54
- "@wordpress/keycodes": "^3.42.4",
55
- "@wordpress/notices": "^4.10.4",
56
- "@wordpress/primitives": "^3.40.4",
57
- "@wordpress/private-apis": "^0.24.4",
58
- "@wordpress/reusable-blocks": "^4.19.4",
59
- "@wordpress/rich-text": "^6.19.4",
60
- "@wordpress/server-side-render": "^4.19.4",
61
- "@wordpress/url": "^3.43.4",
62
- "@wordpress/viewport": "^5.19.4",
63
- "@wordpress/wordcount": "^3.42.4",
34
+ "@wordpress/a11y": "^3.42.6",
35
+ "@wordpress/api-fetch": "^6.39.6",
36
+ "@wordpress/autop": "^3.42.6",
37
+ "@wordpress/blob": "^3.42.6",
38
+ "@wordpress/block-editor": "^12.10.6",
39
+ "@wordpress/blocks": "^12.19.6",
40
+ "@wordpress/components": "^25.8.6",
41
+ "@wordpress/compose": "^6.19.6",
42
+ "@wordpress/core-data": "^6.19.6",
43
+ "@wordpress/data": "^9.12.6",
44
+ "@wordpress/date": "^4.42.6",
45
+ "@wordpress/deprecated": "^3.42.6",
46
+ "@wordpress/dom": "^3.42.6",
47
+ "@wordpress/element": "^5.19.6",
48
+ "@wordpress/escape-html": "^2.42.6",
49
+ "@wordpress/hooks": "^3.42.6",
50
+ "@wordpress/html-entities": "^3.42.6",
51
+ "@wordpress/i18n": "^4.42.6",
52
+ "@wordpress/icons": "^9.33.6",
53
+ "@wordpress/interactivity": "^2.3.6",
54
+ "@wordpress/keycodes": "^3.42.6",
55
+ "@wordpress/notices": "^4.10.6",
56
+ "@wordpress/primitives": "^3.40.6",
57
+ "@wordpress/private-apis": "^0.24.6",
58
+ "@wordpress/reusable-blocks": "^4.19.6",
59
+ "@wordpress/rich-text": "^6.19.6",
60
+ "@wordpress/server-side-render": "^4.19.6",
61
+ "@wordpress/url": "^3.43.6",
62
+ "@wordpress/viewport": "^5.19.6",
63
+ "@wordpress/wordcount": "^3.42.6",
64
64
  "change-case": "^4.1.2",
65
65
  "classnames": "^2.3.1",
66
66
  "colord": "^2.7.0",
@@ -78,5 +78,5 @@
78
78
  "publishConfig": {
79
79
  "access": "public"
80
80
  },
81
- "gitHead": "d1072bbcaf037a18d414da7865ebaf366a0e7062"
81
+ "gitHead": "640c80ab0fb4e0e2bce87e33895939f257e674df"
82
82
  }
@@ -377,6 +377,8 @@ export default function Image( {
377
377
  const lightboxChecked =
378
378
  !! lightbox?.enabled || ( ! lightbox && !! lightboxSetting?.enabled );
379
379
 
380
+ const lightboxToggleDisabled = linkDestination !== 'none';
381
+
380
382
  const dimensionsControl = (
381
383
  <DimensionsTool
382
384
  value={ { width, height, scale, aspectRatio } }
@@ -555,6 +557,14 @@ export default function Image( {
555
557
  lightbox: { enabled: newValue },
556
558
  } );
557
559
  } }
560
+ disabled={ lightboxToggleDisabled }
561
+ help={
562
+ lightboxToggleDisabled
563
+ ? __(
564
+ '“Expand on click” scales the image up, and can’t be combined with a link.'
565
+ )
566
+ : ''
567
+ }
558
568
  />
559
569
  </ToolsPanelItem>
560
570
  ) }
@@ -16,11 +16,13 @@
16
16
  * @return string The block content with the data-id attribute added.
17
17
  */
18
18
  function render_block_core_image( $attributes, $content, $block ) {
19
+ if ( false === stripos( $content, '<img' ) ) {
20
+ return '';
21
+ }
19
22
 
20
23
  $processor = new WP_HTML_Tag_Processor( $content );
21
- $processor->next_tag( 'img' );
22
24
 
23
- if ( $processor->get_attribute( 'src' ) === null ) {
25
+ if ( ! $processor->next_tag( 'img' ) || null === $processor->get_attribute( 'src' ) ) {
24
26
  return '';
25
27
  }
26
28
 
@@ -32,45 +34,47 @@ function render_block_core_image( $attributes, $content, $block ) {
32
34
  $processor->set_attribute( 'data-id', $attributes['data-id'] );
33
35
  }
34
36
 
35
- $lightbox_enabled = false;
36
37
  $link_destination = isset( $attributes['linkDestination'] ) ? $attributes['linkDestination'] : 'none';
37
38
  $lightbox_settings = block_core_image_get_lightbox_settings( $block->parsed_block );
38
39
 
39
- // If the lightbox is enabled and the image is not linked, flag the lightbox to be rendered.
40
- if ( isset( $lightbox_settings ) && 'none' === $link_destination ) {
41
-
42
- if ( isset( $lightbox_settings['enabled'] ) && true === $lightbox_settings['enabled'] ) {
43
- $lightbox_enabled = true;
44
- }
45
- }
40
+ $view_js_file_handle = 'wp-block-image-view';
41
+ $script_handles = $block->block_type->view_script_handles;
46
42
 
47
- // If at least one block in the page has the lightbox, mark the block type as interactive.
48
- if ( $lightbox_enabled ) {
43
+ /*
44
+ * If the lightbox is enabled and the image is not linked, add the filter
45
+ * and the JavaScript view file.
46
+ */
47
+ if (
48
+ isset( $lightbox_settings ) &&
49
+ 'none' === $link_destination &&
50
+ isset( $lightbox_settings['enabled'] ) &&
51
+ true === $lightbox_settings['enabled']
52
+ ) {
49
53
  $block->block_type->supports['interactivity'] = true;
50
- }
51
-
52
- // Determine whether the view script should be enqueued or not.
53
- $view_js_file = 'wp-block-image-view';
54
- if ( ! wp_script_is( $view_js_file ) ) {
55
- $script_handles = $block->block_type->view_script_handles;
56
54
 
57
- // If the script is not needed, and it is still in the `view_script_handles`, remove it.
58
- if ( ! $lightbox_enabled && in_array( $view_js_file, $script_handles, true ) ) {
59
- $block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
60
- }
61
- // If the script is needed, but it was previously removed, add it again.
62
- if ( $lightbox_enabled && ! in_array( $view_js_file, $script_handles, true ) ) {
63
- $block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file ) );
55
+ if ( ! in_array( $view_js_file_handle, $script_handles, true ) ) {
56
+ $block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file_handle ) );
64
57
  }
65
- }
66
58
 
67
- if ( $lightbox_enabled ) {
68
- // This render needs to happen in a filter with priority 15 to ensure that it
69
- // runs after the duotone filter and that duotone styles are applied to the image
70
- // in the lightbox. We also need to ensure that the lightbox works with any plugins
71
- // that might use filters as well. We can consider removing this in the future if the
72
- // way the blocks are rendered changes, or if a new kind of filter is introduced.
59
+ /*
60
+ * This render needs to happen in a filter with priority 15 to ensure
61
+ * that it runs after the duotone filter and that duotone styles are
62
+ * applied to the image in the lightbox. We also need to ensure that the
63
+ * lightbox works with any plugins that might use filters as well. We
64
+ * can consider removing this in the future if the way the blocks are
65
+ * rendered changes, or if a new kind of filter is introduced.
66
+ */
73
67
  add_filter( 'render_block_core/image', 'block_core_image_render_lightbox', 15, 2 );
68
+ } else {
69
+ /*
70
+ * Remove the filter and the JavaScript view file if previously added by
71
+ * other Image blocks.
72
+ */
73
+ remove_filter( 'render_block_core/image', 'block_core_image_render_lightbox', 15 );
74
+ // If the script is not needed, and it is still in the `view_script_handles`, remove it.
75
+ if ( in_array( $view_js_file_handle, $script_handles, true ) ) {
76
+ $block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file_handle ) );
77
+ }
74
78
  }
75
79
 
76
80
  return $processor->get_updated_html();
@@ -123,11 +127,28 @@ function block_core_image_get_lightbox_settings( $block ) {
123
127
  * @return string Filtered block content.
124
128
  */
125
129
  function block_core_image_render_lightbox( $block_content, $block ) {
130
+ /*
131
+ * If it's not possible that an IMG element exists then return the given
132
+ * block content as-is. It may be that there's no actual image in the block
133
+ * or it could be that another plugin already modified this HTML.
134
+ */
135
+ if ( false === stripos( $block_content, '<img' ) ) {
136
+ return $block_content;
137
+ }
138
+
126
139
  $processor = new WP_HTML_Tag_Processor( $block_content );
127
140
 
128
141
  $aria_label = __( 'Enlarge image' );
129
142
 
130
- $processor->next_tag( 'img' );
143
+ /*
144
+ * If there's definitely no IMG element in the block then return the given
145
+ * block content as-is. There's nothing that this code can knowingly modify
146
+ * to add the lightbox behavior.
147
+ */
148
+ if ( ! $processor->next_tag( 'img' ) ) {
149
+ return $block_content;
150
+ }
151
+
131
152
  $alt_attribute = $processor->get_attribute( 'alt' );
132
153
 
133
154
  // An empty alt attribute `alt=""` is valid for decorative images.
@@ -200,6 +221,7 @@ function block_core_image_render_lightbox( $block_content, $block ) {
200
221
  $w->set_attribute( 'data-wp-init', 'effects.core.image.setCurrentSrc' );
201
222
  $w->set_attribute( 'data-wp-on--load', 'actions.core.image.handleLoad' );
202
223
  $w->set_attribute( 'data-wp-effect', 'effects.core.image.setButtonStyles' );
224
+ $w->set_attribute( 'data-wp-effect--setStylesOnResize', 'effects.core.image.setStylesOnResize' );
203
225
  $body_content = $w->get_updated_html();
204
226
 
205
227
  // Wrap the image in the body content with a button.
@@ -309,8 +331,6 @@ HTML;
309
331
  * @since 6.4.0
310
332
  *
311
333
  * @global WP_Scripts $wp_scripts
312
- *
313
- * @return void
314
334
  */
315
335
  function block_core_image_ensure_interactivity_dependency() {
316
336
  global $wp_scripts;
@@ -326,8 +346,6 @@ add_action( 'wp_print_scripts', 'block_core_image_ensure_interactivity_dependenc
326
346
 
327
347
  /**
328
348
  * Registers the `core/image` block on server.
329
- *
330
- * @return void
331
349
  */
332
350
  function register_block_core_image() {
333
351
  register_block_type_from_metadata(
package/src/image/view.js CHANGED
@@ -105,7 +105,10 @@ store(
105
105
  context.core.image.scrollDelta = 0;
106
106
 
107
107
  context.core.image.lightboxEnabled = true;
108
- setStyles( context, event );
108
+ setStyles(
109
+ context,
110
+ event.target.previousElementSibling
111
+ );
109
112
 
110
113
  context.core.image.scrollTopReset =
111
114
  window.pageYOffset ||
@@ -338,6 +341,15 @@ store(
338
341
  context.core.image.imageButtonHeight = offsetHeight;
339
342
  }
340
343
  },
344
+ setStylesOnResize: ( { state, context, ref } ) => {
345
+ if (
346
+ context.core.image.lightboxEnabled &&
347
+ ( state.core.image.windowWidth ||
348
+ state.core.image.windowHeight )
349
+ ) {
350
+ setStyles( context, ref );
351
+ }
352
+ },
341
353
  },
342
354
  },
343
355
  },
@@ -362,7 +374,7 @@ store(
362
374
  * @param {Object} context - An Interactivity API context
363
375
  * @param {Object} event - A triggering event
364
376
  */
365
- function setStyles( context, event ) {
377
+ function setStyles( context, ref ) {
366
378
  // The reference img element lies adjacent
367
379
  // to the event target button in the DOM.
368
380
  let {
@@ -370,9 +382,8 @@ function setStyles( context, event ) {
370
382
  naturalHeight,
371
383
  offsetWidth: originalWidth,
372
384
  offsetHeight: originalHeight,
373
- } = event.target.previousElementSibling;
374
- let { x: screenPosX, y: screenPosY } =
375
- event.target.previousElementSibling.getBoundingClientRect();
385
+ } = ref;
386
+ let { x: screenPosX, y: screenPosY } = ref.getBoundingClientRect();
376
387
 
377
388
  // Natural ratio of the image clicked to open the lightbox.
378
389
  const naturalRatio = naturalWidth / naturalHeight;
@@ -484,9 +484,10 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
484
484
  .join( ' ' ) }
485
485
  { createInterpolateElement(
486
486
  sprintf(
487
- /* translators: 1: The static string "Read more", 2: The post title only visible to screen readers. */
488
- __( '… <a>%1$s<span>: %2$s</span></a>' ),
489
- __( 'Read more' ),
487
+ /* translators: 1: Hidden accessibility text: Post title */
488
+ __(
489
+ '… <a>Read more<span>: %1$s</span></a>'
490
+ ),
490
491
  titleTrimmed || __( '(no title)' )
491
492
  ),
492
493
  {
@@ -152,10 +152,9 @@ function render_block_core_latest_posts( $attributes ) {
152
152
  if ( $excerpt_length <= $block_core_latest_posts_excerpt_length ) {
153
153
  $trimmed_excerpt = substr( $trimmed_excerpt, 0, -11 );
154
154
  $trimmed_excerpt .= sprintf(
155
- /* translators: 1: A URL to a post, 2: The static string "Read more", 3: The post title only visible to screen readers. */
156
- __( '… <a href="%1$s" rel="noopener noreferrer">%2$s<span class="screen-reader-text">: %3$s</span></a>' ),
155
+ /* translators: 1: A URL to a post, 2: Hidden accessibility text: Post title */
156
+ __( '… <a href="%1$s" rel="noopener noreferrer">Read more<span class="screen-reader-text">: %2$s</span></a>' ),
157
157
  esc_url( $post_link ),
158
- __( 'Read more' ),
159
158
  esc_html( $title )
160
159
  );
161
160
  }
@@ -76,6 +76,24 @@ export default function useMerge( clientId, onMerge ) {
76
76
  }
77
77
 
78
78
  return ( forward ) => {
79
+ function mergeWithNested( clientIdA, clientIdB ) {
80
+ registry.batch( () => {
81
+ // When merging a sub list item with a higher next list item, we
82
+ // also need to move any nested list items. Check if there's a
83
+ // listed list, and append its nested list items to the current
84
+ // list.
85
+ const [ nestedListClientId ] = getBlockOrder( clientIdB );
86
+ if ( nestedListClientId ) {
87
+ moveBlocksToPosition(
88
+ getBlockOrder( nestedListClientId ),
89
+ nestedListClientId,
90
+ getBlockRootClientId( clientIdA )
91
+ );
92
+ }
93
+ mergeBlocks( clientIdA, clientIdB );
94
+ } );
95
+ }
96
+
79
97
  if ( forward ) {
80
98
  const nextBlockClientId = getNextId( clientId );
81
99
 
@@ -87,14 +105,7 @@ export default function useMerge( clientId, onMerge ) {
87
105
  if ( getParentListItemId( nextBlockClientId ) ) {
88
106
  outdentListItem( nextBlockClientId );
89
107
  } else {
90
- registry.batch( () => {
91
- moveBlocksToPosition(
92
- getBlockOrder( nextBlockClientId ),
93
- nextBlockClientId,
94
- getPreviousBlockClientId( nextBlockClientId )
95
- );
96
- mergeBlocks( clientId, nextBlockClientId );
97
- } );
108
+ mergeWithNested( clientId, nextBlockClientId );
98
109
  }
99
110
  } else {
100
111
  // Merging is only done from the top level. For lowel levels, the
@@ -104,21 +115,7 @@ export default function useMerge( clientId, onMerge ) {
104
115
  outdentListItem( clientId );
105
116
  } else if ( previousBlockClientId ) {
106
117
  const trailingId = getTrailingId( previousBlockClientId );
107
- registry.batch( () => {
108
- // When merging a list item with a previous trailing list
109
- // item, we also need to move any nested list items. First,
110
- // check if there's a listed list. If there's a nested list,
111
- // append its nested list items to the trailing list.
112
- const [ nestedListClientId ] = getBlockOrder( clientId );
113
- if ( nestedListClientId ) {
114
- moveBlocksToPosition(
115
- getBlockOrder( nestedListClientId ),
116
- nestedListClientId,
117
- getBlockRootClientId( trailingId )
118
- );
119
- }
120
- mergeBlocks( trailingId, clientId );
121
- } );
118
+ mergeWithNested( trailingId, clientId );
122
119
  } else {
123
120
  onMerge( forward );
124
121
  }
@@ -5,6 +5,6 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri
5
5
 
6
6
  export const { lock, unlock } =
7
7
  __dangerousOptInToUnstableAPIsOnlyForCoreModules(
8
- 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',
8
+ 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.',
9
9
  '@wordpress/block-library'
10
10
  );
@@ -884,7 +884,6 @@ function Navigation( {
884
884
  <ResponsiveWrapper
885
885
  id={ clientId }
886
886
  onToggle={ setResponsiveMenuVisibility }
887
- label={ __( 'Menu' ) }
888
887
  hasIcon={ hasIcon }
889
888
  icon={ icon }
890
889
  isOpen={ isResponsiveMenuOpen }
@@ -696,9 +696,22 @@ function render_block_core_navigation( $attributes, $content, $block ) {
696
696
  $responsive_dialog_directives = '';
697
697
  $close_button_directives = '';
698
698
  if ( $should_load_view_script ) {
699
+ $nav_element_context = wp_json_encode(
700
+ array(
701
+ 'core' => array(
702
+ 'navigation' => array(
703
+ 'overlayOpenedBy' => array(),
704
+ 'type' => 'overlay',
705
+ 'roleAttribute' => '',
706
+ 'ariaLabel' => __( 'Menu' ),
707
+ ),
708
+ ),
709
+ ),
710
+ JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP
711
+ );
699
712
  $nav_element_directives = '
700
713
  data-wp-interactive
701
- data-wp-context=\'{ "core": { "navigation": { "overlayOpenedBy": {}, "type": "overlay", "roleAttribute": "" } } }\'
714
+ data-wp-context=\'' . $nav_element_context . '\'
702
715
  ';
703
716
  $open_button_directives = '
704
717
  data-wp-on--click="actions.core.navigation.openMenuOnClick"
@@ -714,6 +727,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
714
727
  ';
715
728
  $responsive_dialog_directives = '
716
729
  data-wp-bind--aria-modal="selectors.core.navigation.ariaModal"
730
+ data-wp-bind--aria-label="selectors.core.navigation.ariaLabel"
717
731
  data-wp-bind--role="selectors.core.navigation.roleAttribute"
718
732
  data-wp-effect="effects.core.navigation.focusFirstElement"
719
733
  ';
@@ -723,11 +737,11 @@ function render_block_core_navigation( $attributes, $content, $block ) {
723
737
  }
724
738
 
725
739
  $responsive_container_markup = sprintf(
726
- '<button aria-haspopup="true" %3$s class="%6$s" %11$s>%9$s</button>
727
- <div class="%5$s" style="%7$s" id="%1$s" %12$s>
740
+ '<button aria-haspopup="true" %3$s class="%6$s" %10$s>%8$s</button>
741
+ <div class="%5$s" style="%7$s" id="%1$s" %11$s>
728
742
  <div class="wp-block-navigation__responsive-close" tabindex="-1">
729
- <div class="wp-block-navigation__responsive-dialog" aria-label="%8$s" %13$s>
730
- <button %4$s class="wp-block-navigation__responsive-container-close" %14$s>%10$s</button>
743
+ <div class="wp-block-navigation__responsive-dialog" %12$s>
744
+ <button %4$s class="wp-block-navigation__responsive-container-close" %13$s>%9$s</button>
731
745
  <div class="wp-block-navigation__responsive-container-content" id="%1$s-content">
732
746
  %2$s
733
747
  </div>
@@ -741,7 +755,6 @@ function render_block_core_navigation( $attributes, $content, $block ) {
741
755
  esc_attr( implode( ' ', $responsive_container_classes ) ),
742
756
  esc_attr( implode( ' ', $open_button_classes ) ),
743
757
  esc_attr( safecss_filter_attr( $colors['overlay_inline_styles'] ) ),
744
- __( 'Menu' ),
745
758
  $toggle_button_content,
746
759
  $toggle_close_button_content,
747
760
  $open_button_directives,
@@ -87,6 +87,13 @@ wpStore( {
87
87
  ? 'true'
88
88
  : null;
89
89
  },
90
+ ariaLabel: ( store ) => {
91
+ const { context, selectors } = store;
92
+ return context.core.navigation.type === 'overlay' &&
93
+ selectors.core.navigation.isMenuOpen( store )
94
+ ? context.core.navigation.ariaLabel
95
+ : null;
96
+ },
90
97
  isMenuOpen: ( { context } ) =>
91
98
  // The menu is opened if either `click`, `hover` or `focus` is true.
92
99
  Object.values(
@@ -7,8 +7,6 @@
7
7
 
8
8
  /**
9
9
  * Registers the `core/pattern` block on the server.
10
- *
11
- * @return void
12
10
  */
13
11
  function register_block_core_pattern() {
14
12
  register_block_type_from_metadata(
@@ -46,7 +44,6 @@ function render_block_core_pattern( $attributes ) {
46
44
  // Backward compatibility for handling Block Hooks and injecting the theme attribute in the Gutenberg plugin.
47
45
  // This can be removed when the minimum supported WordPress is >= 6.4.
48
46
  if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN && ! function_exists( 'traverse_and_serialize_blocks' ) ) {
49
- $content = _inject_theme_attribute_in_block_template_content( $content );
50
47
  $blocks = parse_blocks( $content );
51
48
  $content = gutenberg_serialize_blocks( $blocks );
52
49
  }
@@ -34,7 +34,8 @@ function render_block_core_query( $attributes, $content, $block ) {
34
34
  'loadedText' => __( 'Page Loaded.' ),
35
35
  ),
36
36
  ),
37
- )
37
+ ),
38
+ JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP
38
39
  )
39
40
  );
40
41
  $content = $p->get_updated_html();
@@ -281,8 +281,6 @@ function classnames_for_block_core_search( $attributes ) {
281
281
  * @param array $wrapper_styles Current collection of wrapper styles.
282
282
  * @param array $button_styles Current collection of button styles.
283
283
  * @param array $input_styles Current collection of input styles.
284
- *
285
- * @return void
286
284
  */
287
285
  function apply_block_core_search_border_style( $attributes, $property, $side, &$wrapper_styles, &$button_styles, &$input_styles ) {
288
286
  $is_button_inside = isset( $attributes['buttonPosition'] ) && 'button-inside' === $attributes['buttonPosition'];
@@ -327,8 +325,6 @@ function apply_block_core_search_border_style( $attributes, $property, $side, &$
327
325
  * @param array $wrapper_styles Current collection of wrapper styles.
328
326
  * @param array $button_styles Current collection of button styles.
329
327
  * @param array $input_styles Current collection of input styles.
330
- *
331
- * @return void
332
328
  */
333
329
  function apply_block_core_search_border_styles( $attributes, $property, &$wrapper_styles, &$button_styles, &$input_styles ) {
334
330
  apply_block_core_search_border_style( $attributes, $property, null, $wrapper_styles, $button_styles, $input_styles );
@@ -18,13 +18,10 @@ function render_block_core_template_part( $attributes ) {
18
18
  $template_part_id = null;
19
19
  $content = null;
20
20
  $area = WP_TEMPLATE_PART_AREA_UNCATEGORIZED;
21
+ $theme = isset( $attributes['theme'] ) ? $attributes['theme'] : get_stylesheet();
21
22
 
22
- if (
23
- isset( $attributes['slug'] ) &&
24
- isset( $attributes['theme'] ) &&
25
- get_stylesheet() === $attributes['theme']
26
- ) {
27
- $template_part_id = $attributes['theme'] . '//' . $attributes['slug'];
23
+ if ( isset( $attributes['slug'] ) && get_stylesheet() === $theme ) {
24
+ $template_part_id = $theme . '//' . $attributes['slug'];
28
25
  $template_part_query = new WP_Query(
29
26
  array(
30
27
  'post_type' => 'wp_template_part',
@@ -34,7 +31,7 @@ function render_block_core_template_part( $attributes ) {
34
31
  array(
35
32
  'taxonomy' => 'wp_theme',
36
33
  'field' => 'name',
37
- 'terms' => $attributes['theme'],
34
+ 'terms' => $theme,
38
35
  ),
39
36
  ),
40
37
  'posts_per_page' => 1,