@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":["_interactivity","require","focusableSelectors","scrollCallback","isTouching","lastTouchTime","handleScroll","context","Date","now","window","scrollTo","core","image","scrollLeftReset","scrollTopReset","store","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":";;AAGA,IAAAA,cAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA,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,C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,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,GAAGvG,UAAU,CAAEwG,KAAK,EAAEF,IAAK,CAAC;EACpC,CAAC;AACF"}
1
+ {"version":3,"names":["_interactivity","require","focusableSelectors","scrollCallback","isTouching","lastTouchTime","handleScroll","context","Date","now","window","scrollTo","core","image","scrollLeftReset","scrollTopReset","store","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":";;AAGA,IAAAA,cAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA,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;AAEA,IAAAC,oBAAK,EACJ;EACCC,KAAK,EAAE;IACNL,IAAI,EAAE;MACLC,KAAK,EAAE;QACNK,WAAW,EAAER,MAAM,CAACS,UAAU;QAC9BC,YAAY,EAAEV,MAAM,CAACW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e;IACjCV,cAAc,GAAGC,eAAe,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"}
@@ -17,6 +17,7 @@ var _icons = require("@wordpress/icons");
17
17
  var _data = require("@wordpress/data");
18
18
  var _hooks = require("@wordpress/hooks");
19
19
  var _blockEditor = require("@wordpress/block-editor");
20
+ var _notices = require("@wordpress/notices");
20
21
  var _style = _interopRequireDefault(require("./style.scss"));
21
22
  /**
22
23
  * External dependencies
@@ -33,6 +34,7 @@ var _style = _interopRequireDefault(require("./style.scss"));
33
34
  // Blocks that can't be edited through the Unsupported block editor identified by their name.
34
35
  const UBE_INCOMPATIBLE_BLOCKS = ['core/block'];
35
36
  const I18N_BLOCK_SCHEMA_TITLE = 'block title';
37
+ const EMPTY_ARRAY = [];
36
38
  class UnsupportedBlockEdit extends _element.Component {
37
39
  constructor(props) {
38
40
  super(props);
@@ -106,22 +108,42 @@ class UnsupportedBlockEdit extends _element.Component {
106
108
  }
107
109
  renderSheet(blockTitle, blockName) {
108
110
  const {
109
- clientId
111
+ block,
112
+ clientId,
113
+ createSuccessNotice,
114
+ replaceBlocks
110
115
  } = this.props;
111
116
  const {
112
117
  showHelp
113
118
  } = this.state;
119
+
114
120
  /* translators: Missing block alert title. %s: The localized block name */
115
121
  const titleFormat = (0, _i18n.__)("'%s' is not fully-supported");
116
122
  const title = (0, _i18n.sprintf)(titleFormat, blockTitle);
117
- const description = (0, _hooks.applyFilters)('native.missing_block_detail', (0, _i18n.__)('We are working hard to add more blocks with each release.'), blockName);
123
+ let description = (0, _hooks.applyFilters)('native.missing_block_detail', (0, _i18n.__)('We are working hard to add more blocks with each release.'), blockName);
124
+ let customActions = EMPTY_ARRAY;
125
+
126
+ // For Classic blocks, we offer the alternative to convert the content to blocks.
127
+ if (blockName === 'core/freeform') {
128
+ description += ' ' + (0, _i18n.__)('Alternatively, you can convert the content to blocks.');
129
+ /* translators: displayed right after the classic block is converted to blocks. %s: The localized classic block name */
130
+ const successNotice = (0, _i18n.__)("'%s' block converted to blocks");
131
+ customActions = [{
132
+ label: (0, _i18n.__)('Convert to blocks'),
133
+ onPress: () => {
134
+ createSuccessNotice((0, _i18n.sprintf)(successNotice, blockTitle));
135
+ replaceBlocks(block);
136
+ }
137
+ }];
138
+ }
118
139
  return (0, _react.createElement)(_blockEditor.UnsupportedBlockDetails, {
119
140
  clientId: clientId,
120
141
  showSheet: showHelp,
121
142
  onCloseSheet: this.closeSheet,
122
143
  customBlockTitle: blockTitle,
123
144
  title: title,
124
- description: description
145
+ description: description,
146
+ customActions: customActions
125
147
  });
126
148
  }
127
149
  render() {
@@ -163,24 +185,40 @@ class UnsupportedBlockEdit extends _element.Component {
163
185
  }
164
186
  exports.UnsupportedBlockEdit = UnsupportedBlockEdit;
165
187
  var _default = (0, _compose.compose)([(0, _data.withSelect)((select, {
166
- attributes
188
+ attributes,
189
+ clientId
167
190
  }) => {
191
+ const {
192
+ getBlock,
193
+ getSettings
194
+ } = select(_blockEditor.store);
168
195
  const {
169
196
  capabilities
170
- } = select(_blockEditor.store).getSettings();
197
+ } = getSettings();
171
198
  return {
172
199
  isUnsupportedBlockEditorSupported: capabilities?.unsupportedBlockEditor === true,
173
200
  canEnableUnsupportedBlockEditor: capabilities?.canEnableUnsupportedBlockEditor === true,
174
- isEditableInUnsupportedBlockEditor: !UBE_INCOMPATIBLE_BLOCKS.includes(attributes.originalName)
201
+ isEditableInUnsupportedBlockEditor: !UBE_INCOMPATIBLE_BLOCKS.includes(attributes.originalName),
202
+ block: getBlock(clientId)
175
203
  };
176
204
  }), (0, _data.withDispatch)((dispatch, ownProps) => {
177
205
  const {
178
- selectBlock
206
+ selectBlock,
207
+ replaceBlocks
179
208
  } = dispatch(_blockEditor.store);
209
+ const {
210
+ createSuccessNotice
211
+ } = dispatch(_notices.store);
180
212
  return {
181
213
  selectBlock() {
182
214
  selectBlock(ownProps.clientId);
183
- }
215
+ },
216
+ replaceBlocks(block) {
217
+ replaceBlocks(ownProps.clientId, (0, _blocks.rawHandler)({
218
+ HTML: (0, _blocks.serialize)(block)
219
+ }));
220
+ },
221
+ createSuccessNotice
184
222
  };
185
223
  }), _compose.withPreferredColorScheme])(UnsupportedBlockEdit);
186
224
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_components","_compose","_blockLibrary","_blocks","_element","_i18n","_icons","_data","_hooks","_blockEditor","_style","_interopRequireDefault","UBE_INCOMPATIBLE_BLOCKS","I18N_BLOCK_SCHEMA_TITLE","UnsupportedBlockEdit","Component","constructor","props","state","showHelp","toggleSheet","bind","closeSheet","requestFallback","onHelpButtonPressed","setState","componentWillUnmount","timeout","clearTimeout","getTitle","originalName","attributes","blockType","coreBlocks","title","metadata","textdomain","_x","renderHelpIcon","infoIconStyle","getStylesFromColorScheme","styles","infoIcon","infoIconDark","_react","createElement","TouchableOpacity","onPress","style","helpIconContainer","accessibilityLabel","__","accessibilityRole","accessibilityHint","Icon","className","label","icon","help","fill","color","isSelected","selectBlock","canEnableUnsupportedBlockEditor","isUnsupportedBlockEditorSupported","sendButtonPressMessage","sendFallbackMessage","renderSheet","blockTitle","blockName","clientId","titleFormat","sprintf","description","applyFilters","UnsupportedBlockDetails","showSheet","onCloseSheet","customBlockTitle","render","preferredColorScheme","titleStyle","unsupportedBlockMessage","unsupportedBlockMessageDark","subTitleStyle","unsupportedBlockSubtitle","unsupportedBlockSubtitleDark","subtitle","Text","normalizeIconObject","settings","plugins","iconStyle","unsupportedBlockIcon","unsupportedBlockIconDark","iconClassName","TouchableWithoutFeedback","disabled","View","unsupportedBlock","unsupportedBlockDark","unsupportedBlockHeader","src","exports","_default","compose","withSelect","select","capabilities","blockEditorStore","getSettings","unsupportedBlockEditor","isEditableInUnsupportedBlockEditor","includes","withDispatch","dispatch","ownProps","withPreferredColorScheme","default"],"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":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAUA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,YAAA,GAAAV,OAAA;AAQA,IAAAW,MAAA,GAAAC,sBAAA,CAAAZ,OAAA;AA9BA;AACA;AACA;;AAQA;AACA;AACA;;AAeA;AACA;AACA;;AAGA;AACA,MAAMa,uBAAuB,GAAG,CAAE,YAAY,CAAE;AAChD,MAAMC,uBAAuB,GAAG,aAAa;AAEtC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,IAAAhB,MAAA,CAAAC,aAAA,EAAC/C,YAAA,CAAA0F,IAAI;MAACxC,KAAK,EAAGiC;IAAY,GAAG/C,KAAa,CACrC,CAAC,EACLqD,QAAQ,EACR,IAAI,CAACpB,WAAW,CAAEjC,KAAK,EAAEJ,YAAa,CACnC,CACmB,CAAC;EAE7B;AACD;AAACyE,OAAA,CAAAzF,oBAAA,GAAAA,oBAAA;AAAA,IAAA0F,QAAA,GAEc,IAAAC,gBAAO,EAAE,CACvB,IAAAC,gBAAU,EAAE,CAAEC,MAAM,EAAE;EAAE5E;AAAW,CAAC,KAAM;EACzC,MAAM;IAAE6E;EAAa,CAAC,GAAGD,MAAM,CAAEE,kBAAiB,CAAC,CAACC,WAAW,CAAC,CAAC;EACjE,OAAO;IACN9C,iCAAiC,EAChC4C,YAAY,EAAEG,sBAAsB,KAAK,IAAI;IAC9ChD,+BAA+B,EAC9B6C,YAAY,EAAE7C,+BAA+B,KAAK,IAAI;IACvDiD,kCAAkC,EACjC,CAAEpG,uBAAuB,CAACqG,QAAQ,CAAElF,UAAU,CAACD,YAAa;EAC9D,CAAC;AACF,CAAE,CAAC,EACH,IAAAoF,kBAAY,EAAE,CAAEC,QAAQ,EAAEC,QAAQ,KAAM;EACvC,MAAM;IAAEtD;EAAY,CAAC,GAAGqD,QAAQ,CAAEN,kBAAiB,CAAC;EACpD,OAAO;IACN/C,WAAWA,CAAA,EAAG;MACbA,WAAW,CAAEsD,QAAQ,CAAC9C,QAAS,CAAC;IACjC;EACD,CAAC;AACF,CAAE,CAAC,EACH+C,iCAAwB,CACvB,CAAC,CAAEvG,oBAAqB,CAAC;AAAAyF,OAAA,CAAAe,OAAA,GAAAd,QAAA"}
1
+ {"version":3,"names":["_reactNative","require","_components","_compose","_blockLibrary","_blocks","_element","_i18n","_icons","_data","_hooks","_blockEditor","_notices","_style","_interopRequireDefault","UBE_INCOMPATIBLE_BLOCKS","I18N_BLOCK_SCHEMA_TITLE","EMPTY_ARRAY","UnsupportedBlockEdit","Component","constructor","props","state","showHelp","toggleSheet","bind","closeSheet","requestFallback","onHelpButtonPressed","setState","componentWillUnmount","timeout","clearTimeout","getTitle","originalName","attributes","blockType","coreBlocks","title","metadata","textdomain","_x","renderHelpIcon","infoIconStyle","getStylesFromColorScheme","styles","infoIcon","infoIconDark","_react","createElement","TouchableOpacity","onPress","style","helpIconContainer","accessibilityLabel","__","accessibilityRole","accessibilityHint","Icon","className","label","icon","help","fill","color","isSelected","selectBlock","canEnableUnsupportedBlockEditor","isUnsupportedBlockEditorSupported","sendButtonPressMessage","sendFallbackMessage","renderSheet","blockTitle","blockName","block","clientId","createSuccessNotice","replaceBlocks","titleFormat","sprintf","description","applyFilters","customActions","successNotice","UnsupportedBlockDetails","showSheet","onCloseSheet","customBlockTitle","render","preferredColorScheme","titleStyle","unsupportedBlockMessage","unsupportedBlockMessageDark","subTitleStyle","unsupportedBlockSubtitle","unsupportedBlockSubtitleDark","subtitle","Text","normalizeIconObject","settings","plugins","iconStyle","unsupportedBlockIcon","unsupportedBlockIconDark","iconClassName","TouchableWithoutFeedback","disabled","View","unsupportedBlock","unsupportedBlockDark","unsupportedBlockHeader","src","exports","_default","compose","withSelect","select","getBlock","getSettings","blockEditorStore","capabilities","unsupportedBlockEditor","isEditableInUnsupportedBlockEditor","includes","withDispatch","dispatch","ownProps","noticesStore","rawHandler","HTML","serialize","withPreferredColorScheme","default"],"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":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAUA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,YAAA,GAAAV,OAAA;AAIA,IAAAW,QAAA,GAAAX,OAAA;AAKA,IAAAY,MAAA,GAAAC,sBAAA,CAAAb,OAAA;AA/BA;AACA;AACA;;AAQA;AACA;AACA;;AAgBA;AACA;AACA;;AAGA;AACA,MAAMc,uBAAuB,GAAG,CAAE,YAAY,CAAE;AAChD,MAAMC,uBAAuB,GAAG,aAAa;AAE7C,MAAMC,WAAW,GAAG,EAAE;AAEf,MAAMC,oBAAoB,SAASC,kBAAS,CAAC;EACnDC,WAAWA,CAAEC,KAAK,EAAG;IACpB,KAAK,CAAEA,KAAM,CAAC;IACd,IAAI,CAACC,KAAK,GAAG;MAAEC,QAAQ,EAAE;IAAM,CAAC;IAChC,IAAI,CAACC,WAAW,GAAG,IAAI,CAACA,WAAW,CAACC,IAAI,CAAE,IAAK,CAAC;IAChD,IAAI,CAACC,UAAU,GAAG,IAAI,CAACA,UAAU,CAACD,IAAI,CAAE,IAAK,CAAC;IAC9C,IAAI,CAACE,eAAe,GAAG,IAAI,C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G;MACbA,WAAW,CAAE4D,QAAQ,CAACnD,QAAS,CAAC;IACjC,CAAC;IACDE,aAAaA,CAAEH,KAAK,EAAG;MACtBG,aAAa,CACZiD,QAAQ,CAACnD,QAAQ,EACjB,IAAAqD,kBAAU,EAAE;QAAEC,IAAI,EAAE,IAAAC,iBAAS,EAAExD,KAAM;MAAE,CAAE,CAC1C,CAAC;IACF,CAAC;IACDE;EACD,CAAC;AACF,CAAE,CAAC,EACHuD,iCAAwB,CACvB,CAAC,CAAEjH,oBAAqB,CAAC;AAAA8F,OAAA,CAAAoB,OAAA,GAAAnB,QAAA"}
@@ -57,7 +57,7 @@ function ParagraphBlock({
57
57
  dropCap,
58
58
  placeholder
59
59
  } = attributes;
60
- const isDropCapFeatureEnabled = (0, _blockEditor.useSetting)('typography.dropCap');
60
+ const [isDropCapFeatureEnabled] = (0, _blockEditor.useSettings)('typography.dropCap');
61
61
  const blockProps = (0, _blockEditor.useBlockProps)({
62
62
  ref: (0, _useEnter.useOnEnter)({
63
63
  clientId,
@@ -1 +1 @@
1
- {"version":3,"names":["_classnames","_interopRequireDefault","require","_i18n","_components","_blockEditor","_blocks","_icons","_useEnter","name","ParagraphRTLControl","direction","setDirection","isRTL","_react","createElement","ToolbarButton","icon","formatLtr","title","_x","isActive","onClick","undefined","hasDropCapDisabled","align","ParagraphBlock","attributes","mergeBlocks","onReplace","onRemove","setAttributes","clientId","content","dropCap","placeholder","isDropCapFeatureEnabled","useSetting","blockProps","useBlockProps","ref","useOnEnter","className","classnames","style","helpText","__","Fragment","BlockControls","group","AlignmentControl","value","onChange","newAlign","newDirection","InspectorControls","__experimentalToolsPanelItem","hasValue","label","onDeselect","resetAllFilter","panelId","ToggleControl","__nextHasNoMarginBottom","checked","help","disabled","RichText","identifier","tagName","newContent","onSplit","isOriginal","newAttributes","block","createBlock","onMerge","__unstableEmbedURLOnPaste","__unstableAllowPrefixTransformations","_default","exports","default"],"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":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAKA,IAAAG,Y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Q,GAAGA,QAAQ;MAC1B;MAEA,OAAO0C,KAAK;IACb,CAAG;IACHE,OAAO,EAAGhD,WAAa;IACvBC,SAAS,EAAGA,SAAW;IACvBC,QAAQ,EAAGA,QAAU;IACrB,cACCG,OAAO,GACJ,IAAAa,QAAE,EAAE,kBAAmB,CAAC,GACxB,IAAAA,QAAE,EACF,oEACA,CACH;IACD,cAAab,OAAO,GAAG,KAAK,GAAG,IAAM;IACrCE,WAAW,EAAGA,WAAW,IAAI,IAAAW,QAAE,EAAE,0BAA2B,CAAG;IAC/D,2BAA0BX,WAAW,GAAG,IAAI,GAAGZ,SAAW;IAC1DsD,yBAAyB;IACzBC,oCAAoC;EAAA,CACpC,CACA,CAAC;AAEL;AAAC,IAAAC,QAAA,GAEcrD,cAAc;AAAAsD,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_classnames","_interopRequireDefault","require","_i18n","_components","_blockEditor","_blocks","_icons","_useEnter","name","ParagraphRTLControl","direction","setDirection","isRTL","_react","createElement","ToolbarButton","icon","formatLtr","title","_x","isActive","onClick","undefined","hasDropCapDisabled","align","ParagraphBlock","attributes","mergeBlocks","onReplace","onRemove","setAttributes","clientId","content","dropCap","placeholder","isDropCapFeatureEnabled","useSettings","blockProps","useBlockProps","ref","useOnEnter","className","classnames","style","helpText","__","Fragment","BlockControls","group","AlignmentControl","value","onChange","newAlign","newDirection","InspectorControls","__experimentalToolsPanelItem","hasValue","label","onDeselect","resetAllFilter","panelId","ToggleControl","__nextHasNoMarginBottom","checked","help","disabled","RichText","identifier","tagName","newContent","onSplit","isOriginal","newAttributes","block","createBlock","onMerge","__unstableEmbedURLOnPaste","__unstableAllowPrefixTransformations","_default","exports","default"],"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__unstableAllowPrefixTransformations\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default ParagraphBlock;\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAKA,IAAAG,YAAA,GAAAH,OAAA;AAQA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAKA,IAAAM,SAAA,GAAAN,OAAA;AA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W;IACvBC,QAAQ,EAAGA,QAAU;IACrB,cACCG,OAAO,GACJ,IAAAa,QAAE,EAAE,kBAAmB,CAAC,GACxB,IAAAA,QAAE,EACF,oEACA,CACH;IACD,cAAab,OAAO,GAAG,KAAK,GAAG,IAAM;IACrCE,WAAW,EAAGA,WAAW,IAAI,IAAAW,QAAE,EAAE,0BAA2B,CAAG;IAC/D,2BAA0BX,WAAW,GAAG,IAAI,GAAGZ,SAAW;IAC1DsD,yBAAyB;IACzBC,oCAAoC;EAAA,CACpC,CACA,CAAC;AAEL;AAAC,IAAAC,QAAA,GAEcrD,cAAc;AAAAsD,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -41,9 +41,9 @@ const DimensionControls = ({
41
41
  setAttributes,
42
42
  imageSizeOptions = []
43
43
  }) => {
44
- const defaultUnits = ['px', '%', 'vw', 'em', 'rem'];
44
+ const [availableUnits] = (0, _blockEditor.useSettings)('spacing.units');
45
45
  const units = (0, _components.__experimentalUseCustomUnits)({
46
- availableUnits: (0, _blockEditor.useSetting)('spacing.units') || defaultUnits
46
+ availableUnits: availableUnits || ['px', '%', 'vw', 'em', 'rem']
47
47
  });
48
48
  const onDimensionChange = (dimension, nextValue) => {
49
49
  const parsedValue = parseFloat(nextValue);
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_components","_blockEditor","SCALE_OPTIONS","_react","createElement","Fragment","__experimentalToggleGroupControlOption","value","label","_x","DEFAULT_SCALE","DEFAULT_SIZE","scaleHelp","cover","__","contain","fill","DimensionControls","clientId","attributes","aspectRatio","width","height","scale","sizeSlug","setAttributes","imageSizeOptions","defaultUnits","units","useCustomUnits","availableUnits","useSetting","onDimensionChange","dimension","nextValue","parsedValue","parseFloat","isNaN","scaleLabel","showScaleControl","InspectorControls","group","__experimentalToolsPanelItem","hasValue","onDeselect","undefined","resetAllFilter","isShownByDefault","panelId","SelectControl","__nextHasNoMarginBottom","options","onChange","nextAspectRatio","className","__experimentalUnitControl","labelPosition","min","nextHeight","nextWidth","__experimentalToggleGroupControl","help","isBlock","length","nextSizeSlug","_default","exports","default"],"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":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAQA,IAAAE,YAAA,GAAAF,OAAA;AAZA;AACA;AACA;;AAYA,MAAMG,aAAa,GAClB,IAAAC,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAE,QAAA,QACC,IAAAF,MAAA,CAAAC,aAAA,EAACJ,WAAA,CAAAM,sCAAwB;EACxBC,KAAK,EAAC,OAAO;EACbC,KAAK,EAAG,IAAAC,QAAE,EAAE,OAAO,EAAE,0CAA2C;AAAG,CACnE,CAAC,EACF,IAAAN,MAAA,CAAAC,aAAA,EAACJ,WAAA,CAAAM,sCAAwB;EACxBC,KAAK,EA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ACDuD,OAAO;EAAA,GAEL5D,aACiB,CACL,CAChB,EACC,CAAC,CAAEwB,gBAAgB,CAACqC,MAAM,IAC3B,IAAA5D,MAAA,CAAAC,aAAA,EAACJ,WAAA,CAAA0C,4BAAc;IACdC,QAAQ,EAAGA,CAAA,KAAM,CAAC,CAAEnB,QAAU;IAC9BhB,KAAK,EAAG,IAAAM,QAAE,EAAE,YAAa,CAAG;IAC5B8B,UAAU,EAAGA,CAAA,KACZnB,aAAa,CAAE;MAAED,QAAQ,EAAEqB;IAAU,CAAE,CACvC;IACDC,cAAc,EAAGA,CAAA,MAAQ;MACxBtB,QAAQ,EAAEqB;IACX,CAAC,CAAI;IACLE,gBAAgB,EAAG,KAAO;IAC1BC,OAAO,EAAG9B;EAAU,GAEpB,IAAAf,MAAA,CAAAC,aAAA,EAACJ,WAAA,CAAAiD,aAAa;IACbC,uBAAuB;IACvB1C,KAAK,EAAG,IAAAM,QAAE,EAAE,YAAa,CAAG;IAC5BP,KAAK,EAAGiB,QAAQ,IAAIb,YAAc;IAClCwC,OAAO,EAAGzB,gBAAkB;IAC5B0B,QAAQ,EAAKY,YAAY,IACxBvC,aAAa,CAAE;MAAED,QAAQ,EAAEwC;IAAa,CAAE,CAC1C;IACDH,IAAI,EAAG,IAAA/C,QAAE,EAAE,sCAAuC;EAAG,CACrD,CACc,CAEC,CAAC;AAEtB,CAAC;AAAC,IAAAmD,QAAA,GAEahD,iBAAiB;AAAAiD,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_i18n","require","_components","_blockEditor","SCALE_OPTIONS","_react","createElement","Fragment","__experimentalToggleGroupControlOption","value","label","_x","DEFAULT_SCALE","DEFAULT_SIZE","scaleHelp","cover","__","contain","fill","DimensionControls","clientId","attributes","aspectRatio","width","height","scale","sizeSlug","setAttributes","imageSizeOptions","availableUnits","useSettings","units","useCustomUnits","onDimensionChange","dimension","nextValue","parsedValue","parseFloat","isNaN","scaleLabel","showScaleControl","InspectorControls","group","__experimentalToolsPanelItem","hasValue","onDeselect","undefined","resetAllFilter","isShownByDefault","panelId","SelectControl","__nextHasNoMarginBottom","options","onChange","nextAspectRatio","className","__experimentalUnitControl","labelPosition","min","nextHeight","nextWidth","__experimentalToggleGroupControl","help","isBlock","length","nextSizeSlug","_default","exports","default"],"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":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAQA,IAAAE,YAAA,GAAAF,OAAA;AAZA;AACA;AACA;;AAYA,MAAMG,aAAa,GAClB,IAAAC,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAE,QAAA,QACC,IAAAF,MAAA,CAAAC,aAAA,EAACJ,WAAA,CAAAM,sCAAwB;EACxBC,KAAK,EAAC,OAAO;EACbC,KAAK,EAAG,IA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O;IACfqC,IAAI,EAAGhD,SAAS,CAAEW,KAAK,CAAI;IAC3B4B,QAAQ,EAAK5C,KAAK,IACjBkB,aAAa,CAAE;MACdF,KAAK,EAAEhB;IACR,CAAE,CACF;IACDsD,OAAO;EAAA,GAEL3D,aACiB,CACL,CAChB,EACC,CAAC,CAAEwB,gBAAgB,CAACoC,MAAM,IAC3B,IAAA3D,MAAA,CAAAC,aAAA,EAACJ,WAAA,CAAAyC,4BAAc;IACdC,QAAQ,EAAGA,CAAA,KAAM,CAAC,CAAElB,QAAU;IAC9BhB,KAAK,EAAG,IAAAM,QAAE,EAAE,YAAa,CAAG;IAC5B6B,UAAU,EAAGA,CAAA,KACZlB,aAAa,CAAE;MAAED,QAAQ,EAAEoB;IAAU,CAAE,CACvC;IACDC,cAAc,EAAGA,CAAA,MAAQ;MACxBrB,QAAQ,EAAEoB;IACX,CAAC,CAAI;IACLE,gBAAgB,EAAG,KAAO;IAC1BC,OAAO,EAAG7B;EAAU,GAEpB,IAAAf,MAAA,CAAAC,aAAA,EAACJ,WAAA,CAAAgD,aAAa;IACbC,uBAAuB;IACvBzC,KAAK,EAAG,IAAAM,QAAE,EAAE,YAAa,CAAG;IAC5BP,KAAK,EAAGiB,QAAQ,IAAIb,YAAc;IAClCuC,OAAO,EAAGxB,gBAAkB;IAC5ByB,QAAQ,EAAKY,YAAY,IACxBtC,aAAa,CAAE;MAAED,QAAQ,EAAEuC;IAAa,CAAE,CAC1C;IACDH,IAAI,EAAG,IAAA9C,QAAE,EAAE,sCAAuC;EAAG,CACrD,CACc,CAEC,CAAC;AAEtB,CAAC;AAAC,IAAAkD,QAAA,GAEa/C,iBAAiB;AAAAgD,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -17,7 +17,6 @@ var _utils = require("../utils");
17
17
  * Internal dependencies
18
18
  */
19
19
 
20
- const disableEnhancedPaginationDescription = (0, _i18n.__)('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.');
21
20
  const modalDescriptionId = 'wp-block-query-enhanced-pagination-modal__description';
22
21
  function EnhancedPaginationModal({
23
22
  clientId,
@@ -27,31 +26,46 @@ function EnhancedPaginationModal({
27
26
  setAttributes
28
27
  }) {
29
28
  const [isOpen, setOpen] = (0, _element.useState)(false);
30
- const containsThirdPartyBlocks = (0, _utils.useContainsThirdPartyBlocks)(clientId);
29
+ const {
30
+ hasBlocksFromPlugins,
31
+ hasPostContentBlock,
32
+ hasUnsupportedBlocks
33
+ } = (0, _utils.useUnsupportedBlocks)(clientId);
31
34
  (0, _element.useEffect)(() => {
32
- setOpen(containsThirdPartyBlocks && enhancedPagination);
33
- }, [containsThirdPartyBlocks, enhancedPagination, setOpen]);
35
+ if (enhancedPagination && hasUnsupportedBlocks) {
36
+ setAttributes({
37
+ enhancedPagination: false
38
+ });
39
+ setOpen(true);
40
+ }
41
+ }, [enhancedPagination, hasUnsupportedBlocks, setAttributes]);
42
+ const closeModal = () => {
43
+ setOpen(false);
44
+ };
45
+ let notice = (0, _i18n.__)('If you still want to prevent full page reloads, remove that block, then disable "Force page reload" again in the Query Block settings.');
46
+ if (hasBlocksFromPlugins) {
47
+ notice = (0, _i18n.__)('Currently, avoiding full page reloads is not possible when blocks from plugins are present inside the Query block.') + ' ' + notice;
48
+ } else if (hasPostContentBlock) {
49
+ notice = (0, _i18n.__)('Currently, avoiding full page reloads is not possible when a Content block is present inside the Query block.') + ' ' + notice;
50
+ }
34
51
  return isOpen && (0, _react.createElement)(_components.Modal, {
35
- title: (0, _i18n.__)('Enhanced pagination will be disabled'),
52
+ title: (0, _i18n.__)('Query block: Force page reload enabled'),
36
53
  className: "wp-block-query__enhanced-pagination-modal",
37
54
  aria: {
38
55
  describedby: modalDescriptionId
39
56
  },
57
+ role: "alertdialog",
58
+ focusOnMount: "firstElement",
40
59
  isDismissible: false,
41
- shouldCloseOnEsc: false,
42
- shouldCloseOnClickOutside: false
60
+ onRequestClose: closeModal
43
61
  }, (0, _react.createElement)(_components.__experimentalVStack, {
44
62
  alignment: "right",
45
63
  spacing: 5
46
64
  }, (0, _react.createElement)("span", {
47
65
  id: modalDescriptionId
48
- }, disableEnhancedPaginationDescription), (0, _react.createElement)(_components.Button, {
66
+ }, notice), (0, _react.createElement)(_components.Button, {
49
67
  variant: "primary",
50
- onClick: () => {
51
- setAttributes({
52
- enhancedPagination: false
53
- });
54
- }
68
+ onClick: closeModal
55
69
  }, (0, _i18n.__)('OK'))));
56
70
  }
57
71
  //# sourceMappingURL=enhanced-pagination-modal.js.map