@wordpress/block-editor 14.9.0 → 14.10.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 (370) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +40 -0
  4. package/build/components/audio-player/index.native.js +1 -1
  5. package/build/components/audio-player/index.native.js.map +1 -1
  6. package/build/components/background-image-control/index.js +4 -0
  7. package/build/components/background-image-control/index.js.map +1 -1
  8. package/build/components/block-alignment-matrix-control/index.js +32 -0
  9. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  10. package/build/components/block-card/index.js +45 -8
  11. package/build/components/block-card/index.js.map +1 -1
  12. package/build/components/block-edit/edit.js +147 -10
  13. package/build/components/block-edit/edit.js.map +1 -1
  14. package/build/components/block-list/index.js +1 -2
  15. package/build/components/block-list/index.js.map +1 -1
  16. package/build/components/block-list/use-block-props/index.js +2 -2
  17. package/build/components/block-list/use-block-props/index.js.map +1 -1
  18. package/build/components/block-list/zoom-out-separator.js +20 -3
  19. package/build/components/block-list/zoom-out-separator.js.map +1 -1
  20. package/build/components/block-settings-menu/block-settings-dropdown.js +5 -8
  21. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  22. package/build/components/block-styles/utils.js +3 -3
  23. package/build/components/block-styles/utils.js.map +1 -1
  24. package/build/components/block-tools/zoom-out-mode-inserters.js +19 -6
  25. package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  26. package/build/components/button-block-appender/index.js +1 -5
  27. package/build/components/button-block-appender/index.js.map +1 -1
  28. package/build/components/child-layout-control/index.js +6 -0
  29. package/build/components/child-layout-control/index.js.map +1 -1
  30. package/build/components/colors-gradients/dropdown.js +51 -11
  31. package/build/components/colors-gradients/dropdown.js.map +1 -1
  32. package/build/components/contrast-checker/index.native.js +1 -1
  33. package/build/components/contrast-checker/index.native.js.map +1 -1
  34. package/build/components/date-format-picker/index.js +7 -16
  35. package/build/components/date-format-picker/index.js.map +1 -1
  36. package/build/components/font-appearance-control/index.js +9 -0
  37. package/build/components/font-appearance-control/index.js.map +1 -1
  38. package/build/components/font-family/index.js +10 -1
  39. package/build/components/font-family/index.js.map +1 -1
  40. package/build/components/global-styles/color-panel.js +3 -0
  41. package/build/components/global-styles/color-panel.js.map +1 -1
  42. package/build/components/global-styles/typography-utils.js +1 -1
  43. package/build/components/global-styles/typography-utils.js.map +1 -1
  44. package/build/components/global-styles/use-global-styles-output.js +2 -2
  45. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  46. package/build/components/grid/grid-visualizer.js +9 -0
  47. package/build/components/grid/grid-visualizer.js.map +1 -1
  48. package/build/components/grid/utils.js +12 -1
  49. package/build/components/grid/utils.js.map +1 -1
  50. package/build/components/iframe/index.js +1 -1
  51. package/build/components/iframe/index.js.map +1 -1
  52. package/build/components/inner-blocks/use-inner-block-template-sync.js +11 -11
  53. package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  54. package/build/components/inserter/block-patterns-explorer/index.js +1 -1
  55. package/build/components/inserter/block-patterns-explorer/index.js.map +1 -1
  56. package/build/components/inserter/block-patterns-tab/index.js +1 -1
  57. package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
  58. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +4 -4
  59. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  60. package/build/components/inserter/block-patterns-tab/patterns-filter.js +2 -2
  61. package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  62. package/build/components/inserter/category-tabs/index.js +1 -2
  63. package/build/components/inserter/category-tabs/index.js.map +1 -1
  64. package/build/components/inserter/index.js +6 -15
  65. package/build/components/inserter/index.js.map +1 -1
  66. package/build/components/inserter/quick-inserter.js +2 -13
  67. package/build/components/inserter/quick-inserter.js.map +1 -1
  68. package/build/components/keyboard-shortcuts/index.js +2 -2
  69. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  70. package/build/components/line-height-control/index.js +9 -0
  71. package/build/components/line-height-control/index.js.map +1 -1
  72. package/build/components/media-placeholder/index.js +2 -2
  73. package/build/components/media-placeholder/index.js.map +1 -1
  74. package/build/components/media-replace-flow/index.js +26 -26
  75. package/build/components/media-replace-flow/index.js.map +1 -1
  76. package/build/components/plain-text/index.js +34 -0
  77. package/build/components/plain-text/index.js.map +1 -1
  78. package/build/components/provider/index.js +61 -5
  79. package/build/components/provider/index.js.map +1 -1
  80. package/build/components/provider/use-media-upload-settings.js +28 -0
  81. package/build/components/provider/use-media-upload-settings.js.map +1 -0
  82. package/build/components/resolution-tool/index.js +3 -1
  83. package/build/components/resolution-tool/index.js.map +1 -1
  84. package/build/components/responsive-block-control/index.js +1 -1
  85. package/build/components/responsive-block-control/index.js.map +1 -1
  86. package/build/components/rich-text/event-listeners/delete.js +7 -1
  87. package/build/components/rich-text/event-listeners/delete.js.map +1 -1
  88. package/build/components/rich-text/index.js +2 -2
  89. package/build/components/rich-text/index.js.map +1 -1
  90. package/build/components/use-block-drop-zone/index.js +2 -1
  91. package/build/components/use-block-drop-zone/index.js.map +1 -1
  92. package/build/hooks/background.js +2 -0
  93. package/build/hooks/background.js.map +1 -1
  94. package/build/hooks/block-bindings.js +15 -14
  95. package/build/hooks/block-bindings.js.map +1 -1
  96. package/build/hooks/border.js +3 -3
  97. package/build/hooks/border.js.map +1 -1
  98. package/build/hooks/color.js +1 -1
  99. package/build/hooks/color.js.map +1 -1
  100. package/build/hooks/dimensions.js +2 -2
  101. package/build/hooks/dimensions.js.map +1 -1
  102. package/build/hooks/font-family.js +1 -1
  103. package/build/hooks/font-family.js.map +1 -1
  104. package/build/hooks/gap.js +2 -2
  105. package/build/hooks/gap.js.map +1 -1
  106. package/build/hooks/index.js +0 -1
  107. package/build/hooks/index.js.map +1 -1
  108. package/build/hooks/index.native.js +7 -0
  109. package/build/hooks/index.native.js.map +1 -1
  110. package/build/hooks/style.js +7 -7
  111. package/build/hooks/style.js.map +1 -1
  112. package/build/hooks/supports.js +7 -7
  113. package/build/hooks/supports.js.map +1 -1
  114. package/build/hooks/typography.js +6 -6
  115. package/build/hooks/typography.js.map +1 -1
  116. package/build/hooks/use-zoom-out.js +12 -1
  117. package/build/hooks/use-zoom-out.js.map +1 -1
  118. package/build/hooks/utils.js +1 -1
  119. package/build/hooks/utils.js.map +1 -1
  120. package/build/store/private-actions.js +1 -1
  121. package/build/store/private-actions.js.map +1 -1
  122. package/build/store/private-selectors.js +11 -1
  123. package/build/store/private-selectors.js.map +1 -1
  124. package/build/store/reducer.js +93 -12
  125. package/build/store/reducer.js.map +1 -1
  126. package/build/store/selectors.js +6 -8
  127. package/build/store/selectors.js.map +1 -1
  128. package/build/utils/block-bindings.js +95 -0
  129. package/build/utils/block-bindings.js.map +1 -1
  130. package/build-module/components/audio-player/index.native.js +2 -2
  131. package/build-module/components/audio-player/index.native.js.map +1 -1
  132. package/build-module/components/background-image-control/index.js +5 -1
  133. package/build-module/components/background-image-control/index.js.map +1 -1
  134. package/build-module/components/block-alignment-matrix-control/index.js +32 -0
  135. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  136. package/build-module/components/block-card/index.js +45 -8
  137. package/build-module/components/block-card/index.js.map +1 -1
  138. package/build-module/components/block-edit/edit.js +148 -11
  139. package/build-module/components/block-edit/edit.js.map +1 -1
  140. package/build-module/components/block-list/index.js +2 -3
  141. package/build-module/components/block-list/index.js.map +1 -1
  142. package/build-module/components/block-list/use-block-props/index.js +1 -1
  143. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  144. package/build-module/components/block-list/zoom-out-separator.js +20 -3
  145. package/build-module/components/block-list/zoom-out-separator.js.map +1 -1
  146. package/build-module/components/block-settings-menu/block-settings-dropdown.js +5 -8
  147. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  148. package/build-module/components/block-styles/utils.js +3 -3
  149. package/build-module/components/block-styles/utils.js.map +1 -1
  150. package/build-module/components/block-tools/zoom-out-mode-inserters.js +19 -6
  151. package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  152. package/build-module/components/button-block-appender/index.js +2 -6
  153. package/build-module/components/button-block-appender/index.js.map +1 -1
  154. package/build-module/components/child-layout-control/index.js +7 -1
  155. package/build-module/components/child-layout-control/index.js.map +1 -1
  156. package/build-module/components/colors-gradients/dropdown.js +51 -11
  157. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  158. package/build-module/components/contrast-checker/index.native.js +2 -2
  159. package/build-module/components/contrast-checker/index.native.js.map +1 -1
  160. package/build-module/components/date-format-picker/index.js +7 -16
  161. package/build-module/components/date-format-picker/index.js.map +1 -1
  162. package/build-module/components/font-appearance-control/index.js +8 -0
  163. package/build-module/components/font-appearance-control/index.js.map +1 -1
  164. package/build-module/components/font-family/index.js +10 -1
  165. package/build-module/components/font-family/index.js.map +1 -1
  166. package/build-module/components/global-styles/color-panel.js +3 -0
  167. package/build-module/components/global-styles/color-panel.js.map +1 -1
  168. package/build-module/components/global-styles/typography-utils.js +1 -1
  169. package/build-module/components/global-styles/typography-utils.js.map +1 -1
  170. package/build-module/components/global-styles/use-global-styles-output.js +2 -2
  171. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  172. package/build-module/components/grid/grid-visualizer.js +9 -0
  173. package/build-module/components/grid/grid-visualizer.js.map +1 -1
  174. package/build-module/components/grid/utils.js +12 -1
  175. package/build-module/components/grid/utils.js.map +1 -1
  176. package/build-module/components/iframe/index.js +1 -1
  177. package/build-module/components/iframe/index.js.map +1 -1
  178. package/build-module/components/inner-blocks/use-inner-block-template-sync.js +12 -12
  179. package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  180. package/build-module/components/inserter/block-patterns-explorer/index.js +1 -1
  181. package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -1
  182. package/build-module/components/inserter/block-patterns-tab/index.js +1 -1
  183. package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
  184. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +4 -4
  185. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  186. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js +2 -2
  187. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  188. package/build-module/components/inserter/category-tabs/index.js +1 -2
  189. package/build-module/components/inserter/category-tabs/index.js.map +1 -1
  190. package/build-module/components/inserter/index.js +6 -15
  191. package/build-module/components/inserter/index.js.map +1 -1
  192. package/build-module/components/inserter/quick-inserter.js +2 -13
  193. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  194. package/build-module/components/keyboard-shortcuts/index.js +2 -2
  195. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  196. package/build-module/components/line-height-control/index.js +8 -0
  197. package/build-module/components/line-height-control/index.js.map +1 -1
  198. package/build-module/components/media-placeholder/index.js +3 -3
  199. package/build-module/components/media-placeholder/index.js.map +1 -1
  200. package/build-module/components/media-replace-flow/index.js +28 -28
  201. package/build-module/components/media-replace-flow/index.js.map +1 -1
  202. package/build-module/components/plain-text/index.js +34 -0
  203. package/build-module/components/plain-text/index.js.map +1 -1
  204. package/build-module/components/provider/index.js +62 -5
  205. package/build-module/components/provider/index.js.map +1 -1
  206. package/build-module/components/provider/use-media-upload-settings.js +22 -0
  207. package/build-module/components/provider/use-media-upload-settings.js.map +1 -0
  208. package/build-module/components/resolution-tool/index.js +3 -1
  209. package/build-module/components/resolution-tool/index.js.map +1 -1
  210. package/build-module/components/responsive-block-control/index.js +1 -1
  211. package/build-module/components/responsive-block-control/index.js.map +1 -1
  212. package/build-module/components/rich-text/event-listeners/delete.js +7 -1
  213. package/build-module/components/rich-text/event-listeners/delete.js.map +1 -1
  214. package/build-module/components/rich-text/index.js +1 -1
  215. package/build-module/components/rich-text/index.js.map +1 -1
  216. package/build-module/components/use-block-drop-zone/index.js +2 -1
  217. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  218. package/build-module/hooks/background.js +2 -0
  219. package/build-module/hooks/background.js.map +1 -1
  220. package/build-module/hooks/block-bindings.js +13 -12
  221. package/build-module/hooks/block-bindings.js.map +1 -1
  222. package/build-module/hooks/border.js +3 -3
  223. package/build-module/hooks/border.js.map +1 -1
  224. package/build-module/hooks/color.js +1 -1
  225. package/build-module/hooks/color.js.map +1 -1
  226. package/build-module/hooks/dimensions.js +2 -2
  227. package/build-module/hooks/dimensions.js.map +1 -1
  228. package/build-module/hooks/font-family.js +1 -1
  229. package/build-module/hooks/font-family.js.map +1 -1
  230. package/build-module/hooks/gap.js +2 -2
  231. package/build-module/hooks/gap.js.map +1 -1
  232. package/build-module/hooks/index.js +0 -1
  233. package/build-module/hooks/index.js.map +1 -1
  234. package/build-module/hooks/index.native.js +1 -0
  235. package/build-module/hooks/index.native.js.map +1 -1
  236. package/build-module/hooks/style.js +7 -7
  237. package/build-module/hooks/style.js.map +1 -1
  238. package/build-module/hooks/supports.js +7 -7
  239. package/build-module/hooks/supports.js.map +1 -1
  240. package/build-module/hooks/typography.js +6 -6
  241. package/build-module/hooks/typography.js.map +1 -1
  242. package/build-module/hooks/use-zoom-out.js +12 -2
  243. package/build-module/hooks/use-zoom-out.js.map +1 -1
  244. package/build-module/hooks/utils.js +1 -1
  245. package/build-module/hooks/utils.js.map +1 -1
  246. package/build-module/store/private-actions.js +1 -1
  247. package/build-module/store/private-actions.js.map +1 -1
  248. package/build-module/store/private-selectors.js +11 -1
  249. package/build-module/store/private-selectors.js.map +1 -1
  250. package/build-module/store/reducer.js +93 -12
  251. package/build-module/store/reducer.js.map +1 -1
  252. package/build-module/store/selectors.js +6 -8
  253. package/build-module/store/selectors.js.map +1 -1
  254. package/build-module/utils/block-bindings.js +90 -0
  255. package/build-module/utils/block-bindings.js.map +1 -1
  256. package/build-style/style-rtl.css +27 -9
  257. package/build-style/style.css +27 -9
  258. package/package.json +33 -33
  259. package/src/components/audio-player/index.native.js +2 -2
  260. package/src/components/background-image-control/index.js +4 -0
  261. package/src/components/background-image-control/style.scss +4 -2
  262. package/src/components/block-alignment-matrix-control/README.md +29 -6
  263. package/src/components/block-alignment-matrix-control/index.js +31 -0
  264. package/src/components/block-alignment-matrix-control/stories/index.story.js +78 -0
  265. package/src/components/block-card/README.md +7 -0
  266. package/src/components/block-card/index.js +41 -12
  267. package/src/components/block-card/stories/index.story.js +79 -0
  268. package/src/components/block-card/style.scss +9 -1
  269. package/src/components/block-edit/edit.js +218 -11
  270. package/src/components/block-list/index.js +2 -7
  271. package/src/components/block-list/use-block-props/index.js +1 -1
  272. package/src/components/block-list/zoom-out-separator.js +30 -0
  273. package/src/components/block-settings-menu/block-settings-dropdown.js +17 -20
  274. package/src/components/block-styles/utils.js +3 -3
  275. package/src/components/block-title/stories/index.story.js +76 -0
  276. package/src/components/block-tools/style.scss +1 -0
  277. package/src/components/block-tools/zoom-out-mode-inserters.js +21 -3
  278. package/src/components/border-radius-control/README.md +59 -0
  279. package/src/components/border-radius-control/stories/index.story.js +58 -0
  280. package/src/components/button-block-appender/index.js +2 -7
  281. package/src/components/child-layout-control/index.js +14 -0
  282. package/src/components/colors-gradients/dropdown.js +57 -8
  283. package/src/components/colors-gradients/style.scss +5 -0
  284. package/src/components/contrast-checker/index.native.js +2 -2
  285. package/src/components/contrast-checker/stories/index.story.js +117 -0
  286. package/src/components/date-format-picker/README.md +6 -13
  287. package/src/components/date-format-picker/index.js +10 -17
  288. package/src/components/date-format-picker/stories/index.story.js +69 -0
  289. package/src/components/date-format-picker/style.scss +3 -1
  290. package/src/components/default-block-appender/content.scss +1 -0
  291. package/src/components/dimensions-tool/stories/aspect-ratio-tool.story.js +2 -1
  292. package/src/components/dimensions-tool/stories/index.story.js +2 -1
  293. package/src/components/dimensions-tool/stories/scale-tool.story.js +2 -1
  294. package/src/components/dimensions-tool/stories/width-height-tool.story.js +2 -1
  295. package/src/components/font-appearance-control/index.js +15 -0
  296. package/src/components/font-family/README.md +1 -0
  297. package/src/components/font-family/index.js +17 -1
  298. package/src/components/font-family/stories/index.story.js +1 -0
  299. package/src/components/global-styles/color-panel.js +3 -0
  300. package/src/components/global-styles/test/use-global-styles-output.js +1 -1
  301. package/src/components/global-styles/typography-utils.js +1 -1
  302. package/src/components/global-styles/use-global-styles-output.js +2 -2
  303. package/src/components/grid/grid-visualizer.js +11 -0
  304. package/src/components/grid/utils.js +19 -1
  305. package/src/components/iframe/index.js +1 -1
  306. package/src/components/inner-blocks/use-inner-block-template-sync.js +17 -10
  307. package/src/components/inserter/block-patterns-explorer/index.js +2 -3
  308. package/src/components/inserter/block-patterns-tab/index.js +3 -1
  309. package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +4 -4
  310. package/src/components/inserter/block-patterns-tab/patterns-filter.js +2 -2
  311. package/src/components/inserter/category-tabs/index.js +3 -2
  312. package/src/components/inserter/index.js +1 -13
  313. package/src/components/inserter/quick-inserter.js +2 -25
  314. package/src/components/keyboard-shortcuts/index.js +2 -2
  315. package/src/components/line-height-control/README.md +1 -0
  316. package/src/components/line-height-control/index.js +12 -0
  317. package/src/components/line-height-control/stories/index.story.js +1 -0
  318. package/src/components/line-height-control/test/index.js +7 -1
  319. package/src/components/list-view/style.scss +10 -5
  320. package/src/components/media-placeholder/index.js +3 -3
  321. package/src/components/media-replace-flow/README.md +7 -0
  322. package/src/components/media-replace-flow/index.js +28 -36
  323. package/src/components/media-replace-flow/style.scss +6 -6
  324. package/src/components/plain-text/README.md +2 -2
  325. package/src/components/plain-text/index.js +34 -0
  326. package/src/components/plain-text/stories/index.story.js +75 -0
  327. package/src/components/provider/index.js +81 -4
  328. package/src/components/provider/use-media-upload-settings.js +25 -0
  329. package/src/components/resolution-tool/index.js +2 -0
  330. package/src/components/resolution-tool/stories/index.story.js +36 -8
  331. package/src/components/responsive-block-control/index.js +1 -1
  332. package/src/components/rich-text/event-listeners/delete.js +6 -1
  333. package/src/components/rich-text/index.js +1 -1
  334. package/src/components/text-alignment-control/README.md +49 -0
  335. package/src/components/text-alignment-control/stories/index.story.js +56 -18
  336. package/src/components/text-decoration-control/README.md +0 -1
  337. package/src/components/text-decoration-control/stories/index.story.js +51 -16
  338. package/src/components/text-transform-control/README.md +3 -4
  339. package/src/components/text-transform-control/stories/index.story.js +53 -16
  340. package/src/components/use-block-drop-zone/index.js +8 -1
  341. package/src/components/warning/stories/index.story.js +86 -0
  342. package/src/hooks/background.js +6 -0
  343. package/src/hooks/block-bindings.js +17 -18
  344. package/src/hooks/border.js +9 -3
  345. package/src/hooks/color.js +1 -1
  346. package/src/hooks/dimensions.js +2 -2
  347. package/src/hooks/font-family.js +1 -1
  348. package/src/hooks/gap.js +2 -2
  349. package/src/hooks/index.js +0 -1
  350. package/src/hooks/index.native.js +1 -0
  351. package/src/hooks/style.js +13 -7
  352. package/src/hooks/supports.js +7 -7
  353. package/src/hooks/test/style.js +2 -1
  354. package/src/hooks/typography.js +6 -6
  355. package/src/hooks/use-zoom-out.js +10 -2
  356. package/src/hooks/utils.js +1 -1
  357. package/src/store/private-actions.js +1 -0
  358. package/src/store/private-selectors.js +15 -5
  359. package/src/store/reducer.js +112 -19
  360. package/src/store/selectors.js +6 -8
  361. package/src/store/test/private-selectors.js +53 -9
  362. package/src/store/test/reducer.js +172 -166
  363. package/src/store/test/selectors.js +23 -0
  364. package/src/utils/block-bindings.js +95 -0
  365. package/tsconfig.json +2 -5
  366. package/build/hooks/use-bindings-attributes.js +0 -262
  367. package/build/hooks/use-bindings-attributes.js.map +0 -1
  368. package/build-module/hooks/use-bindings-attributes.js +0 -253
  369. package/build-module/hooks/use-bindings-attributes.js.map +0 -1
  370. package/src/hooks/use-bindings-attributes.js +0 -322
@@ -1,262 +0,0 @@
1
- /* wp:polyfill */
2
- "use strict";
3
-
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.canBindAttribute = canBindAttribute;
9
- exports.canBindBlock = canBindBlock;
10
- exports.getBindableAttributes = getBindableAttributes;
11
- exports.withBlockBindingSupport = void 0;
12
- var _blocks = require("@wordpress/blocks");
13
- var _compose = require("@wordpress/compose");
14
- var _data = require("@wordpress/data");
15
- var _element = require("@wordpress/element");
16
- var _hooks = require("@wordpress/hooks");
17
- var _isUrlLike = _interopRequireDefault(require("../components/link-control/is-url-like"));
18
- var _lockUnlock = require("../lock-unlock");
19
- var _blockContext = _interopRequireDefault(require("../components/block-context"));
20
- var _jsxRuntime = require("react/jsx-runtime");
21
- /**
22
- * WordPress dependencies
23
- */
24
-
25
- /**
26
- * Internal dependencies
27
- */
28
-
29
- /** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */
30
- /** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */
31
-
32
- /**
33
- * Given a binding of block attributes, returns a higher order component that
34
- * overrides its `attributes` and `setAttributes` props to sync any changes needed.
35
- *
36
- * @return {WPHigherOrderComponent} Higher-order component.
37
- */const BLOCK_BINDINGS_ALLOWED_BLOCKS = {
38
- 'core/paragraph': ['content'],
39
- 'core/heading': ['content'],
40
- 'core/image': ['id', 'url', 'title', 'alt'],
41
- 'core/button': ['url', 'text', 'linkTarget', 'rel']
42
- };
43
- const DEFAULT_ATTRIBUTE = '__default';
44
-
45
- /**
46
- * Returns the bindings with the `__default` binding for pattern overrides
47
- * replaced with the full-set of supported attributes. e.g.:
48
- *
49
- * bindings passed in: `{ __default: { source: 'core/pattern-overrides' } }`
50
- * bindings returned: `{ content: { source: 'core/pattern-overrides' } }`
51
- *
52
- * @param {string} blockName The block name (e.g. 'core/paragraph').
53
- * @param {Object} bindings A block's bindings from the metadata attribute.
54
- *
55
- * @return {Object} The bindings with default replaced for pattern overrides.
56
- */
57
- function replacePatternOverrideDefaultBindings(blockName, bindings) {
58
- // The `__default` binding currently only works for pattern overrides.
59
- if (bindings?.[DEFAULT_ATTRIBUTE]?.source === 'core/pattern-overrides') {
60
- const supportedAttributes = BLOCK_BINDINGS_ALLOWED_BLOCKS[blockName];
61
- const bindingsWithDefaults = {};
62
- for (const attributeName of supportedAttributes) {
63
- // If the block has mixed binding sources, retain any non pattern override bindings.
64
- const bindingSource = bindings[attributeName] ? bindings[attributeName] : {
65
- source: 'core/pattern-overrides'
66
- };
67
- bindingsWithDefaults[attributeName] = bindingSource;
68
- }
69
- return bindingsWithDefaults;
70
- }
71
- return bindings;
72
- }
73
-
74
- /**
75
- * Based on the given block name,
76
- * check if it is possible to bind the block.
77
- *
78
- * @param {string} blockName - The block name.
79
- * @return {boolean} Whether it is possible to bind the block to sources.
80
- */
81
- function canBindBlock(blockName) {
82
- return blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS;
83
- }
84
-
85
- /**
86
- * Based on the given block name and attribute name,
87
- * check if it is possible to bind the block attribute.
88
- *
89
- * @param {string} blockName - The block name.
90
- * @param {string} attributeName - The attribute name.
91
- * @return {boolean} Whether it is possible to bind the block attribute.
92
- */
93
- function canBindAttribute(blockName, attributeName) {
94
- return canBindBlock(blockName) && BLOCK_BINDINGS_ALLOWED_BLOCKS[blockName].includes(attributeName);
95
- }
96
- function getBindableAttributes(blockName) {
97
- return BLOCK_BINDINGS_ALLOWED_BLOCKS[blockName];
98
- }
99
- const withBlockBindingSupport = exports.withBlockBindingSupport = (0, _compose.createHigherOrderComponent)(BlockEdit => props => {
100
- const registry = (0, _data.useRegistry)();
101
- const blockContext = (0, _element.useContext)(_blockContext.default);
102
- const sources = (0, _data.useSelect)(select => (0, _lockUnlock.unlock)(select(_blocks.store)).getAllBlockBindingsSources());
103
- const {
104
- name,
105
- clientId,
106
- context,
107
- setAttributes
108
- } = props;
109
- const blockBindings = (0, _element.useMemo)(() => replacePatternOverrideDefaultBindings(name, props.attributes.metadata?.bindings), [props.attributes.metadata?.bindings, name]);
110
-
111
- // While this hook doesn't directly call any selectors, `useSelect` is
112
- // used purposely here to ensure `boundAttributes` is updated whenever
113
- // there are attribute updates.
114
- // `source.getValues` may also call a selector via `registry.select`.
115
- const updatedContext = {};
116
- const boundAttributes = (0, _data.useSelect)(select => {
117
- if (!blockBindings) {
118
- return;
119
- }
120
- const attributes = {};
121
- const blockBindingsBySource = new Map();
122
- for (const [attributeName, binding] of Object.entries(blockBindings)) {
123
- const {
124
- source: sourceName,
125
- args: sourceArgs
126
- } = binding;
127
- const source = sources[sourceName];
128
- if (!source || !canBindAttribute(name, attributeName)) {
129
- continue;
130
- }
131
-
132
- // Populate context.
133
- for (const key of source.usesContext || []) {
134
- updatedContext[key] = blockContext[key];
135
- }
136
- blockBindingsBySource.set(source, {
137
- ...blockBindingsBySource.get(source),
138
- [attributeName]: {
139
- args: sourceArgs
140
- }
141
- });
142
- }
143
- if (blockBindingsBySource.size) {
144
- for (const [source, bindings] of blockBindingsBySource) {
145
- // Get values in batch if the source supports it.
146
- let values = {};
147
- if (!source.getValues) {
148
- Object.keys(bindings).forEach(attr => {
149
- // Default to the the source label when `getValues` doesn't exist.
150
- values[attr] = source.label;
151
- });
152
- } else {
153
- values = source.getValues({
154
- select,
155
- context: updatedContext,
156
- clientId,
157
- bindings
158
- });
159
- }
160
- for (const [attributeName, value] of Object.entries(values)) {
161
- if (attributeName === 'url' && (!value || !(0, _isUrlLike.default)(value))) {
162
- // Return null if value is not a valid URL.
163
- attributes[attributeName] = null;
164
- } else {
165
- attributes[attributeName] = value;
166
- }
167
- }
168
- }
169
- }
170
- return attributes;
171
- }, [blockBindings, name, clientId, updatedContext, sources]);
172
- const hasParentPattern = !!updatedContext['pattern/overrides'];
173
- const hasPatternOverridesDefaultBinding = props.attributes.metadata?.bindings?.[DEFAULT_ATTRIBUTE]?.source === 'core/pattern-overrides';
174
- const _setAttributes = (0, _element.useCallback)(nextAttributes => {
175
- registry.batch(() => {
176
- if (!blockBindings) {
177
- setAttributes(nextAttributes);
178
- return;
179
- }
180
- const keptAttributes = {
181
- ...nextAttributes
182
- };
183
- const blockBindingsBySource = new Map();
184
-
185
- // Loop only over the updated attributes to avoid modifying the bound ones that haven't changed.
186
- for (const [attributeName, newValue] of Object.entries(keptAttributes)) {
187
- if (!blockBindings[attributeName] || !canBindAttribute(name, attributeName)) {
188
- continue;
189
- }
190
- const binding = blockBindings[attributeName];
191
- const source = sources[binding?.source];
192
- if (!source?.setValues) {
193
- continue;
194
- }
195
- blockBindingsBySource.set(source, {
196
- ...blockBindingsBySource.get(source),
197
- [attributeName]: {
198
- args: binding.args,
199
- newValue
200
- }
201
- });
202
- delete keptAttributes[attributeName];
203
- }
204
- if (blockBindingsBySource.size) {
205
- for (const [source, bindings] of blockBindingsBySource) {
206
- source.setValues({
207
- select: registry.select,
208
- dispatch: registry.dispatch,
209
- context: updatedContext,
210
- clientId,
211
- bindings
212
- });
213
- }
214
- }
215
- if (
216
- // Don't update non-connected attributes if the block is using pattern overrides
217
- // and the editing is happening while overriding the pattern (not editing the original).
218
- !(hasPatternOverridesDefaultBinding && hasParentPattern) && Object.keys(keptAttributes).length) {
219
- // Don't update caption and href until they are supported.
220
- if (hasPatternOverridesDefaultBinding) {
221
- delete keptAttributes?.caption;
222
- delete keptAttributes?.href;
223
- }
224
- setAttributes(keptAttributes);
225
- }
226
- });
227
- }, [registry, blockBindings, name, clientId, updatedContext, setAttributes, sources, hasPatternOverridesDefaultBinding, hasParentPattern]);
228
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
229
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(BlockEdit, {
230
- ...props,
231
- attributes: {
232
- ...props.attributes,
233
- ...boundAttributes
234
- },
235
- setAttributes: _setAttributes,
236
- context: {
237
- ...context,
238
- ...updatedContext
239
- }
240
- })
241
- });
242
- }, 'withBlockBindingSupport');
243
-
244
- /**
245
- * Filters a registered block's settings to enhance a block's `edit` component
246
- * to upgrade bound attributes.
247
- *
248
- * @param {WPBlockSettings} settings - Registered block settings.
249
- * @param {string} name - Block name.
250
- * @return {WPBlockSettings} Filtered block settings.
251
- */
252
- function shimAttributeSource(settings, name) {
253
- if (!canBindBlock(name)) {
254
- return settings;
255
- }
256
- return {
257
- ...settings,
258
- edit: withBlockBindingSupport(settings.edit)
259
- };
260
- }
261
- (0, _hooks.addFilter)('blocks.registerBlockType', 'core/editor/custom-sources-backwards-compatibility/shim-attribute-source', shimAttributeSource);
262
- //# sourceMappingURL=use-bindings-attributes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_blocks","require","_compose","_data","_element","_hooks","_isUrlLike","_interopRequireDefault","_lockUnlock","_blockContext","_jsxRuntime","BLOCK_BINDINGS_ALLOWED_BLOCKS","DEFAULT_ATTRIBUTE","replacePatternOverrideDefaultBindings","blockName","bindings","source","supportedAttributes","bindingsWithDefaults","attributeName","bindingSource","canBindBlock","canBindAttribute","includes","getBindableAttributes","withBlockBindingSupport","exports","createHigherOrderComponent","BlockEdit","props","registry","useRegistry","blockContext","useContext","BlockContext","sources","useSelect","select","unlock","blocksStore","getAllBlockBindingsSources","name","clientId","context","setAttributes","blockBindings","useMemo","attributes","metadata","updatedContext","boundAttributes","blockBindingsBySource","Map","binding","Object","entries","sourceName","args","sourceArgs","key","usesContext","set","get","size","values","getValues","keys","forEach","attr","label","value","isURLLike","hasParentPattern","hasPatternOverridesDefaultBinding","_setAttributes","useCallback","nextAttributes","batch","keptAttributes","newValue","setValues","dispatch","length","caption","href","jsx","Fragment","children","shimAttributeSource","settings","edit","addFilter"],"sources":["@wordpress/block-editor/src/hooks/use-bindings-attributes.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useCallback, useMemo, useContext } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport isURLLike from '../components/link-control/is-url-like';\nimport { unlock } from '../lock-unlock';\nimport BlockContext from '../components/block-context';\n\n/** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */\n/** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */\n\n/**\n * Given a binding of block attributes, returns a higher order component that\n * overrides its `attributes` and `setAttributes` props to sync any changes needed.\n *\n * @return {WPHigherOrderComponent} Higher-order component.\n */\n\nconst BLOCK_BINDINGS_ALLOWED_BLOCKS = {\n\t'core/paragraph': [ 'content' ],\n\t'core/heading': [ 'content' ],\n\t'core/image': [ 'id', 'url', 'title', 'alt' ],\n\t'core/button': [ 'url', 'text', 'linkTarget', 'rel' ],\n};\n\nconst DEFAULT_ATTRIBUTE = '__default';\n\n/**\n * Returns the bindings with the `__default` binding for pattern overrides\n * replaced with the full-set of supported attributes. e.g.:\n *\n * bindings passed in: `{ __default: { source: 'core/pattern-overrides' } }`\n * bindings returned: `{ content: { source: 'core/pattern-overrides' } }`\n *\n * @param {string} blockName The block name (e.g. 'core/paragraph').\n * @param {Object} bindings A block's bindings from the metadata attribute.\n *\n * @return {Object} The bindings with default replaced for pattern overrides.\n */\nfunction replacePatternOverrideDefaultBindings( blockName, bindings ) {\n\t// The `__default` binding currently only works for pattern overrides.\n\tif (\n\t\tbindings?.[ DEFAULT_ATTRIBUTE ]?.source === 'core/pattern-overrides'\n\t) {\n\t\tconst supportedAttributes = BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];\n\t\tconst bindingsWithDefaults = {};\n\t\tfor ( const attributeName of supportedAttributes ) {\n\t\t\t// If the block has mixed binding sources, retain any non pattern override bindings.\n\t\t\tconst bindingSource = bindings[ attributeName ]\n\t\t\t\t? bindings[ attributeName ]\n\t\t\t\t: { source: 'core/pattern-overrides' };\n\t\t\tbindingsWithDefaults[ attributeName ] = bindingSource;\n\t\t}\n\n\t\treturn bindingsWithDefaults;\n\t}\n\n\treturn bindings;\n}\n\n/**\n * Based on the given block name,\n * check if it is possible to bind the block.\n *\n * @param {string} blockName - The block name.\n * @return {boolean} Whether it is possible to bind the block to sources.\n */\nexport function canBindBlock( blockName ) {\n\treturn blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS;\n}\n\n/**\n * Based on the given block name and attribute name,\n * check if it is possible to bind the block attribute.\n *\n * @param {string} blockName - The block name.\n * @param {string} attributeName - The attribute name.\n * @return {boolean} Whether it is possible to bind the block attribute.\n */\nexport function canBindAttribute( blockName, attributeName ) {\n\treturn (\n\t\tcanBindBlock( blockName ) &&\n\t\tBLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ].includes( attributeName )\n\t);\n}\n\nexport function getBindableAttributes( blockName ) {\n\treturn BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];\n}\n\nexport const withBlockBindingSupport = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst registry = useRegistry();\n\t\tconst blockContext = useContext( BlockContext );\n\t\tconst sources = useSelect( ( select ) =>\n\t\t\tunlock( select( blocksStore ) ).getAllBlockBindingsSources()\n\t\t);\n\t\tconst { name, clientId, context, setAttributes } = props;\n\t\tconst blockBindings = useMemo(\n\t\t\t() =>\n\t\t\t\treplacePatternOverrideDefaultBindings(\n\t\t\t\t\tname,\n\t\t\t\t\tprops.attributes.metadata?.bindings\n\t\t\t\t),\n\t\t\t[ props.attributes.metadata?.bindings, name ]\n\t\t);\n\n\t\t// While this hook doesn't directly call any selectors, `useSelect` is\n\t\t// used purposely here to ensure `boundAttributes` is updated whenever\n\t\t// there are attribute updates.\n\t\t// `source.getValues` may also call a selector via `registry.select`.\n\t\tconst updatedContext = {};\n\t\tconst boundAttributes = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tif ( ! blockBindings ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst attributes = {};\n\n\t\t\t\tconst blockBindingsBySource = new Map();\n\n\t\t\t\tfor ( const [ attributeName, binding ] of Object.entries(\n\t\t\t\t\tblockBindings\n\t\t\t\t) ) {\n\t\t\t\t\tconst { source: sourceName, args: sourceArgs } = binding;\n\t\t\t\t\tconst source = sources[ sourceName ];\n\t\t\t\t\tif (\n\t\t\t\t\t\t! source ||\n\t\t\t\t\t\t! canBindAttribute( name, attributeName )\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Populate context.\n\t\t\t\t\tfor ( const key of source.usesContext || [] ) {\n\t\t\t\t\t\tupdatedContext[ key ] = blockContext[ key ];\n\t\t\t\t\t}\n\n\t\t\t\t\tblockBindingsBySource.set( source, {\n\t\t\t\t\t\t...blockBindingsBySource.get( source ),\n\t\t\t\t\t\t[ attributeName ]: {\n\t\t\t\t\t\t\targs: sourceArgs,\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tif ( blockBindingsBySource.size ) {\n\t\t\t\t\tfor ( const [\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\tbindings,\n\t\t\t\t\t] of blockBindingsBySource ) {\n\t\t\t\t\t\t// Get values in batch if the source supports it.\n\t\t\t\t\t\tlet values = {};\n\t\t\t\t\t\tif ( ! source.getValues ) {\n\t\t\t\t\t\t\tObject.keys( bindings ).forEach( ( attr ) => {\n\t\t\t\t\t\t\t\t// Default to the the source label when `getValues` doesn't exist.\n\t\t\t\t\t\t\t\tvalues[ attr ] = source.label;\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tvalues = source.getValues( {\n\t\t\t\t\t\t\t\tselect,\n\t\t\t\t\t\t\t\tcontext: updatedContext,\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\tbindings,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor ( const [ attributeName, value ] of Object.entries(\n\t\t\t\t\t\t\tvalues\n\t\t\t\t\t\t) ) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tattributeName === 'url' &&\n\t\t\t\t\t\t\t\t( ! value || ! isURLLike( value ) )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// Return null if value is not a valid URL.\n\t\t\t\t\t\t\t\tattributes[ attributeName ] = null;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tattributes[ attributeName ] = value;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn attributes;\n\t\t\t},\n\t\t\t[ blockBindings, name, clientId, updatedContext, sources ]\n\t\t);\n\n\t\tconst hasParentPattern = !! updatedContext[ 'pattern/overrides' ];\n\t\tconst hasPatternOverridesDefaultBinding =\n\t\t\tprops.attributes.metadata?.bindings?.[ DEFAULT_ATTRIBUTE ]\n\t\t\t\t?.source === 'core/pattern-overrides';\n\n\t\tconst _setAttributes = useCallback(\n\t\t\t( nextAttributes ) => {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tif ( ! blockBindings ) {\n\t\t\t\t\t\tsetAttributes( nextAttributes );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst keptAttributes = { ...nextAttributes };\n\t\t\t\t\tconst blockBindingsBySource = new Map();\n\n\t\t\t\t\t// Loop only over the updated attributes to avoid modifying the bound ones that haven't changed.\n\t\t\t\t\tfor ( const [ attributeName, newValue ] of Object.entries(\n\t\t\t\t\t\tkeptAttributes\n\t\t\t\t\t) ) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t! blockBindings[ attributeName ] ||\n\t\t\t\t\t\t\t! canBindAttribute( name, attributeName )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst binding = blockBindings[ attributeName ];\n\t\t\t\t\t\tconst source = sources[ binding?.source ];\n\t\t\t\t\t\tif ( ! source?.setValues ) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tblockBindingsBySource.set( source, {\n\t\t\t\t\t\t\t...blockBindingsBySource.get( source ),\n\t\t\t\t\t\t\t[ attributeName ]: {\n\t\t\t\t\t\t\t\targs: binding.args,\n\t\t\t\t\t\t\t\tnewValue,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tdelete keptAttributes[ attributeName ];\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( blockBindingsBySource.size ) {\n\t\t\t\t\t\tfor ( const [\n\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t\tbindings,\n\t\t\t\t\t\t] of blockBindingsBySource ) {\n\t\t\t\t\t\t\tsource.setValues( {\n\t\t\t\t\t\t\t\tselect: registry.select,\n\t\t\t\t\t\t\t\tdispatch: registry.dispatch,\n\t\t\t\t\t\t\t\tcontext: updatedContext,\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\tbindings,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t// Don't update non-connected attributes if the block is using pattern overrides\n\t\t\t\t\t\t// and the editing is happening while overriding the pattern (not editing the original).\n\t\t\t\t\t\t! (\n\t\t\t\t\t\t\thasPatternOverridesDefaultBinding &&\n\t\t\t\t\t\t\thasParentPattern\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\tObject.keys( keptAttributes ).length\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Don't update caption and href until they are supported.\n\t\t\t\t\t\tif ( hasPatternOverridesDefaultBinding ) {\n\t\t\t\t\t\t\tdelete keptAttributes?.caption;\n\t\t\t\t\t\t\tdelete keptAttributes?.href;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetAttributes( keptAttributes );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[\n\t\t\t\tregistry,\n\t\t\t\tblockBindings,\n\t\t\t\tname,\n\t\t\t\tclientId,\n\t\t\t\tupdatedContext,\n\t\t\t\tsetAttributes,\n\t\t\t\tsources,\n\t\t\t\thasPatternOverridesDefaultBinding,\n\t\t\t\thasParentPattern,\n\t\t\t]\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tattributes={ { ...props.attributes, ...boundAttributes } }\n\t\t\t\t\tsetAttributes={ _setAttributes }\n\t\t\t\t\tcontext={ { ...context, ...updatedContext } }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n\t'withBlockBindingSupport'\n);\n\n/**\n * Filters a registered block's settings to enhance a block's `edit` component\n * to upgrade bound attributes.\n *\n * @param {WPBlockSettings} settings - Registered block settings.\n * @param {string} name - Block name.\n * @return {WPBlockSettings} Filtered block settings.\n */\nfunction shimAttributeSource( settings, name ) {\n\tif ( ! canBindBlock( name ) ) {\n\t\treturn settings;\n\t}\n\n\treturn {\n\t\t...settings,\n\t\tedit: withBlockBindingSupport( settings.edit ),\n\t};\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/custom-sources-backwards-compatibility/shim-attribute-source',\n\tshimAttributeSource\n);\n"],"mappings":";;;;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAKA,IAAAK,UAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAF,sBAAA,CAAAN,OAAA;AAAuD,IAAAS,WAAA,GAAAT,OAAA;AAdvD;AACA;AACA;;AAOA;AACA;AACA;;AAKA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAEA,MAAMU,6BAA6B,GAAG;EACrC,gBAAgB,EAAE,CAAE,SAAS,CAAE;EAC/B,cAAc,EAAE,CAAE,SAAS,CAAE;EAC7B,YAAY,EAAE,CAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAE;EAC7C,aAAa,EAAE,CAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK;AACpD,CAAC;AAED,MAAMC,iBAAiB,GAAG,WAAW;;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D,CAAC","ignoreList":[]}
@@ -1,253 +0,0 @@
1
- /* wp:polyfill */
2
- /**
3
- * WordPress dependencies
4
- */
5
- import { store as blocksStore } from '@wordpress/blocks';
6
- import { createHigherOrderComponent } from '@wordpress/compose';
7
- import { useRegistry, useSelect } from '@wordpress/data';
8
- import { useCallback, useMemo, useContext } from '@wordpress/element';
9
- import { addFilter } from '@wordpress/hooks';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
- import isURLLike from '../components/link-control/is-url-like';
15
- import { unlock } from '../lock-unlock';
16
- import BlockContext from '../components/block-context';
17
-
18
- /** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */
19
- /** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */
20
-
21
- /**
22
- * Given a binding of block attributes, returns a higher order component that
23
- * overrides its `attributes` and `setAttributes` props to sync any changes needed.
24
- *
25
- * @return {WPHigherOrderComponent} Higher-order component.
26
- */
27
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
28
- const BLOCK_BINDINGS_ALLOWED_BLOCKS = {
29
- 'core/paragraph': ['content'],
30
- 'core/heading': ['content'],
31
- 'core/image': ['id', 'url', 'title', 'alt'],
32
- 'core/button': ['url', 'text', 'linkTarget', 'rel']
33
- };
34
- const DEFAULT_ATTRIBUTE = '__default';
35
-
36
- /**
37
- * Returns the bindings with the `__default` binding for pattern overrides
38
- * replaced with the full-set of supported attributes. e.g.:
39
- *
40
- * bindings passed in: `{ __default: { source: 'core/pattern-overrides' } }`
41
- * bindings returned: `{ content: { source: 'core/pattern-overrides' } }`
42
- *
43
- * @param {string} blockName The block name (e.g. 'core/paragraph').
44
- * @param {Object} bindings A block's bindings from the metadata attribute.
45
- *
46
- * @return {Object} The bindings with default replaced for pattern overrides.
47
- */
48
- function replacePatternOverrideDefaultBindings(blockName, bindings) {
49
- // The `__default` binding currently only works for pattern overrides.
50
- if (bindings?.[DEFAULT_ATTRIBUTE]?.source === 'core/pattern-overrides') {
51
- const supportedAttributes = BLOCK_BINDINGS_ALLOWED_BLOCKS[blockName];
52
- const bindingsWithDefaults = {};
53
- for (const attributeName of supportedAttributes) {
54
- // If the block has mixed binding sources, retain any non pattern override bindings.
55
- const bindingSource = bindings[attributeName] ? bindings[attributeName] : {
56
- source: 'core/pattern-overrides'
57
- };
58
- bindingsWithDefaults[attributeName] = bindingSource;
59
- }
60
- return bindingsWithDefaults;
61
- }
62
- return bindings;
63
- }
64
-
65
- /**
66
- * Based on the given block name,
67
- * check if it is possible to bind the block.
68
- *
69
- * @param {string} blockName - The block name.
70
- * @return {boolean} Whether it is possible to bind the block to sources.
71
- */
72
- export function canBindBlock(blockName) {
73
- return blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS;
74
- }
75
-
76
- /**
77
- * Based on the given block name and attribute name,
78
- * check if it is possible to bind the block attribute.
79
- *
80
- * @param {string} blockName - The block name.
81
- * @param {string} attributeName - The attribute name.
82
- * @return {boolean} Whether it is possible to bind the block attribute.
83
- */
84
- export function canBindAttribute(blockName, attributeName) {
85
- return canBindBlock(blockName) && BLOCK_BINDINGS_ALLOWED_BLOCKS[blockName].includes(attributeName);
86
- }
87
- export function getBindableAttributes(blockName) {
88
- return BLOCK_BINDINGS_ALLOWED_BLOCKS[blockName];
89
- }
90
- export const withBlockBindingSupport = createHigherOrderComponent(BlockEdit => props => {
91
- const registry = useRegistry();
92
- const blockContext = useContext(BlockContext);
93
- const sources = useSelect(select => unlock(select(blocksStore)).getAllBlockBindingsSources());
94
- const {
95
- name,
96
- clientId,
97
- context,
98
- setAttributes
99
- } = props;
100
- const blockBindings = useMemo(() => replacePatternOverrideDefaultBindings(name, props.attributes.metadata?.bindings), [props.attributes.metadata?.bindings, name]);
101
-
102
- // While this hook doesn't directly call any selectors, `useSelect` is
103
- // used purposely here to ensure `boundAttributes` is updated whenever
104
- // there are attribute updates.
105
- // `source.getValues` may also call a selector via `registry.select`.
106
- const updatedContext = {};
107
- const boundAttributes = useSelect(select => {
108
- if (!blockBindings) {
109
- return;
110
- }
111
- const attributes = {};
112
- const blockBindingsBySource = new Map();
113
- for (const [attributeName, binding] of Object.entries(blockBindings)) {
114
- const {
115
- source: sourceName,
116
- args: sourceArgs
117
- } = binding;
118
- const source = sources[sourceName];
119
- if (!source || !canBindAttribute(name, attributeName)) {
120
- continue;
121
- }
122
-
123
- // Populate context.
124
- for (const key of source.usesContext || []) {
125
- updatedContext[key] = blockContext[key];
126
- }
127
- blockBindingsBySource.set(source, {
128
- ...blockBindingsBySource.get(source),
129
- [attributeName]: {
130
- args: sourceArgs
131
- }
132
- });
133
- }
134
- if (blockBindingsBySource.size) {
135
- for (const [source, bindings] of blockBindingsBySource) {
136
- // Get values in batch if the source supports it.
137
- let values = {};
138
- if (!source.getValues) {
139
- Object.keys(bindings).forEach(attr => {
140
- // Default to the the source label when `getValues` doesn't exist.
141
- values[attr] = source.label;
142
- });
143
- } else {
144
- values = source.getValues({
145
- select,
146
- context: updatedContext,
147
- clientId,
148
- bindings
149
- });
150
- }
151
- for (const [attributeName, value] of Object.entries(values)) {
152
- if (attributeName === 'url' && (!value || !isURLLike(value))) {
153
- // Return null if value is not a valid URL.
154
- attributes[attributeName] = null;
155
- } else {
156
- attributes[attributeName] = value;
157
- }
158
- }
159
- }
160
- }
161
- return attributes;
162
- }, [blockBindings, name, clientId, updatedContext, sources]);
163
- const hasParentPattern = !!updatedContext['pattern/overrides'];
164
- const hasPatternOverridesDefaultBinding = props.attributes.metadata?.bindings?.[DEFAULT_ATTRIBUTE]?.source === 'core/pattern-overrides';
165
- const _setAttributes = useCallback(nextAttributes => {
166
- registry.batch(() => {
167
- if (!blockBindings) {
168
- setAttributes(nextAttributes);
169
- return;
170
- }
171
- const keptAttributes = {
172
- ...nextAttributes
173
- };
174
- const blockBindingsBySource = new Map();
175
-
176
- // Loop only over the updated attributes to avoid modifying the bound ones that haven't changed.
177
- for (const [attributeName, newValue] of Object.entries(keptAttributes)) {
178
- if (!blockBindings[attributeName] || !canBindAttribute(name, attributeName)) {
179
- continue;
180
- }
181
- const binding = blockBindings[attributeName];
182
- const source = sources[binding?.source];
183
- if (!source?.setValues) {
184
- continue;
185
- }
186
- blockBindingsBySource.set(source, {
187
- ...blockBindingsBySource.get(source),
188
- [attributeName]: {
189
- args: binding.args,
190
- newValue
191
- }
192
- });
193
- delete keptAttributes[attributeName];
194
- }
195
- if (blockBindingsBySource.size) {
196
- for (const [source, bindings] of blockBindingsBySource) {
197
- source.setValues({
198
- select: registry.select,
199
- dispatch: registry.dispatch,
200
- context: updatedContext,
201
- clientId,
202
- bindings
203
- });
204
- }
205
- }
206
- if (
207
- // Don't update non-connected attributes if the block is using pattern overrides
208
- // and the editing is happening while overriding the pattern (not editing the original).
209
- !(hasPatternOverridesDefaultBinding && hasParentPattern) && Object.keys(keptAttributes).length) {
210
- // Don't update caption and href until they are supported.
211
- if (hasPatternOverridesDefaultBinding) {
212
- delete keptAttributes?.caption;
213
- delete keptAttributes?.href;
214
- }
215
- setAttributes(keptAttributes);
216
- }
217
- });
218
- }, [registry, blockBindings, name, clientId, updatedContext, setAttributes, sources, hasPatternOverridesDefaultBinding, hasParentPattern]);
219
- return /*#__PURE__*/_jsx(_Fragment, {
220
- children: /*#__PURE__*/_jsx(BlockEdit, {
221
- ...props,
222
- attributes: {
223
- ...props.attributes,
224
- ...boundAttributes
225
- },
226
- setAttributes: _setAttributes,
227
- context: {
228
- ...context,
229
- ...updatedContext
230
- }
231
- })
232
- });
233
- }, 'withBlockBindingSupport');
234
-
235
- /**
236
- * Filters a registered block's settings to enhance a block's `edit` component
237
- * to upgrade bound attributes.
238
- *
239
- * @param {WPBlockSettings} settings - Registered block settings.
240
- * @param {string} name - Block name.
241
- * @return {WPBlockSettings} Filtered block settings.
242
- */
243
- function shimAttributeSource(settings, name) {
244
- if (!canBindBlock(name)) {
245
- return settings;
246
- }
247
- return {
248
- ...settings,
249
- edit: withBlockBindingSupport(settings.edit)
250
- };
251
- }
252
- addFilter('blocks.registerBlockType', 'core/editor/custom-sources-backwards-compatibility/shim-attribute-source', shimAttributeSource);
253
- //# sourceMappingURL=use-bindings-attributes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["store","blocksStore","createHigherOrderComponent","useRegistry","useSelect","useCallback","useMemo","useContext","addFilter","isURLLike","unlock","BlockContext","jsx","_jsx","Fragment","_Fragment","BLOCK_BINDINGS_ALLOWED_BLOCKS","DEFAULT_ATTRIBUTE","replacePatternOverrideDefaultBindings","blockName","bindings","source","supportedAttributes","bindingsWithDefaults","attributeName","bindingSource","canBindBlock","canBindAttribute","includes","getBindableAttributes","withBlockBindingSupport","BlockEdit","props","registry","blockContext","sources","select","getAllBlockBindingsSources","name","clientId","context","setAttributes","blockBindings","attributes","metadata","updatedContext","boundAttributes","blockBindingsBySource","Map","binding","Object","entries","sourceName","args","sourceArgs","key","usesContext","set","get","size","values","getValues","keys","forEach","attr","label","value","hasParentPattern","hasPatternOverridesDefaultBinding","_setAttributes","nextAttributes","batch","keptAttributes","newValue","setValues","dispatch","length","caption","href","children","shimAttributeSource","settings","edit"],"sources":["@wordpress/block-editor/src/hooks/use-bindings-attributes.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useCallback, useMemo, useContext } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport isURLLike from '../components/link-control/is-url-like';\nimport { unlock } from '../lock-unlock';\nimport BlockContext from '../components/block-context';\n\n/** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */\n/** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */\n\n/**\n * Given a binding of block attributes, returns a higher order component that\n * overrides its `attributes` and `setAttributes` props to sync any changes needed.\n *\n * @return {WPHigherOrderComponent} Higher-order component.\n */\n\nconst BLOCK_BINDINGS_ALLOWED_BLOCKS = {\n\t'core/paragraph': [ 'content' ],\n\t'core/heading': [ 'content' ],\n\t'core/image': [ 'id', 'url', 'title', 'alt' ],\n\t'core/button': [ 'url', 'text', 'linkTarget', 'rel' ],\n};\n\nconst DEFAULT_ATTRIBUTE = '__default';\n\n/**\n * Returns the bindings with the `__default` binding for pattern overrides\n * replaced with the full-set of supported attributes. e.g.:\n *\n * bindings passed in: `{ __default: { source: 'core/pattern-overrides' } }`\n * bindings returned: `{ content: { source: 'core/pattern-overrides' } }`\n *\n * @param {string} blockName The block name (e.g. 'core/paragraph').\n * @param {Object} bindings A block's bindings from the metadata attribute.\n *\n * @return {Object} The bindings with default replaced for pattern overrides.\n */\nfunction replacePatternOverrideDefaultBindings( blockName, bindings ) {\n\t// The `__default` binding currently only works for pattern overrides.\n\tif (\n\t\tbindings?.[ DEFAULT_ATTRIBUTE ]?.source === 'core/pattern-overrides'\n\t) {\n\t\tconst supportedAttributes = BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];\n\t\tconst bindingsWithDefaults = {};\n\t\tfor ( const attributeName of supportedAttributes ) {\n\t\t\t// If the block has mixed binding sources, retain any non pattern override bindings.\n\t\t\tconst bindingSource = bindings[ attributeName ]\n\t\t\t\t? bindings[ attributeName ]\n\t\t\t\t: { source: 'core/pattern-overrides' };\n\t\t\tbindingsWithDefaults[ attributeName ] = bindingSource;\n\t\t}\n\n\t\treturn bindingsWithDefaults;\n\t}\n\n\treturn bindings;\n}\n\n/**\n * Based on the given block name,\n * check if it is possible to bind the block.\n *\n * @param {string} blockName - The block name.\n * @return {boolean} Whether it is possible to bind the block to sources.\n */\nexport function canBindBlock( blockName ) {\n\treturn blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS;\n}\n\n/**\n * Based on the given block name and attribute name,\n * check if it is possible to bind the block attribute.\n *\n * @param {string} blockName - The block name.\n * @param {string} attributeName - The attribute name.\n * @return {boolean} Whether it is possible to bind the block attribute.\n */\nexport function canBindAttribute( blockName, attributeName ) {\n\treturn (\n\t\tcanBindBlock( blockName ) &&\n\t\tBLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ].includes( attributeName )\n\t);\n}\n\nexport function getBindableAttributes( blockName ) {\n\treturn BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];\n}\n\nexport const withBlockBindingSupport = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst registry = useRegistry();\n\t\tconst blockContext = useContext( BlockContext );\n\t\tconst sources = useSelect( ( select ) =>\n\t\t\tunlock( select( blocksStore ) ).getAllBlockBindingsSources()\n\t\t);\n\t\tconst { name, clientId, context, setAttributes } = props;\n\t\tconst blockBindings = useMemo(\n\t\t\t() =>\n\t\t\t\treplacePatternOverrideDefaultBindings(\n\t\t\t\t\tname,\n\t\t\t\t\tprops.attributes.metadata?.bindings\n\t\t\t\t),\n\t\t\t[ props.attributes.metadata?.bindings, name ]\n\t\t);\n\n\t\t// While this hook doesn't directly call any selectors, `useSelect` is\n\t\t// used purposely here to ensure `boundAttributes` is updated whenever\n\t\t// there are attribute updates.\n\t\t// `source.getValues` may also call a selector via `registry.select`.\n\t\tconst updatedContext = {};\n\t\tconst boundAttributes = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tif ( ! blockBindings ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst attributes = {};\n\n\t\t\t\tconst blockBindingsBySource = new Map();\n\n\t\t\t\tfor ( const [ attributeName, binding ] of Object.entries(\n\t\t\t\t\tblockBindings\n\t\t\t\t) ) {\n\t\t\t\t\tconst { source: sourceName, args: sourceArgs } = binding;\n\t\t\t\t\tconst source = sources[ sourceName ];\n\t\t\t\t\tif (\n\t\t\t\t\t\t! source ||\n\t\t\t\t\t\t! canBindAttribute( name, attributeName )\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Populate context.\n\t\t\t\t\tfor ( const key of source.usesContext || [] ) {\n\t\t\t\t\t\tupdatedContext[ key ] = blockContext[ key ];\n\t\t\t\t\t}\n\n\t\t\t\t\tblockBindingsBySource.set( source, {\n\t\t\t\t\t\t...blockBindingsBySource.get( source ),\n\t\t\t\t\t\t[ attributeName ]: {\n\t\t\t\t\t\t\targs: sourceArgs,\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tif ( blockBindingsBySource.size ) {\n\t\t\t\t\tfor ( const [\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\tbindings,\n\t\t\t\t\t] of blockBindingsBySource ) {\n\t\t\t\t\t\t// Get values in batch if the source supports it.\n\t\t\t\t\t\tlet values = {};\n\t\t\t\t\t\tif ( ! source.getValues ) {\n\t\t\t\t\t\t\tObject.keys( bindings ).forEach( ( attr ) => {\n\t\t\t\t\t\t\t\t// Default to the the source label when `getValues` doesn't exist.\n\t\t\t\t\t\t\t\tvalues[ attr ] = source.label;\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tvalues = source.getValues( {\n\t\t\t\t\t\t\t\tselect,\n\t\t\t\t\t\t\t\tcontext: updatedContext,\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\tbindings,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor ( const [ attributeName, value ] of Object.entries(\n\t\t\t\t\t\t\tvalues\n\t\t\t\t\t\t) ) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tattributeName === 'url' &&\n\t\t\t\t\t\t\t\t( ! value || ! isURLLike( value ) )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// Return null if value is not a valid URL.\n\t\t\t\t\t\t\t\tattributes[ attributeName ] = null;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tattributes[ attributeName ] = value;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn attributes;\n\t\t\t},\n\t\t\t[ blockBindings, name, clientId, updatedContext, sources ]\n\t\t);\n\n\t\tconst hasParentPattern = !! updatedContext[ 'pattern/overrides' ];\n\t\tconst hasPatternOverridesDefaultBinding =\n\t\t\tprops.attributes.metadata?.bindings?.[ DEFAULT_ATTRIBUTE ]\n\t\t\t\t?.source === 'core/pattern-overrides';\n\n\t\tconst _setAttributes = useCallback(\n\t\t\t( nextAttributes ) => {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tif ( ! blockBindings ) {\n\t\t\t\t\t\tsetAttributes( nextAttributes );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst keptAttributes = { ...nextAttributes };\n\t\t\t\t\tconst blockBindingsBySource = new Map();\n\n\t\t\t\t\t// Loop only over the updated attributes to avoid modifying the bound ones that haven't changed.\n\t\t\t\t\tfor ( const [ attributeName, newValue ] of Object.entries(\n\t\t\t\t\t\tkeptAttributes\n\t\t\t\t\t) ) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t! blockBindings[ attributeName ] ||\n\t\t\t\t\t\t\t! canBindAttribute( name, attributeName )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst binding = blockBindings[ attributeName ];\n\t\t\t\t\t\tconst source = sources[ binding?.source ];\n\t\t\t\t\t\tif ( ! source?.setValues ) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tblockBindingsBySource.set( source, {\n\t\t\t\t\t\t\t...blockBindingsBySource.get( source ),\n\t\t\t\t\t\t\t[ attributeName ]: {\n\t\t\t\t\t\t\t\targs: binding.args,\n\t\t\t\t\t\t\t\tnewValue,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tdelete keptAttributes[ attributeName ];\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( blockBindingsBySource.size ) {\n\t\t\t\t\t\tfor ( const [\n\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t\tbindings,\n\t\t\t\t\t\t] of blockBindingsBySource ) {\n\t\t\t\t\t\t\tsource.setValues( {\n\t\t\t\t\t\t\t\tselect: registry.select,\n\t\t\t\t\t\t\t\tdispatch: registry.dispatch,\n\t\t\t\t\t\t\t\tcontext: updatedContext,\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\tbindings,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t// Don't update non-connected attributes if the block is using pattern overrides\n\t\t\t\t\t\t// and the editing is happening while overriding the pattern (not editing the original).\n\t\t\t\t\t\t! (\n\t\t\t\t\t\t\thasPatternOverridesDefaultBinding &&\n\t\t\t\t\t\t\thasParentPattern\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\tObject.keys( keptAttributes ).length\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Don't update caption and href until they are supported.\n\t\t\t\t\t\tif ( hasPatternOverridesDefaultBinding ) {\n\t\t\t\t\t\t\tdelete keptAttributes?.caption;\n\t\t\t\t\t\t\tdelete keptAttributes?.href;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetAttributes( keptAttributes );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[\n\t\t\t\tregistry,\n\t\t\t\tblockBindings,\n\t\t\t\tname,\n\t\t\t\tclientId,\n\t\t\t\tupdatedContext,\n\t\t\t\tsetAttributes,\n\t\t\t\tsources,\n\t\t\t\thasPatternOverridesDefaultBinding,\n\t\t\t\thasParentPattern,\n\t\t\t]\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tattributes={ { ...props.attributes, ...boundAttributes } }\n\t\t\t\t\tsetAttributes={ _setAttributes }\n\t\t\t\t\tcontext={ { ...context, ...updatedContext } }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n\t'withBlockBindingSupport'\n);\n\n/**\n * Filters a registered block's settings to enhance a block's `edit` component\n * to upgrade bound attributes.\n *\n * @param {WPBlockSettings} settings - Registered block settings.\n * @param {string} name - Block name.\n * @return {WPBlockSettings} Filtered block settings.\n */\nfunction shimAttributeSource( settings, name ) {\n\tif ( ! canBindBlock( name ) ) {\n\t\treturn settings;\n\t}\n\n\treturn {\n\t\t...settings,\n\t\tedit: withBlockBindingSupport( settings.edit ),\n\t};\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/custom-sources-backwards-compatibility/shim-attribute-source',\n\tshimAttributeSource\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,0BAA0B,QAAQ,oBAAoB;AAC/D,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,WAAW,EAAEC,OAAO,EAAEC,UAAU,QAAQ,oBAAoB;AACrE,SAASC,SAAS,QAAQ,kBAAkB;;AAE5C;AACA;AACA;AACA,OAAOC,SAAS,MAAM,wCAAwC;AAC9D,SAASC,MAAM,QAAQ,gBAAgB;AACvC,OAAOC,YAAY,MAAM,6BAA6B;;AAEtD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AALA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA;AAOA,MAAMC,6BAA6B,GAAG;EACrC,gBAAgB,EAAE,CAAE,SAAS,CAAE;EAC/B,cAAc,EAAE,CAAE,SAAS,CAAE;EAC7B,YAAY,EAAE,CAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAE;EAC7C,aAAa,EAAE,CAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK;AACpD,CAAC;AAED,MAAMC,iBAAiB,GAAG,WAAW;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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