@wordpress/block-library 8.21.0 → 8.21.1-next.f8d8eceb.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.
Files changed (192) hide show
  1. package/build/avatar/index.js +5 -1
  2. package/build/avatar/index.js.map +1 -1
  3. package/build/block/edit-title.native.js +11 -3
  4. package/build/block/edit-title.native.js.map +1 -1
  5. package/build/column/edit.js +2 -1
  6. package/build/column/edit.js.map +1 -1
  7. package/build/column/edit.native.js +2 -1
  8. package/build/column/edit.native.js.map +1 -1
  9. package/build/columns/edit.native.js +2 -1
  10. package/build/columns/edit.native.js.map +1 -1
  11. package/build/cover/controls.native.js +2 -1
  12. package/build/cover/controls.native.js.map +1 -1
  13. package/build/cover/edit/index.js +2 -1
  14. package/build/cover/edit/index.js.map +1 -1
  15. package/build/cover/edit/inspector-controls.js +2 -1
  16. package/build/cover/edit/inspector-controls.js.map +1 -1
  17. package/build/file/view.js +1 -1
  18. package/build/file/view.js.map +1 -1
  19. package/build/form/edit.js +1 -1
  20. package/build/form/edit.js.map +1 -1
  21. package/build/form/variations.js +1 -1
  22. package/build/form/variations.js.map +1 -1
  23. package/build/form-input/index.js +1 -1
  24. package/build/form-input/variations.js +7 -7
  25. package/build/form-input/variations.js.map +1 -1
  26. package/build/form-submission-notification/variations.js +4 -4
  27. package/build/form-submission-notification/variations.js.map +1 -1
  28. package/build/form-submit-button/index.js +1 -1
  29. package/build/group/edit.js +2 -11
  30. package/build/group/edit.js.map +1 -1
  31. package/build/html/preview.js +2 -4
  32. package/build/html/preview.js.map +1 -1
  33. package/build/image/image.js +11 -5
  34. package/build/image/image.js.map +1 -1
  35. package/build/image/view.js +10 -20
  36. package/build/image/view.js.map +1 -1
  37. package/build/missing/edit.native.js +46 -8
  38. package/build/missing/edit.native.js.map +1 -1
  39. package/build/paragraph/edit.js +1 -1
  40. package/build/paragraph/edit.js.map +1 -1
  41. package/build/post-featured-image/dimension-controls.js +2 -2
  42. package/build/post-featured-image/dimension-controls.js.map +1 -1
  43. package/build/query/edit/enhanced-pagination-modal.js +27 -13
  44. package/build/query/edit/enhanced-pagination-modal.js.map +1 -1
  45. package/build/query/edit/inspector-controls/enhanced-pagination-control.js +15 -12
  46. package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  47. package/build/query/utils.js +29 -8
  48. package/build/query/utils.js.map +1 -1
  49. package/build/query/view.js +4 -2
  50. package/build/query/view.js.map +1 -1
  51. package/build/search/edit.js +1 -2
  52. package/build/search/edit.js.map +1 -1
  53. package/build/social-link/edit.native.js +7 -19
  54. package/build/social-link/edit.native.js.map +1 -1
  55. package/build/spacer/controls.js +3 -3
  56. package/build/spacer/controls.js.map +1 -1
  57. package/build/spacer/controls.native.js +2 -1
  58. package/build/spacer/controls.native.js.map +1 -1
  59. package/build/spacer/edit.js +1 -1
  60. package/build/spacer/edit.js.map +1 -1
  61. package/build/spacer/edit.native.js +5 -1
  62. package/build/spacer/edit.native.js.map +1 -1
  63. package/build/tag-cloud/edit.js +2 -1
  64. package/build/tag-cloud/edit.js.map +1 -1
  65. package/build/template-part/edit/inner-blocks.js +2 -2
  66. package/build/template-part/edit/inner-blocks.js.map +1 -1
  67. package/build/term-description/index.js +0 -1
  68. package/build/term-description/index.js.map +1 -1
  69. package/build-module/avatar/index.js +5 -1
  70. package/build-module/avatar/index.js.map +1 -1
  71. package/build-module/block/edit-title.native.js +12 -4
  72. package/build-module/block/edit-title.native.js.map +1 -1
  73. package/build-module/column/edit.js +3 -2
  74. package/build-module/column/edit.js.map +1 -1
  75. package/build-module/column/edit.native.js +3 -2
  76. package/build-module/column/edit.native.js.map +1 -1
  77. package/build-module/columns/edit.native.js +3 -2
  78. package/build-module/columns/edit.native.js.map +1 -1
  79. package/build-module/cover/controls.native.js +3 -2
  80. package/build-module/cover/controls.native.js.map +1 -1
  81. package/build-module/cover/edit/index.js +3 -2
  82. package/build-module/cover/edit/index.js.map +1 -1
  83. package/build-module/cover/edit/inspector-controls.js +3 -2
  84. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  85. package/build-module/file/view.js +2 -2
  86. package/build-module/file/view.js.map +1 -1
  87. package/build-module/form/edit.js +1 -1
  88. package/build-module/form/edit.js.map +1 -1
  89. package/build-module/form/variations.js +1 -1
  90. package/build-module/form/variations.js.map +1 -1
  91. package/build-module/form-input/index.js +1 -1
  92. package/build-module/form-input/variations.js +7 -7
  93. package/build-module/form-input/variations.js.map +1 -1
  94. package/build-module/form-submission-notification/variations.js +4 -4
  95. package/build-module/form-submission-notification/variations.js.map +1 -1
  96. package/build-module/form-submit-button/index.js +1 -1
  97. package/build-module/group/edit.js +3 -12
  98. package/build-module/group/edit.js.map +1 -1
  99. package/build-module/html/preview.js +2 -4
  100. package/build-module/html/preview.js.map +1 -1
  101. package/build-module/image/image.js +12 -6
  102. package/build-module/image/image.js.map +1 -1
  103. package/build-module/image/view.js +10 -20
  104. package/build-module/image/view.js.map +1 -1
  105. package/build-module/missing/edit.native.js +47 -9
  106. package/build-module/missing/edit.native.js.map +1 -1
  107. package/build-module/paragraph/edit.js +2 -2
  108. package/build-module/paragraph/edit.js.map +1 -1
  109. package/build-module/post-featured-image/dimension-controls.js +3 -3
  110. package/build-module/post-featured-image/dimension-controls.js.map +1 -1
  111. package/build-module/query/edit/enhanced-pagination-modal.js +28 -14
  112. package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -1
  113. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +17 -14
  114. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  115. package/build-module/query/utils.js +27 -5
  116. package/build-module/query/utils.js.map +1 -1
  117. package/build-module/query/view.js +4 -2
  118. package/build-module/query/view.js.map +1 -1
  119. package/build-module/search/edit.js +2 -3
  120. package/build-module/search/edit.js.map +1 -1
  121. package/build-module/social-link/edit.native.js +8 -20
  122. package/build-module/social-link/edit.native.js.map +1 -1
  123. package/build-module/spacer/controls.js +4 -4
  124. package/build-module/spacer/controls.js.map +1 -1
  125. package/build-module/spacer/controls.native.js +3 -2
  126. package/build-module/spacer/controls.native.js.map +1 -1
  127. package/build-module/spacer/edit.js +2 -2
  128. package/build-module/spacer/edit.js.map +1 -1
  129. package/build-module/spacer/edit.native.js +6 -2
  130. package/build-module/spacer/edit.native.js.map +1 -1
  131. package/build-module/tag-cloud/edit.js +3 -2
  132. package/build-module/tag-cloud/edit.js.map +1 -1
  133. package/build-module/template-part/edit/inner-blocks.js +3 -3
  134. package/build-module/template-part/edit/inner-blocks.js.map +1 -1
  135. package/build-module/term-description/index.js +0 -1
  136. package/build-module/term-description/index.js.map +1 -1
  137. package/build-style/file/style-rtl.css +0 -5
  138. package/build-style/file/style.css +0 -5
  139. package/build-style/navigation/style-rtl.css +5 -0
  140. package/build-style/navigation/style.css +5 -0
  141. package/build-style/style-rtl.css +5 -5
  142. package/build-style/style.css +5 -5
  143. package/package.json +32 -32
  144. package/src/avatar/block.json +5 -1
  145. package/src/block/edit-title.native.js +16 -13
  146. package/src/calendar/index.php +2 -6
  147. package/src/column/edit.js +3 -8
  148. package/src/column/edit.native.js +3 -8
  149. package/src/columns/edit.native.js +3 -8
  150. package/src/comment-author-avatar/index.php +1 -1
  151. package/src/cover/controls.native.js +3 -8
  152. package/src/cover/edit/index.js +3 -2
  153. package/src/cover/edit/inspector-controls.js +3 -8
  154. package/src/file/index.php +2 -1
  155. package/src/file/style.scss +0 -6
  156. package/src/file/view.js +2 -2
  157. package/src/form/edit.js +1 -1
  158. package/src/form/variations.js +1 -1
  159. package/src/form-input/block.json +1 -1
  160. package/src/form-input/variations.js +7 -7
  161. package/src/form-submission-notification/variations.js +4 -4
  162. package/src/form-submit-button/block.json +1 -1
  163. package/src/freeform/test/__snapshots__/index.native.js.snap +7 -0
  164. package/src/freeform/test/index.native.js +57 -0
  165. package/src/group/edit.js +2 -7
  166. package/src/html/preview.js +9 -4
  167. package/src/image/image.js +17 -6
  168. package/src/image/index.php +5 -6
  169. package/src/image/view.js +13 -19
  170. package/src/missing/edit.native.js +43 -6
  171. package/src/navigation/index.php +1 -1
  172. package/src/navigation/style.scss +6 -1
  173. package/src/paragraph/edit.js +2 -2
  174. package/src/post-featured-image/dimension-controls.js +3 -3
  175. package/src/query/edit/enhanced-pagination-modal.js +37 -21
  176. package/src/query/edit/inspector-controls/enhanced-pagination-control.js +18 -22
  177. package/src/query/index.php +97 -8
  178. package/src/query/utils.js +29 -8
  179. package/src/query/view.js +11 -2
  180. package/src/query-pagination-next/index.php +1 -1
  181. package/src/query-pagination-previous/index.php +1 -1
  182. package/src/search/edit.js +5 -3
  183. package/src/social-link/edit.native.js +12 -26
  184. package/src/social-link/editor.native.scss +0 -9
  185. package/src/social-link/index.php +2 -2
  186. package/src/spacer/controls.js +9 -12
  187. package/src/spacer/controls.native.js +3 -8
  188. package/src/spacer/edit.js +2 -2
  189. package/src/spacer/edit.native.js +6 -5
  190. package/src/tag-cloud/edit.js +3 -7
  191. package/src/template-part/edit/inner-blocks.js +3 -3
  192. package/src/term-description/block.json +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["store","focusableSelectors","scrollCallback","isTouching","lastTouchTime","handleScroll","context","Date","now","window","scrollTo","core","image","scrollLeftReset","scrollTopReset","state","windowWidth","innerWidth","windowHeight","innerHeight","actions","showLightbox","event","imageLoaded","initialized","lastFocusedElement","document","activeElement","scrollDelta","pointerType","lightboxEnabled","setStyles","imageRef","pageYOffset","documentElement","scrollTop","pageXOffset","scrollLeft","bind","addEventListener","hideLightbox","hideAnimationEnabled","setTimeout","removeEventListener","focus","preventScroll","handleKeydown","key","keyCode","shiftKey","firstFocusableElement","preventDefault","lastFocusableElement","handleLoad","effects","ref","imageCurrentSrc","currentSrc","setButtonStyles","handleTouchStart","handleTouchMove","handleTouchEnd","selectors","roleAttribute","ariaModal","dialogLabel","lightboxObjectFit","enlargedImgSrc","imageUploadedSrc","initOriginImage","complete","initLightbox","focusableElements","querySelectorAll","length","querySelector","naturalWidth","naturalHeight","offsetWidth","offsetHeight","figure","parentElement","figureWidth","clientWidth","figureHeight","clientHeight","caption","captionComputedStyle","getComputedStyle","parseFloat","marginTop","marginBottom","buttonOffsetTop","buttonOffsetRight","scaleAttr","naturalRatio","offsetRatio","referenceHeight","imageButtonTop","imageButtonRight","referenceWidth","setStylesOnResize","afterLoad","debounce","originalWidth","originalHeight","x","screenPosX","y","screenPosY","getBoundingClientRect","originalRatio","heightWithoutSpace","widthWithoutSpace","imgMaxWidth","targetWidth","imgMaxHeight","targetHeight","imgRatio","containerMaxWidth","containerMaxHeight","containerWidth","containerHeight","toFixed","reducedHeight","reducedWidth","horizontalPadding","verticalPadding","targetMaxWidth","Math","min","targetMaxHeight","targetContainerRatio","containerScale","lightboxImgWidth","lightboxImgHeight","styleTag","getElementById","createElement","id","head","appendChild","innerHTML","func","wait","timeout","later","clearTimeout"],"sources":["@wordpress/block-library/src/image/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store } from '@wordpress/interactivity';\n\nconst focusableSelectors = [\n\t'a[href]',\n\t'area[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'iframe',\n\t'object',\n\t'embed',\n\t'[contenteditable]',\n\t'[tabindex]:not([tabindex^=\"-\"])',\n];\n\n/*\n * Stores a context-bound scroll handler.\n *\n * This callback could be defined inline inside of the store\n * object but it's created externally to avoid confusion about\n * how its logic is called. This logic is not referenced directly\n * by the directives in the markup because the scroll event we\n * need to listen to is triggered on the window; so by defining it\n * outside of the store, we signal that the behavior here is different.\n * If we find a compelling reason to move it to the store, feel free.\n *\n * @type {Function}\n */\nlet scrollCallback;\n\n/*\n * Tracks whether user is touching screen; used to\n * differentiate behavior for touch and mouse input.\n *\n * @type {boolean}\n */\nlet isTouching = false;\n\n/*\n * Tracks the last time the screen was touched; used to\n * differentiate behavior for touch and mouse input.\n *\n * @type {number}\n */\nlet lastTouchTime = 0;\n\n/*\n * Lightbox page-scroll handler: prevents scrolling.\n *\n * This handler is added to prevent scrolling behaviors that\n * trigger content shift while the lightbox is open.\n *\n * It would be better to accomplish this through CSS alone, but\n * using overflow: hidden is currently the only way to do so, and\n * that causes the layout to shift and prevents the zoom animation\n * from working in some cases because we're unable to account for\n * the layout shift when doing the animation calculations. Instead,\n * here we use JavaScript to prevent and reset the scrolling\n * behavior. In the future, we may be able to use CSS or overflow: hidden\n * instead to not rely on JavaScript, but this seems to be the best approach\n * for now that provides the best visual experience.\n *\n * @param {Object} context Interactivity page context?\n */\nfunction handleScroll( context ) {\n\t// We can't override the scroll behavior on mobile devices\n\t// because doing so breaks the pinch to zoom functionality, and we\n\t// want to allow users to zoom in further on the high-res image.\n\tif ( ! isTouching && Date.now() - lastTouchTime > 450 ) {\n\t\t// We are unable to use event.preventDefault() to prevent scrolling\n\t\t// because the scroll event can't be canceled, so we reset the position instead.\n\t\twindow.scrollTo(\n\t\t\tcontext.core.image.scrollLeftReset,\n\t\t\tcontext.core.image.scrollTopReset\n\t\t);\n\t}\n}\n\nstore(\n\t{\n\t\tstate: {\n\t\t\tcore: {\n\t\t\t\timage: {\n\t\t\t\t\twindowWidth: window.innerWidth,\n\t\t\t\t\twindowHeight: window.innerHeight,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tactions: {\n\t\t\tcore: {\n\t\t\t\timage: {\n\t\t\t\t\tshowLightbox: ( { context, event } ) => {\n\t\t\t\t\t\t// We can't initialize the lightbox until the reference\n\t\t\t\t\t\t// image is loaded, otherwise the UX is broken.\n\t\t\t\t\t\tif ( ! context.core.image.imageLoaded ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontext.core.image.initialized = true;\n\t\t\t\t\t\tcontext.core.image.lastFocusedElement =\n\t\t\t\t\t\t\twindow.document.activeElement;\n\t\t\t\t\t\tcontext.core.image.scrollDelta = 0;\n\t\t\t\t\t\tcontext.core.image.pointerType = event.pointerType;\n\n\t\t\t\t\t\tcontext.core.image.lightboxEnabled = true;\n\t\t\t\t\t\tsetStyles( context, context.core.image.imageRef );\n\n\t\t\t\t\t\tcontext.core.image.scrollTopReset =\n\t\t\t\t\t\t\twindow.pageYOffset ||\n\t\t\t\t\t\t\tdocument.documentElement.scrollTop;\n\n\t\t\t\t\t\t// In most cases, this value will be 0, but this is included\n\t\t\t\t\t\t// in case a user has created a page with horizontal scrolling.\n\t\t\t\t\t\tcontext.core.image.scrollLeftReset =\n\t\t\t\t\t\t\twindow.pageXOffset ||\n\t\t\t\t\t\t\tdocument.documentElement.scrollLeft;\n\n\t\t\t\t\t\t// We define and bind the scroll callback here so\n\t\t\t\t\t\t// that we can pass the context and as an argument.\n\t\t\t\t\t\t// We may be able to change this in the future if we\n\t\t\t\t\t\t// define the scroll callback in the store instead, but\n\t\t\t\t\t\t// this approach seems to tbe clearest for now.\n\t\t\t\t\t\tscrollCallback = handleScroll.bind( null, context );\n\n\t\t\t\t\t\t// We need to add a scroll event listener to the window\n\t\t\t\t\t\t// here because we are unable to otherwise access it via\n\t\t\t\t\t\t// the Interactivity API directives. If we add a native way\n\t\t\t\t\t\t// to access the window, we can remove this.\n\t\t\t\t\t\twindow.addEventListener(\n\t\t\t\t\t\t\t'scroll',\n\t\t\t\t\t\t\tscrollCallback,\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\thideLightbox: async ( { context, event } ) => {\n\t\t\t\t\t\tcontext.core.image.hideAnimationEnabled = true;\n\t\t\t\t\t\tif ( context.core.image.lightboxEnabled ) {\n\t\t\t\t\t\t\t// We want to wait until the close animation is completed\n\t\t\t\t\t\t\t// before allowing a user to scroll again. The duration of this\n\t\t\t\t\t\t\t// animation is defined in the styles.scss and depends on if the\n\t\t\t\t\t\t\t// animation is 'zoom' or 'fade', but in any case we should wait\n\t\t\t\t\t\t\t// a few milliseconds longer than the duration, otherwise a user\n\t\t\t\t\t\t\t// may scroll too soon and cause the animation to look sloppy.\n\t\t\t\t\t\t\tsetTimeout( function () {\n\t\t\t\t\t\t\t\twindow.removeEventListener(\n\t\t\t\t\t\t\t\t\t'scroll',\n\t\t\t\t\t\t\t\t\tscrollCallback\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}, 450 );\n\n\t\t\t\t\t\t\tcontext.core.image.lightboxEnabled = false;\n\n\t\t\t\t\t\t\t// We want to avoid drawing attention to the button\n\t\t\t\t\t\t\t// after the lightbox closes for mouse and touch users.\n\t\t\t\t\t\t\t// Note that the `event.pointerType` property returns\n\t\t\t\t\t\t\t// as an empty string if a keyboard fired the event.\n\t\t\t\t\t\t\tif ( event.pointerType === '' ) {\n\t\t\t\t\t\t\t\tcontext.core.image.lastFocusedElement.focus( {\n\t\t\t\t\t\t\t\t\tpreventScroll: true,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\thandleKeydown: ( { context, actions, event } ) => {\n\t\t\t\t\t\tif ( context.core.image.lightboxEnabled ) {\n\t\t\t\t\t\t\tif ( event.key === 'Tab' || event.keyCode === 9 ) {\n\t\t\t\t\t\t\t\t// If shift + tab it change the direction\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tevent.shiftKey &&\n\t\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\t\tcontext.core.image.firstFocusableElement\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\tcontext.core.image.lastFocusableElement.focus();\n\t\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t\t! event.shiftKey &&\n\t\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\t\tcontext.core.image.lastFocusableElement\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\tcontext.core.image.firstFocusableElement.focus();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tevent.key === 'Escape' ||\n\t\t\t\t\t\t\t\tevent.keyCode === 27\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tactions.core.image.hideLightbox( {\n\t\t\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t// This is fired just by lazily loaded\n\t\t\t\t\t// images on the page, not all images.\n\t\t\t\t\thandleLoad: ( { context, effects, ref } ) => {\n\t\t\t\t\t\tcontext.core.image.imageLoaded = true;\n\t\t\t\t\t\tcontext.core.image.imageCurrentSrc = ref.currentSrc;\n\t\t\t\t\t\teffects.core.image.setButtonStyles( {\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t} );\n\t\t\t\t\t},\n\t\t\t\t\thandleTouchStart: () => {\n\t\t\t\t\t\tisTouching = true;\n\t\t\t\t\t},\n\t\t\t\t\thandleTouchMove: ( { context, event } ) => {\n\t\t\t\t\t\t// On mobile devices, we want to prevent triggering the\n\t\t\t\t\t\t// scroll event because otherwise the page jumps around as\n\t\t\t\t\t\t// we reset the scroll position. This also means that closing\n\t\t\t\t\t\t// the lightbox requires that a user perform a simple tap. This\n\t\t\t\t\t\t// may be changed in the future if we find a better alternative\n\t\t\t\t\t\t// to override or reset the scroll position during swipe actions.\n\t\t\t\t\t\tif ( context.core.image.lightboxEnabled ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\thandleTouchEnd: () => {\n\t\t\t\t\t\t// We need to wait a few milliseconds before resetting\n\t\t\t\t\t\t// to ensure that pinch to zoom works consistently\n\t\t\t\t\t\t// on mobile devices when the lightbox is open.\n\t\t\t\t\t\tlastTouchTime = Date.now();\n\t\t\t\t\t\tisTouching = false;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tselectors: {\n\t\t\tcore: {\n\t\t\t\timage: {\n\t\t\t\t\troleAttribute: ( { context } ) => {\n\t\t\t\t\t\treturn context.core.image.lightboxEnabled\n\t\t\t\t\t\t\t? 'dialog'\n\t\t\t\t\t\t\t: null;\n\t\t\t\t\t},\n\t\t\t\t\tariaModal: ( { context } ) => {\n\t\t\t\t\t\treturn context.core.image.lightboxEnabled\n\t\t\t\t\t\t\t? 'true'\n\t\t\t\t\t\t\t: null;\n\t\t\t\t\t},\n\t\t\t\t\tdialogLabel: ( { context } ) => {\n\t\t\t\t\t\treturn context.core.image.lightboxEnabled\n\t\t\t\t\t\t\t? context.core.image.dialogLabel\n\t\t\t\t\t\t\t: null;\n\t\t\t\t\t},\n\t\t\t\t\tlightboxObjectFit: ( { context } ) => {\n\t\t\t\t\t\tif ( context.core.image.initialized ) {\n\t\t\t\t\t\t\treturn 'cover';\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tenlargedImgSrc: ( { context } ) => {\n\t\t\t\t\t\treturn context.core.image.initialized\n\t\t\t\t\t\t\t? context.core.image.imageUploadedSrc\n\t\t\t\t\t\t\t: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=';\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\teffects: {\n\t\t\tcore: {\n\t\t\t\timage: {\n\t\t\t\t\tinitOriginImage: ( { context, ref } ) => {\n\t\t\t\t\t\tcontext.core.image.imageRef = ref;\n\t\t\t\t\t\tif ( ref.complete ) {\n\t\t\t\t\t\t\tcontext.core.image.imageLoaded = true;\n\t\t\t\t\t\t\tcontext.core.image.imageCurrentSrc = ref.currentSrc;\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tinitLightbox: async ( { context, ref } ) => {\n\t\t\t\t\t\tif ( context.core.image.lightboxEnabled ) {\n\t\t\t\t\t\t\tconst focusableElements =\n\t\t\t\t\t\t\t\tref.querySelectorAll( focusableSelectors );\n\t\t\t\t\t\t\tcontext.core.image.firstFocusableElement =\n\t\t\t\t\t\t\t\tfocusableElements[ 0 ];\n\t\t\t\t\t\t\tcontext.core.image.lastFocusableElement =\n\t\t\t\t\t\t\t\tfocusableElements[\n\t\t\t\t\t\t\t\t\tfocusableElements.length - 1\n\t\t\t\t\t\t\t\t];\n\n\t\t\t\t\t\t\t// We want to avoid drawing unnecessary attention to the close\n\t\t\t\t\t\t\t// button for mouse and touch users. Note that even if opening\n\t\t\t\t\t\t\t// the lightbox via keyboard, the event fired is of type\n\t\t\t\t\t\t\t// `pointerEvent`, so we need to rely on the `event.pointerType`\n\t\t\t\t\t\t\t// property, which returns an empty string for keyboard events.\n\t\t\t\t\t\t\tif ( context.core.image.pointerType === '' ) {\n\t\t\t\t\t\t\t\tref.querySelector( '.close-button' ).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\tsetButtonStyles: ( { context, ref } ) => {\n\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\tnaturalWidth,\n\t\t\t\t\t\t\tnaturalHeight,\n\t\t\t\t\t\t\toffsetWidth,\n\t\t\t\t\t\t\toffsetHeight,\n\t\t\t\t\t\t} = ref;\n\n\t\t\t\t\t\t// If the image isn't loaded yet, we can't\n\t\t\t\t\t\t// calculate where the button should be.\n\t\t\t\t\t\tif ( naturalWidth === 0 || naturalHeight === 0 ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst figure = ref.parentElement;\n\t\t\t\t\t\tconst figureWidth = ref.parentElement.clientWidth;\n\n\t\t\t\t\t\t// We need special handling for the height because\n\t\t\t\t\t\t// a caption will cause the figure to be taller than\n\t\t\t\t\t\t// the image, which means we need to account for that\n\t\t\t\t\t\t// when calculating the placement of the button in the\n\t\t\t\t\t\t// top right corner of the image.\n\t\t\t\t\t\tlet figureHeight = ref.parentElement.clientHeight;\n\t\t\t\t\t\tconst caption = figure.querySelector( 'figcaption' );\n\t\t\t\t\t\tif ( caption ) {\n\t\t\t\t\t\t\tconst captionComputedStyle =\n\t\t\t\t\t\t\t\twindow.getComputedStyle( caption );\n\t\t\t\t\t\t\tfigureHeight =\n\t\t\t\t\t\t\t\tfigureHeight -\n\t\t\t\t\t\t\t\tcaption.offsetHeight -\n\t\t\t\t\t\t\t\tparseFloat( captionComputedStyle.marginTop ) -\n\t\t\t\t\t\t\t\tparseFloat( captionComputedStyle.marginBottom );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst buttonOffsetTop = figureHeight - offsetHeight;\n\t\t\t\t\t\tconst buttonOffsetRight = figureWidth - offsetWidth;\n\n\t\t\t\t\t\t// In the case of an image with object-fit: contain, the\n\t\t\t\t\t\t// size of the <img> element can be larger than the image itself,\n\t\t\t\t\t\t// so we need to calculate where to place the button.\n\t\t\t\t\t\tif ( context.core.image.scaleAttr === 'contain' ) {\n\t\t\t\t\t\t\t// Natural ratio of the image.\n\t\t\t\t\t\t\tconst naturalRatio = naturalWidth / naturalHeight;\n\t\t\t\t\t\t\t// Offset ratio of the image.\n\t\t\t\t\t\t\tconst offsetRatio = offsetWidth / offsetHeight;\n\n\t\t\t\t\t\t\tif ( naturalRatio >= offsetRatio ) {\n\t\t\t\t\t\t\t\t// If it reaches the width first, keep\n\t\t\t\t\t\t\t\t// the width and compute the height.\n\t\t\t\t\t\t\t\tconst referenceHeight =\n\t\t\t\t\t\t\t\t\toffsetWidth / naturalRatio;\n\t\t\t\t\t\t\t\tcontext.core.image.imageButtonTop =\n\t\t\t\t\t\t\t\t\t( offsetHeight - referenceHeight ) / 2 +\n\t\t\t\t\t\t\t\t\tbuttonOffsetTop +\n\t\t\t\t\t\t\t\t\t10;\n\t\t\t\t\t\t\t\tcontext.core.image.imageButtonRight =\n\t\t\t\t\t\t\t\t\tbuttonOffsetRight + 10;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// If it reaches the height first, keep\n\t\t\t\t\t\t\t\t// the height and compute the width.\n\t\t\t\t\t\t\t\tconst referenceWidth =\n\t\t\t\t\t\t\t\t\toffsetHeight * naturalRatio;\n\t\t\t\t\t\t\t\tcontext.core.image.imageButtonTop =\n\t\t\t\t\t\t\t\t\tbuttonOffsetTop + 10;\n\t\t\t\t\t\t\t\tcontext.core.image.imageButtonRight =\n\t\t\t\t\t\t\t\t\t( offsetWidth - referenceWidth ) / 2 +\n\t\t\t\t\t\t\t\t\tbuttonOffsetRight +\n\t\t\t\t\t\t\t\t\t10;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcontext.core.image.imageButtonTop =\n\t\t\t\t\t\t\t\tbuttonOffsetTop + 10;\n\t\t\t\t\t\t\tcontext.core.image.imageButtonRight =\n\t\t\t\t\t\t\t\tbuttonOffsetRight + 10;\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tsetStylesOnResize: ( { state, context, ref } ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tcontext.core.image.lightboxEnabled &&\n\t\t\t\t\t\t\t( state.core.image.windowWidth ||\n\t\t\t\t\t\t\t\tstate.core.image.windowHeight )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tsetStyles( context, ref );\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tafterLoad: ( { state } ) => {\n\t\t\twindow.addEventListener(\n\t\t\t\t'resize',\n\t\t\t\tdebounce( () => {\n\t\t\t\t\tstate.core.image.windowWidth = window.innerWidth;\n\t\t\t\t\tstate.core.image.windowHeight = window.innerHeight;\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t}\n);\n\n/*\n * Computes styles for the lightbox and adds them to the document.\n *\n * @function\n * @param {Object} context - An Interactivity API context\n * @param {Object} event - A triggering event\n */\nfunction setStyles( context, ref ) {\n\t// The reference img element lies adjacent\n\t// to the event target button in the DOM.\n\tlet {\n\t\tnaturalWidth,\n\t\tnaturalHeight,\n\t\toffsetWidth: originalWidth,\n\t\toffsetHeight: originalHeight,\n\t} = ref;\n\tlet { x: screenPosX, y: screenPosY } = ref.getBoundingClientRect();\n\n\t// Natural ratio of the image clicked to open the lightbox.\n\tconst naturalRatio = naturalWidth / naturalHeight;\n\t// Original ratio of the image clicked to open the lightbox.\n\tlet originalRatio = originalWidth / originalHeight;\n\n\t// If it has object-fit: contain, recalculate the original sizes\n\t// and the screen position without the blank spaces.\n\tif ( context.core.image.scaleAttr === 'contain' ) {\n\t\tif ( naturalRatio > originalRatio ) {\n\t\t\tconst heightWithoutSpace = originalWidth / naturalRatio;\n\t\t\t// Recalculate screen position without the top space.\n\t\t\tscreenPosY += ( originalHeight - heightWithoutSpace ) / 2;\n\t\t\toriginalHeight = heightWithoutSpace;\n\t\t} else {\n\t\t\tconst widthWithoutSpace = originalHeight * naturalRatio;\n\t\t\t// Recalculate screen position without the left space.\n\t\t\tscreenPosX += ( originalWidth - widthWithoutSpace ) / 2;\n\t\t\toriginalWidth = widthWithoutSpace;\n\t\t}\n\t}\n\toriginalRatio = originalWidth / originalHeight;\n\n\t// Typically, we use the image's full-sized dimensions. If those\n\t// dimensions have not been set (i.e. an external image with only one size),\n\t// the image's dimensions in the lightbox are the same\n\t// as those of the image in the content.\n\tlet imgMaxWidth = parseFloat(\n\t\tcontext.core.image.targetWidth !== 'none'\n\t\t\t? context.core.image.targetWidth\n\t\t\t: naturalWidth\n\t);\n\tlet imgMaxHeight = parseFloat(\n\t\tcontext.core.image.targetHeight !== 'none'\n\t\t\t? context.core.image.targetHeight\n\t\t\t: naturalHeight\n\t);\n\n\t// Ratio of the biggest image stored in the database.\n\tlet imgRatio = imgMaxWidth / imgMaxHeight;\n\tlet containerMaxWidth = imgMaxWidth;\n\tlet containerMaxHeight = imgMaxHeight;\n\tlet containerWidth = imgMaxWidth;\n\tlet containerHeight = imgMaxHeight;\n\t// Check if the target image has a different ratio than the original one (thumbnail).\n\t// Recalculate the width and height.\n\tif ( naturalRatio.toFixed( 2 ) !== imgRatio.toFixed( 2 ) ) {\n\t\tif ( naturalRatio > imgRatio ) {\n\t\t\t// If the width is reached before the height, we keep the maxWidth\n\t\t\t// and recalculate the height.\n\t\t\t// Unless the difference between the maxHeight and the reducedHeight\n\t\t\t// is higher than the maxWidth, where we keep the reducedHeight and\n\t\t\t// recalculate the width.\n\t\t\tconst reducedHeight = imgMaxWidth / naturalRatio;\n\t\t\tif ( imgMaxHeight - reducedHeight > imgMaxWidth ) {\n\t\t\t\timgMaxHeight = reducedHeight;\n\t\t\t\timgMaxWidth = reducedHeight * naturalRatio;\n\t\t\t} else {\n\t\t\t\timgMaxHeight = imgMaxWidth / naturalRatio;\n\t\t\t}\n\t\t} else {\n\t\t\t// If the height is reached before the width, we keep the maxHeight\n\t\t\t// and recalculate the width.\n\t\t\t// Unless the difference between the maxWidth and the reducedWidth\n\t\t\t// is higher than the maxHeight, where we keep the reducedWidth and\n\t\t\t// recalculate the height.\n\t\t\tconst reducedWidth = imgMaxHeight * naturalRatio;\n\t\t\tif ( imgMaxWidth - reducedWidth > imgMaxHeight ) {\n\t\t\t\timgMaxWidth = reducedWidth;\n\t\t\t\timgMaxHeight = reducedWidth / naturalRatio;\n\t\t\t} else {\n\t\t\t\timgMaxWidth = imgMaxHeight * naturalRatio;\n\t\t\t}\n\t\t}\n\t\tcontainerWidth = imgMaxWidth;\n\t\tcontainerHeight = imgMaxHeight;\n\t\timgRatio = imgMaxWidth / imgMaxHeight;\n\n\t\t// Calculate the max size of the container.\n\t\tif ( originalRatio > imgRatio ) {\n\t\t\tcontainerMaxWidth = imgMaxWidth;\n\t\t\tcontainerMaxHeight = containerMaxWidth / originalRatio;\n\t\t} else {\n\t\t\tcontainerMaxHeight = imgMaxHeight;\n\t\t\tcontainerMaxWidth = containerMaxHeight * originalRatio;\n\t\t}\n\t}\n\n\t// If the image has been pixelated on purpose, keep that size.\n\tif ( originalWidth > containerWidth || originalHeight > containerHeight ) {\n\t\tcontainerWidth = originalWidth;\n\t\tcontainerHeight = originalHeight;\n\t}\n\n\t// Calculate the final lightbox image size and the\n\t// scale factor. MaxWidth is either the window container\n\t// (accounting for padding) or the image resolution.\n\tlet horizontalPadding = 0;\n\tif ( window.innerWidth > 480 ) {\n\t\thorizontalPadding = 80;\n\t} else if ( window.innerWidth > 1920 ) {\n\t\thorizontalPadding = 160;\n\t}\n\tconst verticalPadding = 80;\n\n\tconst targetMaxWidth = Math.min(\n\t\twindow.innerWidth - horizontalPadding,\n\t\tcontainerWidth\n\t);\n\tconst targetMaxHeight = Math.min(\n\t\twindow.innerHeight - verticalPadding,\n\t\tcontainerHeight\n\t);\n\tconst targetContainerRatio = targetMaxWidth / targetMaxHeight;\n\n\tif ( originalRatio > targetContainerRatio ) {\n\t\t// If targetMaxWidth is reached before targetMaxHeight\n\t\tcontainerWidth = targetMaxWidth;\n\t\tcontainerHeight = containerWidth / originalRatio;\n\t} else {\n\t\t// If targetMaxHeight is reached before targetMaxWidth\n\t\tcontainerHeight = targetMaxHeight;\n\t\tcontainerWidth = containerHeight * originalRatio;\n\t}\n\n\tconst containerScale = originalWidth / containerWidth;\n\tconst lightboxImgWidth =\n\t\timgMaxWidth * ( containerWidth / containerMaxWidth );\n\tconst lightboxImgHeight =\n\t\timgMaxHeight * ( containerHeight / containerMaxHeight );\n\n\t// Add the CSS variables needed.\n\tlet styleTag = document.getElementById( 'wp-lightbox-styles' );\n\tif ( ! styleTag ) {\n\t\tstyleTag = document.createElement( 'style' );\n\t\tstyleTag.id = 'wp-lightbox-styles';\n\t\tdocument.head.appendChild( styleTag );\n\t}\n\n\t// As of this writing, using the calculations above will render the lightbox\n\t// with a small, erroneous whitespace on the left side of the image in iOS Safari,\n\t// perhaps due to an inconsistency in how browsers handle absolute positioning and CSS\n\t// transformation. In any case, adding 1 pixel to the container width and height solves\n\t// the problem, though this can be removed if the issue is fixed in the future.\n\tstyleTag.innerHTML = `\n\t\t:root {\n\t\t\t--wp--lightbox-initial-top-position: ${ screenPosY }px;\n\t\t\t--wp--lightbox-initial-left-position: ${ screenPosX }px;\n\t\t\t--wp--lightbox-container-width: ${ containerWidth + 1 }px;\n\t\t\t--wp--lightbox-container-height: ${ containerHeight + 1 }px;\n\t\t\t--wp--lightbox-image-width: ${ lightboxImgWidth }px;\n\t\t\t--wp--lightbox-image-height: ${ lightboxImgHeight }px;\n\t\t\t--wp--lightbox-scale: ${ containerScale };\n\t\t}\n\t`;\n}\n\n/*\n * Debounces a function call.\n *\n * @function\n * @param {Function} func - A function to be called\n * @param {number} wait - The time to wait before calling the function\n */\nfunction debounce( func, wait = 50 ) {\n\tlet timeout;\n\treturn () => {\n\t\tconst later = () => {\n\t\t\ttimeout = null;\n\t\t\tfunc();\n\t\t};\n\t\tclearTimeout( timeout );\n\t\ttimeout = setTimeout( later, wait );\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,0BAA0B;AAEhD,MAAMC,kBAAkB,GAAG,CAC1B,SAAS,EACT,YAAY,EACZ,+DAA+D,EAC/D,2CAA2C,EAC3C,6CAA6C,EAC7C,2CAA2C,EAC3C,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,mBAAmB,EACnB,iCAAiC,CACjC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIC,cAAc;;AAElB;AACA;AACA;AACA;AACA;AACA;AACA,IAAIC,UAAU,GAAG,KAAK;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA,IAAIC,aAAa,GAAG,CAAC;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,YAAYA,CAAEC,OAAO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Y,gBAAkB;AACpD,kCAAmCC,iBAAmB;AACtD,2BAA4BF,cAAgB;AAC5C;AACA,EAAE;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS9B,QAAQA,CAAEwC,IAAI,EAAEC,IAAI,GAAG,EAAE,EAAG;EACpC,IAAIC,OAAO;EACX,OAAO,MAAM;IACZ,MAAMC,KAAK,GAAGA,CAAA,KAAM;MACnBD,OAAO,GAAG,IAAI;MACdF,IAAI,CAAC,CAAC;IACP,CAAC;IACDI,YAAY,CAAEF,OAAQ,CAAC;IACvBA,OAAO,GAAGvG,UAAU,CAAEwG,KAAK,EAAEF,IAAK,CAAC;EACpC,CAAC;AACF"}
1
+ {"version":3,"names":["store","focusableSelectors","scrollCallback","isTouching","lastTouchTime","handleScroll","context","Date","now","window","scrollTo","core","image","scrollLeftReset","scrollTopReset","state","windowWidth","innerWidth","windowHeight","innerHeight","actions","showLightbox","event","imageLoaded","initialized","lastFocusedElement","document","activeElement","scrollDelta","pointerType","lightboxEnabled","setStyles","imageRef","pageYOffset","documentElement","scrollTop","pageXOffset","scrollLeft","bind","addEventListener","hideLightbox","hideAnimationEnabled","setTimeout","removeEventListener","lightboxTriggerRef","focus","preventScroll","handleKeydown","key","keyCode","shiftKey","firstFocusableElement","preventDefault","lastFocusableElement","handleLoad","effects","ref","imageCurrentSrc","currentSrc","setButtonStyles","handleTouchStart","handleTouchMove","handleTouchEnd","selectors","roleAttribute","ariaModal","dialogLabel","lightboxObjectFit","enlargedImgSrc","imageUploadedSrc","initOriginImage","parentElement","querySelector","complete","initLightbox","focusableElements","querySelectorAll","length","naturalWidth","naturalHeight","offsetWidth","offsetHeight","figure","figureWidth","clientWidth","figureHeight","clientHeight","caption","captionComputedStyle","getComputedStyle","parseFloat","marginTop","marginBottom","buttonOffsetTop","buttonOffsetRight","scaleAttr","naturalRatio","offsetRatio","referenceHeight","imageButtonTop","imageButtonRight","referenceWidth","setStylesOnResize","afterLoad","debounce","originalWidth","originalHeight","x","screenPosX","y","screenPosY","getBoundingClientRect","originalRatio","heightWithoutSpace","widthWithoutSpace","imgMaxWidth","targetWidth","imgMaxHeight","targetHeight","imgRatio","containerMaxWidth","containerMaxHeight","containerWidth","containerHeight","toFixed","reducedHeight","reducedWidth","horizontalPadding","verticalPadding","targetMaxWidth","Math","min","targetMaxHeight","targetContainerRatio","containerScale","lightboxImgWidth","lightboxImgHeight","styleTag","getElementById","createElement","id","head","appendChild","innerHTML","func","wait","timeout","later","clearTimeout"],"sources":["@wordpress/block-library/src/image/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store } from '@wordpress/interactivity';\n\nconst focusableSelectors = [\n\t'a[href]',\n\t'area[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'iframe',\n\t'object',\n\t'embed',\n\t'[contenteditable]',\n\t'[tabindex]:not([tabindex^=\"-\"])',\n];\n\n/*\n * Stores a context-bound scroll handler.\n *\n * This callback could be defined inline inside of the store\n * object but it's created externally to avoid confusion about\n * how its logic is called. This logic is not referenced directly\n * by the directives in the markup because the scroll event we\n * need to listen to is triggered on the window; so by defining it\n * outside of the store, we signal that the behavior here is different.\n * If we find a compelling reason to move it to the store, feel free.\n *\n * @type {Function}\n */\nlet scrollCallback;\n\n/*\n * Tracks whether user is touching screen; used to\n * differentiate behavior for touch and mouse input.\n *\n * @type {boolean}\n */\nlet isTouching = false;\n\n/*\n * Tracks the last time the screen was touched; used to\n * differentiate behavior for touch and mouse input.\n *\n * @type {number}\n */\nlet lastTouchTime = 0;\n\n/*\n * Lightbox page-scroll handler: prevents scrolling.\n *\n * This handler is added to prevent scrolling behaviors that\n * trigger content shift while the lightbox is open.\n *\n * It would be better to accomplish this through CSS alone, but\n * using overflow: hidden is currently the only way to do so, and\n * that causes the layout to shift and prevents the zoom animation\n * from working in some cases because we're unable to account for\n * the layout shift when doing the animation calculations. Instead,\n * here we use JavaScript to prevent and reset the scrolling\n * behavior. In the future, we may be able to use CSS or overflow: hidden\n * instead to not rely on JavaScript, but this seems to be the best approach\n * for now that provides the best visual experience.\n *\n * @param {Object} context Interactivity page context?\n */\nfunction handleScroll( context ) {\n\t// We can't override the scroll behavior on mobile devices\n\t// because doing so breaks the pinch to zoom functionality, and we\n\t// want to allow users to zoom in further on the high-res image.\n\tif ( ! isTouching && Date.now() - lastTouchTime > 450 ) {\n\t\t// We are unable to use event.preventDefault() to prevent scrolling\n\t\t// because the scroll event can't be canceled, so we reset the position instead.\n\t\twindow.scrollTo(\n\t\t\tcontext.core.image.scrollLeftReset,\n\t\t\tcontext.core.image.scrollTopReset\n\t\t);\n\t}\n}\n\nstore(\n\t{\n\t\tstate: {\n\t\t\tcore: {\n\t\t\t\timage: {\n\t\t\t\t\twindowWidth: window.innerWidth,\n\t\t\t\t\twindowHeight: window.innerHeight,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tactions: {\n\t\t\tcore: {\n\t\t\t\timage: {\n\t\t\t\t\tshowLightbox: ( { context, event } ) => {\n\t\t\t\t\t\t// We can't initialize the lightbox until the reference\n\t\t\t\t\t\t// image is loaded, otherwise the UX is broken.\n\t\t\t\t\t\tif ( ! context.core.image.imageLoaded ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontext.core.image.initialized = true;\n\t\t\t\t\t\tcontext.core.image.lastFocusedElement =\n\t\t\t\t\t\t\twindow.document.activeElement;\n\t\t\t\t\t\tcontext.core.image.scrollDelta = 0;\n\t\t\t\t\t\tcontext.core.image.pointerType = event.pointerType;\n\n\t\t\t\t\t\tcontext.core.image.lightboxEnabled = true;\n\t\t\t\t\t\tsetStyles( context, context.core.image.imageRef );\n\n\t\t\t\t\t\tcontext.core.image.scrollTopReset =\n\t\t\t\t\t\t\twindow.pageYOffset ||\n\t\t\t\t\t\t\tdocument.documentElement.scrollTop;\n\n\t\t\t\t\t\t// In most cases, this value will be 0, but this is included\n\t\t\t\t\t\t// in case a user has created a page with horizontal scrolling.\n\t\t\t\t\t\tcontext.core.image.scrollLeftReset =\n\t\t\t\t\t\t\twindow.pageXOffset ||\n\t\t\t\t\t\t\tdocument.documentElement.scrollLeft;\n\n\t\t\t\t\t\t// We define and bind the scroll callback here so\n\t\t\t\t\t\t// that we can pass the context and as an argument.\n\t\t\t\t\t\t// We may be able to change this in the future if we\n\t\t\t\t\t\t// define the scroll callback in the store instead, but\n\t\t\t\t\t\t// this approach seems to tbe clearest for now.\n\t\t\t\t\t\tscrollCallback = handleScroll.bind( null, context );\n\n\t\t\t\t\t\t// We need to add a scroll event listener to the window\n\t\t\t\t\t\t// here because we are unable to otherwise access it via\n\t\t\t\t\t\t// the Interactivity API directives. If we add a native way\n\t\t\t\t\t\t// to access the window, we can remove this.\n\t\t\t\t\t\twindow.addEventListener(\n\t\t\t\t\t\t\t'scroll',\n\t\t\t\t\t\t\tscrollCallback,\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\thideLightbox: async ( { context } ) => {\n\t\t\t\t\t\tcontext.core.image.hideAnimationEnabled = true;\n\t\t\t\t\t\tif ( context.core.image.lightboxEnabled ) {\n\t\t\t\t\t\t\t// We want to wait until the close animation is completed\n\t\t\t\t\t\t\t// before allowing a user to scroll again. The duration of this\n\t\t\t\t\t\t\t// animation is defined in the styles.scss and depends on if the\n\t\t\t\t\t\t\t// animation is 'zoom' or 'fade', but in any case we should wait\n\t\t\t\t\t\t\t// a few milliseconds longer than the duration, otherwise a user\n\t\t\t\t\t\t\t// may scroll too soon and cause the animation to look sloppy.\n\t\t\t\t\t\t\tsetTimeout( function () {\n\t\t\t\t\t\t\t\twindow.removeEventListener(\n\t\t\t\t\t\t\t\t\t'scroll',\n\t\t\t\t\t\t\t\t\tscrollCallback\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t// If we don't delay before changing the focus,\n\t\t\t\t\t\t\t\t// the focus ring will appear on Firefox before\n\t\t\t\t\t\t\t\t// the image has finished animating, which looks broken.\n\t\t\t\t\t\t\t\tcontext.core.image.lightboxTriggerRef.focus( {\n\t\t\t\t\t\t\t\t\tpreventScroll: true,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}, 450 );\n\n\t\t\t\t\t\t\tcontext.core.image.lightboxEnabled = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\thandleKeydown: ( { context, actions, event } ) => {\n\t\t\t\t\t\tif ( context.core.image.lightboxEnabled ) {\n\t\t\t\t\t\t\tif ( event.key === 'Tab' || event.keyCode === 9 ) {\n\t\t\t\t\t\t\t\t// If shift + tab it change the direction\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tevent.shiftKey &&\n\t\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\t\tcontext.core.image.firstFocusableElement\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\tcontext.core.image.lastFocusableElement.focus();\n\t\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t\t! event.shiftKey &&\n\t\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\t\tcontext.core.image.lastFocusableElement\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\tcontext.core.image.firstFocusableElement.focus();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tevent.key === 'Escape' ||\n\t\t\t\t\t\t\t\tevent.keyCode === 27\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tactions.core.image.hideLightbox( {\n\t\t\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t// This is fired just by lazily loaded\n\t\t\t\t\t// images on the page, not all images.\n\t\t\t\t\thandleLoad: ( { context, effects, ref } ) => {\n\t\t\t\t\t\tcontext.core.image.imageLoaded = true;\n\t\t\t\t\t\tcontext.core.image.imageCurrentSrc = ref.currentSrc;\n\t\t\t\t\t\teffects.core.image.setButtonStyles( {\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t} );\n\t\t\t\t\t},\n\t\t\t\t\thandleTouchStart: () => {\n\t\t\t\t\t\tisTouching = true;\n\t\t\t\t\t},\n\t\t\t\t\thandleTouchMove: ( { context, event } ) => {\n\t\t\t\t\t\t// On mobile devices, we want to prevent triggering the\n\t\t\t\t\t\t// scroll event because otherwise the page jumps around as\n\t\t\t\t\t\t// we reset the scroll position. This also means that closing\n\t\t\t\t\t\t// the lightbox requires that a user perform a simple tap. This\n\t\t\t\t\t\t// may be changed in the future if we find a better alternative\n\t\t\t\t\t\t// to override or reset the scroll position during swipe actions.\n\t\t\t\t\t\tif ( context.core.image.lightboxEnabled ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\thandleTouchEnd: () => {\n\t\t\t\t\t\t// We need to wait a few milliseconds before resetting\n\t\t\t\t\t\t// to ensure that pinch to zoom works consistently\n\t\t\t\t\t\t// on mobile devices when the lightbox is open.\n\t\t\t\t\t\tlastTouchTime = Date.now();\n\t\t\t\t\t\tisTouching = false;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tselectors: {\n\t\t\tcore: {\n\t\t\t\timage: {\n\t\t\t\t\troleAttribute: ( { context } ) => {\n\t\t\t\t\t\treturn context.core.image.lightboxEnabled\n\t\t\t\t\t\t\t? 'dialog'\n\t\t\t\t\t\t\t: null;\n\t\t\t\t\t},\n\t\t\t\t\tariaModal: ( { context } ) => {\n\t\t\t\t\t\treturn context.core.image.lightboxEnabled\n\t\t\t\t\t\t\t? 'true'\n\t\t\t\t\t\t\t: null;\n\t\t\t\t\t},\n\t\t\t\t\tdialogLabel: ( { context } ) => {\n\t\t\t\t\t\treturn context.core.image.lightboxEnabled\n\t\t\t\t\t\t\t? context.core.image.dialogLabel\n\t\t\t\t\t\t\t: null;\n\t\t\t\t\t},\n\t\t\t\t\tlightboxObjectFit: ( { context } ) => {\n\t\t\t\t\t\tif ( context.core.image.initialized ) {\n\t\t\t\t\t\t\treturn 'cover';\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tenlargedImgSrc: ( { context } ) => {\n\t\t\t\t\t\treturn context.core.image.initialized\n\t\t\t\t\t\t\t? context.core.image.imageUploadedSrc\n\t\t\t\t\t\t\t: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=';\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\teffects: {\n\t\t\tcore: {\n\t\t\t\timage: {\n\t\t\t\t\tinitOriginImage: ( { context, ref } ) => {\n\t\t\t\t\t\tcontext.core.image.imageRef = ref;\n\t\t\t\t\t\tcontext.core.image.lightboxTriggerRef =\n\t\t\t\t\t\t\tref.parentElement.querySelector(\n\t\t\t\t\t\t\t\t'.lightbox-trigger'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( ref.complete ) {\n\t\t\t\t\t\t\tcontext.core.image.imageLoaded = true;\n\t\t\t\t\t\t\tcontext.core.image.imageCurrentSrc = ref.currentSrc;\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tinitLightbox: async ( { context, ref } ) => {\n\t\t\t\t\t\tif ( context.core.image.lightboxEnabled ) {\n\t\t\t\t\t\t\tconst focusableElements =\n\t\t\t\t\t\t\t\tref.querySelectorAll( focusableSelectors );\n\t\t\t\t\t\t\tcontext.core.image.firstFocusableElement =\n\t\t\t\t\t\t\t\tfocusableElements[ 0 ];\n\t\t\t\t\t\t\tcontext.core.image.lastFocusableElement =\n\t\t\t\t\t\t\t\tfocusableElements[\n\t\t\t\t\t\t\t\t\tfocusableElements.length - 1\n\t\t\t\t\t\t\t\t];\n\n\t\t\t\t\t\t\t// Move focus to the dialog when opening it.\n\t\t\t\t\t\t\tref.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tsetButtonStyles: ( { context, ref } ) => {\n\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\tnaturalWidth,\n\t\t\t\t\t\t\tnaturalHeight,\n\t\t\t\t\t\t\toffsetWidth,\n\t\t\t\t\t\t\toffsetHeight,\n\t\t\t\t\t\t} = ref;\n\n\t\t\t\t\t\t// If the image isn't loaded yet, we can't\n\t\t\t\t\t\t// calculate where the button should be.\n\t\t\t\t\t\tif ( naturalWidth === 0 || naturalHeight === 0 ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst figure = ref.parentElement;\n\t\t\t\t\t\tconst figureWidth = ref.parentElement.clientWidth;\n\n\t\t\t\t\t\t// We need special handling for the height because\n\t\t\t\t\t\t// a caption will cause the figure to be taller than\n\t\t\t\t\t\t// the image, which means we need to account for that\n\t\t\t\t\t\t// when calculating the placement of the button in the\n\t\t\t\t\t\t// top right corner of the image.\n\t\t\t\t\t\tlet figureHeight = ref.parentElement.clientHeight;\n\t\t\t\t\t\tconst caption = figure.querySelector( 'figcaption' );\n\t\t\t\t\t\tif ( caption ) {\n\t\t\t\t\t\t\tconst captionComputedStyle =\n\t\t\t\t\t\t\t\twindow.getComputedStyle( caption );\n\t\t\t\t\t\t\tfigureHeight =\n\t\t\t\t\t\t\t\tfigureHeight -\n\t\t\t\t\t\t\t\tcaption.offsetHeight -\n\t\t\t\t\t\t\t\tparseFloat( captionComputedStyle.marginTop ) -\n\t\t\t\t\t\t\t\tparseFloat( captionComputedStyle.marginBottom );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst buttonOffsetTop = figureHeight - offsetHeight;\n\t\t\t\t\t\tconst buttonOffsetRight = figureWidth - offsetWidth;\n\n\t\t\t\t\t\t// In the case of an image with object-fit: contain, the\n\t\t\t\t\t\t// size of the <img> element can be larger than the image itself,\n\t\t\t\t\t\t// so we need to calculate where to place the button.\n\t\t\t\t\t\tif ( context.core.image.scaleAttr === 'contain' ) {\n\t\t\t\t\t\t\t// Natural ratio of the image.\n\t\t\t\t\t\t\tconst naturalRatio = naturalWidth / naturalHeight;\n\t\t\t\t\t\t\t// Offset ratio of the image.\n\t\t\t\t\t\t\tconst offsetRatio = offsetWidth / offsetHeight;\n\n\t\t\t\t\t\t\tif ( naturalRatio >= offsetRatio ) {\n\t\t\t\t\t\t\t\t// If it reaches the width first, keep\n\t\t\t\t\t\t\t\t// the width and compute the height.\n\t\t\t\t\t\t\t\tconst referenceHeight =\n\t\t\t\t\t\t\t\t\toffsetWidth / naturalRatio;\n\t\t\t\t\t\t\t\tcontext.core.image.imageButtonTop =\n\t\t\t\t\t\t\t\t\t( offsetHeight - referenceHeight ) / 2 +\n\t\t\t\t\t\t\t\t\tbuttonOffsetTop +\n\t\t\t\t\t\t\t\t\t10;\n\t\t\t\t\t\t\t\tcontext.core.image.imageButtonRight =\n\t\t\t\t\t\t\t\t\tbuttonOffsetRight + 10;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// If it reaches the height first, keep\n\t\t\t\t\t\t\t\t// the height and compute the width.\n\t\t\t\t\t\t\t\tconst referenceWidth =\n\t\t\t\t\t\t\t\t\toffsetHeight * naturalRatio;\n\t\t\t\t\t\t\t\tcontext.core.image.imageButtonTop =\n\t\t\t\t\t\t\t\t\tbuttonOffsetTop + 10;\n\t\t\t\t\t\t\t\tcontext.core.image.imageButtonRight =\n\t\t\t\t\t\t\t\t\t( offsetWidth - referenceWidth ) / 2 +\n\t\t\t\t\t\t\t\t\tbuttonOffsetRight +\n\t\t\t\t\t\t\t\t\t10;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcontext.core.image.imageButtonTop =\n\t\t\t\t\t\t\t\tbuttonOffsetTop + 10;\n\t\t\t\t\t\t\tcontext.core.image.imageButtonRight =\n\t\t\t\t\t\t\t\tbuttonOffsetRight + 10;\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tsetStylesOnResize: ( { state, context, ref } ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tcontext.core.image.lightboxEnabled &&\n\t\t\t\t\t\t\t( state.core.image.windowWidth ||\n\t\t\t\t\t\t\t\tstate.core.image.windowHeight )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tsetStyles( context, ref );\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tafterLoad: ( { state } ) => {\n\t\t\twindow.addEventListener(\n\t\t\t\t'resize',\n\t\t\t\tdebounce( () => {\n\t\t\t\t\tstate.core.image.windowWidth = window.innerWidth;\n\t\t\t\t\tstate.core.image.windowHeight = window.innerHeight;\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t}\n);\n\n/*\n * Computes styles for the lightbox and adds them to the document.\n *\n * @function\n * @param {Object} context - An Interactivity API context\n * @param {Object} event - A triggering event\n */\nfunction setStyles( context, ref ) {\n\t// The reference img element lies adjacent\n\t// to the event target button in the DOM.\n\tlet {\n\t\tnaturalWidth,\n\t\tnaturalHeight,\n\t\toffsetWidth: originalWidth,\n\t\toffsetHeight: originalHeight,\n\t} = ref;\n\tlet { x: screenPosX, y: screenPosY } = ref.getBoundingClientRect();\n\n\t// Natural ratio of the image clicked to open the lightbox.\n\tconst naturalRatio = naturalWidth / naturalHeight;\n\t// Original ratio of the image clicked to open the lightbox.\n\tlet originalRatio = originalWidth / originalHeight;\n\n\t// If it has object-fit: contain, recalculate the original sizes\n\t// and the screen position without the blank spaces.\n\tif ( context.core.image.scaleAttr === 'contain' ) {\n\t\tif ( naturalRatio > originalRatio ) {\n\t\t\tconst heightWithoutSpace = originalWidth / naturalRatio;\n\t\t\t// Recalculate screen position without the top space.\n\t\t\tscreenPosY += ( originalHeight - heightWithoutSpace ) / 2;\n\t\t\toriginalHeight = heightWithoutSpace;\n\t\t} else {\n\t\t\tconst widthWithoutSpace = originalHeight * naturalRatio;\n\t\t\t// Recalculate screen position without the left space.\n\t\t\tscreenPosX += ( originalWidth - widthWithoutSpace ) / 2;\n\t\t\toriginalWidth = widthWithoutSpace;\n\t\t}\n\t}\n\toriginalRatio = originalWidth / originalHeight;\n\n\t// Typically, we use the image's full-sized dimensions. If those\n\t// dimensions have not been set (i.e. an external image with only one size),\n\t// the image's dimensions in the lightbox are the same\n\t// as those of the image in the content.\n\tlet imgMaxWidth = parseFloat(\n\t\tcontext.core.image.targetWidth !== 'none'\n\t\t\t? context.core.image.targetWidth\n\t\t\t: naturalWidth\n\t);\n\tlet imgMaxHeight = parseFloat(\n\t\tcontext.core.image.targetHeight !== 'none'\n\t\t\t? context.core.image.targetHeight\n\t\t\t: naturalHeight\n\t);\n\n\t// Ratio of the biggest image stored in the database.\n\tlet imgRatio = imgMaxWidth / imgMaxHeight;\n\tlet containerMaxWidth = imgMaxWidth;\n\tlet containerMaxHeight = imgMaxHeight;\n\tlet containerWidth = imgMaxWidth;\n\tlet containerHeight = imgMaxHeight;\n\t// Check if the target image has a different ratio than the original one (thumbnail).\n\t// Recalculate the width and height.\n\tif ( naturalRatio.toFixed( 2 ) !== imgRatio.toFixed( 2 ) ) {\n\t\tif ( naturalRatio > imgRatio ) {\n\t\t\t// If the width is reached before the height, we keep the maxWidth\n\t\t\t// and recalculate the height.\n\t\t\t// Unless the difference between the maxHeight and the reducedHeight\n\t\t\t// is higher than the maxWidth, where we keep the reducedHeight and\n\t\t\t// recalculate the width.\n\t\t\tconst reducedHeight = imgMaxWidth / naturalRatio;\n\t\t\tif ( imgMaxHeight - reducedHeight > imgMaxWidth ) {\n\t\t\t\timgMaxHeight = reducedHeight;\n\t\t\t\timgMaxWidth = reducedHeight * naturalRatio;\n\t\t\t} else {\n\t\t\t\timgMaxHeight = imgMaxWidth / naturalRatio;\n\t\t\t}\n\t\t} else {\n\t\t\t// If the height is reached before the width, we keep the maxHeight\n\t\t\t// and recalculate the width.\n\t\t\t// Unless the difference between the maxWidth and the reducedWidth\n\t\t\t// is higher than the maxHeight, where we keep the reducedWidth and\n\t\t\t// recalculate the height.\n\t\t\tconst reducedWidth = imgMaxHeight * naturalRatio;\n\t\t\tif ( imgMaxWidth - reducedWidth > imgMaxHeight ) {\n\t\t\t\timgMaxWidth = reducedWidth;\n\t\t\t\timgMaxHeight = reducedWidth / naturalRatio;\n\t\t\t} else {\n\t\t\t\timgMaxWidth = imgMaxHeight * naturalRatio;\n\t\t\t}\n\t\t}\n\t\tcontainerWidth = imgMaxWidth;\n\t\tcontainerHeight = imgMaxHeight;\n\t\timgRatio = imgMaxWidth / imgMaxHeight;\n\n\t\t// Calculate the max size of the container.\n\t\tif ( originalRatio > imgRatio ) {\n\t\t\tcontainerMaxWidth = imgMaxWidth;\n\t\t\tcontainerMaxHeight = containerMaxWidth / originalRatio;\n\t\t} else {\n\t\t\tcontainerMaxHeight = imgMaxHeight;\n\t\t\tcontainerMaxWidth = containerMaxHeight * originalRatio;\n\t\t}\n\t}\n\n\t// If the image has been pixelated on purpose, keep that size.\n\tif ( originalWidth > containerWidth || originalHeight > containerHeight ) {\n\t\tcontainerWidth = originalWidth;\n\t\tcontainerHeight = originalHeight;\n\t}\n\n\t// Calculate the final lightbox image size and the\n\t// scale factor. MaxWidth is either the window container\n\t// (accounting for padding) or the image resolution.\n\tlet horizontalPadding = 0;\n\tif ( window.innerWidth > 480 ) {\n\t\thorizontalPadding = 80;\n\t} else if ( window.innerWidth > 1920 ) {\n\t\thorizontalPadding = 160;\n\t}\n\tconst verticalPadding = 80;\n\n\tconst targetMaxWidth = Math.min(\n\t\twindow.innerWidth - horizontalPadding,\n\t\tcontainerWidth\n\t);\n\tconst targetMaxHeight = Math.min(\n\t\twindow.innerHeight - verticalPadding,\n\t\tcontainerHeight\n\t);\n\tconst targetContainerRatio = targetMaxWidth / targetMaxHeight;\n\n\tif ( originalRatio > targetContainerRatio ) {\n\t\t// If targetMaxWidth is reached before targetMaxHeight\n\t\tcontainerWidth = targetMaxWidth;\n\t\tcontainerHeight = containerWidth / originalRatio;\n\t} else {\n\t\t// If targetMaxHeight is reached before targetMaxWidth\n\t\tcontainerHeight = targetMaxHeight;\n\t\tcontainerWidth = containerHeight * originalRatio;\n\t}\n\n\tconst containerScale = originalWidth / containerWidth;\n\tconst lightboxImgWidth =\n\t\timgMaxWidth * ( containerWidth / containerMaxWidth );\n\tconst lightboxImgHeight =\n\t\timgMaxHeight * ( containerHeight / containerMaxHeight );\n\n\t// Add the CSS variables needed.\n\tlet styleTag = document.getElementById( 'wp-lightbox-styles' );\n\tif ( ! styleTag ) {\n\t\tstyleTag = document.createElement( 'style' );\n\t\tstyleTag.id = 'wp-lightbox-styles';\n\t\tdocument.head.appendChild( styleTag );\n\t}\n\n\t// As of this writing, using the calculations above will render the lightbox\n\t// with a small, erroneous whitespace on the left side of the image in iOS Safari,\n\t// perhaps due to an inconsistency in how browsers handle absolute positioning and CSS\n\t// transformation. In any case, adding 1 pixel to the container width and height solves\n\t// the problem, though this can be removed if the issue is fixed in the future.\n\tstyleTag.innerHTML = `\n\t\t:root {\n\t\t\t--wp--lightbox-initial-top-position: ${ screenPosY }px;\n\t\t\t--wp--lightbox-initial-left-position: ${ screenPosX }px;\n\t\t\t--wp--lightbox-container-width: ${ containerWidth + 1 }px;\n\t\t\t--wp--lightbox-container-height: ${ containerHeight + 1 }px;\n\t\t\t--wp--lightbox-image-width: ${ lightboxImgWidth }px;\n\t\t\t--wp--lightbox-image-height: ${ lightboxImgHeight }px;\n\t\t\t--wp--lightbox-scale: ${ containerScale };\n\t\t}\n\t`;\n}\n\n/*\n * Debounces a function call.\n *\n * @function\n * @param {Function} func - A function to be called\n * @param {number} wait - The time to wait before calling the function\n */\nfunction debounce( func, wait = 50 ) {\n\tlet timeout;\n\treturn () => {\n\t\tconst later = () => {\n\t\t\ttimeout = null;\n\t\t\tfunc();\n\t\t};\n\t\tclearTimeout( timeout );\n\t\ttimeout = setTimeout( later, wait );\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,0BAA0B;AAEhD,MAAMC,kBAAkB,GAAG,CAC1B,SAAS,EACT,YAAY,EACZ,+DAA+D,EAC/D,2CAA2C,EAC3C,6CAA6C,EAC7C,2CAA2C,EAC3C,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,mBAAmB,EACnB,iCAAiC,CACjC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIC,cAAc;;AAElB;AACA;AACA;AACA;AACA;AACA;AACA,IAAIC,UAAU,GAAG,KAAK;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA,IAAIC,aAAa,GAAG,CAAC;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,YAAYA,CAAEC,OAAO,EAAG;EAChC;EACA;EACA;EACA,IAAK,CAAEH,UAAU,IAAII,IAAI,CAACC,GAAG,CAAC,CAAC,GAAGJ,aAAa,GAAG,GAAG,EAAG;IACvD;IACA;IACAK,MAAM,CAACC,QAAQ,CACdJ,OAAO,CAACK,IAAI,CAACC,KAAK,CAACC,eAAe,EAClCP,OAAO,CAACK,IAAI,CAACC,KAAK,CAACE,cACpB,CAAC;EACF;AACD;AAEAd,KAAK,CACJ;EACCe,KAAK,EAAE;IACNJ,IAAI,EAAE;MACLC,KAAK,EAAE;QACNI,WAAW,EAAEP,MAAM,CAACQ,UAAU;QAC9BC,YAAY,EAAET,MAAM,CAACU;MACtB;IACD;EACD,CAAC;E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e,GAAGX,aAAa;EACjD;EAEA,MAAMsB,cAAc,GAAG7B,aAAa,GAAGiB,cAAc;EACrD,MAAMa,gBAAgB,GACrBpB,WAAW,IAAKO,cAAc,GAAGF,iBAAiB,CAAE;EACrD,MAAMgB,iBAAiB,GACtBnB,YAAY,IAAKM,eAAe,GAAGF,kBAAkB,CAAE;;EAExD;EACA,IAAIgB,QAAQ,GAAG/G,QAAQ,CAACgH,cAAc,CAAE,oBAAqB,CAAC;EAC9D,IAAK,CAAED,QAAQ,EAAG;IACjBA,QAAQ,GAAG/G,QAAQ,CAACiH,aAAa,CAAE,OAAQ,CAAC;IAC5CF,QAAQ,CAACG,EAAE,GAAG,oBAAoB;IAClClH,QAAQ,CAACmH,IAAI,CAACC,WAAW,CAAEL,QAAS,CAAC;EACtC;;EAEA;EACA;EACA;EACA;EACA;EACAA,QAAQ,CAACM,SAAS,GAAI;AACvB;AACA,0CAA2CjC,UAAY;AACvD,2CAA4CF,UAAY;AACxD,qCAAsCc,cAAc,GAAG,CAAG;AAC1D,sCAAuCC,eAAe,GAAG,CAAG;AAC5D,iCAAkCY,gBAAkB;AACpD,kCAAmCC,iBAAmB;AACtD,2BAA4BF,cAAgB;AAC5C;AACA,EAAE;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS9B,QAAQA,CAAEwC,IAAI,EAAEC,IAAI,GAAG,EAAE,EAAG;EACpC,IAAIC,OAAO;EACX,OAAO,MAAM;IACZ,MAAMC,KAAK,GAAGA,CAAA,KAAM;MACnBD,OAAO,GAAG,IAAI;MACdF,IAAI,CAAC,CAAC;IACP,CAAC;IACDI,YAAY,CAAEF,OAAQ,CAAC;IACvBA,OAAO,GAAGxG,UAAU,CAAEyG,KAAK,EAAEF,IAAK,CAAC;EACpC,CAAC;AACF"}
@@ -10,13 +10,14 @@ import { View, Text, TouchableWithoutFeedback, TouchableOpacity } from 'react-na
10
10
  import { Icon } from '@wordpress/components';
11
11
  import { compose, withPreferredColorScheme } from '@wordpress/compose';
12
12
  import { coreBlocks } from '@wordpress/block-library';
13
- import { normalizeIconObject } from '@wordpress/blocks';
13
+ import { normalizeIconObject, rawHandler, serialize } from '@wordpress/blocks';
14
14
  import { Component } from '@wordpress/element';
15
15
  import { __, _x, sprintf } from '@wordpress/i18n';
16
16
  import { help, plugins } from '@wordpress/icons';
17
17
  import { withSelect, withDispatch } from '@wordpress/data';
18
18
  import { applyFilters } from '@wordpress/hooks';
19
19
  import { UnsupportedBlockDetails, store as blockEditorStore } from '@wordpress/block-editor';
20
+ import { store as noticesStore } from '@wordpress/notices';
20
21
 
21
22
  /**
22
23
  * Internal dependencies
@@ -26,6 +27,7 @@ import styles from './style.scss';
26
27
  // Blocks that can't be edited through the Unsupported block editor identified by their name.
27
28
  const UBE_INCOMPATIBLE_BLOCKS = ['core/block'];
28
29
  const I18N_BLOCK_SCHEMA_TITLE = 'block title';
30
+ const EMPTY_ARRAY = [];
29
31
  export class UnsupportedBlockEdit extends Component {
30
32
  constructor(props) {
31
33
  super(props);
@@ -99,22 +101,42 @@ export class UnsupportedBlockEdit extends Component {
99
101
  }
100
102
  renderSheet(blockTitle, blockName) {
101
103
  const {
102
- clientId
104
+ block,
105
+ clientId,
106
+ createSuccessNotice,
107
+ replaceBlocks
103
108
  } = this.props;
104
109
  const {
105
110
  showHelp
106
111
  } = this.state;
112
+
107
113
  /* translators: Missing block alert title. %s: The localized block name */
108
114
  const titleFormat = __("'%s' is not fully-supported");
109
115
  const title = sprintf(titleFormat, blockTitle);
110
- const description = applyFilters('native.missing_block_detail', __('We are working hard to add more blocks with each release.'), blockName);
116
+ let description = applyFilters('native.missing_block_detail', __('We are working hard to add more blocks with each release.'), blockName);
117
+ let customActions = EMPTY_ARRAY;
118
+
119
+ // For Classic blocks, we offer the alternative to convert the content to blocks.
120
+ if (blockName === 'core/freeform') {
121
+ description += ' ' + __('Alternatively, you can convert the content to blocks.');
122
+ /* translators: displayed right after the classic block is converted to blocks. %s: The localized classic block name */
123
+ const successNotice = __("'%s' block converted to blocks");
124
+ customActions = [{
125
+ label: __('Convert to blocks'),
126
+ onPress: () => {
127
+ createSuccessNotice(sprintf(successNotice, blockTitle));
128
+ replaceBlocks(block);
129
+ }
130
+ }];
131
+ }
111
132
  return createElement(UnsupportedBlockDetails, {
112
133
  clientId: clientId,
113
134
  showSheet: showHelp,
114
135
  onCloseSheet: this.closeSheet,
115
136
  customBlockTitle: blockTitle,
116
137
  title: title,
117
- description: description
138
+ description: description,
139
+ customActions: customActions
118
140
  });
119
141
  }
120
142
  render() {
@@ -155,24 +177,40 @@ export class UnsupportedBlockEdit extends Component {
155
177
  }
156
178
  }
157
179
  export default compose([withSelect((select, {
158
- attributes
180
+ attributes,
181
+ clientId
159
182
  }) => {
183
+ const {
184
+ getBlock,
185
+ getSettings
186
+ } = select(blockEditorStore);
160
187
  const {
161
188
  capabilities
162
- } = select(blockEditorStore).getSettings();
189
+ } = getSettings();
163
190
  return {
164
191
  isUnsupportedBlockEditorSupported: capabilities?.unsupportedBlockEditor === true,
165
192
  canEnableUnsupportedBlockEditor: capabilities?.canEnableUnsupportedBlockEditor === true,
166
- isEditableInUnsupportedBlockEditor: !UBE_INCOMPATIBLE_BLOCKS.includes(attributes.originalName)
193
+ isEditableInUnsupportedBlockEditor: !UBE_INCOMPATIBLE_BLOCKS.includes(attributes.originalName),
194
+ block: getBlock(clientId)
167
195
  };
168
196
  }), withDispatch((dispatch, ownProps) => {
169
197
  const {
170
- selectBlock
198
+ selectBlock,
199
+ replaceBlocks
171
200
  } = dispatch(blockEditorStore);
201
+ const {
202
+ createSuccessNotice
203
+ } = dispatch(noticesStore);
172
204
  return {
173
205
  selectBlock() {
174
206
  selectBlock(ownProps.clientId);
175
- }
207
+ },
208
+ replaceBlocks(block) {
209
+ replaceBlocks(ownProps.clientId, rawHandler({
210
+ HTML: serialize(block)
211
+ }));
212
+ },
213
+ createSuccessNotice
176
214
  };
177
215
  }), withPreferredColorScheme])(UnsupportedBlockEdit);
178
216
  //# sourceMappingURL=edit.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["View","Text","TouchableWithoutFeedback","TouchableOpacity","Icon","compose","withPreferredColorScheme","coreBlocks","normalizeIconObject","Component","__","_x","sprintf","help","plugins","withSelect","withDispatch","applyFilters","UnsupportedBlockDetails","store","blockEditorStore","styles","UBE_INCOMPATIBLE_BLOCKS","I18N_BLOCK_SCHEMA_TITLE","UnsupportedBlockEdit","constructor","props","state","showHelp","toggleSheet","bind","closeSheet","requestFallback","onHelpButtonPressed","setState","componentWillUnmount","timeout","clearTimeout","getTitle","originalName","attributes","blockType","title","metadata","textdomain","renderHelpIcon","infoIconStyle","getStylesFromColorScheme","infoIcon","infoIconDark","createElement","onPress","style","helpIconContainer","accessibilityLabel","accessibilityRole","accessibilityHint","className","label","icon","fill","color","isSelected","selectBlock","canEnableUnsupportedBlockEditor","isUnsupportedBlockEditorSupported","sendButtonPressMessage","sendFallbackMessage","renderSheet","blockTitle","blockName","clientId","titleFormat","description","showSheet","onCloseSheet","customBlockTitle","render","preferredColorScheme","titleStyle","unsupportedBlockMessage","unsupportedBlockMessageDark","subTitleStyle","unsupportedBlockSubtitle","unsupportedBlockSubtitleDark","subtitle","settings","iconStyle","unsupportedBlockIcon","unsupportedBlockIconDark","iconClassName","disabled","unsupportedBlock","unsupportedBlockDark","unsupportedBlockHeader","src","select","capabilities","getSettings","unsupportedBlockEditor","isEditableInUnsupportedBlockEditor","includes","dispatch","ownProps"],"sources":["@wordpress/block-library/src/missing/edit.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tView,\n\tText,\n\tTouchableWithoutFeedback,\n\tTouchableOpacity,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Icon } from '@wordpress/components';\nimport { compose, withPreferredColorScheme } from '@wordpress/compose';\nimport { coreBlocks } from '@wordpress/block-library';\nimport { normalizeIconObject } from '@wordpress/blocks';\nimport { Component } from '@wordpress/element';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { help, plugins } from '@wordpress/icons';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { applyFilters } from '@wordpress/hooks';\nimport {\n\tUnsupportedBlockDetails,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\n// Blocks that can't be edited through the Unsupported block editor identified by their name.\nconst UBE_INCOMPATIBLE_BLOCKS = [ 'core/block' ];\nconst I18N_BLOCK_SCHEMA_TITLE = 'block title';\n\nexport class UnsupportedBlockEdit extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\t\tthis.state = { showHelp: false };\n\t\tthis.toggleSheet = this.toggleSheet.bind( this );\n\t\tthis.closeSheet = this.closeSheet.bind( this );\n\t\tthis.requestFallback = this.requestFallback.bind( this );\n\t\tthis.onHelpButtonPressed = this.onHelpButtonPressed.bind( this );\n\t}\n\n\ttoggleSheet() {\n\t\tthis.setState( {\n\t\t\tshowHelp: ! this.state.showHelp,\n\t\t} );\n\t}\n\n\tcloseSheet() {\n\t\tthis.setState( {\n\t\t\tshowHelp: false,\n\t\t} );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif ( this.timeout ) {\n\t\t\tclearTimeout( this.timeout );\n\t\t}\n\t}\n\n\tgetTitle() {\n\t\tconst { originalName } = this.props.attributes;\n\t\tconst blockType = coreBlocks[ originalName ];\n\t\tconst title = blockType?.metadata.title;\n\t\tconst textdomain = blockType?.metadata.textdomain;\n\n\t\treturn title && textdomain\n\t\t\t? // eslint-disable-next-line @wordpress/i18n-no-variables, @wordpress/i18n-text-domain\n\t\t\t _x( title, I18N_BLOCK_SCHEMA_TITLE, textdomain )\n\t\t\t: originalName;\n\t}\n\n\trenderHelpIcon() {\n\t\tconst infoIconStyle = this.props.getStylesFromColorScheme(\n\t\t\tstyles.infoIcon,\n\t\t\tstyles.infoIconDark\n\t\t);\n\n\t\treturn (\n\t\t\t<TouchableOpacity\n\t\t\t\tonPress={ this.onHelpButtonPressed }\n\t\t\t\tstyle={ styles.helpIconContainer }\n\t\t\t\taccessibilityLabel={ __( 'Help button' ) }\n\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\taccessibilityHint={ __( 'Tap here to show help' ) }\n\t\t\t>\n\t\t\t\t<Icon\n\t\t\t\t\tclassName=\"unsupported-icon-help\"\n\t\t\t\t\tlabel={ __( 'Help icon' ) }\n\t\t\t\t\ticon={ help }\n\t\t\t\t\tfill={ infoIconStyle.color }\n\t\t\t\t/>\n\t\t\t</TouchableOpacity>\n\t\t);\n\t}\n\n\tonHelpButtonPressed() {\n\t\tif ( ! this.props.isSelected ) {\n\t\t\tthis.props.selectBlock();\n\t\t}\n\t\tthis.toggleSheet();\n\t}\n\n\trequestFallback() {\n\t\tif (\n\t\t\tthis.props.canEnableUnsupportedBlockEditor &&\n\t\t\tthis.props.isUnsupportedBlockEditorSupported === false\n\t\t) {\n\t\t\tthis.toggleSheet();\n\t\t\tthis.setState( { sendButtonPressMessage: true } );\n\t\t} else {\n\t\t\tthis.toggleSheet();\n\t\t\tthis.setState( { sendFallbackMessage: true } );\n\t\t}\n\t}\n\n\trenderSheet( blockTitle, blockName ) {\n\t\tconst { clientId } = this.props;\n\t\tconst { showHelp } = this.state;\n\t\t/* translators: Missing block alert title. %s: The localized block name */\n\t\tconst titleFormat = __( \"'%s' is not fully-supported\" );\n\t\tconst title = sprintf( titleFormat, blockTitle );\n\t\tconst description = applyFilters(\n\t\t\t'native.missing_block_detail',\n\t\t\t__( 'We are working hard to add more blocks with each release.' ),\n\t\t\tblockName\n\t\t);\n\n\t\treturn (\n\t\t\t<UnsupportedBlockDetails\n\t\t\t\tclientId={ clientId }\n\t\t\t\tshowSheet={ showHelp }\n\t\t\t\tonCloseSheet={ this.closeSheet }\n\t\t\t\tcustomBlockTitle={ blockTitle }\n\t\t\t\ttitle={ title }\n\t\t\t\tdescription={ description }\n\t\t\t/>\n\t\t);\n\t}\n\n\trender() {\n\t\tconst { originalName } = this.props.attributes;\n\t\tconst { getStylesFromColorScheme, preferredColorScheme } = this.props;\n\t\tconst blockType = coreBlocks[ originalName ];\n\n\t\tconst title = this.getTitle();\n\t\tconst titleStyle = getStylesFromColorScheme(\n\t\t\tstyles.unsupportedBlockMessage,\n\t\t\tstyles.unsupportedBlockMessageDark\n\t\t);\n\n\t\tconst subTitleStyle = getStylesFromColorScheme(\n\t\t\tstyles.unsupportedBlockSubtitle,\n\t\t\tstyles.unsupportedBlockSubtitleDark\n\t\t);\n\n\t\tconst subtitle = (\n\t\t\t<Text style={ subTitleStyle }>{ __( 'Unsupported' ) }</Text>\n\t\t);\n\n\t\tconst icon = blockType\n\t\t\t? normalizeIconObject( blockType.settings.icon )\n\t\t\t: plugins;\n\t\tconst iconStyle = getStylesFromColorScheme(\n\t\t\tstyles.unsupportedBlockIcon,\n\t\t\tstyles.unsupportedBlockIconDark\n\t\t);\n\t\tconst iconClassName = 'unsupported-icon' + '-' + preferredColorScheme;\n\t\treturn (\n\t\t\t<TouchableWithoutFeedback\n\t\t\t\tdisabled={ ! this.props.isSelected }\n\t\t\t\taccessibilityLabel={ __( 'Help button' ) }\n\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\taccessibilityHint={ __( 'Tap here to show help' ) }\n\t\t\t\tonPress={ this.toggleSheet }\n\t\t\t>\n\t\t\t\t<View\n\t\t\t\t\tstyle={ getStylesFromColorScheme(\n\t\t\t\t\t\tstyles.unsupportedBlock,\n\t\t\t\t\t\tstyles.unsupportedBlockDark\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ this.renderHelpIcon() }\n\t\t\t\t\t<View style={ styles.unsupportedBlockHeader }>\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\tclassName={ iconClassName }\n\t\t\t\t\t\t\ticon={ icon && icon.src ? icon.src : icon }\n\t\t\t\t\t\t\tfill={ iconStyle.color }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Text style={ titleStyle }>{ title }</Text>\n\t\t\t\t\t</View>\n\t\t\t\t\t{ subtitle }\n\t\t\t\t\t{ this.renderSheet( title, originalName ) }\n\t\t\t\t</View>\n\t\t\t</TouchableWithoutFeedback>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select, { attributes } ) => {\n\t\tconst { capabilities } = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tisUnsupportedBlockEditorSupported:\n\t\t\t\tcapabilities?.unsupportedBlockEditor === true,\n\t\t\tcanEnableUnsupportedBlockEditor:\n\t\t\t\tcapabilities?.canEnableUnsupportedBlockEditor === true,\n\t\t\tisEditableInUnsupportedBlockEditor:\n\t\t\t\t! UBE_INCOMPATIBLE_BLOCKS.includes( attributes.originalName ),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch, ownProps ) => {\n\t\tconst { selectBlock } = dispatch( blockEditorStore );\n\t\treturn {\n\t\t\tselectBlock() {\n\t\t\t\tselectBlock( ownProps.clientId );\n\t\t\t},\n\t\t};\n\t} ),\n\twithPreferredColorScheme,\n] )( UnsupportedBlockEdit );\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,IAAI,EACJC,IAAI,EACJC,wBAAwB,EACxBC,gBAAgB,QACV,cAAc;;AAErB;AACA;AACA;AACA,SAASC,IAAI,QAAQ,uBAAuB;AAC5C,SAASC,OAAO,EAAEC,wBAAwB,QAAQ,oBAAoB;AACtE,SAASC,UAAU,QAAQ,0BAA0B;AACrD,SAASC,mBAAmB,QAAQ,mBAAmB;AACvD,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACjD,SAASC,IAAI,EAAEC,OAAO,QAAQ,kBAAkB;AAChD,SAASC,UAAU,EAAEC,YAAY,QAAQ,iBAAiB;AAC1D,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SACCC,uBAAuB,EACvBC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;;AAEhC;AACA;AACA;AACA,OAAOC,MAAM,MAAM,c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E,CAAEiF,MAAM,EAAE;EAAExD;AAAW,CAAC,KAAM;EACzC,MAAM;IAAEyD;EAAa,CAAC,GAAGD,MAAM,CAAE5E,gBAAiB,CAAC,CAAC8E,WAAW,CAAC,CAAC;EACjE,OAAO;IACNjC,iCAAiC,EAChCgC,YAAY,EAAEE,sBAAsB,KAAK,IAAI;IAC9CnC,+BAA+B,EAC9BiC,YAAY,EAAEjC,+BAA+B,KAAK,IAAI;IACvDoC,kCAAkC,EACjC,CAAE9E,uBAAuB,CAAC+E,QAAQ,CAAE7D,UAAU,CAACD,YAAa;EAC9D,CAAC;AACF,CAAE,CAAC,EACHvB,YAAY,CAAE,CAAEsF,QAAQ,EAAEC,QAAQ,KAAM;EACvC,MAAM;IAAExC;EAAY,CAAC,GAAGuC,QAAQ,CAAElF,gBAAiB,CAAC;EACpD,OAAO;IACN2C,WAAWA,CAAA,EAAG;MACbA,WAAW,CAAEwC,QAAQ,CAAChC,QAAS,CAAC;IACjC;EACD,CAAC;AACF,CAAE,CAAC,EACHjE,wBAAwB,CACvB,CAAC,CAAEkB,oBAAqB,CAAC"}
1
+ {"version":3,"names":["View","Text","TouchableWithoutFeedback","TouchableOpacity","Icon","compose","withPreferredColorScheme","coreBlocks","normalizeIconObject","rawHandler","serialize","Component","__","_x","sprintf","help","plugins","withSelect","withDispatch","applyFilters","UnsupportedBlockDetails","store","blockEditorStore","noticesStore","styles","UBE_INCOMPATIBLE_BLOCKS","I18N_BLOCK_SCHEMA_TITLE","EMPTY_ARRAY","UnsupportedBlockEdit","constructor","props","state","showHelp","toggleSheet","bind","closeSheet","requestFallback","onHelpButtonPressed","setState","componentWillUnmount","timeout","clearTimeout","getTitle","originalName","attributes","blockType","title","metadata","textdomain","renderHelpIcon","infoIconStyle","getStylesFromColorScheme","infoIcon","infoIconDark","createElement","onPress","style","helpIconContainer","accessibilityLabel","accessibilityRole","accessibilityHint","className","label","icon","fill","color","isSelected","selectBlock","canEnableUnsupportedBlockEditor","isUnsupportedBlockEditorSupported","sendButtonPressMessage","sendFallbackMessage","renderSheet","blockTitle","blockName","block","clientId","createSuccessNotice","replaceBlocks","titleFormat","description","customActions","successNotice","showSheet","onCloseSheet","customBlockTitle","render","preferredColorScheme","titleStyle","unsupportedBlockMessage","unsupportedBlockMessageDark","subTitleStyle","unsupportedBlockSubtitle","unsupportedBlockSubtitleDark","subtitle","settings","iconStyle","unsupportedBlockIcon","unsupportedBlockIconDark","iconClassName","disabled","unsupportedBlock","unsupportedBlockDark","unsupportedBlockHeader","src","select","getBlock","getSettings","capabilities","unsupportedBlockEditor","isEditableInUnsupportedBlockEditor","includes","dispatch","ownProps","HTML"],"sources":["@wordpress/block-library/src/missing/edit.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tView,\n\tText,\n\tTouchableWithoutFeedback,\n\tTouchableOpacity,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Icon } from '@wordpress/components';\nimport { compose, withPreferredColorScheme } from '@wordpress/compose';\nimport { coreBlocks } from '@wordpress/block-library';\nimport { normalizeIconObject, rawHandler, serialize } from '@wordpress/blocks';\nimport { Component } from '@wordpress/element';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { help, plugins } from '@wordpress/icons';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { applyFilters } from '@wordpress/hooks';\nimport {\n\tUnsupportedBlockDetails,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\n// Blocks that can't be edited through the Unsupported block editor identified by their name.\nconst UBE_INCOMPATIBLE_BLOCKS = [ 'core/block' ];\nconst I18N_BLOCK_SCHEMA_TITLE = 'block title';\n\nconst EMPTY_ARRAY = [];\n\nexport class UnsupportedBlockEdit extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\t\tthis.state = { showHelp: false };\n\t\tthis.toggleSheet = this.toggleSheet.bind( this );\n\t\tthis.closeSheet = this.closeSheet.bind( this );\n\t\tthis.requestFallback = this.requestFallback.bind( this );\n\t\tthis.onHelpButtonPressed = this.onHelpButtonPressed.bind( this );\n\t}\n\n\ttoggleSheet() {\n\t\tthis.setState( {\n\t\t\tshowHelp: ! this.state.showHelp,\n\t\t} );\n\t}\n\n\tcloseSheet() {\n\t\tthis.setState( {\n\t\t\tshowHelp: false,\n\t\t} );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif ( this.timeout ) {\n\t\t\tclearTimeout( this.timeout );\n\t\t}\n\t}\n\n\tgetTitle() {\n\t\tconst { originalName } = this.props.attributes;\n\t\tconst blockType = coreBlocks[ originalName ];\n\t\tconst title = blockType?.metadata.title;\n\t\tconst textdomain = blockType?.metadata.textdomain;\n\n\t\treturn title && textdomain\n\t\t\t? // eslint-disable-next-line @wordpress/i18n-no-variables, @wordpress/i18n-text-domain\n\t\t\t _x( title, I18N_BLOCK_SCHEMA_TITLE, textdomain )\n\t\t\t: originalName;\n\t}\n\n\trenderHelpIcon() {\n\t\tconst infoIconStyle = this.props.getStylesFromColorScheme(\n\t\t\tstyles.infoIcon,\n\t\t\tstyles.infoIconDark\n\t\t);\n\n\t\treturn (\n\t\t\t<TouchableOpacity\n\t\t\t\tonPress={ this.onHelpButtonPressed }\n\t\t\t\tstyle={ styles.helpIconContainer }\n\t\t\t\taccessibilityLabel={ __( 'Help button' ) }\n\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\taccessibilityHint={ __( 'Tap here to show help' ) }\n\t\t\t>\n\t\t\t\t<Icon\n\t\t\t\t\tclassName=\"unsupported-icon-help\"\n\t\t\t\t\tlabel={ __( 'Help icon' ) }\n\t\t\t\t\ticon={ help }\n\t\t\t\t\tfill={ infoIconStyle.color }\n\t\t\t\t/>\n\t\t\t</TouchableOpacity>\n\t\t);\n\t}\n\n\tonHelpButtonPressed() {\n\t\tif ( ! this.props.isSelected ) {\n\t\t\tthis.props.selectBlock();\n\t\t}\n\t\tthis.toggleSheet();\n\t}\n\n\trequestFallback() {\n\t\tif (\n\t\t\tthis.props.canEnableUnsupportedBlockEditor &&\n\t\t\tthis.props.isUnsupportedBlockEditorSupported === false\n\t\t) {\n\t\t\tthis.toggleSheet();\n\t\t\tthis.setState( { sendButtonPressMessage: true } );\n\t\t} else {\n\t\t\tthis.toggleSheet();\n\t\t\tthis.setState( { sendFallbackMessage: true } );\n\t\t}\n\t}\n\n\trenderSheet( blockTitle, blockName ) {\n\t\tconst { block, clientId, createSuccessNotice, replaceBlocks } =\n\t\t\tthis.props;\n\t\tconst { showHelp } = this.state;\n\n\t\t/* translators: Missing block alert title. %s: The localized block name */\n\t\tconst titleFormat = __( \"'%s' is not fully-supported\" );\n\t\tconst title = sprintf( titleFormat, blockTitle );\n\t\tlet description = applyFilters(\n\t\t\t'native.missing_block_detail',\n\t\t\t__( 'We are working hard to add more blocks with each release.' ),\n\t\t\tblockName\n\t\t);\n\t\tlet customActions = EMPTY_ARRAY;\n\n\t\t// For Classic blocks, we offer the alternative to convert the content to blocks.\n\t\tif ( blockName === 'core/freeform' ) {\n\t\t\tdescription +=\n\t\t\t\t' ' +\n\t\t\t\t__( 'Alternatively, you can convert the content to blocks.' );\n\t\t\t/* translators: displayed right after the classic block is converted to blocks. %s: The localized classic block name */\n\t\t\tconst successNotice = __( \"'%s' block converted to blocks\" );\n\t\t\tcustomActions = [\n\t\t\t\t{\n\t\t\t\t\tlabel: __( 'Convert to blocks' ),\n\t\t\t\t\tonPress: () => {\n\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\tsprintf( successNotice, blockTitle )\n\t\t\t\t\t\t);\n\t\t\t\t\t\treplaceBlocks( block );\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn (\n\t\t\t<UnsupportedBlockDetails\n\t\t\t\tclientId={ clientId }\n\t\t\t\tshowSheet={ showHelp }\n\t\t\t\tonCloseSheet={ this.closeSheet }\n\t\t\t\tcustomBlockTitle={ blockTitle }\n\t\t\t\ttitle={ title }\n\t\t\t\tdescription={ description }\n\t\t\t\tcustomActions={ customActions }\n\t\t\t/>\n\t\t);\n\t}\n\n\trender() {\n\t\tconst { originalName } = this.props.attributes;\n\t\tconst { getStylesFromColorScheme, preferredColorScheme } = this.props;\n\t\tconst blockType = coreBlocks[ originalName ];\n\n\t\tconst title = this.getTitle();\n\t\tconst titleStyle = getStylesFromColorScheme(\n\t\t\tstyles.unsupportedBlockMessage,\n\t\t\tstyles.unsupportedBlockMessageDark\n\t\t);\n\n\t\tconst subTitleStyle = getStylesFromColorScheme(\n\t\t\tstyles.unsupportedBlockSubtitle,\n\t\t\tstyles.unsupportedBlockSubtitleDark\n\t\t);\n\n\t\tconst subtitle = (\n\t\t\t<Text style={ subTitleStyle }>{ __( 'Unsupported' ) }</Text>\n\t\t);\n\n\t\tconst icon = blockType\n\t\t\t? normalizeIconObject( blockType.settings.icon )\n\t\t\t: plugins;\n\t\tconst iconStyle = getStylesFromColorScheme(\n\t\t\tstyles.unsupportedBlockIcon,\n\t\t\tstyles.unsupportedBlockIconDark\n\t\t);\n\t\tconst iconClassName = 'unsupported-icon' + '-' + preferredColorScheme;\n\t\treturn (\n\t\t\t<TouchableWithoutFeedback\n\t\t\t\tdisabled={ ! this.props.isSelected }\n\t\t\t\taccessibilityLabel={ __( 'Help button' ) }\n\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\taccessibilityHint={ __( 'Tap here to show help' ) }\n\t\t\t\tonPress={ this.toggleSheet }\n\t\t\t>\n\t\t\t\t<View\n\t\t\t\t\tstyle={ getStylesFromColorScheme(\n\t\t\t\t\t\tstyles.unsupportedBlock,\n\t\t\t\t\t\tstyles.unsupportedBlockDark\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ this.renderHelpIcon() }\n\t\t\t\t\t<View style={ styles.unsupportedBlockHeader }>\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\tclassName={ iconClassName }\n\t\t\t\t\t\t\ticon={ icon && icon.src ? icon.src : icon }\n\t\t\t\t\t\t\tfill={ iconStyle.color }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Text style={ titleStyle }>{ title }</Text>\n\t\t\t\t\t</View>\n\t\t\t\t\t{ subtitle }\n\t\t\t\t\t{ this.renderSheet( title, originalName ) }\n\t\t\t\t</View>\n\t\t\t</TouchableWithoutFeedback>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select, { attributes, clientId } ) => {\n\t\tconst { getBlock, getSettings } = select( blockEditorStore );\n\t\tconst { capabilities } = getSettings();\n\t\treturn {\n\t\t\tisUnsupportedBlockEditorSupported:\n\t\t\t\tcapabilities?.unsupportedBlockEditor === true,\n\t\t\tcanEnableUnsupportedBlockEditor:\n\t\t\t\tcapabilities?.canEnableUnsupportedBlockEditor === true,\n\t\t\tisEditableInUnsupportedBlockEditor:\n\t\t\t\t! UBE_INCOMPATIBLE_BLOCKS.includes( attributes.originalName ),\n\t\t\tblock: getBlock( clientId ),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch, ownProps ) => {\n\t\tconst { selectBlock, replaceBlocks } = dispatch( blockEditorStore );\n\t\tconst { createSuccessNotice } = dispatch( noticesStore );\n\t\treturn {\n\t\t\tselectBlock() {\n\t\t\t\tselectBlock( ownProps.clientId );\n\t\t\t},\n\t\t\treplaceBlocks( block ) {\n\t\t\t\treplaceBlocks(\n\t\t\t\t\townProps.clientId,\n\t\t\t\t\trawHandler( { HTML: serialize( block ) } )\n\t\t\t\t);\n\t\t\t},\n\t\t\tcreateSuccessNotice,\n\t\t};\n\t} ),\n\twithPreferredColorScheme,\n] )( UnsupportedBlockEdit );\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,IAAI,EACJC,IAAI,EACJC,wBAAwB,EACxBC,gBAAgB,QACV,cAAc;;AAErB;AACA;AACA;AACA,SAASC,IAAI,QAAQ,uBAAuB;AAC5C,SAASC,OAAO,EAAEC,wBAAwB,QAAQ,oBAAoB;AACtE,SAASC,UAA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,YAAY,EAAEC,sBAAsB,KAAK,IAAI;IAC9CzC,+BAA+B,EAC9BwC,YAAY,EAAExC,+BAA+B,KAAK,IAAI;IACvD0C,kCAAkC,EACjC,CAAErF,uBAAuB,CAACsF,QAAQ,CAAEnE,UAAU,CAACD,YAAa,CAAC;IAC9DgC,KAAK,EAAE+B,QAAQ,CAAE9B,QAAS;EAC3B,CAAC;AACF,CAAE,CAAC,EACH1D,YAAY,CAAE,CAAE8F,QAAQ,EAAEC,QAAQ,KAAM;EACvC,MAAM;IAAE9C,WAAW;IAAEW;EAAc,CAAC,GAAGkC,QAAQ,CAAE1F,gBAAiB,CAAC;EACnE,MAAM;IAAEuD;EAAoB,CAAC,GAAGmC,QAAQ,CAAEzF,YAAa,CAAC;EACxD,OAAO;IACN4C,WAAWA,CAAA,EAAG;MACbA,WAAW,CAAE8C,QAAQ,CAACrC,QAAS,CAAC;IACjC,CAAC;IACDE,aAAaA,CAAEH,KAAK,EAAG;MACtBG,aAAa,CACZmC,QAAQ,CAACrC,QAAQ,EACjBnE,UAAU,CAAE;QAAEyG,IAAI,EAAExG,SAAS,CAAEiE,KAAM;MAAE,CAAE,CAC1C,CAAC;IACF,CAAC;IACDE;EACD,CAAC;AACF,CAAE,CAAC,EACHvE,wBAAwB,CACvB,CAAC,CAAEsB,oBAAqB,CAAC"}
@@ -9,7 +9,7 @@ import classnames from 'classnames';
9
9
  */
10
10
  import { __, _x, isRTL } from '@wordpress/i18n';
11
11
  import { ToolbarButton, ToggleControl, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
12
- import { AlignmentControl, BlockControls, InspectorControls, RichText, useBlockProps, useSetting } from '@wordpress/block-editor';
12
+ import { AlignmentControl, BlockControls, InspectorControls, RichText, useBlockProps, useSettings } from '@wordpress/block-editor';
13
13
  import { createBlock } from '@wordpress/blocks';
14
14
  import { formatLtr } from '@wordpress/icons';
15
15
 
@@ -49,7 +49,7 @@ function ParagraphBlock({
49
49
  dropCap,
50
50
  placeholder
51
51
  } = attributes;
52
- const isDropCapFeatureEnabled = useSetting('typography.dropCap');
52
+ const [isDropCapFeatureEnabled] = useSettings('typography.dropCap');
53
53
  const blockProps = useBlockProps({
54
54
  ref: useOnEnter({
55
55
  clientId,
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","__","_x","isRTL","ToolbarButton","ToggleControl","__experimentalToolsPanelItem","ToolsPanelItem","AlignmentControl","BlockControls","InspectorControls","RichText","useBlockProps","useSetting","createBlock","formatLtr","useOnEnter","name","ParagraphRTLControl","direction","setDirection","createElement","icon","title","isActive","onClick","undefined","hasDropCapDisabled","align","ParagraphBlock","attributes","mergeBlocks","onReplace","onRemove","setAttributes","clientId","content","dropCap","placeholder","isDropCapFeatureEnabled","blockProps","ref","className","style","helpText","Fragment","group","value","onChange","newAlign","newDirection","hasValue","label","onDeselect","resetAllFilter","panelId","__nextHasNoMarginBottom","checked","help","disabled","identifier","tagName","newContent","onSplit","isOriginal","newAttributes","block","onMerge","__unstableEmbedURLOnPaste","__unstableAllowPrefixTransformations"],"sources":["@wordpress/block-library/src/paragraph/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, isRTL } from '@wordpress/i18n';\nimport {\n\tToolbarButton,\n\tToggleControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tuseSetting,\n} from '@wordpress/block-editor';\nimport { createBlock } from '@wordpress/blocks';\nimport { formatLtr } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { useOnEnter } from './use-enter';\n\nconst name = 'core/paragraph';\n\nfunction ParagraphRTLControl( { direction, setDirection } ) {\n\treturn (\n\t\tisRTL() && (\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ formatLtr }\n\t\t\t\ttitle={ _x( 'Left to right', 'editor button' ) }\n\t\t\t\tisActive={ direction === 'ltr' }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetDirection( direction === 'ltr' ? undefined : 'ltr' );\n\t\t\t\t} }\n\t\t\t/>\n\t\t)\n\t);\n}\n\nfunction hasDropCapDisabled( align ) {\n\treturn align === ( isRTL() ? 'left' : 'right' ) || align === 'center';\n}\n\nfunction ParagraphBlock( {\n\tattributes,\n\tmergeBlocks,\n\tonReplace,\n\tonRemove,\n\tsetAttributes,\n\tclientId,\n} ) {\n\tconst { align, content, direction, dropCap, placeholder } = attributes;\n\tconst isDropCapFeatureEnabled = useSetting( 'typography.dropCap' );\n\tconst blockProps = useBlockProps( {\n\t\tref: useOnEnter( { clientId, content } ),\n\t\tclassName: classnames( {\n\t\t\t'has-drop-cap': hasDropCapDisabled( align ) ? false : dropCap,\n\t\t\t[ `has-text-align-${ align }` ]: align,\n\t\t} ),\n\t\tstyle: { direction },\n\t} );\n\n\tlet helpText;\n\tif ( hasDropCapDisabled( align ) ) {\n\t\thelpText = __( 'Not available for aligned text.' );\n\t} else if ( dropCap ) {\n\t\thelpText = __( 'Showing large initial letter.' );\n\t} else {\n\t\thelpText = __( 'Toggle to show a large initial letter.' );\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<AlignmentControl\n\t\t\t\t\tvalue={ align }\n\t\t\t\t\tonChange={ ( newAlign ) =>\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\talign: newAlign,\n\t\t\t\t\t\t\tdropCap: hasDropCapDisabled( newAlign )\n\t\t\t\t\t\t\t\t? false\n\t\t\t\t\t\t\t\t: dropCap,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<ParagraphRTLControl\n\t\t\t\t\tdirection={ direction }\n\t\t\t\t\tsetDirection={ ( newDirection ) =>\n\t\t\t\t\t\tsetAttributes( { direction: newDirection } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t{ isDropCapFeatureEnabled && (\n\t\t\t\t<InspectorControls group=\"typography\">\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! dropCap }\n\t\t\t\t\t\tlabel={ __( 'Drop cap' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { dropCap: undefined } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tresetAllFilter={ () => ( { dropCap: undefined } ) }\n\t\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Drop cap' ) }\n\t\t\t\t\t\t\tchecked={ !! dropCap }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { dropCap: ! dropCap } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\thelp={ helpText }\n\t\t\t\t\t\t\tdisabled={\n\t\t\t\t\t\t\t\thasDropCapDisabled( align ) ? true : false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t<RichText\n\t\t\t\tidentifier=\"content\"\n\t\t\t\ttagName=\"p\"\n\t\t\t\t{ ...blockProps }\n\t\t\t\tvalue={ content }\n\t\t\t\tonChange={ ( newContent ) =>\n\t\t\t\t\tsetAttributes( { content: newContent } )\n\t\t\t\t}\n\t\t\t\tonSplit={ ( value, isOriginal ) => {\n\t\t\t\t\tlet newAttributes;\n\n\t\t\t\t\tif ( isOriginal || value ) {\n\t\t\t\t\t\tnewAttributes = {\n\t\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\t\tcontent: value,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst block = createBlock( name, newAttributes );\n\n\t\t\t\t\tif ( isOriginal ) {\n\t\t\t\t\t\tblock.clientId = clientId;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn block;\n\t\t\t\t} }\n\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\tonReplace={ onReplace }\n\t\t\t\tonRemove={ onRemove }\n\t\t\t\taria-label={\n\t\t\t\t\tcontent\n\t\t\t\t\t\t? __( 'Block: Paragraph' )\n\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t'Empty block; start writing or type forward slash to choose a block'\n\t\t\t\t\t\t )\n\t\t\t\t}\n\t\t\t\tdata-empty={ content ? false : true }\n\t\t\t\tplaceholder={ placeholder || __( 'Type / to choose a block' ) }\n\t\t\t\tdata-custom-placeholder={ placeholder ? true : undefined }\n\t\t\t\t__unstableEmbedURLOnPaste\n\t\t\t\t__unstableAllowPrefixTransformations\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default ParagraphBlock;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,EAAEC,EAAE,EAAEC,KAAK,QAAQ,iBAAiB;AAC/C,SACCC,aAAa,EACbC,aAAa,EACbC,4BAA4B,IAAIC,cAAc,QACxC,uBAAuB;AAC9B,SACCC,gBAAgB,EAChBC,aAAa,EACbC,iBAAiB,EACjBC,QAAQ,EACRC,aAAa,EACbC,UAAU,QACJ,yBAAyB;AAChC,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,SAAS,QAAQ,kBAAkB;;AAE5C;AACA;AACA;AACA,SAASC,UAAU,QAAQ,aAAa;AAExC,MAAMC,IAAI,GAAG,gBAAgB;AAE7B,SAASC,mBAAmBA,CAAE;EAAEC,SAAS;EAAEC;AAAa,CAAC,EAAG;EAC3D,OACCjB,KAAK,CAAC,CAAC,IACNkB,aAAA,CAACjB,aAAa;IACbkB,IAAI,EAAGP,SAAW;IAClBQ,KAAK,EAAGrB,EAAE,CAAE,eAAe,EAAE,eAAgB,CAAG;IAChDsB,QAAQ,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AG;IAAA,GACNrB,UAAU;IACfO,KAAK,EAAGX,OAAS;IACjBY,QAAQ,EAAKc,UAAU,IACtB5B,aAAa,CAAE;MAAEE,OAAO,EAAE0B;IAAW,CAAE,CACvC;IACDC,OAAO,EAAGA,CAAEhB,KAAK,EAAEiB,UAAU,KAAM;MAClC,IAAIC,aAAa;MAEjB,IAAKD,UAAU,IAAIjB,KAAK,EAAG;QAC1BkB,aAAa,GAAG;UACf,GAAGnC,UAAU;UACbM,OAAO,EAAEW;QACV,CAAC;MACF;MAEA,MAAMmB,KAAK,GAAGpD,WAAW,CAAEG,IAAI,EAAEgD,aAAc,CAAC;MAEhD,IAAKD,UAAU,EAAG;QACjBE,KAAK,CAAC/B,QAAQ,GAAGA,QAAQ;MAC1B;MAEA,OAAO+B,KAAK;IACb,CAAG;IACHC,OAAO,EAAGpC,WAAa;IACvBC,SAAS,EAAGA,SAAW;IACvBC,QAAQ,EAAGA,QAAU;IACrB,cACCG,OAAO,GACJnC,EAAE,CAAE,kBAAmB,CAAC,GACxBA,EAAE,CACF,oEACA,CACH;IACD,cAAamC,OAAO,GAAG,KAAK,GAAG,IAAM;IACrCE,WAAW,EAAGA,WAAW,IAAIrC,EAAE,CAAE,0BAA2B,CAAG;IAC/D,2BAA0BqC,WAAW,GAAG,IAAI,GAAGZ,SAAW;IAC1D0C,yBAAyB;IACzBC,oCAAoC;EAAA,CACpC,CACA,CAAC;AAEL;AAEA,eAAexC,cAAc"}
1
+ {"version":3,"names":["classnames","__","_x","isRTL","ToolbarButton","ToggleControl","__experimentalToolsPanelItem","ToolsPanelItem","AlignmentControl","BlockControls","InspectorControls","RichText","useBlockProps","useSettings","createBlock","formatLtr","useOnEnter","name","ParagraphRTLControl","direction","setDirection","createElement","icon","title","isActive","onClick","undefined","hasDropCapDisabled","align","ParagraphBlock","attributes","mergeBlocks","onReplace","onRemove","setAttributes","clientId","content","dropCap","placeholder","isDropCapFeatureEnabled","blockProps","ref","className","style","helpText","Fragment","group","value","onChange","newAlign","newDirection","hasValue","label","onDeselect","resetAllFilter","panelId","__nextHasNoMarginBottom","checked","help","disabled","identifier","tagName","newContent","onSplit","isOriginal","newAttributes","block","onMerge","__unstableEmbedURLOnPaste","__unstableAllowPrefixTransformations"],"sources":["@wordpress/block-library/src/paragraph/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, isRTL } from '@wordpress/i18n';\nimport {\n\tToolbarButton,\n\tToggleControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tuseSettings,\n} from '@wordpress/block-editor';\nimport { createBlock } from '@wordpress/blocks';\nimport { formatLtr } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { useOnEnter } from './use-enter';\n\nconst name = 'core/paragraph';\n\nfunction ParagraphRTLControl( { direction, setDirection } ) {\n\treturn (\n\t\tisRTL() && (\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ formatLtr }\n\t\t\t\ttitle={ _x( 'Left to right', 'editor button' ) }\n\t\t\t\tisActive={ direction === 'ltr' }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetDirection( direction === 'ltr' ? undefined : 'ltr' );\n\t\t\t\t} }\n\t\t\t/>\n\t\t)\n\t);\n}\n\nfunction hasDropCapDisabled( align ) {\n\treturn align === ( isRTL() ? 'left' : 'right' ) || align === 'center';\n}\n\nfunction ParagraphBlock( {\n\tattributes,\n\tmergeBlocks,\n\tonReplace,\n\tonRemove,\n\tsetAttributes,\n\tclientId,\n} ) {\n\tconst { align, content, direction, dropCap, placeholder } = attributes;\n\tconst [ isDropCapFeatureEnabled ] = useSettings( 'typography.dropCap' );\n\tconst blockProps = useBlockProps( {\n\t\tref: useOnEnter( { clientId, content } ),\n\t\tclassName: classnames( {\n\t\t\t'has-drop-cap': hasDropCapDisabled( align ) ? false : dropCap,\n\t\t\t[ `has-text-align-${ align }` ]: align,\n\t\t} ),\n\t\tstyle: { direction },\n\t} );\n\n\tlet helpText;\n\tif ( hasDropCapDisabled( align ) ) {\n\t\thelpText = __( 'Not available for aligned text.' );\n\t} else if ( dropCap ) {\n\t\thelpText = __( 'Showing large initial letter.' );\n\t} else {\n\t\thelpText = __( 'Toggle to show a large initial letter.' );\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<AlignmentControl\n\t\t\t\t\tvalue={ align }\n\t\t\t\t\tonChange={ ( newAlign ) =>\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\talign: newAlign,\n\t\t\t\t\t\t\tdropCap: hasDropCapDisabled( newAlign )\n\t\t\t\t\t\t\t\t? false\n\t\t\t\t\t\t\t\t: dropCap,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<ParagraphRTLControl\n\t\t\t\t\tdirection={ direction }\n\t\t\t\t\tsetDirection={ ( newDirection ) =>\n\t\t\t\t\t\tsetAttributes( { direction: newDirection } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t{ isDropCapFeatureEnabled && (\n\t\t\t\t<InspectorControls group=\"typography\">\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! dropCap }\n\t\t\t\t\t\tlabel={ __( 'Drop cap' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { dropCap: undefined } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tresetAllFilter={ () => ( { dropCap: undefined } ) }\n\t\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Drop cap' ) }\n\t\t\t\t\t\t\tchecked={ !! dropCap }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { dropCap: ! dropCap } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\thelp={ helpText }\n\t\t\t\t\t\t\tdisabled={\n\t\t\t\t\t\t\t\thasDropCapDisabled( align ) ? true : false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t<RichText\n\t\t\t\tidentifier=\"content\"\n\t\t\t\ttagName=\"p\"\n\t\t\t\t{ ...blockProps }\n\t\t\t\tvalue={ content }\n\t\t\t\tonChange={ ( newContent ) =>\n\t\t\t\t\tsetAttributes( { content: newContent } )\n\t\t\t\t}\n\t\t\t\tonSplit={ ( value, isOriginal ) => {\n\t\t\t\t\tlet newAttributes;\n\n\t\t\t\t\tif ( isOriginal || value ) {\n\t\t\t\t\t\tnewAttributes = {\n\t\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\t\tcontent: value,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst block = createBlock( name, newAttributes );\n\n\t\t\t\t\tif ( isOriginal ) {\n\t\t\t\t\t\tblock.clientId = clientId;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn block;\n\t\t\t\t} }\n\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\tonReplace={ onReplace }\n\t\t\t\tonRemove={ onRemove }\n\t\t\t\taria-label={\n\t\t\t\t\tcontent\n\t\t\t\t\t\t? __( 'Block: Paragraph' )\n\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t'Empty block; start writing or type forward slash to choose a block'\n\t\t\t\t\t\t )\n\t\t\t\t}\n\t\t\t\tdata-empty={ content ? false : true }\n\t\t\t\tplaceholder={ placeholder || __( 'Type / to choose a block' ) }\n\t\t\t\tdata-custom-placeholder={ placeholder ? true : undefined }\n\t\t\t\t__unstableEmbedURLOnPaste\n\t\t\t\t__unstableAllowPrefix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OAAO+B,KAAK;IACb,CAAG;IACHC,OAAO,EAAGpC,WAAa;IACvBC,SAAS,EAAGA,SAAW;IACvBC,QAAQ,EAAGA,QAAU;IACrB,cACCG,OAAO,GACJnC,EAAE,CAAE,kBAAmB,CAAC,GACxBA,EAAE,CACF,oEACA,CACH;IACD,cAAamC,OAAO,GAAG,KAAK,GAAG,IAAM;IACrCE,WAAW,EAAGA,WAAW,IAAIrC,EAAE,CAAE,0BAA2B,CAAG;IAC/D,2BAA0BqC,WAAW,GAAG,IAAI,GAAGZ,SAAW;IAC1D0C,yBAAyB;IACzBC,oCAAoC;EAAA,CACpC,CACA,CAAC;AAEL;AAEA,eAAexC,cAAc"}
@@ -4,7 +4,7 @@ import { createElement, Fragment } from "react";
4
4
  */
5
5
  import { __, _x } from '@wordpress/i18n';
6
6
  import { SelectControl, __experimentalUnitControl as UnitControl, __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, __experimentalUseCustomUnits as useCustomUnits, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
7
- import { InspectorControls, useSetting } from '@wordpress/block-editor';
7
+ import { InspectorControls, useSettings } from '@wordpress/block-editor';
8
8
  const SCALE_OPTIONS = createElement(Fragment, null, createElement(ToggleGroupControlOption, {
9
9
  value: "cover",
10
10
  label: _x('Cover', 'Scale option for Image dimension control')
@@ -34,9 +34,9 @@ const DimensionControls = ({
34
34
  setAttributes,
35
35
  imageSizeOptions = []
36
36
  }) => {
37
- const defaultUnits = ['px', '%', 'vw', 'em', 'rem'];
37
+ const [availableUnits] = useSettings('spacing.units');
38
38
  const units = useCustomUnits({
39
- availableUnits: useSetting('spacing.units') || defaultUnits
39
+ availableUnits: availableUnits || ['px', '%', 'vw', 'em', 'rem']
40
40
  });
41
41
  const onDimensionChange = (dimension, nextValue) => {
42
42
  const parsedValue = parseFloat(nextValue);
@@ -1 +1 @@
1
- {"version":3,"names":["__","_x","SelectControl","__experimentalUnitControl","UnitControl","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOption","ToggleGroupControlOption","__experimentalUseCustomUnits","useCustomUnits","__experimentalToolsPanelItem","ToolsPanelItem","InspectorControls","useSetting","SCALE_OPTIONS","createElement","Fragment","value","label","DEFAULT_SCALE","DEFAULT_SIZE","scaleHelp","cover","contain","fill","DimensionControls","clientId","attributes","aspectRatio","width","height","scale","sizeSlug","setAttributes","imageSizeOptions","defaultUnits","units","availableUnits","onDimensionChange","dimension","nextValue","parsedValue","parseFloat","isNaN","scaleLabel","showScaleControl","group","hasValue","onDeselect","undefined","resetAllFilter","isShownByDefault","panelId","__nextHasNoMarginBottom","options","onChange","nextAspectRatio","className","labelPosition","min","nextHeight","nextWidth","help","isBlock","length","nextSizeSlug"],"sources":["@wordpress/block-library/src/post-featured-image/dimension-controls.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tSelectControl,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { InspectorControls, useSetting } from '@wordpress/block-editor';\n\nconst SCALE_OPTIONS = (\n\t<>\n\t\t<ToggleGroupControlOption\n\t\t\tvalue=\"cover\"\n\t\t\tlabel={ _x( 'Cover', 'Scale option for Image dimension control' ) }\n\t\t/>\n\t\t<ToggleGroupControlOption\n\t\t\tvalue=\"contain\"\n\t\t\tlabel={ _x(\n\t\t\t\t'Contain',\n\t\t\t\t'Scale option for Image dimension control'\n\t\t\t) }\n\t\t/>\n\t\t<ToggleGroupControlOption\n\t\t\tvalue=\"fill\"\n\t\t\tlabel={ _x( 'Fill', 'Scale option for Image dimension control' ) }\n\t\t/>\n\t</>\n);\n\nconst DEFAULT_SCALE = 'cover';\nconst DEFAULT_SIZE = 'full';\n\nconst scaleHelp = {\n\tcover: __(\n\t\t'Image is scaled and cropped to fill the entire space without being distorted.'\n\t),\n\tcontain: __(\n\t\t'Image is scaled to fill the space without clipping nor distorting.'\n\t),\n\tfill: __(\n\t\t'Image will be stretched and distorted to completely fill the space.'\n\t),\n};\n\nconst DimensionControls = ( {\n\tclientId,\n\tattributes: { aspectRatio, width, height, scale, sizeSlug },\n\tsetAttributes,\n\timageSizeOptions = [],\n} ) => {\n\tconst defaultUnits = [ 'px', '%', 'vw', 'em', 'rem' ];\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || defaultUnits,\n\t} );\n\tconst onDimensionChange = ( dimension, nextValue ) => {\n\t\tconst parsedValue = parseFloat( nextValue );\n\t\t/**\n\t\t * If we have no value set and we change the unit,\n\t\t * we don't want to set the attribute, as it would\n\t\t * end up having the unit as value without any number.\n\t\t */\n\t\tif ( isNaN( parsedValue ) && nextValue ) return;\n\t\tsetAttributes( {\n\t\t\t[ dimension ]: parsedValue < 0 ? '0' : nextValue,\n\t\t} );\n\t};\n\tconst scaleLabel = _x( 'Scale', 'Image scaling options' );\n\n\tconst showScaleControl =\n\t\theight || ( aspectRatio && aspectRatio !== 'auto' );\n\n\treturn (\n\t\t<InspectorControls group=\"dimensions\">\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! aspectRatio }\n\t\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { aspectRatio: undefined } ) }\n\t\t\t\tresetAllFilter={ () => ( {\n\t\t\t\t\taspectRatio: undefined,\n\t\t\t\t} ) }\n\t\t\t\tisShownByDefault={ true }\n\t\t\t\tpanelId={ clientId }\n\t\t\t>\n\t\t\t\t<SelectControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\t\t\tvalue={ aspectRatio }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t// These should use the same values as AspectRatioDropdown in @wordpress/block-editor\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Original' ),\n\t\t\t\t\t\t\tvalue: 'auto',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Square' ),\n\t\t\t\t\t\t\tvalue: '1',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( '16:9' ),\n\t\t\t\t\t\t\tvalue: '16/9',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( '4:3' ),\n\t\t\t\t\t\t\tvalue: '4/3',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( '3:2' ),\n\t\t\t\t\t\t\tvalue: '3/2',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( '9:16' ),\n\t\t\t\t\t\t\tvalue: '9/16',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( '3:4' ),\n\t\t\t\t\t\t\tvalue: '3/4',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( '2:3' ),\n\t\t\t\t\t\t\tvalue: '2/3',\n\t\t\t\t\t\t},\n\t\t\t\t\t] }\n\t\t\t\t\tonChange={ ( nextAspectRatio ) =>\n\t\t\t\t\t\tsetAttributes( { aspectRatio: nextAspectRatio } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\t\t\t<ToolsPanelItem\n\t\t\t\tclassName=\"single-column\"\n\t\t\t\thasValue={ () => !! height }\n\t\t\t\tlabel={ __( 'Height' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { height: undefined } ) }\n\t\t\t\tresetAllFilter={ () => ( {\n\t\t\t\t\theight: undefined,\n\t\t\t\t} ) }\n\t\t\t\tisShownByDefault={ true }\n\t\t\t\tpanelId={ clientId }\n\t\t\t>\n\t\t\t\t<UnitControl\n\t\t\t\t\tlabel={ __( 'Height' ) }\n\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\tvalue={ height || '' }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tonChange={ ( nextHeight ) =>\n\t\t\t\t\t\tonDimensionChange( 'height', nextHeight )\n\t\t\t\t\t}\n\t\t\t\t\tunits={ units }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\t\t\t<ToolsPanelItem\n\t\t\t\tclassName=\"single-column\"\n\t\t\t\thasValue={ () => !! width }\n\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { width: undefined } ) }\n\t\t\t\tresetAllFilter={ () => ( {\n\t\t\t\t\twidth: undefined,\n\t\t\t\t} ) }\n\t\t\t\tisShownByDefault={ true }\n\t\t\t\tpanelId={ clientId }\n\t\t\t>\n\t\t\t\t<UnitControl\n\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\tvalue={ width || '' }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tonChange={ ( nextWidth ) =>\n\t\t\t\t\t\tonDimensionChange( 'width', nextWidth )\n\t\t\t\t\t}\n\t\t\t\t\tunits={ units }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\t\t\t{ showScaleControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => !! scale && scale !== DEFAULT_SCALE }\n\t\t\t\t\tlabel={ scaleLabel }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tscale: DEFAULT_SCALE,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t\tresetAllFilter={ () => ( {\n\t\t\t\t\t\tscale: DEFAULT_SCALE,\n\t\t\t\t\t} ) }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ scaleLabel }\n\t\t\t\t\t\tvalue={ scale }\n\t\t\t\t\t\thelp={ scaleHelp[ scale ] }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tscale: value,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisBlock\n\t\t\t\t\t>\n\t\t\t\t\t\t{ SCALE_OPTIONS }\n\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ !! imageSizeOptions.length && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => !! sizeSlug }\n\t\t\t\t\tlabel={ __( 'Resolution' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { sizeSlug: undefined } )\n\t\t\t\t\t}\n\t\t\t\t\tresetAllFilter={ () => ( {\n\t\t\t\t\t\tsizeSlug: undefined,\n\t\t\t\t\t} ) }\n\t\t\t\t\tisShownByDefault={ false }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Resolution' ) }\n\t\t\t\t\t\tvalue={ sizeSlug || DEFAULT_SIZE }\n\t\t\t\t\t\toptions={ imageSizeOptions }\n\t\t\t\t\t\tonChange={ ( nextSizeSlug ) =>\n\t\t\t\t\t\t\tsetAttributes( { sizeSlug: nextSizeSlug } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\thelp={ __( 'Select the size of the source image.' ) }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n};\n\nexport default DimensionControls;\n"],"mappings":";AAAA;AACA;AACA;A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Aa,CAAE;MACdF,KAAK,EAAEd;IACR,CAAE,CACF;IACD8C,OAAO;EAAA,GAELjD,aACiB,CACL,CAChB,EACC,CAAC,CAAEoB,gBAAgB,CAAC8B,MAAM,IAC3BjD,aAAA,CAACJ,cAAc;IACdoC,QAAQ,EAAGA,CAAA,KAAM,CAAC,CAAEf,QAAU;IAC9Bd,KAAK,EAAGnB,EAAE,CAAE,YAAa,CAAG;IAC5BiD,UAAU,EAAGA,CAAA,KACZf,aAAa,CAAE;MAAED,QAAQ,EAAEiB;IAAU,CAAE,CACvC;IACDC,cAAc,EAAGA,CAAA,MAAQ;MACxBlB,QAAQ,EAAEiB;IACX,CAAC,CAAI;IACLE,gBAAgB,EAAG,KAAO;IAC1BC,OAAO,EAAG1B;EAAU,GAEpBX,aAAA,CAACd,aAAa;IACboD,uBAAuB;IACvBnC,KAAK,EAAGnB,EAAE,CAAE,YAAa,CAAG;IAC5BkB,KAAK,EAAGe,QAAQ,IAAIZ,YAAc;IAClCkC,OAAO,EAAGpB,gBAAkB;IAC5BqB,QAAQ,EAAKU,YAAY,IACxBhC,aAAa,CAAE;MAAED,QAAQ,EAAEiC;IAAa,CAAE,CAC1C;IACDH,IAAI,EAAG/D,EAAE,CAAE,sCAAuC;EAAG,CACrD,CACc,CAEC,CAAC;AAEtB,CAAC;AAED,eAAe0B,iBAAiB"}
1
+ {"version":3,"names":["__","_x","SelectControl","__experimentalUnitControl","UnitControl","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOption","ToggleGroupControlOption","__experimentalUseCustomUnits","useCustomUnits","__experimentalToolsPanelItem","ToolsPanelItem","InspectorControls","useSettings","SCALE_OPTIONS","createElement","Fragment","value","label","DEFAULT_SCALE","DEFAULT_SIZE","scaleHelp","cover","contain","fill","DimensionControls","clientId","attributes","aspectRatio","width","height","scale","sizeSlug","setAttributes","imageSizeOptions","availableUnits","units","onDimensionChange","dimension","nextValue","parsedValue","parseFloat","isNaN","scaleLabel","showScaleControl","group","hasValue","onDeselect","undefined","resetAllFilter","isShownByDefault","panelId","__nextHasNoMarginBottom","options","onChange","nextAspectRatio","className","labelPosition","min","nextHeight","nextWidth","help","isBlock","length","nextSizeSlug"],"sources":["@wordpress/block-library/src/post-featured-image/dimension-controls.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tSelectControl,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { InspectorControls, useSettings } from '@wordpress/block-editor';\n\nconst SCALE_OPTIONS = (\n\t<>\n\t\t<ToggleGroupControlOption\n\t\t\tvalue=\"cover\"\n\t\t\tlabel={ _x( 'Cover', 'Scale option for Image dimension control' ) }\n\t\t/>\n\t\t<ToggleGroupControlOption\n\t\t\tvalue=\"contain\"\n\t\t\tlabel={ _x(\n\t\t\t\t'Contain',\n\t\t\t\t'Scale option for Image dimension control'\n\t\t\t) }\n\t\t/>\n\t\t<ToggleGroupControlOption\n\t\t\tvalue=\"fill\"\n\t\t\tlabel={ _x( 'Fill', 'Scale option for Image dimension control' ) }\n\t\t/>\n\t</>\n);\n\nconst DEFAULT_SCALE = 'cover';\nconst DEFAULT_SIZE = 'full';\n\nconst scaleHelp = {\n\tcover: __(\n\t\t'Image is scaled and cropped to fill the entire space without being distorted.'\n\t),\n\tcontain: __(\n\t\t'Image is scaled to fill the space without clipping nor distorting.'\n\t),\n\tfill: __(\n\t\t'Image will be stretched and distorted to completely fill the space.'\n\t),\n};\n\nconst DimensionControls = ( {\n\tclientId,\n\tattributes: { aspectRatio, width, height, scale, sizeSlug },\n\tsetAttributes,\n\timageSizeOptions = [],\n} ) => {\n\tconst [ availableUnits ] = useSettings( 'spacing.units' );\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: availableUnits || [ 'px', '%', 'vw', 'em', 'rem' ],\n\t} );\n\tconst onDimensionChange = ( dimension, nextValue ) => {\n\t\tconst parsedValue = parseFloat( nextValue );\n\t\t/**\n\t\t * If we have no value set and we change the unit,\n\t\t * we don't want to set the attribute, as it would\n\t\t * end up having the unit as value without any number.\n\t\t */\n\t\tif ( isNaN( parsedValue ) && nextValue ) return;\n\t\tsetAttributes( {\n\t\t\t[ dimension ]: parsedValue < 0 ? '0' : nextValue,\n\t\t} );\n\t};\n\tconst scaleLabel = _x( 'Scale', 'Image scaling options' );\n\n\tconst showScaleControl =\n\t\theight || ( aspectRatio && aspectRatio !== 'auto' );\n\n\treturn (\n\t\t<InspectorControls group=\"dimensions\">\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! aspectRatio }\n\t\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { aspectRatio: undefined } ) }\n\t\t\t\tresetAllFilter={ () => ( {\n\t\t\t\t\taspectRatio: undefined,\n\t\t\t\t} ) }\n\t\t\t\tisShownByDefault={ true }\n\t\t\t\tpanelId={ clientId }\n\t\t\t>\n\t\t\t\t<SelectControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\t\t\tvalue={ aspectRatio }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t// These should use the same values as AspectRatioDropdown in @wordpress/block-editor\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Original' ),\n\t\t\t\t\t\t\tvalue: 'auto',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Square' ),\n\t\t\t\t\t\t\tvalue: '1',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( '16:9' ),\n\t\t\t\t\t\t\tvalue: '16/9',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( '4:3' ),\n\t\t\t\t\t\t\tvalue: '4/3',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( '3:2' ),\n\t\t\t\t\t\t\tvalue: '3/2',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( '9:16' ),\n\t\t\t\t\t\t\tvalue: '9/16',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( '3:4' ),\n\t\t\t\t\t\t\tvalue: '3/4',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( '2:3' ),\n\t\t\t\t\t\t\tvalue: '2/3',\n\t\t\t\t\t\t},\n\t\t\t\t\t] }\n\t\t\t\t\tonChange={ ( nextAspectRatio ) =>\n\t\t\t\t\t\tsetAttributes( { aspectRatio: nextAspectRatio } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\t\t\t<ToolsPanelItem\n\t\t\t\tclassName=\"single-column\"\n\t\t\t\thasValue={ () => !! height }\n\t\t\t\tlabel={ __( 'Height' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { height: undefined } ) }\n\t\t\t\tresetAllFilter={ () => ( {\n\t\t\t\t\theight: undefined,\n\t\t\t\t} ) }\n\t\t\t\tisShownByDefault={ true }\n\t\t\t\tpanelId={ clientId }\n\t\t\t>\n\t\t\t\t<UnitControl\n\t\t\t\t\tlabel={ __( 'Height' ) }\n\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\tvalue={ height || '' }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tonChange={ ( nextHeight ) =>\n\t\t\t\t\t\tonDimensionChange( 'height', nextHeight )\n\t\t\t\t\t}\n\t\t\t\t\tunits={ units }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\t\t\t<ToolsPanelItem\n\t\t\t\tclassName=\"single-column\"\n\t\t\t\thasValue={ () => !! width }\n\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\tonDeselect={ () => setAttributes( { width: undefined } ) }\n\t\t\t\tresetAllFilter={ () => ( {\n\t\t\t\t\twidth: undefined,\n\t\t\t\t} ) }\n\t\t\t\tisShownByDefault={ true }\n\t\t\t\tpanelId={ clientId }\n\t\t\t>\n\t\t\t\t<UnitControl\n\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\tvalue={ width || '' }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tonChange={ ( nextWidth ) =>\n\t\t\t\t\t\tonDimensionChange( 'width', nextWidth )\n\t\t\t\t\t}\n\t\t\t\t\tunits={ units }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\t\t\t{ showScaleControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => !! scale && scale !== DEFAULT_SCALE }\n\t\t\t\t\tlabel={ scaleLabel }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tscale: DEFAULT_SCALE,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t\tresetAllFilter={ () => ( {\n\t\t\t\t\t\tscale: DEFAULT_SCALE,\n\t\t\t\t\t} ) }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ scaleLabel }\n\t\t\t\t\t\tvalue={ scale }\n\t\t\t\t\t\thelp={ scaleHelp[ scale ] }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tscale: value,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisBlock\n\t\t\t\t\t>\n\t\t\t\t\t\t{ SCALE_OPTIONS }\n\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ !! imageSizeOptions.length && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => !! sizeSlug }\n\t\t\t\t\tlabel={ __( 'Resolution' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { sizeSlug: undefined } )\n\t\t\t\t\t}\n\t\t\t\t\tresetAllFilter={ () => ( {\n\t\t\t\t\t\tsizeSlug: undefined,\n\t\t\t\t\t} ) }\n\t\t\t\t\tisShownByDefault={ false }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Resolution' ) }\n\t\t\t\t\t\tvalue={ sizeSlug || DEFAULT_SIZE }\n\t\t\t\t\t\toptions={ imageSizeOptions }\n\t\t\t\t\t\tonChange={ ( nextSizeSlug ) =>\n\t\t\t\t\t\t\tsetAttributes( { sizeSlug: nextSizeSlug } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\thelp={ __( 'Select the size of the source image.' ) }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n};\n\nexport default DimensionControls;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACxC,SACCC,aAAa,EACbC,yBAAyB,IAAIC,WAAW,EACxCC,gCAAgC,IAAIC,kBAAkB,EACtDC,sCAAsC,IAAIC,wBAAwB,EAClEC,4BAA4B,IAAIC,cAAc,EAC9CC,4BAA4B,IAAIC,cAAc,QACxC,uBAAuB;AAC9B,SAASC,iBAAiB,EAAEC,WAAW,QAAQ,yBAAyB;AAExE,MAAMC,aAAa,GAClBC,aAAA,CAAAC,QAAA,QACCD,aAAA,CAACR,wBAAwB;EACxB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vC;IACDC,cAAc,EAAGA,CAAA,MAAQ;MACxBjB,QAAQ,EAAEgB;IACX,CAAC,CAAI;IACLE,gBAAgB,EAAG,KAAO;IAC1BC,OAAO,EAAGzB;EAAU,GAEpBX,aAAA,CAACd,aAAa;IACbmD,uBAAuB;IACvBlC,KAAK,EAAGnB,EAAE,CAAE,YAAa,CAAG;IAC5BkB,KAAK,EAAGe,QAAQ,IAAIZ,YAAc;IAClCiC,OAAO,EAAGnB,gBAAkB;IAC5BoB,QAAQ,EAAKU,YAAY,IACxB/B,aAAa,CAAE;MAAED,QAAQ,EAAEgC;IAAa,CAAE,CAC1C;IACDH,IAAI,EAAG9D,EAAE,CAAE,sCAAuC;EAAG,CACrD,CACc,CAEC,CAAC;AAEtB,CAAC;AAED,eAAe0B,iBAAiB"}
@@ -9,8 +9,7 @@ import { useState, useEffect } from '@wordpress/element';
9
9
  /**
10
10
  * Internal dependencies
11
11
  */
12
- import { useContainsThirdPartyBlocks } from '../utils';
13
- const disableEnhancedPaginationDescription = __('Plugin blocks are not supported yet. For the enhanced pagination to work, remove the plugin block, then re-enable "Enhanced pagination" in the Query Block settings.');
12
+ import { useUnsupportedBlocks } from '../utils';
14
13
  const modalDescriptionId = 'wp-block-query-enhanced-pagination-modal__description';
15
14
  export default function EnhancedPaginationModal({
16
15
  clientId,
@@ -20,31 +19,46 @@ export default function EnhancedPaginationModal({
20
19
  setAttributes
21
20
  }) {
22
21
  const [isOpen, setOpen] = useState(false);
23
- const containsThirdPartyBlocks = useContainsThirdPartyBlocks(clientId);
22
+ const {
23
+ hasBlocksFromPlugins,
24
+ hasPostContentBlock,
25
+ hasUnsupportedBlocks
26
+ } = useUnsupportedBlocks(clientId);
24
27
  useEffect(() => {
25
- setOpen(containsThirdPartyBlocks && enhancedPagination);
26
- }, [containsThirdPartyBlocks, enhancedPagination, setOpen]);
28
+ if (enhancedPagination && hasUnsupportedBlocks) {
29
+ setAttributes({
30
+ enhancedPagination: false
31
+ });
32
+ setOpen(true);
33
+ }
34
+ }, [enhancedPagination, hasUnsupportedBlocks, setAttributes]);
35
+ const closeModal = () => {
36
+ setOpen(false);
37
+ };
38
+ let notice = __('If you still want to prevent full page reloads, remove that block, then disable "Force page reload" again in the Query Block settings.');
39
+ if (hasBlocksFromPlugins) {
40
+ notice = __('Currently, avoiding full page reloads is not possible when blocks from plugins are present inside the Query block.') + ' ' + notice;
41
+ } else if (hasPostContentBlock) {
42
+ notice = __('Currently, avoiding full page reloads is not possible when a Content block is present inside the Query block.') + ' ' + notice;
43
+ }
27
44
  return isOpen && createElement(Modal, {
28
- title: __('Enhanced pagination will be disabled'),
45
+ title: __('Query block: Force page reload enabled'),
29
46
  className: "wp-block-query__enhanced-pagination-modal",
30
47
  aria: {
31
48
  describedby: modalDescriptionId
32
49
  },
50
+ role: "alertdialog",
51
+ focusOnMount: "firstElement",
33
52
  isDismissible: false,
34
- shouldCloseOnEsc: false,
35
- shouldCloseOnClickOutside: false
53
+ onRequestClose: closeModal
36
54
  }, createElement(VStack, {
37
55
  alignment: "right",
38
56
  spacing: 5
39
57
  }, createElement("span", {
40
58
  id: modalDescriptionId
41
- }, disableEnhancedPaginationDescription), createElement(Button, {
59
+ }, notice), createElement(Button, {
42
60
  variant: "primary",
43
- onClick: () => {
44
- setAttributes({
45
- enhancedPagination: false
46
- });
47
- }
61
+ onClick: closeModal
48
62
  }, __('OK'))));
49
63
  }
50
64
  //# sourceMappingURL=enhanced-pagination-modal.js.map