@wordpress/block-editor 9.0.0 → 9.1.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 (235) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +1 -0
  3. package/build/components/block-alignment-matrix-control/index.js +1 -6
  4. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  5. package/build/components/block-content-overlay/index.js +4 -82
  6. package/build/components/block-content-overlay/index.js.map +1 -1
  7. package/build/components/block-draggable/draggable-chip.native.js +64 -0
  8. package/build/components/block-draggable/draggable-chip.native.js.map +1 -0
  9. package/build/components/block-draggable/dropping-insertion-point.native.js +157 -0
  10. package/build/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
  11. package/build/components/block-draggable/index.native.js +484 -0
  12. package/build/components/block-draggable/index.native.js.map +1 -0
  13. package/build/components/block-draggable/use-scroll-when-dragging.native.js +130 -0
  14. package/build/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
  15. package/build/components/block-list/block-list-context.native.js +195 -0
  16. package/build/components/block-list/block-list-context.native.js.map +1 -0
  17. package/build/components/block-list/block-list-item-cell.native.js +67 -0
  18. package/build/components/block-list/block-list-item-cell.native.js.map +1 -0
  19. package/build/components/block-list/block-list-item.native.js +12 -9
  20. package/build/components/block-list/block-list-item.native.js.map +1 -1
  21. package/build/components/block-list/block.native.js +26 -5
  22. package/build/components/block-list/block.native.js.map +1 -1
  23. package/build/components/block-list/index.native.js +75 -23
  24. package/build/components/block-list/index.native.js.map +1 -1
  25. package/build/components/block-list/use-block-props/index.js +8 -4
  26. package/build/components/block-list/use-block-props/index.js.map +1 -1
  27. package/build/components/block-list/use-in-between-inserter.js +1 -1
  28. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  29. package/build/components/block-mobile-toolbar/index.native.js +9 -3
  30. package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
  31. package/build/components/block-mover/index.native.js +17 -4
  32. package/build/components/block-mover/index.native.js.map +1 -1
  33. package/build/components/block-popover/inbetween.js +10 -2
  34. package/build/components/block-popover/inbetween.js.map +1 -1
  35. package/build/components/block-popover/index.js +4 -16
  36. package/build/components/block-popover/index.js.map +1 -1
  37. package/build/components/block-preview/index.js +1 -1
  38. package/build/components/block-preview/index.js.map +1 -1
  39. package/build/components/block-tools/selected-block-popover.js +1 -29
  40. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  41. package/build/components/border-radius-control/input-controls.js +10 -3
  42. package/build/components/border-radius-control/input-controls.js.map +1 -1
  43. package/build/components/colors-gradients/dropdown.js +149 -44
  44. package/build/components/colors-gradients/dropdown.js.map +1 -1
  45. package/build/components/iframe/index.js +51 -50
  46. package/build/components/iframe/index.js.map +1 -1
  47. package/build/components/image-editor/use-save-image.js +3 -1
  48. package/build/components/image-editor/use-save-image.js.map +1 -1
  49. package/build/components/index.js +5 -14
  50. package/build/components/index.js.map +1 -1
  51. package/build/components/inserter/index.native.js +1 -1
  52. package/build/components/inserter/index.native.js.map +1 -1
  53. package/build/components/link-control/constants.js +11 -1
  54. package/build/components/link-control/constants.js.map +1 -1
  55. package/build/components/link-control/search-results.js +4 -3
  56. package/build/components/link-control/search-results.js.map +1 -1
  57. package/build/components/link-control/use-search-handler.js +4 -4
  58. package/build/components/link-control/use-search-handler.js.map +1 -1
  59. package/build/components/list-view/drop-indicator.js +0 -1
  60. package/build/components/list-view/drop-indicator.js.map +1 -1
  61. package/build/components/navigable-toolbar/index.js +12 -2
  62. package/build/components/navigable-toolbar/index.js.map +1 -1
  63. package/build/components/rich-text/format-toolbar-container.js +0 -1
  64. package/build/components/rich-text/format-toolbar-container.js.map +1 -1
  65. package/build/components/rich-text/index.js +1 -1
  66. package/build/components/rich-text/index.js.map +1 -1
  67. package/build/components/url-input/index.js +4 -1
  68. package/build/components/url-input/index.js.map +1 -1
  69. package/build/components/use-block-drop-zone/index.native.js +167 -0
  70. package/build/components/use-block-drop-zone/index.native.js.map +1 -0
  71. package/build/components/use-on-block-drop/index.native.js +95 -0
  72. package/build/components/use-on-block-drop/index.native.js.map +1 -0
  73. package/build/components/warning/index.js +6 -1
  74. package/build/components/warning/index.js.map +1 -1
  75. package/build/hooks/anchor.js.map +1 -1
  76. package/build/hooks/border.js +2 -7
  77. package/build/hooks/border.js.map +1 -1
  78. package/build/hooks/color-panel.js +14 -7
  79. package/build/hooks/color-panel.js.map +1 -1
  80. package/build/hooks/style.js +14 -13
  81. package/build/hooks/style.js.map +1 -1
  82. package/build/hooks/typography.js +6 -2
  83. package/build/hooks/typography.js.map +1 -1
  84. package/build-module/components/block-alignment-matrix-control/index.js +1 -6
  85. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  86. package/build-module/components/block-content-overlay/index.js +3 -78
  87. package/build-module/components/block-content-overlay/index.js.map +1 -1
  88. package/build-module/components/block-draggable/draggable-chip.native.js +50 -0
  89. package/build-module/components/block-draggable/draggable-chip.native.js.map +1 -0
  90. package/build-module/components/block-draggable/dropping-insertion-point.native.js +137 -0
  91. package/build-module/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
  92. package/build-module/components/block-draggable/index.native.js +449 -0
  93. package/build-module/components/block-draggable/index.native.js.map +1 -0
  94. package/build-module/components/block-draggable/use-scroll-when-dragging.native.js +120 -0
  95. package/build-module/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
  96. package/build-module/components/block-list/block-list-context.native.js +179 -0
  97. package/build-module/components/block-list/block-list-context.native.js.map +1 -0
  98. package/build-module/components/block-list/block-list-item-cell.native.js +59 -0
  99. package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -0
  100. package/build-module/components/block-list/block-list-item.native.js +12 -9
  101. package/build-module/components/block-list/block-list-item.native.js.map +1 -1
  102. package/build-module/components/block-list/block.native.js +25 -5
  103. package/build-module/components/block-list/block.native.js.map +1 -1
  104. package/build-module/components/block-list/index.native.js +72 -23
  105. package/build-module/components/block-list/index.native.js.map +1 -1
  106. package/build-module/components/block-list/use-block-props/index.js +9 -5
  107. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  108. package/build-module/components/block-list/use-in-between-inserter.js +1 -1
  109. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  110. package/build-module/components/block-mobile-toolbar/index.native.js +8 -3
  111. package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
  112. package/build-module/components/block-mover/index.native.js +18 -5
  113. package/build-module/components/block-mover/index.native.js.map +1 -1
  114. package/build-module/components/block-popover/inbetween.js +10 -2
  115. package/build-module/components/block-popover/inbetween.js.map +1 -1
  116. package/build-module/components/block-popover/index.js +4 -15
  117. package/build-module/components/block-popover/index.js.map +1 -1
  118. package/build-module/components/block-preview/index.js +1 -1
  119. package/build-module/components/block-preview/index.js.map +1 -1
  120. package/build-module/components/block-tools/selected-block-popover.js +2 -29
  121. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  122. package/build-module/components/border-radius-control/input-controls.js +11 -4
  123. package/build-module/components/border-radius-control/input-controls.js.map +1 -1
  124. package/build-module/components/colors-gradients/dropdown.js +151 -46
  125. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  126. package/build-module/components/iframe/index.js +52 -51
  127. package/build-module/components/iframe/index.js.map +1 -1
  128. package/build-module/components/image-editor/use-save-image.js +2 -1
  129. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  130. package/build-module/components/index.js +1 -2
  131. package/build-module/components/index.js.map +1 -1
  132. package/build-module/components/inserter/index.native.js +1 -1
  133. package/build-module/components/inserter/index.native.js.map +1 -1
  134. package/build-module/components/link-control/constants.js +5 -0
  135. package/build-module/components/link-control/constants.js.map +1 -1
  136. package/build-module/components/link-control/search-results.js +3 -4
  137. package/build-module/components/link-control/search-results.js.map +1 -1
  138. package/build-module/components/link-control/use-search-handler.js +5 -5
  139. package/build-module/components/link-control/use-search-handler.js.map +1 -1
  140. package/build-module/components/list-view/drop-indicator.js +0 -1
  141. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  142. package/build-module/components/navigable-toolbar/index.js +12 -2
  143. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  144. package/build-module/components/rich-text/format-toolbar-container.js +0 -1
  145. package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
  146. package/build-module/components/rich-text/index.js +1 -1
  147. package/build-module/components/rich-text/index.js.map +1 -1
  148. package/build-module/components/url-input/index.js +4 -1
  149. package/build-module/components/url-input/index.js.map +1 -1
  150. package/build-module/components/use-block-drop-zone/index.native.js +148 -0
  151. package/build-module/components/use-block-drop-zone/index.native.js.map +1 -0
  152. package/build-module/components/use-on-block-drop/index.native.js +83 -0
  153. package/build-module/components/use-on-block-drop/index.native.js.map +1 -0
  154. package/build-module/components/warning/index.js +6 -1
  155. package/build-module/components/warning/index.js.map +1 -1
  156. package/build-module/hooks/anchor.js.map +1 -1
  157. package/build-module/hooks/border.js +2 -7
  158. package/build-module/hooks/border.js.map +1 -1
  159. package/build-module/hooks/color-panel.js +11 -6
  160. package/build-module/hooks/color-panel.js.map +1 -1
  161. package/build-module/hooks/style.js +15 -14
  162. package/build-module/hooks/style.js.map +1 -1
  163. package/build-module/hooks/typography.js +6 -2
  164. package/build-module/hooks/typography.js.map +1 -1
  165. package/build-style/style-rtl.css +60 -174
  166. package/build-style/style.css +60 -174
  167. package/package.json +28 -28
  168. package/src/components/block-alignment-matrix-control/index.js +1 -5
  169. package/src/components/block-content-overlay/index.js +8 -95
  170. package/src/components/block-content-overlay/style.scss +2 -11
  171. package/src/components/block-draggable/draggable-chip.native.js +49 -0
  172. package/src/components/block-draggable/dropping-insertion-point.native.js +181 -0
  173. package/src/components/block-draggable/dropping-insertion-point.native.scss +8 -0
  174. package/src/components/block-draggable/index.native.js +458 -0
  175. package/src/components/block-draggable/style.native.scss +19 -0
  176. package/src/components/block-draggable/use-scroll-when-dragging.native.js +135 -0
  177. package/src/components/block-list/block-list-context.native.js +175 -0
  178. package/src/components/block-list/block-list-item-cell.native.js +49 -0
  179. package/src/components/block-list/block-list-item.native.js +7 -11
  180. package/src/components/block-list/block.native.js +36 -8
  181. package/src/components/block-list/index.native.js +54 -13
  182. package/src/components/block-list/test/block-list-context.native.js +253 -0
  183. package/src/components/block-list/test/fixtures/block-list-context.native.js +79 -0
  184. package/src/components/block-list/use-block-props/index.js +10 -5
  185. package/src/components/block-list/use-in-between-inserter.js +1 -1
  186. package/src/components/block-mobile-toolbar/index.native.js +8 -1
  187. package/src/components/block-mover/index.native.js +22 -6
  188. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +6 -0
  189. package/src/components/block-popover/inbetween.js +9 -1
  190. package/src/components/block-popover/index.js +1 -16
  191. package/src/components/block-popover/style.scss +1 -0
  192. package/src/components/block-preview/index.js +1 -4
  193. package/src/components/block-switcher/style.scss +2 -39
  194. package/src/components/block-tools/selected-block-popover.js +1 -36
  195. package/src/components/block-tools/style.scss +1 -12
  196. package/src/components/border-radius-control/input-controls.js +16 -8
  197. package/src/components/border-radius-control/style.scss +3 -2
  198. package/src/components/colors-gradients/dropdown.js +156 -62
  199. package/src/components/colors-gradients/style.scss +51 -23
  200. package/src/components/duotone-control/style.scss +1 -7
  201. package/src/components/iframe/index.js +62 -54
  202. package/src/components/image-editor/use-save-image.js +2 -1
  203. package/src/components/index.js +1 -2
  204. package/src/components/inserter/index.native.js +1 -1
  205. package/src/components/inserter/style.scss +2 -1
  206. package/src/components/link-control/constants.js +11 -0
  207. package/src/components/link-control/search-results.js +4 -5
  208. package/src/components/link-control/use-search-handler.js +11 -5
  209. package/src/components/list-view/drop-indicator.js +0 -1
  210. package/src/components/list-view/style.scss +2 -1
  211. package/src/components/navigable-toolbar/index.js +12 -2
  212. package/src/components/preview-options/style.scss +0 -4
  213. package/src/components/rich-text/format-toolbar-container.js +0 -1
  214. package/src/components/rich-text/index.js +1 -1
  215. package/src/components/rich-text/style.scss +2 -8
  216. package/src/components/url-input/index.js +3 -1
  217. package/src/components/use-block-drop-zone/index.native.js +173 -0
  218. package/src/components/use-on-block-drop/index.native.js +119 -0
  219. package/src/components/warning/index.js +47 -42
  220. package/src/components/warning/test/__snapshots__/index.js.snap +15 -6
  221. package/src/components/warning/test/index.js +1 -1
  222. package/src/hooks/anchor.js +1 -1
  223. package/src/hooks/border.js +2 -11
  224. package/src/hooks/border.scss +0 -48
  225. package/src/hooks/color-panel.js +13 -9
  226. package/src/hooks/color.scss +0 -62
  227. package/src/hooks/style.js +25 -39
  228. package/src/hooks/typography.js +2 -0
  229. package/src/style.scss +0 -1
  230. package/build/components/colors-gradients/tools-panel-color-dropdown.js +0 -89
  231. package/build/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
  232. package/build-module/components/colors-gradients/tools-panel-color-dropdown.js +0 -75
  233. package/build-module/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
  234. package/src/components/block-alignment-matrix-control/style.scss +0 -10
  235. package/src/components/colors-gradients/tools-panel-color-dropdown.js +0 -85
@@ -274,6 +274,8 @@ class URLInput extends _element.Component {
274
274
 
275
275
  case _keycodes.ENTER:
276
276
  {
277
+ event.preventDefault();
278
+
277
279
  if (this.props.onSubmit) {
278
280
  this.props.onSubmit(null, event);
279
281
  }
@@ -321,6 +323,8 @@ class URLInput extends _element.Component {
321
323
 
322
324
  case _keycodes.ENTER:
323
325
  {
326
+ event.preventDefault();
327
+
324
328
  if (this.state.selectedSuggestion !== null) {
325
329
  this.selectLink(suggestion);
326
330
 
@@ -481,7 +485,6 @@ class URLInput extends _element.Component {
481
485
  if (!(0, _lodash.isFunction)(renderSuggestions) && showSuggestions && !!suggestions.length) {
482
486
  return (0, _element.createElement)(_components.Popover, {
483
487
  position: "bottom",
484
- noArrow: true,
485
488
  focusOnMount: false
486
489
  }, (0, _element.createElement)("div", (0, _extends2.default)({}, suggestionsListProps, {
487
490
  className: (0, _classnames.default)('block-editor-url-input__suggestions', `${className}__suggestions`)
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/url-input/index.js"],"names":["URLInput","Component","constructor","props","onChange","bind","onFocus","onKeyDown","selectLink","handleOnClick","bindSuggestionNode","autocompleteRef","inputRef","updateSuggestions","suggestionNodes","isUpdatingSuggestions","state","suggestions","showSuggestions","selectedSuggestion","suggestionsListboxId","suggestionOptionIdPrefix","componentDidUpdate","prevProps","value","__experimentalShowInitialSuggestions","scrollingIntoView","current","onlyScrollIfNeeded","setTimeout","disableSuggestions","length","componentDidMount","shouldShowInitialSuggestions","componentWillUnmount","suggestionsRequest","cancel","index","ref","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalHandleURLSuggestions","handleURLSuggestions","isInitialSuggestions","trim","setState","loading","request","then","debouncedSpeak","catch","event","inputValue","target","keyCode","UP","selectionStart","preventDefault","setSelectionRange","DOWN","ENTER","onSubmit","suggestion","previousIndex","nextIndex","TAB","speak","url","focus","getDerivedStateFromProps","instanceId","shouldShowSuggestions","hasValue","render","renderControl","renderSuggestions","label","className","isFullWidth","placeholder","__experimentalRenderControl","inputId","controlProps","id","inputProps","required","type","role","undefined","__experimentalRenderSuggestions","suggestionsListProps","buildSuggestionItemProps","tabIndex","isLoading","handleSuggestionClick","map","title","withSafeTimeout","withSpokenMessages","withInstanceId","select","getSettings","blockEditorStore"],"mappings":";;;;;;;;;AAWA;;;;AARA;;AACA;;AACA;;AAKA;;AAEA;;AACA;;AAOA;;AACA;;AACA;;AAKA;;AA3BA;AACA;AACA;;AAKA;AACA;AACA;;AAeA;AACA;AACA;AAGA,MAAMA,QAAN,SAAuBC,kBAAvB,CAAiC;AAChCC,EAAAA,WAAW,CAAEC,KAAF,EAAU;AACpB,UAAOA,KAAP;AAEA,SAAKC,QAAL,GAAgB,KAAKA,QAAL,CAAcC,IAAd,CAAoB,IAApB,CAAhB;AACA,SAAKC,OAAL,GAAe,KAAKA,OAAL,CAAaD,IAAb,CAAmB,IAAnB,CAAf;AACA,SAAKE,SAAL,GAAiB,KAAKA,SAAL,CAAeF,IAAf,CAAqB,IAArB,CAAjB;AACA,SAAKG,UAAL,GAAkB,KAAKA,UAAL,CAAgBH,IAAhB,CA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EAEV,GAAGb,SAAW,eAFJ;AAFb,UAOG5D,WAAW,CAAC8E,GAAZ,CAAiB,CAAEjC,UAAF,EAAczB,KAAd,KAClB,4BAAC,kBAAD,6BACMsD,wBAAwB,CAC5B7B,UAD4B,EAE5BzB,KAF4B,CAD9B;AAKC,QAAA,GAAG,EAAGyB,UAAU,CAACqB,EALlB;AAMC,QAAA,SAAS,EAAG,yBACX,oCADW,EAEX;AACC,yBACC9C,KAAK,KAAKlB;AAFZ,SAFW,CANb;AAaC,QAAA,OAAO,EAAG,MACT,KAAKV,aAAL,CAAoBqD,UAApB;AAdF,UAiBGA,UAAU,CAACkC,KAjBd,CADC,CAPH,CADD,CADD;AAiCA;;AACD,WAAO,IAAP;AACA;;AA/hB+B;AAkiBjC;AACA;AACA;;;eACe,sBACdC,wBADc,EAEdC,8BAFc,EAGdC,uBAHc,EAId,sBAAY,CAAEC,MAAF,EAAUjG,KAAV,KAAqB;AAChC;AACA;AACA,MAAK,wBAAYA,KAAK,CAACoC,kCAAlB,CAAL,EAA8D;AAC7D;AACA;;AACD,QAAM;AAAE8D,IAAAA;AAAF,MAAkBD,MAAM,CAAEE,YAAF,CAA9B;AACA,SAAO;AACN/D,IAAAA,kCAAkC,EAAE8D,WAAW,GAC7C9D;AAFI,GAAP;AAIA,CAXD,CAJc,EAgBZvC,QAhBY,C","sourcesContent":["/**\n * External dependencies\n */\nimport { debounce, isFunction } from 'lodash';\nimport classnames from 'classnames';\nimport scrollIntoView from 'dom-scroll-into-view';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport { Component, createRef } from '@wordpress/element';\nimport { UP, DOWN, ENTER, TAB } from '@wordpress/keycodes';\nimport {\n\tBaseControl,\n\tButton,\n\tSpinner,\n\twithSpokenMessages,\n\tPopover,\n} from '@wordpress/components';\nimport { withInstanceId, withSafeTimeout, compose } from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nclass URLInput extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\n\t\tthis.onChange = this.onChange.bind( this );\n\t\tthis.onFocus = this.onFocus.bind( this );\n\t\tthis.onKeyDown = this.onKeyDown.bind( this );\n\t\tthis.selectLink = this.selectLink.bind( this );\n\t\tthis.handleOnClick = this.handleOnClick.bind( this );\n\t\tthis.bindSuggestionNode = this.bindSuggestionNode.bind( this );\n\t\tthis.autocompleteRef = props.autocompleteRef || createRef();\n\t\tthis.inputRef = createRef();\n\t\tthis.updateSuggestions = debounce(\n\t\t\tthis.updateSuggestions.bind( this ),\n\t\t\t200\n\t\t);\n\n\t\tthis.suggestionNodes = [];\n\n\t\tthis.isUpdatingSuggestions = false;\n\n\t\tthis.state = {\n\t\t\tsuggestions: [],\n\t\t\tshowSuggestions: false,\n\t\t\tselectedSuggestion: null,\n\n\t\t\tsuggestionsListboxId: '',\n\t\t\tsuggestionOptionIdPrefix: '',\n\t\t};\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tconst { showSuggestions, selectedSuggestion } = this.state;\n\t\tconst {\n\t\t\tvalue,\n\t\t\t__experimentalShowInitialSuggestions = false,\n\t\t} = this.props;\n\n\t\t// Only have to worry about scrolling selected suggestion into view\n\t\t// when already expanded.\n\t\tif (\n\t\t\tshowSuggestions &&\n\t\t\tselectedSuggestion !== null &&\n\t\t\tthis.suggestionNodes[ selectedSuggestion ] &&\n\t\t\t! this.scrollingIntoView\n\t\t) {\n\t\t\tthis.scrollingIntoView = true;\n\t\t\tscrollIntoView(\n\t\t\t\tthis.suggestionNodes[ selectedSuggestion ],\n\t\t\t\tthis.autocompleteRef.current,\n\t\t\t\t{\n\t\t\t\t\tonlyScrollIfNeeded: true,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tthis.props.setTimeout( () => {\n\t\t\t\tthis.scrollingIntoView = false;\n\t\t\t}, 100 );\n\t\t}\n\n\t\t// Update suggestions when the value changes.\n\t\tif (\n\t\t\tprevProps.value !== value &&\n\t\t\t! this.props.disableSuggestions &&\n\t\t\t! this.isUpdatingSuggestions\n\t\t) {\n\t\t\tif ( value?.length ) {\n\t\t\t\t// If the new value is not empty we need to update with suggestions for it.\n\t\t\t\tthis.updateSuggestions( value );\n\t\t\t} else if ( __experimentalShowInitialSuggestions ) {\n\t\t\t\t// If the new value is empty and we can show initial suggestions, then show initial suggestions.\n\t\t\t\tthis.updateSuggestions();\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.shouldShowInitialSuggestions() ) {\n\t\t\tthis.updateSuggestions();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tthis.suggestionsRequest?.cancel?.();\n\t\tdelete this.suggestionsRequest;\n\t}\n\n\tbindSuggestionNode( index ) {\n\t\treturn ( ref ) => {\n\t\t\tthis.suggestionNodes[ index ] = ref;\n\t\t};\n\t}\n\n\tshouldShowInitialSuggestions() {\n\t\tconst { suggestions } = this.state;\n\t\tconst {\n\t\t\t__experimentalShowInitialSuggestions = false,\n\t\t\tvalue,\n\t\t} = this.props;\n\t\treturn (\n\t\t\t! this.isUpdatingSuggestions &&\n\t\t\t__experimentalShowInitialSuggestions &&\n\t\t\t! ( value && value.length ) &&\n\t\t\t! ( suggestions && suggestions.length )\n\t\t);\n\t}\n\n\tupdateSuggestions( value = '' ) {\n\t\tconst {\n\t\t\t__experimentalFetchLinkSuggestions: fetchLinkSuggestions,\n\t\t\t__experimentalHandleURLSuggestions: handleURLSuggestions,\n\t\t} = this.props;\n\n\t\tif ( ! fetchLinkSuggestions ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Initial suggestions may only show if there is no value\n\t\t// (note: this includes whitespace).\n\t\tconst isInitialSuggestions = ! value?.length;\n\n\t\t// Trim only now we've determined whether or not it originally had a \"length\"\n\t\t// (even if that value was all whitespace).\n\t\tvalue = value.trim();\n\n\t\t// Allow a suggestions request if:\n\t\t// - there are at least 2 characters in the search input (except manual searches where\n\t\t// search input length is not required to trigger a fetch)\n\t\t// - this is a direct entry (eg: a URL)\n\t\tif (\n\t\t\t! isInitialSuggestions &&\n\t\t\t( value.length < 2 || ( ! handleURLSuggestions && isURL( value ) ) )\n\t\t) {\n\t\t\tthis.setState( {\n\t\t\t\tshowSuggestions: false,\n\t\t\t\tselectedSuggestion: null,\n\t\t\t\tloading: false,\n\t\t\t} );\n\n\t\t\treturn;\n\t\t}\n\n\t\tthis.isUpdatingSuggestions = true;\n\n\t\tthis.setState( {\n\t\t\tselectedSuggestion: null,\n\t\t\tloading: true,\n\t\t} );\n\n\t\tconst request = fetchLinkSuggestions( value, {\n\t\t\tisInitialSuggestions,\n\t\t} );\n\n\t\trequest\n\t\t\t.then( ( suggestions ) => {\n\t\t\t\t// A fetch Promise doesn't have an abort option. It's mimicked by\n\t\t\t\t// comparing the request reference in on the instance, which is\n\t\t\t\t// reset or deleted on subsequent requests or unmounting.\n\t\t\t\tif ( this.suggestionsRequest !== request ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.setState( {\n\t\t\t\t\tsuggestions,\n\t\t\t\t\tloading: false,\n\t\t\t\t\tshowSuggestions: !! suggestions.length,\n\t\t\t\t} );\n\n\t\t\t\tif ( !! suggestions.length ) {\n\t\t\t\t\tthis.props.debouncedSpeak(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %s: number of results. */\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\tsuggestions.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tsuggestions.length\n\t\t\t\t\t\t),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.props.debouncedSpeak(\n\t\t\t\t\t\t__( 'No results.' ),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthis.isUpdatingSuggestions = false;\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tif ( this.suggestionsRequest === request ) {\n\t\t\t\t\tthis.setState( {\n\t\t\t\t\t\tloading: false,\n\t\t\t\t\t} );\n\t\t\t\t\tthis.isUpdatingSuggestions = false;\n\t\t\t\t}\n\t\t\t} );\n\n\t\t// Note that this assignment is handled *before* the async search request\n\t\t// as a Promise always resolves on the next tick of the event loop.\n\t\tthis.suggestionsRequest = request;\n\t}\n\n\tonChange( event ) {\n\t\tconst inputValue = event.target.value;\n\n\t\tthis.props.onChange( inputValue );\n\t\tif ( ! this.props.disableSuggestions ) {\n\t\t\tthis.updateSuggestions( inputValue );\n\t\t}\n\t}\n\n\tonFocus() {\n\t\tconst { suggestions } = this.state;\n\t\tconst { disableSuggestions, value } = this.props;\n\n\t\t// When opening the link editor, if there's a value present, we want to load the suggestions pane with the results for this input search value\n\t\t// Don't re-run the suggestions on focus if there are already suggestions present (prevents searching again when tabbing between the input and buttons)\n\t\tif (\n\t\t\tvalue &&\n\t\t\t! disableSuggestions &&\n\t\t\t! this.isUpdatingSuggestions &&\n\t\t\t! ( suggestions && suggestions.length )\n\t\t) {\n\t\t\t// Ensure the suggestions are updated with the current input value.\n\t\t\tthis.updateSuggestions( value );\n\t\t}\n\t}\n\n\tonKeyDown( event ) {\n\t\tconst {\n\t\t\tshowSuggestions,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestions,\n\t\t\tloading,\n\t\t} = this.state;\n\n\t\t// If the suggestions are not shown or loading, we shouldn't handle the arrow keys\n\t\t// We shouldn't preventDefault to allow block arrow keys navigation.\n\t\tif ( ! showSuggestions || ! suggestions.length || loading ) {\n\t\t\t// In the Windows version of Firefox the up and down arrows don't move the caret\n\t\t\t// within an input field like they do for Mac Firefox/Chrome/Safari. This causes\n\t\t\t// a form of focus trapping that is disruptive to the user experience. This disruption\n\t\t\t// only happens if the caret is not in the first or last position in the text input.\n\t\t\t// See: https://github.com/WordPress/gutenberg/issues/5693#issuecomment-436684747\n\t\t\tswitch ( event.keyCode ) {\n\t\t\t\t// When UP is pressed, if the caret is at the start of the text, move it to the 0\n\t\t\t\t// position.\n\t\t\t\tcase UP: {\n\t\t\t\t\tif ( 0 !== event.target.selectionStart ) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\t// Set the input caret to position 0.\n\t\t\t\t\t\tevent.target.setSelectionRange( 0, 0 );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t// When DOWN is pressed, if the caret is not at the end of the text, move it to the\n\t\t\t\t// last position.\n\t\t\t\tcase DOWN: {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.props.value.length !== event.target.selectionStart\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\t// Set the input caret to the last position.\n\t\t\t\t\t\tevent.target.setSelectionRange(\n\t\t\t\t\t\t\tthis.props.value.length,\n\t\t\t\t\t\t\tthis.props.value.length\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Submitting while loading should trigger onSubmit.\n\t\t\t\tcase ENTER: {\n\t\t\t\t\tif ( this.props.onSubmit ) {\n\t\t\t\t\t\tthis.props.onSubmit( null, event );\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst suggestion = this.state.suggestions[\n\t\t\tthis.state.selectedSuggestion\n\t\t];\n\n\t\tswitch ( event.keyCode ) {\n\t\t\tcase UP: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst previousIndex = ! selectedSuggestion\n\t\t\t\t\t? suggestions.length - 1\n\t\t\t\t\t: selectedSuggestion - 1;\n\t\t\t\tthis.setState( {\n\t\t\t\t\tselectedSuggestion: previousIndex,\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase DOWN: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst nextIndex =\n\t\t\t\t\tselectedSuggestion === null ||\n\t\t\t\t\tselectedSuggestion === suggestions.length - 1\n\t\t\t\t\t\t? 0\n\t\t\t\t\t\t: selectedSuggestion + 1;\n\t\t\t\tthis.setState( {\n\t\t\t\t\tselectedSuggestion: nextIndex,\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase TAB: {\n\t\t\t\tif ( this.state.selectedSuggestion !== null ) {\n\t\t\t\t\tthis.selectLink( suggestion );\n\t\t\t\t\t// Announce a link has been selected when tabbing away from the input field.\n\t\t\t\t\tthis.props.speak( __( 'Link selected.' ) );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ENTER: {\n\t\t\t\tif ( this.state.selectedSuggestion !== null ) {\n\t\t\t\t\tthis.selectLink( suggestion );\n\n\t\t\t\t\tif ( this.props.onSubmit ) {\n\t\t\t\t\t\tthis.props.onSubmit( suggestion, event );\n\t\t\t\t\t}\n\t\t\t\t} else if ( this.props.onSubmit ) {\n\t\t\t\t\tthis.props.onSubmit( null, event );\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tselectLink( suggestion ) {\n\t\tthis.props.onChange( suggestion.url, suggestion );\n\t\tthis.setState( {\n\t\t\tselectedSuggestion: null,\n\t\t\tshowSuggestions: false,\n\t\t} );\n\t}\n\n\thandleOnClick( suggestion ) {\n\t\tthis.selectLink( suggestion );\n\t\t// Move focus to the input field when a link suggestion is clicked.\n\t\tthis.inputRef.current.focus();\n\t}\n\n\tstatic getDerivedStateFromProps(\n\t\t{\n\t\t\tvalue,\n\t\t\tinstanceId,\n\t\t\tdisableSuggestions,\n\t\t\t__experimentalShowInitialSuggestions = false,\n\t\t},\n\t\t{ showSuggestions }\n\t) {\n\t\tlet shouldShowSuggestions = showSuggestions;\n\n\t\tconst hasValue = value && value.length;\n\n\t\tif ( ! __experimentalShowInitialSuggestions && ! hasValue ) {\n\t\t\tshouldShowSuggestions = false;\n\t\t}\n\n\t\tif ( disableSuggestions === true ) {\n\t\t\tshouldShowSuggestions = false;\n\t\t}\n\n\t\treturn {\n\t\t\tshowSuggestions: shouldShowSuggestions,\n\t\t\tsuggestionsListboxId: `block-editor-url-input-suggestions-${ instanceId }`,\n\t\t\tsuggestionOptionIdPrefix: `block-editor-url-input-suggestion-${ instanceId }`,\n\t\t};\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ this.renderControl() }\n\t\t\t\t{ this.renderSuggestions() }\n\t\t\t</>\n\t\t);\n\t}\n\n\trenderControl() {\n\t\tconst {\n\t\t\tlabel = null,\n\t\t\tclassName,\n\t\t\tisFullWidth,\n\t\t\tinstanceId,\n\t\t\tplaceholder = __( 'Paste URL or type to search' ),\n\t\t\t__experimentalRenderControl: renderControl,\n\t\t\tvalue = '',\n\t\t} = this.props;\n\n\t\tconst {\n\t\t\tloading,\n\t\t\tshowSuggestions,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestionsListboxId,\n\t\t\tsuggestionOptionIdPrefix,\n\t\t} = this.state;\n\n\t\tconst inputId = `url-input-control-${ instanceId }`;\n\n\t\tconst controlProps = {\n\t\t\tid: inputId, // Passes attribute to label for the for attribute\n\t\t\tlabel,\n\t\t\tclassName: classnames( 'block-editor-url-input', className, {\n\t\t\t\t'is-full-width': isFullWidth,\n\t\t\t} ),\n\t\t};\n\n\t\tconst inputProps = {\n\t\t\tid: inputId,\n\t\t\tvalue,\n\t\t\trequired: true,\n\t\t\tclassName: 'block-editor-url-input__input',\n\t\t\ttype: 'text',\n\t\t\tonChange: this.onChange,\n\t\t\tonFocus: this.onFocus,\n\t\t\tplaceholder,\n\t\t\tonKeyDown: this.onKeyDown,\n\t\t\trole: 'combobox',\n\t\t\t'aria-label': label ? undefined : __( 'URL' ), // Ensure input always has an accessible label\n\t\t\t'aria-expanded': showSuggestions,\n\t\t\t'aria-autocomplete': 'list',\n\t\t\t'aria-owns': suggestionsListboxId,\n\t\t\t'aria-activedescendant':\n\t\t\t\tselectedSuggestion !== null\n\t\t\t\t\t? `${ suggestionOptionIdPrefix }-${ selectedSuggestion }`\n\t\t\t\t\t: undefined,\n\t\t\tref: this.inputRef,\n\t\t};\n\n\t\tif ( renderControl ) {\n\t\t\treturn renderControl( controlProps, inputProps, loading );\n\t\t}\n\n\t\treturn (\n\t\t\t<BaseControl { ...controlProps }>\n\t\t\t\t<input { ...inputProps } />\n\t\t\t\t{ loading && <Spinner /> }\n\t\t\t</BaseControl>\n\t\t);\n\t}\n\n\trenderSuggestions() {\n\t\tconst {\n\t\t\tclassName,\n\t\t\t__experimentalRenderSuggestions: renderSuggestions,\n\t\t\tvalue = '',\n\t\t\t__experimentalShowInitialSuggestions = false,\n\t\t} = this.props;\n\n\t\tconst {\n\t\t\tshowSuggestions,\n\t\t\tsuggestions,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestionsListboxId,\n\t\t\tsuggestionOptionIdPrefix,\n\t\t\tloading,\n\t\t} = this.state;\n\n\t\tconst suggestionsListProps = {\n\t\t\tid: suggestionsListboxId,\n\t\t\tref: this.autocompleteRef,\n\t\t\trole: 'listbox',\n\t\t};\n\n\t\tconst buildSuggestionItemProps = ( suggestion, index ) => {\n\t\t\treturn {\n\t\t\t\trole: 'option',\n\t\t\t\ttabIndex: '-1',\n\t\t\t\tid: `${ suggestionOptionIdPrefix }-${ index }`,\n\t\t\t\tref: this.bindSuggestionNode( index ),\n\t\t\t\t'aria-selected': index === selectedSuggestion,\n\t\t\t};\n\t\t};\n\n\t\tif (\n\t\t\tisFunction( renderSuggestions ) &&\n\t\t\tshowSuggestions &&\n\t\t\t!! suggestions.length\n\t\t) {\n\t\t\treturn renderSuggestions( {\n\t\t\t\tsuggestions,\n\t\t\t\tselectedSuggestion,\n\t\t\t\tsuggestionsListProps,\n\t\t\t\tbuildSuggestionItemProps,\n\t\t\t\tisLoading: loading,\n\t\t\t\thandleSuggestionClick: this.handleOnClick,\n\t\t\t\tisInitialSuggestions:\n\t\t\t\t\t__experimentalShowInitialSuggestions &&\n\t\t\t\t\t! ( value && value.length ),\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\t! isFunction( renderSuggestions ) &&\n\t\t\tshowSuggestions &&\n\t\t\t!! suggestions.length\n\t\t) {\n\t\t\treturn (\n\t\t\t\t<Popover position=\"bottom\" noArrow focusOnMount={ false }>\n\t\t\t\t\t<div\n\t\t\t\t\t\t{ ...suggestionsListProps }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-url-input__suggestions',\n\t\t\t\t\t\t\t`${ className }__suggestions`\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ suggestions.map( ( suggestion, index ) => (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t{ ...buildSuggestionItemProps(\n\t\t\t\t\t\t\t\t\tsuggestion,\n\t\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tkey={ suggestion.id }\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t'block-editor-url-input__suggestion',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t'is-selected':\n\t\t\t\t\t\t\t\t\t\t\tindex === selectedSuggestion,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\tthis.handleOnClick( suggestion )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ suggestion.title }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</div>\n\t\t\t\t</Popover>\n\t\t\t);\n\t\t}\n\t\treturn null;\n\t}\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-input/README.md\n */\nexport default compose(\n\twithSafeTimeout,\n\twithSpokenMessages,\n\twithInstanceId,\n\twithSelect( ( select, props ) => {\n\t\t// If a link suggestions handler is already provided then\n\t\t// bail.\n\t\tif ( isFunction( props.__experimentalFetchLinkSuggestions ) ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\t__experimentalFetchLinkSuggestions: getSettings()\n\t\t\t\t.__experimentalFetchLinkSuggestions,\n\t\t};\n\t} )\n)( URLInput );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/url-input/index.js"],"names":["URLInput","Component","constructor","props","onChange","bind","onFocus","onKeyDown","selectLink","handleOnClick","bindSuggestionNode","autocompleteRef","inputRef","updateSuggestions","suggestionNodes","isUpdatingSuggestions","state","suggestions","showSuggestions","selectedSuggestion","suggestionsListboxId","suggestionOptionIdPrefix","componentDidUpdate","prevProps","value","__experimentalShowInitialSuggestions","scrollingIntoView","current","onlyScrollIfNeeded","setTimeout","disableSuggestions","length","componentDidMount","shouldShowInitialSuggestions","componentWillUnmount","suggestionsRequest","cancel","index","ref","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalHandleURLSuggestions","handleURLSuggestions","isInitialSuggestions","trim","setState","loading","request","then","debouncedSpeak","catch","event","inputValue","target","keyCode","UP","selectionStart","preventDefault","setSelectionRange","DOWN","ENTER","onSubmit","suggestion","previousIndex","nextIndex","TAB","speak","url","focus","getDerivedStateFromProps","instanceId","shouldShowSuggestions","hasValue","render","renderControl","renderSuggestions","label","className","isFullWidth","placeholder","__experimentalRenderControl","inputId","controlProps","id","inputProps","required","type","role","undefined","__experimentalRenderSuggestions","suggestionsListProps","buildSuggestionItemProps","tabIndex","isLoading","handleSuggestionClick","map","title","withSafeTimeout","withSpokenMessages","withInstanceId","select","getSettings","blockEditorStore"],"mappings":";;;;;;;;;AAWA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MAAM,CAAEE,YAAF,CAA9B;AACA,SAAO;AACN/D,IAAAA,kCAAkC,EAAE8D,WAAW,GAC7C9D;AAFI,GAAP;AAIA,CAXD,CAJc,EAgBZvC,QAhBY,C","sourcesContent":["/**\n * External dependencies\n */\nimport { debounce, isFunction } from 'lodash';\nimport classnames from 'classnames';\nimport scrollIntoView from 'dom-scroll-into-view';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport { Component, createRef } from '@wordpress/element';\nimport { UP, DOWN, ENTER, TAB } from '@wordpress/keycodes';\nimport {\n\tBaseControl,\n\tButton,\n\tSpinner,\n\twithSpokenMessages,\n\tPopover,\n} from '@wordpress/components';\nimport { withInstanceId, withSafeTimeout, compose } from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nclass URLInput extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\n\t\tthis.onChange = this.onChange.bind( this );\n\t\tthis.onFocus = this.onFocus.bind( this );\n\t\tthis.onKeyDown = this.onKeyDown.bind( this );\n\t\tthis.selectLink = this.selectLink.bind( this );\n\t\tthis.handleOnClick = this.handleOnClick.bind( this );\n\t\tthis.bindSuggestionNode = this.bindSuggestionNode.bind( this );\n\t\tthis.autocompleteRef = props.autocompleteRef || createRef();\n\t\tthis.inputRef = createRef();\n\t\tthis.updateSuggestions = debounce(\n\t\t\tthis.updateSuggestions.bind( this ),\n\t\t\t200\n\t\t);\n\n\t\tthis.suggestionNodes = [];\n\n\t\tthis.isUpdatingSuggestions = false;\n\n\t\tthis.state = {\n\t\t\tsuggestions: [],\n\t\t\tshowSuggestions: false,\n\t\t\tselectedSuggestion: null,\n\n\t\t\tsuggestionsListboxId: '',\n\t\t\tsuggestionOptionIdPrefix: '',\n\t\t};\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tconst { showSuggestions, selectedSuggestion } = this.state;\n\t\tconst {\n\t\t\tvalue,\n\t\t\t__experimentalShowInitialSuggestions = false,\n\t\t} = this.props;\n\n\t\t// Only have to worry about scrolling selected suggestion into view\n\t\t// when already expanded.\n\t\tif (\n\t\t\tshowSuggestions &&\n\t\t\tselectedSuggestion !== null &&\n\t\t\tthis.suggestionNodes[ selectedSuggestion ] &&\n\t\t\t! this.scrollingIntoView\n\t\t) {\n\t\t\tthis.scrollingIntoView = true;\n\t\t\tscrollIntoView(\n\t\t\t\tthis.suggestionNodes[ selectedSuggestion ],\n\t\t\t\tthis.autocompleteRef.current,\n\t\t\t\t{\n\t\t\t\t\tonlyScrollIfNeeded: true,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tthis.props.setTimeout( () => {\n\t\t\t\tthis.scrollingIntoView = false;\n\t\t\t}, 100 );\n\t\t}\n\n\t\t// Update suggestions when the value changes.\n\t\tif (\n\t\t\tprevProps.value !== value &&\n\t\t\t! this.props.disableSuggestions &&\n\t\t\t! this.isUpdatingSuggestions\n\t\t) {\n\t\t\tif ( value?.length ) {\n\t\t\t\t// If the new value is not empty we need to update with suggestions for it.\n\t\t\t\tthis.updateSuggestions( value );\n\t\t\t} else if ( __experimentalShowInitialSuggestions ) {\n\t\t\t\t// If the new value is empty and we can show initial suggestions, then show initial suggestions.\n\t\t\t\tthis.updateSuggestions();\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.shouldShowInitialSuggestions() ) {\n\t\t\tthis.updateSuggestions();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tthis.suggestionsRequest?.cancel?.();\n\t\tdelete this.suggestionsRequest;\n\t}\n\n\tbindSuggestionNode( index ) {\n\t\treturn ( ref ) => {\n\t\t\tthis.suggestionNodes[ index ] = ref;\n\t\t};\n\t}\n\n\tshouldShowInitialSuggestions() {\n\t\tconst { suggestions } = this.state;\n\t\tconst {\n\t\t\t__experimentalShowInitialSuggestions = false,\n\t\t\tvalue,\n\t\t} = this.props;\n\t\treturn (\n\t\t\t! this.isUpdatingSuggestions &&\n\t\t\t__experimentalShowInitialSuggestions &&\n\t\t\t! ( value && value.length ) &&\n\t\t\t! ( suggestions && suggestions.length )\n\t\t);\n\t}\n\n\tupdateSuggestions( value = '' ) {\n\t\tconst {\n\t\t\t__experimentalFetchLinkSuggestions: fetchLinkSuggestions,\n\t\t\t__experimentalHandleURLSuggestions: handleURLSuggestions,\n\t\t} = this.props;\n\n\t\tif ( ! fetchLinkSuggestions ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Initial suggestions may only show if there is no value\n\t\t// (note: this includes whitespace).\n\t\tconst isInitialSuggestions = ! value?.length;\n\n\t\t// Trim only now we've determined whether or not it originally had a \"length\"\n\t\t// (even if that value was all whitespace).\n\t\tvalue = value.trim();\n\n\t\t// Allow a suggestions request if:\n\t\t// - there are at least 2 characters in the search input (except manual searches where\n\t\t// search input length is not required to trigger a fetch)\n\t\t// - this is a direct entry (eg: a URL)\n\t\tif (\n\t\t\t! isInitialSuggestions &&\n\t\t\t( value.length < 2 || ( ! handleURLSuggestions && isURL( value ) ) )\n\t\t) {\n\t\t\tthis.setState( {\n\t\t\t\tshowSuggestions: false,\n\t\t\t\tselectedSuggestion: null,\n\t\t\t\tloading: false,\n\t\t\t} );\n\n\t\t\treturn;\n\t\t}\n\n\t\tthis.isUpdatingSuggestions = true;\n\n\t\tthis.setState( {\n\t\t\tselectedSuggestion: null,\n\t\t\tloading: true,\n\t\t} );\n\n\t\tconst request = fetchLinkSuggestions( value, {\n\t\t\tisInitialSuggestions,\n\t\t} );\n\n\t\trequest\n\t\t\t.then( ( suggestions ) => {\n\t\t\t\t// A fetch Promise doesn't have an abort option. It's mimicked by\n\t\t\t\t// comparing the request reference in on the instance, which is\n\t\t\t\t// reset or deleted on subsequent requests or unmounting.\n\t\t\t\tif ( this.suggestionsRequest !== request ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.setState( {\n\t\t\t\t\tsuggestions,\n\t\t\t\t\tloading: false,\n\t\t\t\t\tshowSuggestions: !! suggestions.length,\n\t\t\t\t} );\n\n\t\t\t\tif ( !! suggestions.length ) {\n\t\t\t\t\tthis.props.debouncedSpeak(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %s: number of results. */\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\tsuggestions.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tsuggestions.length\n\t\t\t\t\t\t),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.props.debouncedSpeak(\n\t\t\t\t\t\t__( 'No results.' ),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthis.isUpdatingSuggestions = false;\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tif ( this.suggestionsRequest === request ) {\n\t\t\t\t\tthis.setState( {\n\t\t\t\t\t\tloading: false,\n\t\t\t\t\t} );\n\t\t\t\t\tthis.isUpdatingSuggestions = false;\n\t\t\t\t}\n\t\t\t} );\n\n\t\t// Note that this assignment is handled *before* the async search request\n\t\t// as a Promise always resolves on the next tick of the event loop.\n\t\tthis.suggestionsRequest = request;\n\t}\n\n\tonChange( event ) {\n\t\tconst inputValue = event.target.value;\n\n\t\tthis.props.onChange( inputValue );\n\t\tif ( ! this.props.disableSuggestions ) {\n\t\t\tthis.updateSuggestions( inputValue );\n\t\t}\n\t}\n\n\tonFocus() {\n\t\tconst { suggestions } = this.state;\n\t\tconst { disableSuggestions, value } = this.props;\n\n\t\t// When opening the link editor, if there's a value present, we want to load the suggestions pane with the results for this input search value\n\t\t// Don't re-run the suggestions on focus if there are already suggestions present (prevents searching again when tabbing between the input and buttons)\n\t\tif (\n\t\t\tvalue &&\n\t\t\t! disableSuggestions &&\n\t\t\t! this.isUpdatingSuggestions &&\n\t\t\t! ( suggestions && suggestions.length )\n\t\t) {\n\t\t\t// Ensure the suggestions are updated with the current input value.\n\t\t\tthis.updateSuggestions( value );\n\t\t}\n\t}\n\n\tonKeyDown( event ) {\n\t\tconst {\n\t\t\tshowSuggestions,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestions,\n\t\t\tloading,\n\t\t} = this.state;\n\n\t\t// If the suggestions are not shown or loading, we shouldn't handle the arrow keys\n\t\t// We shouldn't preventDefault to allow block arrow keys navigation.\n\t\tif ( ! showSuggestions || ! suggestions.length || loading ) {\n\t\t\t// In the Windows version of Firefox the up and down arrows don't move the caret\n\t\t\t// within an input field like they do for Mac Firefox/Chrome/Safari. This causes\n\t\t\t// a form of focus trapping that is disruptive to the user experience. This disruption\n\t\t\t// only happens if the caret is not in the first or last position in the text input.\n\t\t\t// See: https://github.com/WordPress/gutenberg/issues/5693#issuecomment-436684747\n\t\t\tswitch ( event.keyCode ) {\n\t\t\t\t// When UP is pressed, if the caret is at the start of the text, move it to the 0\n\t\t\t\t// position.\n\t\t\t\tcase UP: {\n\t\t\t\t\tif ( 0 !== event.target.selectionStart ) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\t// Set the input caret to position 0.\n\t\t\t\t\t\tevent.target.setSelectionRange( 0, 0 );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t// When DOWN is pressed, if the caret is not at the end of the text, move it to the\n\t\t\t\t// last position.\n\t\t\t\tcase DOWN: {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.props.value.length !== event.target.selectionStart\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\t// Set the input caret to the last position.\n\t\t\t\t\t\tevent.target.setSelectionRange(\n\t\t\t\t\t\t\tthis.props.value.length,\n\t\t\t\t\t\t\tthis.props.value.length\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Submitting while loading should trigger onSubmit.\n\t\t\t\tcase ENTER: {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif ( this.props.onSubmit ) {\n\t\t\t\t\t\tthis.props.onSubmit( null, event );\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst suggestion = this.state.suggestions[\n\t\t\tthis.state.selectedSuggestion\n\t\t];\n\n\t\tswitch ( event.keyCode ) {\n\t\t\tcase UP: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst previousIndex = ! selectedSuggestion\n\t\t\t\t\t? suggestions.length - 1\n\t\t\t\t\t: selectedSuggestion - 1;\n\t\t\t\tthis.setState( {\n\t\t\t\t\tselectedSuggestion: previousIndex,\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase DOWN: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst nextIndex =\n\t\t\t\t\tselectedSuggestion === null ||\n\t\t\t\t\tselectedSuggestion === suggestions.length - 1\n\t\t\t\t\t\t? 0\n\t\t\t\t\t\t: selectedSuggestion + 1;\n\t\t\t\tthis.setState( {\n\t\t\t\t\tselectedSuggestion: nextIndex,\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase TAB: {\n\t\t\t\tif ( this.state.selectedSuggestion !== null ) {\n\t\t\t\t\tthis.selectLink( suggestion );\n\t\t\t\t\t// Announce a link has been selected when tabbing away from the input field.\n\t\t\t\t\tthis.props.speak( __( 'Link selected.' ) );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ENTER: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( this.state.selectedSuggestion !== null ) {\n\t\t\t\t\tthis.selectLink( suggestion );\n\n\t\t\t\t\tif ( this.props.onSubmit ) {\n\t\t\t\t\t\tthis.props.onSubmit( suggestion, event );\n\t\t\t\t\t}\n\t\t\t\t} else if ( this.props.onSubmit ) {\n\t\t\t\t\tthis.props.onSubmit( null, event );\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tselectLink( suggestion ) {\n\t\tthis.props.onChange( suggestion.url, suggestion );\n\t\tthis.setState( {\n\t\t\tselectedSuggestion: null,\n\t\t\tshowSuggestions: false,\n\t\t} );\n\t}\n\n\thandleOnClick( suggestion ) {\n\t\tthis.selectLink( suggestion );\n\t\t// Move focus to the input field when a link suggestion is clicked.\n\t\tthis.inputRef.current.focus();\n\t}\n\n\tstatic getDerivedStateFromProps(\n\t\t{\n\t\t\tvalue,\n\t\t\tinstanceId,\n\t\t\tdisableSuggestions,\n\t\t\t__experimentalShowInitialSuggestions = false,\n\t\t},\n\t\t{ showSuggestions }\n\t) {\n\t\tlet shouldShowSuggestions = showSuggestions;\n\n\t\tconst hasValue = value && value.length;\n\n\t\tif ( ! __experimentalShowInitialSuggestions && ! hasValue ) {\n\t\t\tshouldShowSuggestions = false;\n\t\t}\n\n\t\tif ( disableSuggestions === true ) {\n\t\t\tshouldShowSuggestions = false;\n\t\t}\n\n\t\treturn {\n\t\t\tshowSuggestions: shouldShowSuggestions,\n\t\t\tsuggestionsListboxId: `block-editor-url-input-suggestions-${ instanceId }`,\n\t\t\tsuggestionOptionIdPrefix: `block-editor-url-input-suggestion-${ instanceId }`,\n\t\t};\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ this.renderControl() }\n\t\t\t\t{ this.renderSuggestions() }\n\t\t\t</>\n\t\t);\n\t}\n\n\trenderControl() {\n\t\tconst {\n\t\t\tlabel = null,\n\t\t\tclassName,\n\t\t\tisFullWidth,\n\t\t\tinstanceId,\n\t\t\tplaceholder = __( 'Paste URL or type to search' ),\n\t\t\t__experimentalRenderControl: renderControl,\n\t\t\tvalue = '',\n\t\t} = this.props;\n\n\t\tconst {\n\t\t\tloading,\n\t\t\tshowSuggestions,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestionsListboxId,\n\t\t\tsuggestionOptionIdPrefix,\n\t\t} = this.state;\n\n\t\tconst inputId = `url-input-control-${ instanceId }`;\n\n\t\tconst controlProps = {\n\t\t\tid: inputId, // Passes attribute to label for the for attribute\n\t\t\tlabel,\n\t\t\tclassName: classnames( 'block-editor-url-input', className, {\n\t\t\t\t'is-full-width': isFullWidth,\n\t\t\t} ),\n\t\t};\n\n\t\tconst inputProps = {\n\t\t\tid: inputId,\n\t\t\tvalue,\n\t\t\trequired: true,\n\t\t\tclassName: 'block-editor-url-input__input',\n\t\t\ttype: 'text',\n\t\t\tonChange: this.onChange,\n\t\t\tonFocus: this.onFocus,\n\t\t\tplaceholder,\n\t\t\tonKeyDown: this.onKeyDown,\n\t\t\trole: 'combobox',\n\t\t\t'aria-label': label ? undefined : __( 'URL' ), // Ensure input always has an accessible label\n\t\t\t'aria-expanded': showSuggestions,\n\t\t\t'aria-autocomplete': 'list',\n\t\t\t'aria-owns': suggestionsListboxId,\n\t\t\t'aria-activedescendant':\n\t\t\t\tselectedSuggestion !== null\n\t\t\t\t\t? `${ suggestionOptionIdPrefix }-${ selectedSuggestion }`\n\t\t\t\t\t: undefined,\n\t\t\tref: this.inputRef,\n\t\t};\n\n\t\tif ( renderControl ) {\n\t\t\treturn renderControl( controlProps, inputProps, loading );\n\t\t}\n\n\t\treturn (\n\t\t\t<BaseControl { ...controlProps }>\n\t\t\t\t<input { ...inputProps } />\n\t\t\t\t{ loading && <Spinner /> }\n\t\t\t</BaseControl>\n\t\t);\n\t}\n\n\trenderSuggestions() {\n\t\tconst {\n\t\t\tclassName,\n\t\t\t__experimentalRenderSuggestions: renderSuggestions,\n\t\t\tvalue = '',\n\t\t\t__experimentalShowInitialSuggestions = false,\n\t\t} = this.props;\n\n\t\tconst {\n\t\t\tshowSuggestions,\n\t\t\tsuggestions,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestionsListboxId,\n\t\t\tsuggestionOptionIdPrefix,\n\t\t\tloading,\n\t\t} = this.state;\n\n\t\tconst suggestionsListProps = {\n\t\t\tid: suggestionsListboxId,\n\t\t\tref: this.autocompleteRef,\n\t\t\trole: 'listbox',\n\t\t};\n\n\t\tconst buildSuggestionItemProps = ( suggestion, index ) => {\n\t\t\treturn {\n\t\t\t\trole: 'option',\n\t\t\t\ttabIndex: '-1',\n\t\t\t\tid: `${ suggestionOptionIdPrefix }-${ index }`,\n\t\t\t\tref: this.bindSuggestionNode( index ),\n\t\t\t\t'aria-selected': index === selectedSuggestion,\n\t\t\t};\n\t\t};\n\n\t\tif (\n\t\t\tisFunction( renderSuggestions ) &&\n\t\t\tshowSuggestions &&\n\t\t\t!! suggestions.length\n\t\t) {\n\t\t\treturn renderSuggestions( {\n\t\t\t\tsuggestions,\n\t\t\t\tselectedSuggestion,\n\t\t\t\tsuggestionsListProps,\n\t\t\t\tbuildSuggestionItemProps,\n\t\t\t\tisLoading: loading,\n\t\t\t\thandleSuggestionClick: this.handleOnClick,\n\t\t\t\tisInitialSuggestions:\n\t\t\t\t\t__experimentalShowInitialSuggestions &&\n\t\t\t\t\t! ( value && value.length ),\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\t! isFunction( renderSuggestions ) &&\n\t\t\tshowSuggestions &&\n\t\t\t!! suggestions.length\n\t\t) {\n\t\t\treturn (\n\t\t\t\t<Popover position=\"bottom\" focusOnMount={ false }>\n\t\t\t\t\t<div\n\t\t\t\t\t\t{ ...suggestionsListProps }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-url-input__suggestions',\n\t\t\t\t\t\t\t`${ className }__suggestions`\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ suggestions.map( ( suggestion, index ) => (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t{ ...buildSuggestionItemProps(\n\t\t\t\t\t\t\t\t\tsuggestion,\n\t\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tkey={ suggestion.id }\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t'block-editor-url-input__suggestion',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t'is-selected':\n\t\t\t\t\t\t\t\t\t\t\tindex === selectedSuggestion,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\tthis.handleOnClick( suggestion )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ suggestion.title }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</div>\n\t\t\t\t</Popover>\n\t\t\t);\n\t\t}\n\t\treturn null;\n\t}\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-input/README.md\n */\nexport default compose(\n\twithSafeTimeout,\n\twithSpokenMessages,\n\twithInstanceId,\n\twithSelect( ( select, props ) => {\n\t\t// If a link suggestions handler is already provided then\n\t\t// bail.\n\t\tif ( isFunction( props.__experimentalFetchLinkSuggestions ) ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\t__experimentalFetchLinkSuggestions: getSettings()\n\t\t\t\t.__experimentalFetchLinkSuggestions,\n\t\t};\n\t} )\n)( URLInput );\n"]}
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = useBlockDropZone;
9
+ exports.getNearestBlockIndex = getNearestBlockIndex;
10
+
11
+ var _reactNativeReanimated = require("react-native-reanimated");
12
+
13
+ var _data = require("@wordpress/data");
14
+
15
+ var _element = require("@wordpress/element");
16
+
17
+ var _compose = require("@wordpress/compose");
18
+
19
+ var _store = require("../../store");
20
+
21
+ var _blockListContext = require("../block-list/block-list-context");
22
+
23
+ var _math = require("../../utils/math");
24
+
25
+ var _useOnBlockDrop = _interopRequireDefault(require("../use-on-block-drop"));
26
+
27
+ /**
28
+ * External dependencies
29
+ */
30
+
31
+ /**
32
+ * WordPress dependencies
33
+ */
34
+
35
+ /**
36
+ * Internal dependencies
37
+ */
38
+
39
+ /** @typedef {import('../../utils/math').WPPoint} WPPoint */
40
+
41
+ /**
42
+ * The orientation of a block list.
43
+ *
44
+ * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation
45
+ */
46
+
47
+ /**
48
+ * Given a list of blocks layouts finds the index that a block should be dropped at.
49
+ *
50
+ * @param {Object} blocksLayouts Blocks layouts object.
51
+ * @param {WPPoint} position The position of the item being dragged.
52
+ * @param {WPBlockListOrientation} orientation The orientation of a block list.
53
+ * @param {boolean} isRTL Check if current locale is RTL.
54
+ *
55
+ * @return {number|undefined} The block index that's closest to the drag position.
56
+ */
57
+ function getNearestBlockIndex(blocksLayouts, position, orientation, isRTL) {
58
+ const allowedEdges = orientation === 'horizontal' ? ['left', 'right'] : ['top', 'bottom'];
59
+ const isRightToLeft = isRTL;
60
+ let candidateIndex;
61
+ let candidateDistance; // Only enabled for root level blocks.
62
+
63
+ blocksLayouts.forEach((element, index) => {
64
+ const {
65
+ x,
66
+ y,
67
+ width,
68
+ height
69
+ } = element;
70
+ const rect = {
71
+ x: element.x,
72
+ y: element.y,
73
+ top: y,
74
+ right: x + width,
75
+ bottom: y + height,
76
+ left: x,
77
+ width,
78
+ height
79
+ };
80
+ const [distance, edge] = (0, _math.getDistanceToNearestEdge)(position, rect, allowedEdges);
81
+
82
+ if (candidateDistance === undefined || distance < candidateDistance) {
83
+ // If the user is dropping to the trailing edge of the block
84
+ // add 1 to the index to represent dragging after.
85
+ // Take RTL languages into account where the left edge is
86
+ // the trailing edge.
87
+ const isTrailingEdge = edge === 'bottom' || !isRightToLeft && edge === 'right' || isRightToLeft && edge === 'left';
88
+ const offset = isTrailingEdge ? 1 : 0; // Update the currently known best candidate.
89
+
90
+ candidateDistance = distance;
91
+ candidateIndex = index + offset;
92
+ }
93
+ });
94
+ return candidateIndex;
95
+ }
96
+ /**
97
+ * @typedef {Object} WPBlockDropZoneConfig
98
+ * @property {string} rootClientId The root client id for the block list.
99
+ */
100
+
101
+ /**
102
+ * A React hook that can be used to make a block list handle drag and drop.
103
+ *
104
+ * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.
105
+ *
106
+ * @return {Object} An object that contains `targetBlockIndex` and the event
107
+ * handlers `onBlockDragOver`, `onBlockDragEnd` and `onBlockDrop`.
108
+ */
109
+
110
+
111
+ function useBlockDropZone() {
112
+ let {
113
+ // An undefined value represents a top-level block. Default to an empty
114
+ // string for this so that `targetRootClientId` can be easily compared to
115
+ // values returned by the `getRootBlockClientId` selector, which also uses
116
+ // an empty string to represent top-level blocks.
117
+ rootClientId: targetRootClientId = ''
118
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
119
+ const targetBlockIndex = (0, _reactNativeReanimated.useSharedValue)(null);
120
+ const {
121
+ getBlockListSettings,
122
+ getSettings
123
+ } = (0, _data.useSelect)(_store.store);
124
+ const {
125
+ blocksLayouts,
126
+ getBlockLayoutsOrderedByYCoord
127
+ } = (0, _blockListContext.useBlockListContext)();
128
+ const getSortedBlocksLayouts = (0, _element.useCallback)(() => {
129
+ return getBlockLayoutsOrderedByYCoord(blocksLayouts.current);
130
+ }, [blocksLayouts.current]);
131
+ const isRTL = getSettings().isRTL;
132
+ const onBlockDrop = (0, _useOnBlockDrop.default)();
133
+ const throttled = (0, _compose.useThrottle)((0, _element.useCallback)(event => {
134
+ var _getBlockListSettings;
135
+
136
+ const sortedBlockLayouts = getSortedBlocksLayouts();
137
+ const targetIndex = getNearestBlockIndex(sortedBlockLayouts, {
138
+ x: event.x,
139
+ y: event.y
140
+ }, (_getBlockListSettings = getBlockListSettings(targetRootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation, isRTL);
141
+
142
+ if (targetIndex !== null) {
143
+ targetBlockIndex.value = targetIndex !== null && targetIndex !== void 0 ? targetIndex : 0;
144
+ }
145
+ }, [getSortedBlocksLayouts, getNearestBlockIndex, getBlockListSettings, targetBlockIndex]), 200);
146
+ return {
147
+ onBlockDragOver(event) {
148
+ throttled(event);
149
+ },
150
+
151
+ onBlockDragEnd() {
152
+ throttled.cancel();
153
+ targetBlockIndex.value = null;
154
+ },
155
+
156
+ onBlockDrop: event => {
157
+ if (targetBlockIndex.value !== null) {
158
+ onBlockDrop({ ...event,
159
+ targetRootClientId,
160
+ targetBlockIndex: targetBlockIndex.value
161
+ });
162
+ }
163
+ },
164
+ targetBlockIndex
165
+ };
166
+ }
167
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-block-drop-zone/index.native.js"],"names":["getNearestBlockIndex","blocksLayouts","position","orientation","isRTL","allowedEdges","isRightToLeft","candidateIndex","candidateDistance","forEach","element","index","x","y","width","height","rect","top","right","bottom","left","distance","edge","undefined","isTrailingEdge","offset","useBlockDropZone","rootClientId","targetRootClientId","targetBlockIndex","getBlockListSettings","getSettings","blockEditorStore","getBlockLayoutsOrderedByYCoord","getSortedBlocksLayouts","current","onBlockDrop","throttled","event","sortedBlockLayouts","targetIndex","value","onBlockDragOver","onBlockDragEnd","cancel"],"mappings":";;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAMA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,oBAAT,CACNC,aADM,EAENC,QAFM,EAGNC,WAHM,EAINC,KAJ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AsBjB,GAtBiB,CAAlB;AAyBA,SAAO;AACNa,IAAAA,eAAe,CAAEJ,KAAF,EAAU;AACxBD,MAAAA,SAAS,CAAEC,KAAF,CAAT;AACA,KAHK;;AAINK,IAAAA,cAAc,GAAG;AAChBN,MAAAA,SAAS,CAACO,MAAV;AACAf,MAAAA,gBAAgB,CAACY,KAAjB,GAAyB,IAAzB;AACA,KAPK;;AAQNL,IAAAA,WAAW,EAAIE,KAAF,IAAa;AACzB,UAAKT,gBAAgB,CAACY,KAAjB,KAA2B,IAAhC,EAAuC;AACtCL,QAAAA,WAAW,CAAE,EACZ,GAAGE,KADS;AAEZV,UAAAA,kBAFY;AAGZC,UAAAA,gBAAgB,EAAEA,gBAAgB,CAACY;AAHvB,SAAF,CAAX;AAKA;AACD,KAhBK;AAiBNZ,IAAAA;AAjBM,GAAP;AAmBA","sourcesContent":["/**\n * External dependencies\n */\nimport { useSharedValue } from 'react-native-reanimated';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\nimport { useThrottle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { useBlockListContext } from '../block-list/block-list-context';\nimport { getDistanceToNearestEdge } from '../../utils/math';\nimport useOnBlockDrop from '../use-on-block-drop';\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n\n/**\n * The orientation of a block list.\n *\n * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation\n */\n\n/**\n * Given a list of blocks layouts finds the index that a block should be dropped at.\n *\n * @param {Object} blocksLayouts Blocks layouts object.\n * @param {WPPoint} position The position of the item being dragged.\n * @param {WPBlockListOrientation} orientation The orientation of a block list.\n * @param {boolean} isRTL Check if current locale is RTL.\n *\n * @return {number|undefined} The block index that's closest to the drag position.\n */\nexport function getNearestBlockIndex(\n\tblocksLayouts,\n\tposition,\n\torientation,\n\tisRTL\n) {\n\tconst allowedEdges =\n\t\torientation === 'horizontal'\n\t\t\t? [ 'left', 'right' ]\n\t\t\t: [ 'top', 'bottom' ];\n\n\tconst isRightToLeft = isRTL;\n\n\tlet candidateIndex;\n\tlet candidateDistance;\n\n\t// Only enabled for root level blocks.\n\tblocksLayouts.forEach( ( element, index ) => {\n\t\tconst { x, y, width, height } = element;\n\t\tconst rect = {\n\t\t\tx: element.x,\n\t\t\ty: element.y,\n\t\t\ttop: y,\n\t\t\tright: x + width,\n\t\t\tbottom: y + height,\n\t\t\tleft: x,\n\t\t\twidth,\n\t\t\theight,\n\t\t};\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\tposition,\n\t\t\trect,\n\t\t\tallowedEdges\n\t\t);\n\n\t\tif ( candidateDistance === undefined || distance < candidateDistance ) {\n\t\t\t// If the user is dropping to the trailing edge of the block\n\t\t\t// add 1 to the index to represent dragging after.\n\t\t\t// Take RTL languages into account where the left edge is\n\t\t\t// the trailing edge.\n\t\t\tconst isTrailingEdge =\n\t\t\t\tedge === 'bottom' ||\n\t\t\t\t( ! isRightToLeft && edge === 'right' ) ||\n\t\t\t\t( isRightToLeft && edge === 'left' );\n\t\t\tconst offset = isTrailingEdge ? 1 : 0;\n\n\t\t\t// Update the currently known best candidate.\n\t\t\tcandidateDistance = distance;\n\t\t\tcandidateIndex = index + offset;\n\t\t}\n\t} );\n\treturn candidateIndex;\n}\n\n/**\n * @typedef {Object} WPBlockDropZoneConfig\n * @property {string} rootClientId The root client id for the block list.\n */\n\n/**\n * A React hook that can be used to make a block list handle drag and drop.\n *\n * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.\n *\n * @return {Object} An object that contains `targetBlockIndex` and the event\n * handlers `onBlockDragOver`, `onBlockDragEnd` and `onBlockDrop`.\n */\nexport default function useBlockDropZone( {\n\t// An undefined value represents a top-level block. Default to an empty\n\t// string for this so that `targetRootClientId` can be easily compared to\n\t// values returned by the `getRootBlockClientId` selector, which also uses\n\t// an empty string to represent top-level blocks.\n\trootClientId: targetRootClientId = '',\n} = {} ) {\n\tconst targetBlockIndex = useSharedValue( null );\n\n\tconst { getBlockListSettings, getSettings } = useSelect( blockEditorStore );\n\tconst {\n\t\tblocksLayouts,\n\t\tgetBlockLayoutsOrderedByYCoord,\n\t} = useBlockListContext();\n\n\tconst getSortedBlocksLayouts = useCallback( () => {\n\t\treturn getBlockLayoutsOrderedByYCoord( blocksLayouts.current );\n\t}, [ blocksLayouts.current ] );\n\n\tconst isRTL = getSettings().isRTL;\n\n\tconst onBlockDrop = useOnBlockDrop();\n\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event ) => {\n\t\t\t\tconst sortedBlockLayouts = getSortedBlocksLayouts();\n\n\t\t\t\tconst targetIndex = getNearestBlockIndex(\n\t\t\t\t\tsortedBlockLayouts,\n\t\t\t\t\t{ x: event.x, y: event.y },\n\t\t\t\t\tgetBlockListSettings( targetRootClientId )?.orientation,\n\t\t\t\t\tisRTL\n\t\t\t\t);\n\t\t\t\tif ( targetIndex !== null ) {\n\t\t\t\t\ttargetBlockIndex.value = targetIndex ?? 0;\n\t\t\t\t}\n\t\t\t},\n\t\t\t[\n\t\t\t\tgetSortedBlocksLayouts,\n\t\t\t\tgetNearestBlockIndex,\n\t\t\t\tgetBlockListSettings,\n\t\t\t\ttargetBlockIndex,\n\t\t\t]\n\t\t),\n\t\t200\n\t);\n\n\treturn {\n\t\tonBlockDragOver( event ) {\n\t\t\tthrottled( event );\n\t\t},\n\t\tonBlockDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\ttargetBlockIndex.value = null;\n\t\t},\n\t\tonBlockDrop: ( event ) => {\n\t\t\tif ( targetBlockIndex.value !== null ) {\n\t\t\t\tonBlockDrop( {\n\t\t\t\t\t...event,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\ttargetBlockIndex: targetBlockIndex.value,\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\ttargetBlockIndex,\n\t};\n}\n"]}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useOnBlockDrop;
7
+ exports.onBlockDrop = onBlockDrop;
8
+
9
+ var _blocks = require("@wordpress/blocks");
10
+
11
+ var _data = require("@wordpress/data");
12
+
13
+ var _store = require("../../store");
14
+
15
+ /**
16
+ * WordPress dependencies
17
+ */
18
+
19
+ /**
20
+ * Internal dependencies
21
+ */
22
+
23
+ /**
24
+ * A function that returns an event handler function for block drop events.
25
+ *
26
+ * @param {Function} getBlockIndex A function that gets the index of a block.
27
+ * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.
28
+ * @param {Function} moveBlocksToPosition A function that moves blocks.
29
+ * @param {Function} insertBlocks A function that inserts blocks.
30
+ * @param {Function} clearSelectedBlock A function that clears block selection.
31
+ * @return {Function} The event handler for a block drop event.
32
+ */
33
+ function onBlockDrop(getBlockIndex, getClientIdsOfDescendants, moveBlocksToPosition, insertBlocks, clearSelectedBlock) {
34
+ return _ref => {
35
+ let {
36
+ blocks,
37
+ srcClientIds: sourceClientIds,
38
+ srcRootClientId: sourceRootClientId,
39
+ targetBlockIndex,
40
+ targetRootClientId,
41
+ type: dropType
42
+ } = _ref;
43
+
44
+ // If the user is inserting a block.
45
+ if (dropType === 'inserter') {
46
+ clearSelectedBlock();
47
+ const blocksToInsert = blocks.map(block => (0, _blocks.cloneBlock)(block));
48
+ insertBlocks(blocksToInsert, targetBlockIndex, targetRootClientId, true, null);
49
+ } // If the user is moving a block.
50
+
51
+
52
+ if (dropType === 'block') {
53
+ const sourceBlockIndex = getBlockIndex(sourceClientIds[0]); // If the user is dropping to the same position, return early.
54
+
55
+ if (sourceRootClientId === targetRootClientId && sourceBlockIndex === targetBlockIndex) {
56
+ return;
57
+ } // If the user is attempting to drop a block within its own
58
+ // nested blocks, return early as this would create infinite
59
+ // recursion.
60
+
61
+
62
+ if (sourceClientIds.includes(targetRootClientId) || getClientIdsOfDescendants(sourceClientIds).some(id => id === targetRootClientId)) {
63
+ return;
64
+ }
65
+
66
+ const isAtSameLevel = sourceRootClientId === targetRootClientId;
67
+ const draggedBlockCount = sourceClientIds.length; // If the block is kept at the same level and moved downwards,
68
+ // subtract to take into account that the blocks being dragged
69
+ // were removed from the block list above the insertion point.
70
+
71
+ const insertIndex = isAtSameLevel && sourceBlockIndex < targetBlockIndex ? targetBlockIndex - draggedBlockCount : targetBlockIndex;
72
+ moveBlocksToPosition(sourceClientIds, sourceRootClientId, targetRootClientId, insertIndex);
73
+ }
74
+ };
75
+ }
76
+ /**
77
+ * A React hook for handling block drop events.
78
+ *
79
+ * @return {Function} The event handler for a block drop event.
80
+ */
81
+
82
+
83
+ function useOnBlockDrop() {
84
+ const {
85
+ getBlockIndex,
86
+ getClientIdsOfDescendants
87
+ } = (0, _data.useSelect)(_store.store);
88
+ const {
89
+ insertBlocks,
90
+ moveBlocksToPosition,
91
+ clearSelectedBlock
92
+ } = (0, _data.useDispatch)(_store.store);
93
+ return onBlockDrop(getBlockIndex, getClientIdsOfDescendants, moveBlocksToPosition, insertBlocks, clearSelectedBlock);
94
+ }
95
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-on-block-drop/index.native.js"],"names":["onBlockDrop","getBlockIndex","getClientIdsOfDescendants","moveBlocksToPosition","insertBlocks","clearSelectedBlock","blocks","srcClientIds","sourceClientIds","srcRootClientId","sourceRootClientId","targetBlockIndex","targetRootClientId","type","dropType","blocksToInsert","map","block","sourceBlockIndex","includes","some","id","isAtSameLevel","draggedBlockCount","length","insertIndex","useOnBlockDrop","blockEditorStore"],"mappings":";;;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAT,CACNC,aADM,EAENC,yBAFM,EAGNC,oBAHM,EAINC,YAJM,EAKNC,kBALM,EAML;AACD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;AACA;AACA;;;AACe,SAASC,cAAT,GAA0B;AACxC,QAAM;AAAEzB,IAAAA,aAAF;AAAiBC,IAAAA;AAAjB,MAA+C,qBACpDyB,YADoD,CAArD;AAGA,QAAM;AACLvB,IAAAA,YADK;AAELD,IAAAA,oBAFK;AAGLE,IAAAA;AAHK,MAIF,uBAAasB,YAAb,CAJJ;AAMA,SAAO3B,WAAW,CACjBC,aADiB,EAEjBC,yBAFiB,EAGjBC,oBAHiB,EAIjBC,YAJiB,EAKjBC,kBALiB,CAAlB;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * A function that returns an event handler function for block drop events.\n *\n * @param {Function} getBlockIndex A function that gets the index of a block.\n * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.\n * @param {Function} moveBlocksToPosition A function that moves blocks.\n * @param {Function} insertBlocks A function that inserts blocks.\n * @param {Function} clearSelectedBlock A function that clears block selection.\n * @return {Function} The event handler for a block drop event.\n */\nexport function onBlockDrop(\n\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocksToPosition,\n\tinsertBlocks,\n\tclearSelectedBlock\n) {\n\treturn ( {\n\t\tblocks,\n\t\tsrcClientIds: sourceClientIds,\n\t\tsrcRootClientId: sourceRootClientId,\n\t\ttargetBlockIndex,\n\t\ttargetRootClientId,\n\t\ttype: dropType,\n\t} ) => {\n\t\t// If the user is inserting a block.\n\t\tif ( dropType === 'inserter' ) {\n\t\t\tclearSelectedBlock();\n\t\t\tconst blocksToInsert = blocks.map( ( block ) =>\n\t\t\t\tcloneBlock( block )\n\t\t\t);\n\t\t\tinsertBlocks(\n\t\t\t\tblocksToInsert,\n\t\t\t\ttargetBlockIndex,\n\t\t\t\ttargetRootClientId,\n\t\t\t\ttrue,\n\t\t\t\tnull\n\t\t\t);\n\t\t}\n\n\t\t// If the user is moving a block.\n\t\tif ( dropType === 'block' ) {\n\t\t\tconst sourceBlockIndex = getBlockIndex( sourceClientIds[ 0 ] );\n\n\t\t\t// If the user is dropping to the same position, return early.\n\t\t\tif (\n\t\t\t\tsourceRootClientId === targetRootClientId &&\n\t\t\t\tsourceBlockIndex === targetBlockIndex\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is attempting to drop a block within its own\n\t\t\t// nested blocks, return early as this would create infinite\n\t\t\t// recursion.\n\t\t\tif (\n\t\t\t\tsourceClientIds.includes( targetRootClientId ) ||\n\t\t\t\tgetClientIdsOfDescendants( sourceClientIds ).some(\n\t\t\t\t\t( id ) => id === targetRootClientId\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isAtSameLevel = sourceRootClientId === targetRootClientId;\n\t\t\tconst draggedBlockCount = sourceClientIds.length;\n\n\t\t\t// If the block is kept at the same level and moved downwards,\n\t\t\t// subtract to take into account that the blocks being dragged\n\t\t\t// were removed from the block list above the insertion point.\n\t\t\tconst insertIndex =\n\t\t\t\tisAtSameLevel && sourceBlockIndex < targetBlockIndex\n\t\t\t\t\t? targetBlockIndex - draggedBlockCount\n\t\t\t\t\t: targetBlockIndex;\n\n\t\t\tmoveBlocksToPosition(\n\t\t\t\tsourceClientIds,\n\t\t\t\tsourceRootClientId,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tinsertIndex\n\t\t\t);\n\t\t}\n\t};\n}\n\n/**\n * A React hook for handling block drop events.\n *\n * @return {Function} The event handler for a block drop event.\n */\nexport default function useOnBlockDrop() {\n\tconst { getBlockIndex, getClientIdsOfDescendants } = useSelect(\n\t\tblockEditorStore\n\t);\n\tconst {\n\t\tinsertBlocks,\n\t\tmoveBlocksToPosition,\n\t\tclearSelectedBlock,\n\t} = useDispatch( blockEditorStore );\n\n\treturn onBlockDrop(\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocksToPosition,\n\t\tinsertBlocks,\n\t\tclearSelectedBlock\n\t);\n}\n"]}
@@ -32,6 +32,11 @@ function Warning(_ref) {
32
32
  secondaryActions
33
33
  } = _ref;
34
34
  return (0, _element.createElement)("div", {
35
+ style: {
36
+ display: 'contents',
37
+ all: 'initial'
38
+ }
39
+ }, (0, _element.createElement)("div", {
35
40
  className: (0, _classnames.default)(className, 'block-editor-warning')
36
41
  }, (0, _element.createElement)("div", {
37
42
  className: "block-editor-warning__contents"
@@ -54,7 +59,7 @@ function Warning(_ref) {
54
59
  }, () => (0, _element.createElement)(_components.MenuGroup, null, secondaryActions.map((item, pos) => (0, _element.createElement)(_components.MenuItem, {
55
60
  onClick: item.onClick,
56
61
  key: pos
57
- }, item.title)))))));
62
+ }, item.title))))))));
58
63
  }
59
64
  /**
60
65
  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/warning/README.md
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/warning/index.js"],"names":["Warning","className","actions","children","secondaryActions","Children","count","map","action","i","moreHorizontal","position","item","pos","onClick","title"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AAXA;AACA;AACA;;AAGA;AACA;AACA;AAMA,SAASA,OAAT,OAAuE;AAAA,MAArD;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,OAAb;AAAsBC,IAAAA,QAAtB;AAAgCC,IAAAA;AAAhC,GAAqD;AACtE,SACC;AAAK,IAAA,SAAS,EAAG,yBAAYH,SAAZ,EAAuB,sBAAvB;AAAjB,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAG,IAAA,SAAS,EAAC;AAAb,KAA+CE,QAA/C,CADD,EAGG,CAAEE,kBAASC,KAAT,CAAgBJ,OAAhB,IAA4B,CAA5B,IAAiCE,gBAAnC,KACD;AAAK,IAAA,SAAS,EAAC;AAAf,KACGC,kBAASC,KAAT,CAAgBJ,OAAhB,IAA4B,CAA5B,IACDG,kBAASE,GAAT,CAAcL,OAAd,EAAuB,CAAEM,MAAF,EAAUC,CAAV,KACtB;AACC,IAAA,GAAG,EAAGA,CADP;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGD,MAJH,CADD,CAFF,EAUGJ,gBAAgB,IACjB,4BAAC,wBAAD;AACC,IAAA,SAAS,EAAC,iCADX;AAEC,IAAA,IAAI,EAAGM,qBAFR;AAGC,IAAA,KAAK,EAAG,cAAI,cAAJ,CAHT;AAIC,IAAA,YAAY,EAAG;AACdC,MAAAA,QAAQ,EAAE,aADI;AAEdV,MAAAA,SAAS,EAAE;AAFG,KAJhB;AAQC,IAAA,OAAO;AARR,KAUG,MACD,4BAAC,qBAAD,QACGG,gBAAgB,CAACG,GAAjB,CACD,CAAEK,IAAF,EAAQC,GAAR,KACC,4BAAC,oBAAD;AACC,IAAA,OAAO,EAAGD,IAAI,CAACE,OADhB;AAEC,IAAA,GAAG,EAAGD;AAFP,KAIGD,IAAI,CAACG,KAJR,CAFA,CADH,CAXF,CAXF,CAJF,CADD,CADD;AAgDA;AAED;AACA;AACA;;;eACef,O","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Children } from '@wordpress/element';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { moreHorizontal } from '@wordpress/icons';\n\nfunction Warning( { className, actions, children, secondaryActions } ) {\n\treturn (\n\t\t<div className={ classnames( className, 'block-editor-warning' ) }>\n\t\t\t<div className=\"block-editor-warning__contents\">\n\t\t\t\t<p className=\"block-editor-warning__message\">{ children }</p>\n\n\t\t\t\t{ ( Children.count( actions ) > 0 || secondaryActions ) && (\n\t\t\t\t\t<div className=\"block-editor-warning__actions\">\n\t\t\t\t\t\t{ Children.count( actions ) > 0 &&\n\t\t\t\t\t\t\tChildren.map( actions, ( action, i ) => (\n\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-warning__action\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ action }\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t{ secondaryActions && (\n\t\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\t\tclassName=\"block-editor-warning__secondary\"\n\t\t\t\t\t\t\t\ticon={ moreHorizontal }\n\t\t\t\t\t\t\t\tlabel={ __( 'More options' ) }\n\t\t\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\t\t\tposition: 'bottom left',\n\t\t\t\t\t\t\t\t\tclassName: 'block-editor-warning__dropdown',\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tnoIcons\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ () => (\n\t\t\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t\t\t{ secondaryActions.map(\n\t\t\t\t\t\t\t\t\t\t\t( item, pos ) => (\n\t\t\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ item.onClick }\n\t\t\t\t\t\t\t\t\t\t\t\t\tkey={ pos }\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ item.title }\n\t\t\t\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</DropdownMenu>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/warning/README.md\n */\nexport default Warning;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/warning/index.js"],"names":["Warning","className","actions","children","secondaryActions","display","all","Children","count","map","action","i","moreHorizontal","position","item","pos","onClick","title"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AAXA;AACA;AACA;;AAGA;AACA;AACA;AAMA,SAASA,OAAT,OAAuE;AAAA,MAArD;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,OAAb;AAAsBC,IAAAA,QAAtB;AAAgCC,IAAAA;AAAhC,GAAqD;AACtE,SACC;AAAK,IAAA,KAAK,EAAG;AAAEC,MAAAA,OAAO,EAAE,UAAX;AAAuBC,MAAAA,GAAG,EAAE;AAA5B;AAAb,KACC;AAAK,IAAA,SAAS,EAAG,yBAAYL,SAAZ,EAAuB,sBAAvB;AAAjB,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAG,IAAA,SAAS,EAAC;AAAb,KACGE,QADH,CADD,EAKG,CAAEI,kBAASC,KAAT,CAAgBN,OAAhB,IAA4B,CAA5B,IAAiCE,gBAAnC,KACD;AAAK,IAAA,SAAS,EAAC;AAAf,KACGG,kBAASC,KAAT,CAAgBN,OAAhB,IAA4B,CAA5B,IACDK,kBAASE,GAAT,CAAcP,OAAd,EAAuB,CAAEQ,MAAF,EAAUC,CAAV,KACtB;AACC,IAAA,GAAG,EAAGA,CADP;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGD,MAJH,CADD,CAFF,EAUGN,gBAAgB,IACjB,4BAAC,wBAAD;AACC,IAAA,SAAS,EAAC,iCADX;AAEC,IAAA,IAAI,EAAGQ,qBAFR;AAGC,IAAA,KAAK,EAAG,cAAI,cAAJ,CAHT;AAIC,IAAA,YAAY,EAAG;AACdC,MAAAA,QAAQ,EAAE,aADI;AAEdZ,MAAAA,SAAS,EACR;AAHa,KAJhB;AASC,IAAA,OAAO;AATR,KAWG,MACD,4BAAC,qBAAD,QACGG,gBAAgB,CAACK,GAAjB,CACD,CAAEK,IAAF,EAAQC,GAAR,KACC,4BAAC,oBAAD;AACC,IAAA,OAAO,EAAGD,IAAI,CAACE,OADhB;AAEC,IAAA,GAAG,EAAGD;AAFP,KAIGD,IAAI,CAACG,KAJR,CAFA,CADH,CAZF,CAXF,CANF,CADD,CADD,CADD;AAqDA;AAED;AACA;AACA;;;eACejB,O","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Children } from '@wordpress/element';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { moreHorizontal } from '@wordpress/icons';\n\nfunction Warning( { className, actions, children, secondaryActions } ) {\n\treturn (\n\t\t<div style={ { display: 'contents', all: 'initial' } }>\n\t\t\t<div className={ classnames( className, 'block-editor-warning' ) }>\n\t\t\t\t<div className=\"block-editor-warning__contents\">\n\t\t\t\t\t<p className=\"block-editor-warning__message\">\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</p>\n\n\t\t\t\t\t{ ( Children.count( actions ) > 0 || secondaryActions ) && (\n\t\t\t\t\t\t<div className=\"block-editor-warning__actions\">\n\t\t\t\t\t\t\t{ Children.count( actions ) > 0 &&\n\t\t\t\t\t\t\t\tChildren.map( actions, ( action, i ) => (\n\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-warning__action\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ action }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t{ secondaryActions && (\n\t\t\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-warning__secondary\"\n\t\t\t\t\t\t\t\t\ticon={ moreHorizontal }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'More options' ) }\n\t\t\t\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\t\t\t\tposition: 'bottom left',\n\t\t\t\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-warning__dropdown',\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tnoIcons\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ () => (\n\t\t\t\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t\t\t\t{ secondaryActions.map(\n\t\t\t\t\t\t\t\t\t\t\t\t( item, pos ) => (\n\t\t\t\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ item.onClick }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tkey={ pos }\n\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ item.title }\n\t\t\t\t\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</DropdownMenu>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/warning/README.md\n */\nexport default Warning;\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"names":["ANCHOR_REGEX","ANCHOR_SCHEMA","type","source","attribute","selector","addAttribute","settings","attributes","anchor","withInspectorControl","BlockEdit","props","hasAnchor","name","isSelected","isWeb","Platform","OS","textControl","nextValue","replace","setAttributes","addSaveProps","extraProps","blockType","id"],"mappings":";;;;;;;;;AAaA;;AAVA;;AAKA;;AACA;;AACA;;AAC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AAuC,uBAAvC,EAAgElB,YAAhE;AACA,sBACC,kBADD,EAEC,2CAFD,EAGCI,oBAHD;AAKA,sBACC,kCADD,EAEC,wBAFD,EAGCa,YAHD","sourcesContent":["/**\n * External dependencies\n */\nimport { has } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\nconst ANCHOR_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'id',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( has( settings.attributes, [ 'anchor', 'type' ] ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: ANCHOR_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning the anchor ID, if block supports anchor.\n *\n * @param {WPComponent} BlockEdit Original component.\n *\n * @return {WPComponent} Wrapped component.\n */\nexport const withInspectorControl = createHigherOrderComponent(\n\t( BlockEdit ) => {\n\t\treturn ( props ) => {\n\t\t\tconst hasAnchor = hasBlockSupport( props.name, 'anchor' );\n\n\t\t\tif ( hasAnchor && props.isSelected ) {\n\t\t\t\tconst isWeb = Platform.OS === 'web';\n\t\t\t\tconst textControl = (\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tclassName=\"html-anchor-control\"\n\t\t\t\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/support/article/page-jumps/'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t\t\t\t</ExternalLink>\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\tvalue={ props.attributes.anchor || '' }\n\t\t\t\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\tanchor: nextValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t);\n\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ /*\n\t\t\t\t\t\t * We plan to remove scoping anchors to 'core/heading' to support\n\t\t\t\t\t\t * anchors for all eligble blocks. Additionally we plan to explore\n\t\t\t\t\t\t * leveraging InspectorAdvancedControls instead of a custom\n\t\t\t\t\t\t * PanelBody title. https://git.io/Jtcov\n\t\t\t\t\t\t */ }\n\t\t\t\t\t\t{ ! isWeb && props.name === 'core/heading' && (\n\t\t\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t\t\t<PanelBody title={ __( 'Heading settings' ) }>\n\t\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t};\n\t},\n\t'withInspectorControl'\n);\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/anchor/with-inspector-control',\n\twithInspectorControl\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/anchor/save-props',\n\taddSaveProps\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"names":["ANCHOR_REGEX","ANCHOR_SCHEMA","type","source","attribute","selector","addAttribute","settings","attributes","anchor","withInspectorControl","BlockEdit","props","hasAnchor","name","isSelected","isWeb","Platform","OS","textControl","nextValue","replace","setAttributes","addSaveProps","extraProps","blockType","id"],"mappings":";;;;;;;;;AAaA;;AAVA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA,MAAMA,YAAY,GAAG,QAArB;AAEA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,IAAI,EAAE,QADe;AAErBC,EAAAA,MAAM,EAAE,WAFa;AAGrBC,EAAAA,SAAS,EAAE,IAHU;AAIrBC,EAAAA,QAAQ,EAAE;AAJW,CAAtB;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,YAAT,CAAuBC,QAAvB,EAAkC;AACxC;AACA,MAAK,iBAAKA,QAAQ,CAACC,UAAd,EAA0B,CAAE,QAAF,EAAY,MAAZ,CAA1B,CAAL,EAAwD;AACvD,WAAOD,QAAP;AACA;;AACD,MAAK,6BAAiBA,QAAjB,EAA2B,QAA3B,CAAL,EAA6C;AAC5C;AACAA,IAAAA,QAAQ,CAACC,UAAT,GAAsB,EACrB,GAAGD,QAAQ,CAACC,UADS;AAErBC,MAAAA,MAAM,EAAER;AAFa,KAAtB;AAIA;;AAED,SAAOM,QAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMG,oBAAoB,GAAG,yCACjCC,SAAF,IAAiB;AAChB,SAASC,KAAF,IAAa;AACnB,UAAMC,SAAS,GAAG,6BAAiBD,KAAK,CAACE,IAAvB,EAA6B,QAA7B,CAAlB;;AAEA,QAAKD,SAAS,IAAID,KAAK,CAACG,UAAxB,EAAqC;AACpC,YAAMC,KAAK,GAAGC,kBAASC,EAAT,KAAgB,KAA9B;AACA,YAAMC,WAAW,GAChB,4BAAC,uBAAD;AACC,QAAA,SAAS,EAAC,qBADX;AAEC,QAAA,KAAK,EAAG,cAAI,aAAJ,CAFT;AA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B,UAAU,CAACC,MAAX,KAAsB,EAAtB,GAA2B,IAA3B,GAAkCD,UAAU,CAACC,MAA7D;AACA;;AAED,SAAOe,UAAP;AACA;;AAED,sBAAW,0BAAX,EAAuC,uBAAvC,EAAgElB,YAAhE;AACA,sBACC,kBADD,EAEC,2CAFD,EAGCI,oBAHD;AAKA,sBACC,kCADD,EAEC,wBAFD,EAGCa,YAHD","sourcesContent":["/**\n * External dependencies\n */\nimport { has } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\nconst ANCHOR_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'id',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( has( settings.attributes, [ 'anchor', 'type' ] ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: ANCHOR_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning the anchor ID, if block supports anchor.\n *\n * @param {WPComponent} BlockEdit Original component.\n *\n * @return {WPComponent} Wrapped component.\n */\nexport const withInspectorControl = createHigherOrderComponent(\n\t( BlockEdit ) => {\n\t\treturn ( props ) => {\n\t\t\tconst hasAnchor = hasBlockSupport( props.name, 'anchor' );\n\n\t\t\tif ( hasAnchor && props.isSelected ) {\n\t\t\t\tconst isWeb = Platform.OS === 'web';\n\t\t\t\tconst textControl = (\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tclassName=\"html-anchor-control\"\n\t\t\t\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/support/article/page-jumps/'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t\t\t\t</ExternalLink>\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\tvalue={ props.attributes.anchor || '' }\n\t\t\t\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\tanchor: nextValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t);\n\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ /*\n\t\t\t\t\t\t * We plan to remove scoping anchors to 'core/heading' to support\n\t\t\t\t\t\t * anchors for all eligble blocks. Additionally we plan to explore\n\t\t\t\t\t\t * leveraging InspectorAdvancedControls instead of a custom\n\t\t\t\t\t\t * PanelBody title. https://github.com/WordPress/gutenberg/issues/28363\n\t\t\t\t\t\t */ }\n\t\t\t\t\t\t{ ! isWeb && props.name === 'core/heading' && (\n\t\t\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t\t\t<PanelBody title={ __( 'Heading settings' ) }>\n\t\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t};\n\t},\n\t'withInspectorControl'\n);\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/anchor/with-inspector-control',\n\twithInspectorControl\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/anchor/save-props',\n\taddSaveProps\n);\n"]}
@@ -320,13 +320,8 @@ function BorderPanel(props) {
320
320
  colors: colors,
321
321
  enableAlpha: true,
322
322
  onChange: onBorderChange,
323
- popoverClassNames: {
324
- linked: 'block-editor__border-box-control__popover',
325
- top: 'block-editor__border-box-control__popover-top',
326
- right: 'block-editor__border-box-control__popover-right',
327
- bottom: 'block-editor__border-box-control__popover-bottom',
328
- left: 'block-editor__border-box-control__popover-left'
329
- },
323
+ popoverPlacement: "left-start",
324
+ popoverOffset: 40,
330
325
  showStyle: isStyleSupported,
331
326
  value: hydratedBorder,
332
327
  __experimentalHasMultipleOrigins: true,