@wordpress/block-editor 12.13.0 → 12.14.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 (344) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-heading-level-dropdown/index.js +1 -1
  3. package/build/components/block-heading-level-dropdown/index.js.map +1 -1
  4. package/build/components/block-list/index.js +2 -9
  5. package/build/components/block-list/index.js.map +1 -1
  6. package/build/components/block-list-appender/index.js +16 -3
  7. package/build/components/block-list-appender/index.js.map +1 -1
  8. package/build/components/block-quick-navigation/index.js +6 -4
  9. package/build/components/block-quick-navigation/index.js.map +1 -1
  10. package/build/components/block-styles/index.js +0 -8
  11. package/build/components/block-styles/index.js.map +1 -1
  12. package/build/components/block-switcher/pattern-transformations-menu.js +18 -14
  13. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  14. package/build/components/block-tools/back-compat.js +2 -2
  15. package/build/components/block-tools/back-compat.js.map +1 -1
  16. package/build/components/block-tools/block-contextual-toolbar.js +11 -81
  17. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  18. package/build/components/block-tools/empty-block-inserter.js +56 -0
  19. package/build/components/block-tools/empty-block-inserter.js.map +1 -0
  20. package/build/components/block-tools/index.js +48 -9
  21. package/build/components/block-tools/index.js.map +1 -1
  22. package/build/components/block-tools/selected-block-tools.js +113 -0
  23. package/build/components/block-tools/selected-block-tools.js.map +1 -0
  24. package/build/components/block-tools/use-selected-block-tool-props.js +56 -0
  25. package/build/components/block-tools/use-selected-block-tool-props.js.map +1 -0
  26. package/build/components/editable-text/index.js +1 -2
  27. package/build/components/editable-text/index.js.map +1 -1
  28. package/build/components/iframe/index.js +4 -3
  29. package/build/components/iframe/index.js.map +1 -1
  30. package/build/components/inserter/block-patterns-explorer/{explorer.js → index.js} +7 -7
  31. package/build/components/inserter/block-patterns-explorer/index.js.map +1 -0
  32. package/build/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +1 -1
  33. package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -0
  34. package/build/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +4 -4
  35. package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -0
  36. package/build/components/inserter/block-patterns-tab/index.js +75 -0
  37. package/build/components/inserter/block-patterns-tab/index.js.map +1 -0
  38. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +48 -0
  39. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -0
  40. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +108 -0
  41. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -0
  42. package/build/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +18 -34
  43. package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -0
  44. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +55 -0
  45. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -0
  46. package/build/components/inserter/block-patterns-tab/utils.js +70 -0
  47. package/build/components/inserter/block-patterns-tab/utils.js.map +1 -0
  48. package/build/components/inserter/media-tab/media-list.js +9 -5
  49. package/build/components/inserter/media-tab/media-list.js.map +1 -1
  50. package/build/components/inserter/media-tab/media-preview.js +15 -12
  51. package/build/components/inserter/media-tab/media-preview.js.map +1 -1
  52. package/build/components/inserter/menu.js +3 -4
  53. package/build/components/inserter/menu.js.map +1 -1
  54. package/build/components/link-control/index.js +6 -5
  55. package/build/components/link-control/index.js.map +1 -1
  56. package/build/components/list-view/block-select-button.js +39 -0
  57. package/build/components/list-view/block-select-button.js.map +1 -1
  58. package/build/components/list-view/block.js +16 -3
  59. package/build/components/list-view/block.js.map +1 -1
  60. package/build/components/list-view/index.js +3 -2
  61. package/build/components/list-view/index.js.map +1 -1
  62. package/build/components/navigable-toolbar/index.js +69 -18
  63. package/build/components/navigable-toolbar/index.js.map +1 -1
  64. package/build/components/provider/use-block-sync.js +1 -14
  65. package/build/components/provider/use-block-sync.js.map +1 -1
  66. package/build/components/rich-text/index.js +0 -1
  67. package/build/components/rich-text/index.js.map +1 -1
  68. package/build/components/rich-text/index.native.js +3 -1
  69. package/build/components/rich-text/index.native.js.map +1 -1
  70. package/build/components/rich-text/native/format-edit.js +45 -0
  71. package/build/components/rich-text/native/format-edit.js.map +1 -0
  72. package/build/components/rich-text/native/get-format-colors.native.js +41 -0
  73. package/build/components/rich-text/native/get-format-colors.native.js.map +1 -0
  74. package/build/components/rich-text/native/index.js +9 -0
  75. package/build/components/rich-text/native/index.js.map +1 -0
  76. package/build/components/rich-text/native/index.native.js +1158 -0
  77. package/build/components/rich-text/native/index.native.js.map +1 -0
  78. package/build/components/rich-text/native/toolbar-button-with-options.native.js +58 -0
  79. package/build/components/rich-text/native/toolbar-button-with-options.native.js.map +1 -0
  80. package/build/components/rich-text/native/use-format-types.js +111 -0
  81. package/build/components/rich-text/native/use-format-types.js.map +1 -0
  82. package/build/components/rich-text/use-paste-handler.js +2 -5
  83. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  84. package/build/components/url-popover/image-url-input-ui.js +2 -1
  85. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  86. package/build/components/writing-flow/use-tab-nav.js +7 -3
  87. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  88. package/build/hooks/align.js +10 -10
  89. package/build/hooks/align.js.map +1 -1
  90. package/build/hooks/align.native.js +2 -2
  91. package/build/hooks/align.native.js.map +1 -1
  92. package/build/hooks/anchor.js +7 -6
  93. package/build/hooks/anchor.js.map +1 -1
  94. package/build/hooks/background.js +16 -4
  95. package/build/hooks/background.js.map +1 -1
  96. package/build/hooks/block-hooks.js +7 -8
  97. package/build/hooks/block-hooks.js.map +1 -1
  98. package/build/hooks/block-rename-ui.js +7 -5
  99. package/build/hooks/block-rename-ui.js.map +1 -1
  100. package/build/hooks/content-lock-ui.js +5 -5
  101. package/build/hooks/content-lock-ui.js.map +1 -1
  102. package/build/hooks/custom-class-name.js +8 -7
  103. package/build/hooks/custom-class-name.js.map +1 -1
  104. package/build/hooks/custom-fields.js +4 -4
  105. package/build/hooks/custom-fields.js.map +1 -1
  106. package/build/hooks/duotone.js +9 -20
  107. package/build/hooks/duotone.js.map +1 -1
  108. package/build/hooks/layout.js +90 -86
  109. package/build/hooks/layout.js.map +1 -1
  110. package/build/hooks/position.js +10 -9
  111. package/build/hooks/position.js.map +1 -1
  112. package/build/hooks/style.js +10 -13
  113. package/build/hooks/style.js.map +1 -1
  114. package/build/hooks/utils.js +30 -0
  115. package/build/hooks/utils.js.map +1 -1
  116. package/build/private-apis.js +3 -0
  117. package/build/private-apis.js.map +1 -1
  118. package/build/store/actions.js +30 -37
  119. package/build/store/actions.js.map +1 -1
  120. package/build/store/reducer.js +18 -0
  121. package/build/store/reducer.js.map +1 -1
  122. package/build/store/selectors.js +16 -13
  123. package/build/store/selectors.js.map +1 -1
  124. package/build-module/components/block-heading-level-dropdown/index.js +1 -1
  125. package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
  126. package/build-module/components/block-list/index.js +3 -10
  127. package/build-module/components/block-list/index.js.map +1 -1
  128. package/build-module/components/block-list-appender/index.js +16 -3
  129. package/build-module/components/block-list-appender/index.js.map +1 -1
  130. package/build-module/components/block-quick-navigation/index.js +7 -5
  131. package/build-module/components/block-quick-navigation/index.js.map +1 -1
  132. package/build-module/components/block-styles/index.js +0 -8
  133. package/build-module/components/block-styles/index.js.map +1 -1
  134. package/build-module/components/block-switcher/pattern-transformations-menu.js +17 -13
  135. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  136. package/build-module/components/block-tools/back-compat.js +1 -1
  137. package/build-module/components/block-tools/back-compat.js.map +1 -1
  138. package/build-module/components/block-tools/block-contextual-toolbar.js +11 -80
  139. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  140. package/build-module/components/block-tools/empty-block-inserter.js +48 -0
  141. package/build-module/components/block-tools/empty-block-inserter.js.map +1 -0
  142. package/build-module/components/block-tools/index.js +48 -9
  143. package/build-module/components/block-tools/index.js.map +1 -1
  144. package/build-module/components/block-tools/selected-block-tools.js +105 -0
  145. package/build-module/components/block-tools/selected-block-tools.js.map +1 -0
  146. package/build-module/components/block-tools/use-selected-block-tool-props.js +50 -0
  147. package/build-module/components/block-tools/use-selected-block-tool-props.js.map +1 -0
  148. package/build-module/components/editable-text/index.js +1 -2
  149. package/build-module/components/editable-text/index.js.map +1 -1
  150. package/build-module/components/iframe/index.js +4 -3
  151. package/build-module/components/iframe/index.js.map +1 -1
  152. package/build-module/components/inserter/block-patterns-explorer/{explorer.js → index.js} +5 -5
  153. package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -0
  154. package/build-module/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +1 -1
  155. package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -0
  156. package/build-module/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +2 -2
  157. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -0
  158. package/build-module/components/inserter/block-patterns-tab/index.js +66 -0
  159. package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -0
  160. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +42 -0
  161. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -0
  162. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +100 -0
  163. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -0
  164. package/build-module/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +7 -20
  165. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -0
  166. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +47 -0
  167. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -0
  168. package/build-module/components/inserter/block-patterns-tab/utils.js +58 -0
  169. package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -0
  170. package/build-module/components/inserter/media-tab/media-list.js +9 -5
  171. package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
  172. package/build-module/components/inserter/media-tab/media-preview.js +15 -12
  173. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
  174. package/build-module/components/inserter/menu.js +4 -3
  175. package/build-module/components/inserter/menu.js.map +1 -1
  176. package/build-module/components/link-control/index.js +7 -6
  177. package/build-module/components/link-control/index.js.map +1 -1
  178. package/build-module/components/list-view/block-select-button.js +39 -0
  179. package/build-module/components/list-view/block-select-button.js.map +1 -1
  180. package/build-module/components/list-view/block.js +16 -3
  181. package/build-module/components/list-view/block.js.map +1 -1
  182. package/build-module/components/list-view/index.js +3 -2
  183. package/build-module/components/list-view/index.js.map +1 -1
  184. package/build-module/components/navigable-toolbar/index.js +69 -17
  185. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  186. package/build-module/components/provider/use-block-sync.js +1 -14
  187. package/build-module/components/provider/use-block-sync.js.map +1 -1
  188. package/build-module/components/rich-text/index.js +0 -1
  189. package/build-module/components/rich-text/index.js.map +1 -1
  190. package/build-module/components/rich-text/index.native.js +3 -1
  191. package/build-module/components/rich-text/index.native.js.map +1 -1
  192. package/build-module/components/rich-text/native/format-edit.js +38 -0
  193. package/build-module/components/rich-text/native/format-edit.js.map +1 -0
  194. package/build-module/components/rich-text/native/get-format-colors.native.js +34 -0
  195. package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -0
  196. package/build-module/components/rich-text/native/index.js +2 -0
  197. package/build-module/components/rich-text/native/index.js.map +1 -0
  198. package/build-module/components/rich-text/native/index.native.js +1148 -0
  199. package/build-module/components/rich-text/native/index.native.js.map +1 -0
  200. package/build-module/components/rich-text/native/toolbar-button-with-options.native.js +51 -0
  201. package/build-module/components/rich-text/native/toolbar-button-with-options.native.js.map +1 -0
  202. package/build-module/components/rich-text/native/use-format-types.js +104 -0
  203. package/build-module/components/rich-text/native/use-format-types.js.map +1 -0
  204. package/build-module/components/rich-text/use-paste-handler.js +2 -5
  205. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  206. package/build-module/components/url-popover/image-url-input-ui.js +2 -1
  207. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  208. package/build-module/components/writing-flow/use-tab-nav.js +7 -3
  209. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  210. package/build-module/hooks/align.js +8 -8
  211. package/build-module/hooks/align.js.map +1 -1
  212. package/build-module/hooks/align.native.js +2 -2
  213. package/build-module/hooks/align.native.js.map +1 -1
  214. package/build-module/hooks/anchor.js +5 -4
  215. package/build-module/hooks/anchor.js.map +1 -1
  216. package/build-module/hooks/background.js +17 -5
  217. package/build-module/hooks/background.js.map +1 -1
  218. package/build-module/hooks/block-hooks.js +5 -6
  219. package/build-module/hooks/block-hooks.js.map +1 -1
  220. package/build-module/hooks/block-rename-ui.js +5 -3
  221. package/build-module/hooks/block-rename-ui.js.map +1 -1
  222. package/build-module/hooks/content-lock-ui.js +3 -3
  223. package/build-module/hooks/content-lock-ui.js.map +1 -1
  224. package/build-module/hooks/custom-class-name.js +6 -5
  225. package/build-module/hooks/custom-class-name.js.map +1 -1
  226. package/build-module/hooks/custom-fields.js +4 -4
  227. package/build-module/hooks/custom-fields.js.map +1 -1
  228. package/build-module/hooks/duotone.js +10 -21
  229. package/build-module/hooks/duotone.js.map +1 -1
  230. package/build-module/hooks/layout.js +90 -86
  231. package/build-module/hooks/layout.js.map +1 -1
  232. package/build-module/hooks/position.js +11 -10
  233. package/build-module/hooks/position.js.map +1 -1
  234. package/build-module/hooks/style.js +10 -13
  235. package/build-module/hooks/style.js.map +1 -1
  236. package/build-module/hooks/utils.js +30 -1
  237. package/build-module/hooks/utils.js.map +1 -1
  238. package/build-module/private-apis.js +4 -1
  239. package/build-module/private-apis.js.map +1 -1
  240. package/build-module/store/actions.js +29 -37
  241. package/build-module/store/actions.js.map +1 -1
  242. package/build-module/store/reducer.js +17 -0
  243. package/build-module/store/reducer.js.map +1 -1
  244. package/build-module/store/selectors.js +15 -13
  245. package/build-module/store/selectors.js.map +1 -1
  246. package/build-style/style-rtl.css +16 -15
  247. package/build-style/style.css +16 -15
  248. package/package.json +31 -31
  249. package/src/components/block-heading-level-dropdown/index.js +1 -1
  250. package/src/components/block-list/index.js +4 -18
  251. package/src/components/block-list-appender/index.js +20 -4
  252. package/src/components/block-quick-navigation/index.js +11 -5
  253. package/src/components/block-styles/index.js +0 -10
  254. package/src/components/block-switcher/pattern-transformations-menu.js +20 -14
  255. package/src/components/block-toolbar/style.scss +8 -0
  256. package/src/components/block-tools/back-compat.js +1 -1
  257. package/src/components/block-tools/block-contextual-toolbar.js +11 -134
  258. package/src/components/block-tools/empty-block-inserter.js +56 -0
  259. package/src/components/block-tools/index.js +72 -16
  260. package/src/components/block-tools/selected-block-tools.js +127 -0
  261. package/src/components/block-tools/style.scss +0 -10
  262. package/src/components/block-tools/use-selected-block-tool-props.js +66 -0
  263. package/src/components/editable-text/index.js +1 -8
  264. package/src/components/iframe/index.js +4 -3
  265. package/src/components/inserter/block-patterns-explorer/{explorer.js → index.js} +4 -4
  266. package/src/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +4 -1
  267. package/src/components/inserter/block-patterns-tab/index.js +118 -0
  268. package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +48 -0
  269. package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +175 -0
  270. package/src/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +15 -21
  271. package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +96 -0
  272. package/src/components/inserter/block-patterns-tab/utils.js +76 -0
  273. package/src/components/inserter/media-tab/media-list.js +7 -7
  274. package/src/components/inserter/media-tab/media-preview.js +27 -22
  275. package/src/components/inserter/menu.js +4 -5
  276. package/src/components/link-control/README.md +2 -2
  277. package/src/components/link-control/index.js +15 -6
  278. package/src/components/link-control/style.scss +8 -5
  279. package/src/components/list-view/block-select-button.js +44 -1
  280. package/src/components/list-view/block.js +11 -11
  281. package/src/components/list-view/index.js +2 -0
  282. package/src/components/media-replace-flow/style.scss +2 -2
  283. package/src/components/navigable-toolbar/index.js +71 -25
  284. package/src/components/plain-text/README.md +3 -3
  285. package/src/components/provider/use-block-sync.js +2 -21
  286. package/src/components/rich-text/README.md +9 -8
  287. package/src/components/rich-text/index.js +0 -1
  288. package/src/components/rich-text/index.native.js +3 -1
  289. package/src/components/rich-text/native/format-edit.js +44 -0
  290. package/src/components/rich-text/native/get-format-colors.native.js +54 -0
  291. package/src/components/rich-text/native/index.js +1 -0
  292. package/src/components/rich-text/native/index.native.js +1363 -0
  293. package/src/components/rich-text/native/style.native.scss +28 -0
  294. package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +79 -0
  295. package/src/components/rich-text/native/test/index.native.js +278 -0
  296. package/src/components/rich-text/native/test/performance/rich-text.native.js +44 -0
  297. package/src/components/rich-text/native/toolbar-button-with-options.native.js +61 -0
  298. package/src/components/rich-text/native/use-format-types.js +146 -0
  299. package/src/components/rich-text/use-paste-handler.js +1 -6
  300. package/src/components/url-popover/image-url-input-ui.js +1 -0
  301. package/src/components/writing-flow/use-tab-nav.js +8 -3
  302. package/src/hooks/align.js +8 -8
  303. package/src/hooks/align.native.js +2 -2
  304. package/src/hooks/anchor.js +21 -23
  305. package/src/hooks/background.js +28 -6
  306. package/src/hooks/block-hooks.js +20 -16
  307. package/src/hooks/block-rename-ui.js +6 -4
  308. package/src/hooks/content-lock-ui.js +3 -3
  309. package/src/hooks/custom-class-name.js +7 -6
  310. package/src/hooks/custom-fields.js +5 -5
  311. package/src/hooks/duotone.js +23 -33
  312. package/src/hooks/layout.js +114 -105
  313. package/src/hooks/position.js +8 -21
  314. package/src/hooks/style.js +17 -31
  315. package/src/hooks/test/align.js +4 -4
  316. package/src/hooks/utils.js +33 -1
  317. package/src/private-apis.js +4 -1
  318. package/src/store/actions.js +26 -72
  319. package/src/store/reducer.js +19 -0
  320. package/src/store/selectors.js +13 -19
  321. package/build/components/block-tools/selected-block-popover.js +0 -221
  322. package/build/components/block-tools/selected-block-popover.js.map +0 -1
  323. package/build/components/inserter/block-patterns-explorer/explorer.js.map +0 -1
  324. package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +0 -1
  325. package/build/components/inserter/block-patterns-explorer/sidebar.js.map +0 -1
  326. package/build/components/inserter/block-patterns-filter.js.map +0 -1
  327. package/build/components/inserter/block-patterns-tab.js +0 -270
  328. package/build/components/inserter/block-patterns-tab.js.map +0 -1
  329. package/build/store/utils.js +0 -22
  330. package/build/store/utils.js.map +0 -1
  331. package/build-module/components/block-tools/selected-block-popover.js +0 -213
  332. package/build-module/components/block-tools/selected-block-popover.js.map +0 -1
  333. package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +0 -1
  334. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +0 -1
  335. package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +0 -1
  336. package/build-module/components/inserter/block-patterns-filter.js.map +0 -1
  337. package/build-module/components/inserter/block-patterns-tab.js +0 -254
  338. package/build-module/components/inserter/block-patterns-tab.js.map +0 -1
  339. package/build-module/store/utils.js +0 -16
  340. package/build-module/store/utils.js.map +0 -1
  341. package/src/components/block-tools/selected-block-popover.js +0 -265
  342. package/src/components/inserter/block-patterns-tab.js +0 -448
  343. package/src/store/utils.js +0 -12
  344. /package/src/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +0 -0
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_hooks","_element","_components","_compose","_blocks","_data","_components2","_store","EMPTY_OBJECT","BlockHooksControl","props","blockTypes","useSelect","select","blocksStore","getBlockTypes","hookedBlocksForCurrentBlock","useMemo","filter","blockHooks","blockName","blockIndex","rootClientId","innerBlocksLength","getBlock","getBlockIndex","getBlockRootClientId","blockEditorStore","clientId","innerBlocks","length","hookedBlockClientIds","getGlobalBlockCount","_hookedBlockClientIds","reduce","clientIds","block","name","relativePosition","candidates","hookedBlock","find","Object","values","insertBlock","removeBlock","useDispatch","hookedBlocksForCurrentBlockIfNotPresentElsewhere","groupedHookedBlocks","groups","namespace","split","push","insertBlockIntoDesignatedLocation","_react","createElement","InspectorControls","PanelBody","className","title","__","initialOpen","keys","map","vendor","Fragment","key","checked","ToggleControl","label","__experimentalHStack","justify","BlockIcon","icon","onChange","createBlock","withBlockHooks","createHigherOrderComponent","BlockEdit","blockEdit","exports","addFilter"],"sources":["@wordpress/block-editor/src/hooks/block-hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { addFilter } from '@wordpress/hooks';\nimport { Fragment, useMemo } from '@wordpress/element';\nimport {\n\t__experimentalHStack as HStack,\n\tPanelBody,\n\tToggleControl,\n} from '@wordpress/components';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { BlockIcon, InspectorControls } from '../components';\nimport { store as blockEditorStore } from '../store';\n\nconst EMPTY_OBJECT = {};\n\nfunction BlockHooksControl( props ) {\n\tconst blockTypes = useSelect(\n\t\t( select ) => select( blocksStore ).getBlockTypes(),\n\t\t[]\n\t);\n\n\tconst hookedBlocksForCurrentBlock = useMemo(\n\t\t() =>\n\t\t\tblockTypes?.filter(\n\t\t\t\t( { blockHooks } ) =>\n\t\t\t\t\tblockHooks && props.blockName in blockHooks\n\t\t\t),\n\t\t[ blockTypes, props.blockName ]\n\t);\n\n\tconst { blockIndex, rootClientId, innerBlocksLength } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, getBlockIndex, getBlockRootClientId } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tblockIndex: getBlockIndex( props.clientId ),\n\t\t\t\tinnerBlocksLength: getBlock( props.clientId )?.innerBlocks\n\t\t\t\t\t?.length,\n\t\t\t\trootClientId: getBlockRootClientId( props.clientId ),\n\t\t\t};\n\t\t},\n\t\t[ props.clientId ]\n\t);\n\n\tconst hookedBlockClientIds = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, getGlobalBlockCount } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\tconst _hookedBlockClientIds = hookedBlocksForCurrentBlock.reduce(\n\t\t\t\t( clientIds, block ) => {\n\t\t\t\t\t// If the block doesn't exist anywhere in the block tree,\n\t\t\t\t\t// we know that we have to display the toggle for it, and set\n\t\t\t\t\t// it to disabled.\n\t\t\t\t\tif ( getGlobalBlockCount( block.name ) === 0 ) {\n\t\t\t\t\t\treturn clientIds;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst relativePosition =\n\t\t\t\t\t\tblock?.blockHooks?.[ props.blockName ];\n\t\t\t\t\tlet candidates;\n\n\t\t\t\t\tswitch ( relativePosition ) {\n\t\t\t\t\t\tcase 'before':\n\t\t\t\t\t\tcase 'after':\n\t\t\t\t\t\t\t// Any of the current block's siblings (with the right block type) qualifies\n\t\t\t\t\t\t\t// as a hooked block (inserted `before` or `after` the current one), as the block\n\t\t\t\t\t\t\t// might've been automatically inserted and then moved around a bit by the user.\n\t\t\t\t\t\t\tcandidates = getBlock( rootClientId )?.innerBlocks;\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'first_child':\n\t\t\t\t\t\tcase 'last_child':\n\t\t\t\t\t\t\t// Any of the current block's child blocks (with the right block type) qualifies\n\t\t\t\t\t\t\t// as a hooked first or last child block, as the block might've been automatically\n\t\t\t\t\t\t\t// inserted and then moved around a bit by the user.\n\t\t\t\t\t\t\tcandidates = getBlock( props.clientId ).innerBlocks;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst hookedBlock = candidates?.find(\n\t\t\t\t\t\t( { name } ) => name === block.name\n\t\t\t\t\t);\n\n\t\t\t\t\t// If the block exists in the designated location, we consider it hooked\n\t\t\t\t\t// and show the toggle as enabled.\n\t\t\t\t\tif ( hookedBlock ) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...clientIds,\n\t\t\t\t\t\t\t[ block.name ]: hookedBlock.clientId,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\t// If no hooked block was found in any of its designated locations,\n\t\t\t\t\t// but it exists elsewhere in the block tree, we consider it manually inserted.\n\t\t\t\t\t// In this case, we take note and will remove the corresponding toggle from the\n\t\t\t\t\t// block inspector panel.\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...clientIds,\n\t\t\t\t\t\t[ block.name ]: false,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\n\t\t\tif ( Object.values( _hookedBlockClientIds ).length > 0 ) {\n\t\t\t\treturn _hookedBlockClientIds;\n\t\t\t}\n\n\t\t\treturn EMPTY_OBJECT;\n\t\t},\n\t\t[\n\t\t\thookedBlocksForCurrentBlock,\n\t\t\tprops.blockName,\n\t\t\tprops.clientId,\n\t\t\trootClientId,\n\t\t]\n\t);\n\n\tconst { insertBlock, removeBlock } = useDispatch( blockEditorStore );\n\n\t// Remove toggle if block isn't present in the designated location but elsewhere in the block tree.\n\tconst hookedBlocksForCurrentBlockIfNotPresentElsewhere =\n\t\thookedBlocksForCurrentBlock?.filter(\n\t\t\t( block ) => hookedBlockClientIds?.[ block.name ] !== false\n\t\t);\n\n\tif ( ! hookedBlocksForCurrentBlockIfNotPresentElsewhere.length ) {\n\t\treturn null;\n\t}\n\n\t// Group by block namespace (i.e. prefix before the slash).\n\tconst groupedHookedBlocks = hookedBlocksForCurrentBlock.reduce(\n\t\t( groups, block ) => {\n\t\t\tconst [ namespace ] = block.name.split( '/' );\n\t\t\tif ( ! groups[ namespace ] ) {\n\t\t\t\tgroups[ namespace ] = [];\n\t\t\t}\n\t\t\tgroups[ namespace ].push( block );\n\t\t\treturn groups;\n\t\t},\n\t\t{}\n\t);\n\n\tconst insertBlockIntoDesignatedLocation = ( block, relativePosition ) => {\n\t\tswitch ( relativePosition ) {\n\t\t\tcase 'before':\n\t\t\tcase 'after':\n\t\t\t\tinsertBlock(\n\t\t\t\t\tblock,\n\t\t\t\t\trelativePosition === 'after' ? blockIndex + 1 : blockIndex,\n\t\t\t\t\trootClientId, // Insert as a child of the current block's parent\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t\tbreak;\n\n\t\t\tcase 'first_child':\n\t\t\tcase 'last_child':\n\t\t\t\tinsertBlock(\n\t\t\t\t\tblock,\n\t\t\t\t\t// TODO: It'd be great if insertBlock() would accept negative indices for insertion.\n\t\t\t\t\trelativePosition === 'first_child' ? 0 : innerBlocksLength,\n\t\t\t\t\tprops.clientId, // Insert as a child of the current block.\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t}\n\t};\n\n\treturn (\n\t\t<InspectorControls>\n\t\t\t<PanelBody\n\t\t\t\tclassName=\"block-editor-hooks__block-hooks\"\n\t\t\t\ttitle={ __( 'Plugins' ) }\n\t\t\t\tinitialOpen={ true }\n\t\t\t>\n\t\t\t\t{ Object.keys( groupedHookedBlocks ).map( ( vendor ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Fragment key={ vendor }>\n\t\t\t\t\t\t\t<h3>{ vendor }</h3>\n\t\t\t\t\t\t\t{ groupedHookedBlocks[ vendor ].map( ( block ) => {\n\t\t\t\t\t\t\t\tconst checked =\n\t\t\t\t\t\t\t\t\tblock.name in hookedBlockClientIds;\n\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t\t\tchecked={ checked }\n\t\t\t\t\t\t\t\t\t\tkey={ block.title }\n\t\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t\t<HStack justify=\"flex-start\">\n\t\t\t\t\t\t\t\t\t\t\t\t<BlockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\ticon={ block.icon }\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<span>{ block.title }</span>\n\t\t\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\t\t\t\t\t\tif ( ! checked ) {\n\t\t\t\t\t\t\t\t\t\t\t\t// Create and insert block.\n\t\t\t\t\t\t\t\t\t\t\t\tconst relativePosition =\n\t\t\t\t\t\t\t\t\t\t\t\t\tblock.blockHooks[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tprops.blockName\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\tinsertBlockIntoDesignatedLocation(\n\t\t\t\t\t\t\t\t\t\t\t\t\tcreateBlock( block.name ),\n\t\t\t\t\t\t\t\t\t\t\t\t\trelativePosition\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\treturn;\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t// Remove block.\n\t\t\t\t\t\t\t\t\t\t\tconst clientId =\n\t\t\t\t\t\t\t\t\t\t\t\thookedBlockClientIds[\n\t\t\t\t\t\t\t\t\t\t\t\t\tblock.name\n\t\t\t\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t\t\t\tremoveBlock( clientId, false );\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);\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n}\n\nexport const withBlockHooks = createHigherOrderComponent( ( BlockEdit ) => {\n\treturn ( props ) => {\n\t\tconst blockEdit = <BlockEdit key=\"edit\" { ...props } />;\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ blockEdit }\n\t\t\t\t<BlockHooksControl\n\t\t\t\t\tblockName={ props.name }\n\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t};\n}, 'withBlockHooks' );\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/block-hooks/with-inspector-control',\n\twithBlockHooks\n);\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAKA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAKA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AAnBA;AACA;AACA;;AAaA;AACA;AACA;;AAIA,MAAMS,YAAY,GAAG,CAAC,CAAC;AAEvB,SAASC,iBAAiBA,CAAEC,KAAK,EAAG;EACnC,MAAMC,UAAU,GAAG,IAAAC,eAAS,EACzBC,MAAM,IAAMA,MAAM,CAAEC,aAAY,CAAC,CAACC,aAAa,CAAC,CAAC,EACnD,EACD,CAAC;EAED,MAAMC,2BAA2B,GAAG,IAAAC,gBAAO,EAC1C,MACCN,UAAU,EAAEO,MAAM,CACjB,CAAE;IAAEC;EAAW,CAAC,KACfA,UAAU,IAAIT,KAAK,CAACU,SAAS,IAAID,UACnC,CAAC,EACF,CAAER,UAAU,EAAED,KAAK,CAACU,SAAS,CAC9B,CAAC;EAED,MAAM;IAAEC,UAAU;IAAEC,YAAY;IAAEC;EAAkB,CAAC,GAAG,IAAAX,eAAS,EAC9DC,MAAM,IAAM;IACb,MAAM;MAAEW,QAAQ;MAAEC,aAAa;MAAEC;IAAqB,CAAC,GACtDb,MAAM,CAAEc,YAAiB,CAAC;IAE3B,OAAO;MACNN,UAAU,EAAEI,aAAa,CAAEf,KAAK,C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B,KAAK,CAACuB,KAAa,CACpB,CACR;QACDe,QAAQ,EAAGA,CAAA,KAAM;UAChB,IAAK,CAAEP,OAAO,EAAG;YAChB;YACA,MAAM7B,gBAAgB,GACrBF,KAAK,CAACjB,UAAU,CACfT,KAAK,CAACU,SAAS,CACf;YACFiC,iCAAiC,CAChC,IAAAsB,mBAAW,EAAEvC,KAAK,CAACC,IAAK,CAAC,EACzBC,gBACD,CAAC;YACD;UACD;;UAEA;UACA,MAAMV,QAAQ,GACbG,oBAAoB,CACnBK,KAAK,CAACC,IAAI,CACV;UACFQ,WAAW,CAAEjB,QAAQ,EAAE,KAAM,CAAC;QAC/B;MAAG,CACH,CAAC;IAEJ,CAAE,CACO,CAAC;EAEb,CAAE,CACQ,CACO,CAAC;AAEtB;AAEO,MAAMgD,cAAc,GAAG,IAAAC,mCAA0B,EAAIC,SAAS,IAAM;EAC1E,OAASpE,KAAK,IAAM;IACnB,MAAMqE,SAAS,GAAG,IAAAzB,MAAA,CAAAC,aAAA,EAACuB,SAAS;MAACZ,GAAG,EAAC,MAAM;MAAA,GAAMxD;IAAK,CAAI,CAAC;IACvD,OACC,IAAA4C,MAAA,CAAAC,aAAA,EAAAtD,QAAA,CAAAgE,QAAA,QACGc,SAAS,EACX,IAAAzB,MAAA,CAAAC,aAAA,EAAC9C,iBAAiB;MACjBW,SAAS,EAAGV,KAAK,CAAC2B,IAAM;MACxBT,QAAQ,EAAGlB,KAAK,CAACkB;IAAU,CAC3B,CACA,CAAC;EAEL,CAAC;AACF,CAAC,EAAE,gBAAiB,CAAC;AAACoD,OAAA,CAAAJ,cAAA,GAAAA,cAAA;AAEtB,IAAAK,gBAAS,EACR,kBAAkB,EAClB,yCAAyC,EACzCL,cACD,CAAC"}
1
+ {"version":3,"names":["_i18n","require","_hooks","_element","_components","_compose","_blocks","_data","_components2","_store","EMPTY_OBJECT","BlockHooksControl","props","blockTypes","useSelect","select","blocksStore","getBlockTypes","hookedBlocksForCurrentBlock","useMemo","filter","blockHooks","blockName","blockIndex","rootClientId","innerBlocksLength","getBlock","getBlockIndex","getBlockRootClientId","blockEditorStore","clientId","innerBlocks","length","hookedBlockClientIds","getGlobalBlockCount","_hookedBlockClientIds","reduce","clientIds","block","name","relativePosition","candidates","hookedBlock","find","Object","values","insertBlock","removeBlock","useDispatch","hookedBlocksForCurrentBlockIfNotPresentElsewhere","groupedHookedBlocks","groups","namespace","split","push","insertBlockIntoDesignatedLocation","_react","createElement","InspectorControls","PanelBody","className","title","__","initialOpen","keys","map","vendor","Fragment","key","checked","ToggleControl","label","__experimentalHStack","justify","BlockIcon","icon","onChange","createBlock","withBlockHooksControls","createHigherOrderComponent","BlockEdit","isSelected","exports","addFilter"],"sources":["@wordpress/block-editor/src/hooks/block-hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { addFilter } from '@wordpress/hooks';\nimport { Fragment, useMemo } from '@wordpress/element';\nimport {\n\t__experimentalHStack as HStack,\n\tPanelBody,\n\tToggleControl,\n} from '@wordpress/components';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { BlockIcon, InspectorControls } from '../components';\nimport { store as blockEditorStore } from '../store';\n\nconst EMPTY_OBJECT = {};\n\nfunction BlockHooksControl( props ) {\n\tconst blockTypes = useSelect(\n\t\t( select ) => select( blocksStore ).getBlockTypes(),\n\t\t[]\n\t);\n\n\tconst hookedBlocksForCurrentBlock = useMemo(\n\t\t() =>\n\t\t\tblockTypes?.filter(\n\t\t\t\t( { blockHooks } ) =>\n\t\t\t\t\tblockHooks && props.blockName in blockHooks\n\t\t\t),\n\t\t[ blockTypes, props.blockName ]\n\t);\n\n\tconst { blockIndex, rootClientId, innerBlocksLength } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, getBlockIndex, getBlockRootClientId } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tblockIndex: getBlockIndex( props.clientId ),\n\t\t\t\tinnerBlocksLength: getBlock( props.clientId )?.innerBlocks\n\t\t\t\t\t?.length,\n\t\t\t\trootClientId: getBlockRootClientId( props.clientId ),\n\t\t\t};\n\t\t},\n\t\t[ props.clientId ]\n\t);\n\n\tconst hookedBlockClientIds = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, getGlobalBlockCount } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\tconst _hookedBlockClientIds = hookedBlocksForCurrentBlock.reduce(\n\t\t\t\t( clientIds, block ) => {\n\t\t\t\t\t// If the block doesn't exist anywhere in the block tree,\n\t\t\t\t\t// we know that we have to display the toggle for it, and set\n\t\t\t\t\t// it to disabled.\n\t\t\t\t\tif ( getGlobalBlockCount( block.name ) === 0 ) {\n\t\t\t\t\t\treturn clientIds;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst relativePosition =\n\t\t\t\t\t\tblock?.blockHooks?.[ props.blockName ];\n\t\t\t\t\tlet candidates;\n\n\t\t\t\t\tswitch ( relativePosition ) {\n\t\t\t\t\t\tcase 'before':\n\t\t\t\t\t\tcase 'after':\n\t\t\t\t\t\t\t// Any of the current block's siblings (with the right block type) qualifies\n\t\t\t\t\t\t\t// as a hooked block (inserted `before` or `after` the current one), as the block\n\t\t\t\t\t\t\t// might've been automatically inserted and then moved around a bit by the user.\n\t\t\t\t\t\t\tcandidates = getBlock( rootClientId )?.innerBlocks;\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'first_child':\n\t\t\t\t\t\tcase 'last_child':\n\t\t\t\t\t\t\t// Any of the current block's child blocks (with the right block type) qualifies\n\t\t\t\t\t\t\t// as a hooked first or last child block, as the block might've been automatically\n\t\t\t\t\t\t\t// inserted and then moved around a bit by the user.\n\t\t\t\t\t\t\tcandidates = getBlock( props.clientId ).innerBlocks;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst hookedBlock = candidates?.find(\n\t\t\t\t\t\t( { name } ) => name === block.name\n\t\t\t\t\t);\n\n\t\t\t\t\t// If the block exists in the designated location, we consider it hooked\n\t\t\t\t\t// and show the toggle as enabled.\n\t\t\t\t\tif ( hookedBlock ) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...clientIds,\n\t\t\t\t\t\t\t[ block.name ]: hookedBlock.clientId,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\t// If no hooked block was found in any of its designated locations,\n\t\t\t\t\t// but it exists elsewhere in the block tree, we consider it manually inserted.\n\t\t\t\t\t// In this case, we take note and will remove the corresponding toggle from the\n\t\t\t\t\t// block inspector panel.\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...clientIds,\n\t\t\t\t\t\t[ block.name ]: false,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\n\t\t\tif ( Object.values( _hookedBlockClientIds ).length > 0 ) {\n\t\t\t\treturn _hookedBlockClientIds;\n\t\t\t}\n\n\t\t\treturn EMPTY_OBJECT;\n\t\t},\n\t\t[\n\t\t\thookedBlocksForCurrentBlock,\n\t\t\tprops.blockName,\n\t\t\tprops.clientId,\n\t\t\trootClientId,\n\t\t]\n\t);\n\n\tconst { insertBlock, removeBlock } = useDispatch( blockEditorStore );\n\n\t// Remove toggle if block isn't present in the designated location but elsewhere in the block tree.\n\tconst hookedBlocksForCurrentBlockIfNotPresentElsewhere =\n\t\thookedBlocksForCurrentBlock?.filter(\n\t\t\t( block ) => hookedBlockClientIds?.[ block.name ] !== false\n\t\t);\n\n\tif ( ! hookedBlocksForCurrentBlockIfNotPresentElsewhere.length ) {\n\t\treturn null;\n\t}\n\n\t// Group by block namespace (i.e. prefix before the slash).\n\tconst groupedHookedBlocks = hookedBlocksForCurrentBlock.reduce(\n\t\t( groups, block ) => {\n\t\t\tconst [ namespace ] = block.name.split( '/' );\n\t\t\tif ( ! groups[ namespace ] ) {\n\t\t\t\tgroups[ namespace ] = [];\n\t\t\t}\n\t\t\tgroups[ namespace ].push( block );\n\t\t\treturn groups;\n\t\t},\n\t\t{}\n\t);\n\n\tconst insertBlockIntoDesignatedLocation = ( block, relativePosition ) => {\n\t\tswitch ( relativePosition ) {\n\t\t\tcase 'before':\n\t\t\tcase 'after':\n\t\t\t\tinsertBlock(\n\t\t\t\t\tblock,\n\t\t\t\t\trelativePosition === 'after' ? blockIndex + 1 : blockIndex,\n\t\t\t\t\trootClientId, // Insert as a child of the current block's parent\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t\tbreak;\n\n\t\t\tcase 'first_child':\n\t\t\tcase 'last_child':\n\t\t\t\tinsertBlock(\n\t\t\t\t\tblock,\n\t\t\t\t\t// TODO: It'd be great if insertBlock() would accept negative indices for insertion.\n\t\t\t\t\trelativePosition === 'first_child' ? 0 : innerBlocksLength,\n\t\t\t\t\tprops.clientId, // Insert as a child of the current block.\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t}\n\t};\n\n\treturn (\n\t\t<InspectorControls>\n\t\t\t<PanelBody\n\t\t\t\tclassName=\"block-editor-hooks__block-hooks\"\n\t\t\t\ttitle={ __( 'Plugins' ) }\n\t\t\t\tinitialOpen={ true }\n\t\t\t>\n\t\t\t\t{ Object.keys( groupedHookedBlocks ).map( ( vendor ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Fragment key={ vendor }>\n\t\t\t\t\t\t\t<h3>{ vendor }</h3>\n\t\t\t\t\t\t\t{ groupedHookedBlocks[ vendor ].map( ( block ) => {\n\t\t\t\t\t\t\t\tconst checked =\n\t\t\t\t\t\t\t\t\tblock.name in hookedBlockClientIds;\n\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t\t\tchecked={ checked }\n\t\t\t\t\t\t\t\t\t\tkey={ block.title }\n\t\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t\t<HStack justify=\"flex-start\">\n\t\t\t\t\t\t\t\t\t\t\t\t<BlockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\ticon={ block.icon }\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<span>{ block.title }</span>\n\t\t\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\t\t\t\t\t\tif ( ! checked ) {\n\t\t\t\t\t\t\t\t\t\t\t\t// Create and insert block.\n\t\t\t\t\t\t\t\t\t\t\t\tconst relativePosition =\n\t\t\t\t\t\t\t\t\t\t\t\t\tblock.blockHooks[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tprops.blockName\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\tinsertBlockIntoDesignatedLocation(\n\t\t\t\t\t\t\t\t\t\t\t\t\tcreateBlock( block.name ),\n\t\t\t\t\t\t\t\t\t\t\t\t\trelativePosition\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\treturn;\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t// Remove block.\n\t\t\t\t\t\t\t\t\t\t\tconst clientId =\n\t\t\t\t\t\t\t\t\t\t\t\thookedBlockClientIds[\n\t\t\t\t\t\t\t\t\t\t\t\t\tblock.name\n\t\t\t\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t\t\t\tremoveBlock( clientId, false );\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);\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n}\n\nexport const withBlockHooksControls = createHigherOrderComponent(\n\t( BlockEdit ) => {\n\t\treturn ( props ) => {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t\t\t{ props.isSelected && (\n\t\t\t\t\t\t<BlockHooksControl\n\t\t\t\t\t\t\tblockName={ props.name }\n\t\t\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t);\n\t\t};\n\t},\n\t'withBlockHooksControls'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/block-hooks/with-inspector-controls',\n\twithBlockHooksControls\n);\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAKA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAKA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AAnBA;AACA;AACA;;AAaA;AACA;AACA;;AAIA,MAAMS,YAAY,GAAG,CAAC,CAAC;AAEvB,SAASC,iBAAiBA,CAAEC,KAAK,EAAG;EACnC,MAAMC,UAAU,GAAG,IAAAC,eAAS,EACzBC,MAAM,IAAMA,MAAM,CAAEC,aAAY,CAAC,CAACC,aAAa,CAAC,CAAC,EACnD,EACD,CAAC;EAED,MAAMC,2BAA2B,GAAG,IAAAC,gBAAO,EAC1C,MACCN,UAAU,EAAEO,MAAM,CACjB,CAAE;IAAEC;EAAW,CAAC,KACfA,UAAU,IAAIT,KAAK,CAACU,SAAS,IAAID,UACnC,CAAC,EACF,CAAER,UAAU,EAAED,KAAK,CAACU,SAAS,CAC9B,CAAC;EAED,MAAM;IAAEC,UAAU;IAAEC,YAAY;IAAEC;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,EAClB,iDAAiD,EACjDL,sBACD,CAAC"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.withBlockRenameControl = void 0;
6
+ exports.withBlockRenameControls = void 0;
7
7
  var _react = require("react");
8
8
  var _compose = require("@wordpress/compose");
9
9
  var _hooks = require("@wordpress/hooks");
@@ -69,6 +69,7 @@ function RenameModal({
69
69
  spacing: "3"
70
70
  }, (0, _react.createElement)(_components.TextControl, {
71
71
  __nextHasNoMarginBottom: true,
72
+ __next40pxDefaultSize: true,
72
73
  value: editedBlockName,
73
74
  label: (0, _i18n.__)('Block name'),
74
75
  hideLabelFromVision: true,
@@ -98,6 +99,7 @@ function BlockRenameControl(props) {
98
99
  group: "advanced"
99
100
  }, (0, _react.createElement)(_components.TextControl, {
100
101
  __nextHasNoMarginBottom: true,
102
+ __next40pxDefaultSize: true,
101
103
  label: (0, _i18n.__)('Block name'),
102
104
  value: customName || '',
103
105
  onChange: onChange
@@ -135,7 +137,7 @@ function BlockRenameControl(props) {
135
137
  }
136
138
  }));
137
139
  }
138
- const withBlockRenameControl = (0, _compose.createHigherOrderComponent)(BlockEdit => props => {
140
+ const withBlockRenameControls = (0, _compose.createHigherOrderComponent)(BlockEdit => props => {
139
141
  const {
140
142
  clientId,
141
143
  name,
@@ -159,7 +161,7 @@ const withBlockRenameControl = (0, _compose.createHigherOrderComponent)(BlockEdi
159
161
  key: "edit",
160
162
  ...props
161
163
  }));
162
- }, 'withToolbarControls');
163
- exports.withBlockRenameControl = withBlockRenameControl;
164
- (0, _hooks.addFilter)('editor.BlockEdit', 'core/block-rename-ui/with-block-rename-control', withBlockRenameControl);
164
+ }, 'withBlockRenameControls');
165
+ exports.withBlockRenameControls = withBlockRenameControls;
166
+ (0, _hooks.addFilter)('editor.BlockEdit', 'core/block-rename-ui/with-block-rename-controls', withBlockRenameControls);
165
167
  //# sourceMappingURL=block-rename-ui.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_compose","require","_hooks","_i18n","_blocks","_components","_element","_a11y","_components2","emptyString","testString","trim","length","RenameModal","blockName","originalBlockName","onClose","onSave","editedBlockName","setEditedBlockName","useState","nameHasChanged","nameIsOriginal","nameIsEmpty","isNameValid","autoSelectInputText","event","target","select","dialogDescription","useInstanceId","handleSubmit","message","sprintf","__","speak","_react","createElement","Modal","title","onRequestClose","overlayClassName","aria","describedby","focusOnMount","id","onSubmit","e","preventDefault","__experimentalVStack","spacing","TextControl","__nextHasNoMarginBottom","value","label","hideLabelFromVision","placeholder","onChange","onFocus","__experimentalHStack","justify","Button","variant","onClick","type","BlockRenameControl","props","renamingBlock","setRenamingBlock","clientId","customName","blockInformation","useBlockDisplayInformation","Fragment","InspectorControls","group","BlockSettingsMenuControls","selectedClientIds","canRename","MenuItem","newName","undefined","withBlockRenameControl","createHigherOrderComponent","BlockEdit","name","attributes","setAttributes","isSelected","supportsBlockNaming","hasBlockSupport","metadata","key","exports","addFilter"],"sources":["@wordpress/block-editor/src/hooks/block-rename-ui.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport {\n\tMenuItem,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tButton,\n\tTextControl,\n\tModal,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockSettingsMenuControls,\n\tuseBlockDisplayInformation,\n\tInspectorControls,\n} from '../components';\n\nconst emptyString = ( testString ) => testString?.trim()?.length === 0;\n\nfunction RenameModal( { blockName, originalBlockName, onClose, onSave } ) {\n\tconst [ editedBlockName, setEditedBlockName ] = useState( blockName );\n\n\tconst nameHasChanged = editedBlockName !== blockName;\n\tconst nameIsOriginal = editedBlockName === originalBlockName;\n\tconst nameIsEmpty = emptyString( editedBlockName );\n\n\tconst isNameValid = nameHasChanged || nameIsOriginal;\n\n\tconst autoSelectInputText = ( event ) => event.target.select();\n\n\tconst dialogDescription = useInstanceId(\n\t\tRenameModal,\n\t\t`block-editor-rename-modal__description`\n\t);\n\n\tconst handleSubmit = () => {\n\t\tconst message =\n\t\t\tnameIsOriginal || nameIsEmpty\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: %s: new name/label for the block */\n\t\t\t\t\t\t__( 'Block name reset to: \"%s\".' ),\n\t\t\t\t\t\teditedBlockName\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: new name/label for the block */\n\t\t\t\t\t\t__( 'Block name changed to: \"%s\".' ),\n\t\t\t\t\t\teditedBlockName\n\t\t\t\t );\n\n\t\t// Must be assertive to immediately announce change.\n\t\tspeak( message, 'assertive' );\n\t\tonSave( editedBlockName );\n\n\t\t// Immediate close avoids ability to hit save multiple times.\n\t\tonClose();\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Rename' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t\toverlayClassName=\"block-editor-block-rename-modal\"\n\t\t\taria={ {\n\t\t\t\tdescribedby: dialogDescription,\n\t\t\t} }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t>\n\t\t\t<p id={ dialogDescription }>\n\t\t\t\t{ __( 'Enter a custom name for this block.' ) }\n\t\t\t</p>\n\t\t\t<form\n\t\t\t\tonSubmit={ ( e ) => {\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\tif ( ! isNameValid ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\thandleSubmit();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tvalue={ editedBlockName }\n\t\t\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t\tplaceholder={ originalBlockName }\n\t\t\t\t\t\tonChange={ setEditedBlockName }\n\t\t\t\t\t\tonFocus={ autoSelectInputText }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\taria-disabled={ ! isNameValid }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n\nfunction BlockRenameControl( props ) {\n\tconst [ renamingBlock, setRenamingBlock ] = useState( false );\n\n\tconst { clientId, customName, onChange } = props;\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\t\tvalue={ customName || '' }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t{ ( { selectedClientIds } ) => {\n\t\t\t\t\t// Only enabled for single selections.\n\t\t\t\t\tconst canRename =\n\t\t\t\t\t\tselectedClientIds.length === 1 &&\n\t\t\t\t\t\tclientId === selectedClientIds[ 0 ];\n\n\t\t\t\t\t// This check ensures the `BlockSettingsMenuControls` fill\n\t\t\t\t\t// doesn't render multiple times and also that it renders for\n\t\t\t\t\t// the block from which the menu was triggered.\n\t\t\t\t\tif ( ! canRename ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetRenamingBlock( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\taria-expanded={ renamingBlock }\n\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Rename' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t</BlockSettingsMenuControls>\n\n\t\t\t{ renamingBlock && (\n\t\t\t\t<RenameModal\n\t\t\t\t\tblockName={ customName || '' }\n\t\t\t\t\toriginalBlockName={ blockInformation?.title }\n\t\t\t\t\tonClose={ () => setRenamingBlock( false ) }\n\t\t\t\t\tonSave={ ( newName ) => {\n\t\t\t\t\t\t// If the new value is the block's original name (e.g. `Group`)\n\t\t\t\t\t\t// or it is an empty string then assume the intent is to reset\n\t\t\t\t\t\t// the value. Therefore reset the metadata.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnewName === blockInformation?.title ||\n\t\t\t\t\t\t\temptyString( newName )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnewName = undefined;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tonChange( newName );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const withBlockRenameControl = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { clientId, name, attributes, setAttributes, isSelected } = props;\n\n\t\tconst supportsBlockNaming = hasBlockSupport( name, 'renaming', true );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ isSelected && supportsBlockNaming && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockRenameControl\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tcustomName={ attributes?.metadata?.name }\n\t\t\t\t\t\t\tonChange={ ( newName ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\t\t...attributes?.metadata,\n\t\t\t\t\t\t\t\t\t\tname: newName,\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} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withToolbarControls'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/block-rename-ui/with-block-rename-control',\n\twithBlockRenameControl\n);\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAQA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAKA,IAAAO,YAAA,GAAAP,OAAA;AArBA;AACA;AACA;;AAgBA;AACA;AACA;;AAOA,MAAMQ,WAAW,GAAKC,UAAU,IAAMA,UAAU,EAAEC,IAAI,CAAC,CAAC,EAAEC,MAAM,KAAK,CAAC;AAEtE,SAASC,WAAWA,CAAE;EAAEC,SAAS;EAAEC,iBAAiB;EAAEC,OAAO;EAAEC;AAAO,CAAC,EAAG;EACzE,MAAM,CAAEC,eAAe,EAAEC,kBAAkB,CAAE,GAAG,IAAAC,iBAAQ,EAAEN,SAAU,CAAC;EAErE,MAAMO,cAAc,GAAGH,eAAe,KAAKJ,SAAS;EACpD,MAAMQ,cAAc,GAAGJ,eAAe,KAAKH,iBAAiB;EAC5D,MAAMQ,WAAW,GAAGd,WAAW,CAAES,eAAgB,CAAC;EAElD,MAAMM,WAAW,GAAGH,cAAc,IAAIC,cAAc;EAEpD,M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,CAAC,GAAGtB,KAAK;EAEvE,MAAMuB,mBAAmB,GAAG,IAAAC,uBAAe,EAAEL,IAAI,EAAE,UAAU,EAAE,IAAK,CAAC;EAErE,OACC,IAAAjD,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAqC,QAAA,QACGe,UAAU,IAAIC,mBAAmB,IAClC,IAAArD,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAqC,QAAA,QACC,IAAArC,MAAA,CAAAC,aAAA,EAAC4B,kBAAkB;IAClBI,QAAQ,EAAGA,QAAU;IACrBC,UAAU,EAAGgB,UAAU,EAAEK,QAAQ,EAAEN,IAAM;IACzC5B,QAAQ,EAAKuB,OAAO,IAAM;MACzBO,aAAa,CAAE;QACdI,QAAQ,EAAE;UACT,GAAGL,UAAU,EAAEK,QAAQ;UACvBN,IAAI,EAAEL;QACP;MACD,CAAE,CAAC;IACJ;EAAG,CACH,CACA,CACF,EAED,IAAA5C,MAAA,CAAAC,aAAA,EAAC+C,SAAS;IAACQ,GAAG,EAAC,MAAM;IAAA,GAAM1B;EAAK,CAAI,CACnC,CAAC;AAEL,CAAC,EACD,qBACD,CAAC;AAAC2B,OAAA,CAAAX,sBAAA,GAAAA,sBAAA;AAEF,IAAAY,gBAAS,EACR,kBAAkB,EAClB,gDAAgD,EAChDZ,sBACD,CAAC"}
1
+ {"version":3,"names":["_compose","require","_hooks","_i18n","_blocks","_components","_element","_a11y","_components2","emptyString","testString","trim","length","RenameModal","blockName","originalBlockName","onClose","onSave","editedBlockName","setEditedBlockName","useState","nameHasChanged","nameIsOriginal","nameIsEmpty","isNameValid","autoSelectInputText","event","target","select","dialogDescription","useInstanceId","handleSubmit","message","sprintf","__","speak","_react","createElement","Modal","title","onRequestClose","overlayClassName","aria","describedby","focusOnMount","id","onSubmit","e","preventDefault","__experimentalVStack","spacing","TextControl","__nextHasNoMarginBottom","__next40pxDefaultSize","value","label","hideLabelFromVision","placeholder","onChange","onFocus","__experimentalHStack","justify","Button","variant","onClick","type","BlockRenameControl","props","renamingBlock","setRenamingBlock","clientId","customName","blockInformation","useBlockDisplayInformation","Fragment","InspectorControls","group","BlockSettingsMenuControls","selectedClientIds","canRename","MenuItem","newName","undefined","withBlockRenameControls","createHigherOrderComponent","BlockEdit","name","attributes","setAttributes","isSelected","supportsBlockNaming","hasBlockSupport","metadata","key","exports","addFilter"],"sources":["@wordpress/block-editor/src/hooks/block-rename-ui.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport {\n\tMenuItem,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tButton,\n\tTextControl,\n\tModal,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockSettingsMenuControls,\n\tuseBlockDisplayInformation,\n\tInspectorControls,\n} from '../components';\n\nconst emptyString = ( testString ) => testString?.trim()?.length === 0;\n\nfunction RenameModal( { blockName, originalBlockName, onClose, onSave } ) {\n\tconst [ editedBlockName, setEditedBlockName ] = useState( blockName );\n\n\tconst nameHasChanged = editedBlockName !== blockName;\n\tconst nameIsOriginal = editedBlockName === originalBlockName;\n\tconst nameIsEmpty = emptyString( editedBlockName );\n\n\tconst isNameValid = nameHasChanged || nameIsOriginal;\n\n\tconst autoSelectInputText = ( event ) => event.target.select();\n\n\tconst dialogDescription = useInstanceId(\n\t\tRenameModal,\n\t\t`block-editor-rename-modal__description`\n\t);\n\n\tconst handleSubmit = () => {\n\t\tconst message =\n\t\t\tnameIsOriginal || nameIsEmpty\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: %s: new name/label for the block */\n\t\t\t\t\t\t__( 'Block name reset to: \"%s\".' ),\n\t\t\t\t\t\teditedBlockName\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: new name/label for the block */\n\t\t\t\t\t\t__( 'Block name changed to: \"%s\".' ),\n\t\t\t\t\t\teditedBlockName\n\t\t\t\t );\n\n\t\t// Must be assertive to immediately announce change.\n\t\tspeak( message, 'assertive' );\n\t\tonSave( editedBlockName );\n\n\t\t// Immediate close avoids ability to hit save multiple times.\n\t\tonClose();\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Rename' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t\toverlayClassName=\"block-editor-block-rename-modal\"\n\t\t\taria={ {\n\t\t\t\tdescribedby: dialogDescription,\n\t\t\t} }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t>\n\t\t\t<p id={ dialogDescription }>\n\t\t\t\t{ __( 'Enter a custom name for this block.' ) }\n\t\t\t</p>\n\t\t\t<form\n\t\t\t\tonSubmit={ ( e ) => {\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\tif ( ! isNameValid ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\thandleSubmit();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvalue={ editedBlockName }\n\t\t\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t\tplaceholder={ originalBlockName }\n\t\t\t\t\t\tonChange={ setEditedBlockName }\n\t\t\t\t\t\tonFocus={ autoSelectInputText }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\taria-disabled={ ! isNameValid }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n\nfunction BlockRenameControl( props ) {\n\tconst [ renamingBlock, setRenamingBlock ] = useState( false );\n\n\tconst { clientId, customName, onChange } = props;\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\t\tvalue={ customName || '' }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t{ ( { selectedClientIds } ) => {\n\t\t\t\t\t// Only enabled for single selections.\n\t\t\t\t\tconst canRename =\n\t\t\t\t\t\tselectedClientIds.length === 1 &&\n\t\t\t\t\t\tclientId === selectedClientIds[ 0 ];\n\n\t\t\t\t\t// This check ensures the `BlockSettingsMenuControls` fill\n\t\t\t\t\t// doesn't render multiple times and also that it renders for\n\t\t\t\t\t// the block from which the menu was triggered.\n\t\t\t\t\tif ( ! canRename ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetRenamingBlock( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\taria-expanded={ renamingBlock }\n\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Rename' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t</BlockSettingsMenuControls>\n\n\t\t\t{ renamingBlock && (\n\t\t\t\t<RenameModal\n\t\t\t\t\tblockName={ customName || '' }\n\t\t\t\t\toriginalBlockName={ blockInformation?.title }\n\t\t\t\t\tonClose={ () => setRenamingBlock( false ) }\n\t\t\t\t\tonSave={ ( newName ) => {\n\t\t\t\t\t\t// If the new value is the block's original name (e.g. `Group`)\n\t\t\t\t\t\t// or it is an empty string then assume the intent is to reset\n\t\t\t\t\t\t// the value. Therefore reset the metadata.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnewName === blockInformation?.title ||\n\t\t\t\t\t\t\temptyString( newName )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnewName = undefined;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tonChange( newName );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const withBlockRenameControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { clientId, name, attributes, setAttributes, isSelected } = props;\n\n\t\tconst supportsBlockNaming = hasBlockSupport( name, 'renaming', true );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ isSelected && supportsBlockNaming && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockRenameControl\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tcustomName={ attributes?.metadata?.name }\n\t\t\t\t\t\t\tonChange={ ( newName ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\t\t...attributes?.metadata,\n\t\t\t\t\t\t\t\t\t\tname: newName,\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} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withBlockRenameControls'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/block-rename-ui/with-block-rename-controls',\n\twithBlockRenameControls\n);\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAQA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAKA,IAAAO,YAAA,GAAAP,OAAA;AArBA;AACA;AACA;;AAgBA;AACA;AACA;;AAOA,MAAMQ,WAAW,GAAKC,UAAU,IAAMA,UAAU,EAAEC,IAAI,CAAC,CAAC,EAAEC,MAAM,KAAK,CAAC;AAEtE,SAASC,WAAWA,CAAE;EAAEC,SAAS;EAAEC,iBAAiB;EAAEC,OAAO;EAAEC;AAAO,CAAC,EAAG;EACzE,MAAM,CAAEC,eAAe,EAAEC,kBAAkB,CAAE,GAAG,IAAAC,iBAAQ,EAAEN,SAAU,CAAC;EAErE,MAAMO,cAAc,GAAGH,eAAe,KAAKJ,SAAS;EACpD,MAAMQ,cAAc,GAAGJ,eAAe,KAAKH,iBAAiB;EAC5D,MAAMQ,WAAW,GAAGd,WAAW,CAAES,eAAgB,CAAC;EAElD,MAAMM,WAAW,GAAGH,cAAc,IAAIC,cAAc;EAEpD,MAAMG,mBAAmB,GAAKC,KAAK,IAAMA,KAAK,CAACC,MAAM,CAACC,MAAM,CAAC,CAAC;EAE9D,MAAMC,iBAAiB,GAAG,IAAAC,sBAAa,EACtCjB,WAAW,EACV,wCACF,CAAC;EAED,MAAMkB,YAAY,GAAGA,CAAA,KAAM;IAC1B,MAAMC,OAAO,GACZV,cAAc,IAAIC,WAAW,GAC1B,IAAAU,aAAO,GACP;IACA,IAAAC,QAAE,EAAE,4BAA6B,CAAC,EAClChB,eACA,CAAC,GAC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AAC,aAAA,EAAC6B,kBAAkB;IAClBI,QAAQ,EAAGA,QAAU;IACrBC,UAAU,EAAGgB,UAAU,EAAEK,QAAQ,EAAEN,IAAM;IACzC5B,QAAQ,EAAKuB,OAAO,IAAM;MACzBO,aAAa,CAAE;QACdI,QAAQ,EAAE;UACT,GAAGL,UAAU,EAAEK,QAAQ;UACvBN,IAAI,EAAEL;QACP;MACD,CAAE,CAAC;IACJ;EAAG,CACH,CACA,CACF,EAED,IAAA7C,MAAA,CAAAC,aAAA,EAACgD,SAAS;IAACQ,GAAG,EAAC,MAAM;IAAA,GAAM1B;EAAK,CAAI,CACnC,CAAC;AAEL,CAAC,EACD,yBACD,CAAC;AAAC2B,OAAA,CAAAX,uBAAA,GAAAA,uBAAA;AAEF,IAAAY,gBAAS,EACR,kBAAkB,EAClB,iDAAiD,EACjDZ,uBACD,CAAC"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.withBlockControls = void 0;
6
+ exports.withContentLockControls = void 0;
7
7
  var _react = require("react");
8
8
  var _components = require("@wordpress/components");
9
9
  var _compose = require("@wordpress/compose");
@@ -39,7 +39,7 @@ function StopEditingAsBlocksOnOutsideSelect({
39
39
  }, [isBlockOrDescendantSelected, stopEditingAsBlock]);
40
40
  return null;
41
41
  }
42
- const withBlockControls = (0, _compose.createHigherOrderComponent)(BlockEdit => props => {
42
+ const withContentLockControls = (0, _compose.createHigherOrderComponent)(BlockEdit => props => {
43
43
  const {
44
44
  getBlockListSettings,
45
45
  getSettings
@@ -125,7 +125,7 @@ const withBlockControls = (0, _compose.createHigherOrderComponent)(BlockEdit =>
125
125
  key: "edit",
126
126
  ...props
127
127
  }));
128
- }, 'withToolbarControls');
129
- exports.withBlockControls = withBlockControls;
130
- (0, _hooks.addFilter)('editor.BlockEdit', 'core/content-lock-ui/with-block-controls', withBlockControls);
128
+ }, 'withContentLockControls');
129
+ exports.withContentLockControls = withContentLockControls;
130
+ (0, _hooks.addFilter)('editor.BlockEdit', 'core/content-lock-ui/with-block-controls', withContentLockControls);
131
131
  //# sourceMappingURL=content-lock-ui.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_compose","_data","_hooks","_i18n","_element","_store","_components2","StopEditingAsBlocksOnOutsideSelect","clientId","stopEditingAsBlock","isBlockOrDescendantSelected","useSelect","select","isBlockSelected","hasSelectedInnerBlock","blockEditorStore","useEffect","withBlockControls","createHigherOrderComponent","BlockEdit","props","getBlockListSettings","getSettings","focusModeToRevert","useRef","templateLock","isLockedByParent","isEditingAsBlocks","__unstableGetContentLockingParent","getTemplateLock","__unstableGetTemporarilyEditingAsBlocks","updateSettings","updateBlockListSettings","__unstableSetTemporarilyEditingAsBlocks","useDispatch","isContentLocked","__unstableMarkNextChangeAsNotPersistent","updateBlockAttributes","useCallback","focusMode","current","_react","createElement","key","showStopEditingAsBlocks","showStartEditingAsBlocks","isSelected","Fragment","BlockControls","group","ToolbarButton","onClick","__","BlockSettingsMenuControls","onClose","MenuItem","undefined","exports","addFilter"],"sources":["@wordpress/block-editor/src/hooks/content-lock-ui.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ToolbarButton, MenuItem } from '@wordpress/components';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { addFilter } from '@wordpress/hooks';\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, useRef, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { BlockControls, BlockSettingsMenuControls } from '../components';\n\nfunction StopEditingAsBlocksOnOutsideSelect( {\n\tclientId,\n\tstopEditingAsBlock,\n} ) {\n\tconst isBlockOrDescendantSelected = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isBlockSelected, hasSelectedInnerBlock } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn (\n\t\t\t\tisBlockSelected( clientId ) ||\n\t\t\t\thasSelectedInnerBlock( clientId, true )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\tuseEffect( () => {\n\t\tif ( ! isBlockOrDescendantSelected ) {\n\t\t\tstopEditingAsBlock();\n\t\t}\n\t}, [ isBlockOrDescendantSelected, stopEditingAsBlock ] );\n\treturn null;\n}\n\nexport const withBlockControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { getBlockListSettings, getSettings } =\n\t\t\tuseSelect( blockEditorStore );\n\t\tconst focusModeToRevert = useRef();\n\t\tconst { templateLock, isLockedByParent, isEditingAsBlocks } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\t__unstableGetContentLockingParent,\n\t\t\t\t\tgetTemplateLock,\n\t\t\t\t\t__unstableGetTemporarilyEditingAsBlocks,\n\t\t\t\t} = select( blockEditorStore );\n\t\t\t\treturn {\n\t\t\t\t\ttemplateLock: getTemplateLock( props.clientId ),\n\t\t\t\t\tisLockedByParent: !! __unstableGetContentLockingParent(\n\t\t\t\t\t\tprops.clientId\n\t\t\t\t\t),\n\t\t\t\t\tisEditingAsBlocks:\n\t\t\t\t\t\t__unstableGetTemporarilyEditingAsBlocks() ===\n\t\t\t\t\t\tprops.clientId,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ props.clientId ]\n\t\t);\n\n\t\tconst {\n\t\t\tupdateSettings,\n\t\t\tupdateBlockListSettings,\n\t\t\t__unstableSetTemporarilyEditingAsBlocks,\n\t\t} = useDispatch( blockEditorStore );\n\t\tconst isContentLocked =\n\t\t\t! isLockedByParent && templateLock === 'contentOnly';\n\t\tconst {\n\t\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\t\tupdateBlockAttributes,\n\t\t} = useDispatch( blockEditorStore );\n\n\t\tconst stopEditingAsBlock = useCallback( () => {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateBlockAttributes( props.clientId, {\n\t\t\t\ttemplateLock: 'contentOnly',\n\t\t\t} );\n\t\t\tupdateBlockListSettings( props.clientId, {\n\t\t\t\t...getBlockListSettings( props.clientId ),\n\t\t\t\ttemplateLock: 'contentOnly',\n\t\t\t} );\n\t\t\tupdateSettings( { focusMode: focusModeToRevert.current } );\n\t\t\t__unstableSetTemporarilyEditingAsBlocks();\n\t\t}, [\n\t\t\tprops.clientId,\n\t\t\tupdateSettings,\n\t\t\tupdateBlockListSettings,\n\t\t\tgetBlockListSettings,\n\t\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\t\tupdateBlockAttributes,\n\t\t\t__unstableSetTemporarilyEditingAsBlocks,\n\t\t] );\n\n\t\tif ( ! isContentLocked && ! isEditingAsBlocks ) {\n\t\t\treturn <BlockEdit key=\"edit\" { ...props } />;\n\t\t}\n\n\t\tconst showStopEditingAsBlocks = isEditingAsBlocks && ! isContentLocked;\n\t\tconst showStartEditingAsBlocks =\n\t\t\t! isEditingAsBlocks && isContentLocked && props.isSelected;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ showStopEditingAsBlocks && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<StopEditingAsBlocksOnOutsideSelect\n\t\t\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\t\t\tstopEditingAsBlock={ stopEditingAsBlock }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tstopEditingAsBlock();\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{ __( 'Done' ) }\n\t\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t\t</BlockControls>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t{ showStartEditingAsBlocks && (\n\t\t\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\t\t\t\t\tupdateBlockAttributes( props.clientId, {\n\t\t\t\t\t\t\t\t\t\ttemplateLock: undefined,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\tupdateBlockListSettings( props.clientId, {\n\t\t\t\t\t\t\t\t\t\t...getBlockListSettings(\n\t\t\t\t\t\t\t\t\t\t\tprops.clientId\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\ttemplateLock: false,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\tfocusModeToRevert.current =\n\t\t\t\t\t\t\t\t\t\tgetSettings().focusMode;\n\t\t\t\t\t\t\t\t\tupdateSettings( { focusMode: true } );\n\t\t\t\t\t\t\t\t\t__unstableSetTemporarilyEditingAsBlocks(\n\t\t\t\t\t\t\t\t\t\tprops.clientId\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tonClose();\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{ __( 'Modify' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</BlockSettingsMenuControls>\n\t\t\t\t) }\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withToolbarControls'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/content-lock-ui/with-block-controls',\n\twithBlockControls\n);\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,Y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ACwB,GAAG,EAAC,MAAM;IAAA,GAAMvB;EAAK,CAAI,CACnC,CAAC;AAEL,CAAC,EACD,qBACD,CAAC;AAACqC,OAAA,CAAAxC,iBAAA,GAAAA,iBAAA;AAEF,IAAAyC,gBAAS,EACR,kBAAkB,EAClB,0CAA0C,EAC1CzC,iBACD,CAAC"}
1
+ {"version":3,"names":["_components","require","_compose","_data","_hooks","_i18n","_element","_store","_components2","StopEditingAsBlocksOnOutsideSelect","clientId","stopEditingAsBlock","isBlockOrDescendantSelected","useSelect","select","isBlockSelected","hasSelectedInnerBlock","blockEditorStore","useEffect","withContentLockControls","createHigherOrderComponent","BlockEdit","props","getBlockListSettings","getSettings","focusModeToRevert","useRef","templateLock","isLockedByParent","isEditingAsBlocks","__unstableGetContentLockingParent","getTemplateLock","__unstableGetTemporarilyEditingAsBlocks","updateSettings","updateBlockListSettings","__unstableSetTemporarilyEditingAsBlocks","useDispatch","isContentLocked","__unstableMarkNextChangeAsNotPersistent","updateBlockAttributes","useCallback","focusMode","current","_react","createElement","key","showStopEditingAsBlocks","showStartEditingAsBlocks","isSelected","Fragment","BlockControls","group","ToolbarButton","onClick","__","BlockSettingsMenuControls","onClose","MenuItem","undefined","exports","addFilter"],"sources":["@wordpress/block-editor/src/hooks/content-lock-ui.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ToolbarButton, MenuItem } from '@wordpress/components';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { addFilter } from '@wordpress/hooks';\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, useRef, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { BlockControls, BlockSettingsMenuControls } from '../components';\n\nfunction StopEditingAsBlocksOnOutsideSelect( {\n\tclientId,\n\tstopEditingAsBlock,\n} ) {\n\tconst isBlockOrDescendantSelected = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isBlockSelected, hasSelectedInnerBlock } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn (\n\t\t\t\tisBlockSelected( clientId ) ||\n\t\t\t\thasSelectedInnerBlock( clientId, true )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\tuseEffect( () => {\n\t\tif ( ! isBlockOrDescendantSelected ) {\n\t\t\tstopEditingAsBlock();\n\t\t}\n\t}, [ isBlockOrDescendantSelected, stopEditingAsBlock ] );\n\treturn null;\n}\n\nexport const withContentLockControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { getBlockListSettings, getSettings } =\n\t\t\tuseSelect( blockEditorStore );\n\t\tconst focusModeToRevert = useRef();\n\t\tconst { templateLock, isLockedByParent, isEditingAsBlocks } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\t__unstableGetContentLockingParent,\n\t\t\t\t\tgetTemplateLock,\n\t\t\t\t\t__unstableGetTemporarilyEditingAsBlocks,\n\t\t\t\t} = select( blockEditorStore );\n\t\t\t\treturn {\n\t\t\t\t\ttemplateLock: getTemplateLock( props.clientId ),\n\t\t\t\t\tisLockedByParent: !! __unstableGetContentLockingParent(\n\t\t\t\t\t\tprops.clientId\n\t\t\t\t\t),\n\t\t\t\t\tisEditingAsBlocks:\n\t\t\t\t\t\t__unstableGetTemporarilyEditingAsBlocks() ===\n\t\t\t\t\t\tprops.clientId,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ props.clientId ]\n\t\t);\n\n\t\tconst {\n\t\t\tupdateSettings,\n\t\t\tupdateBlockListSettings,\n\t\t\t__unstableSetTemporarilyEditingAsBlocks,\n\t\t} = useDispatch( blockEditorStore );\n\t\tconst isContentLocked =\n\t\t\t! isLockedByParent && templateLock === 'contentOnly';\n\t\tconst {\n\t\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\t\tupdateBlockAttributes,\n\t\t} = useDispatch( blockEditorStore );\n\n\t\tconst stopEditingAsBlock = useCallback( () => {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateBlockAttributes( props.clientId, {\n\t\t\t\ttemplateLock: 'contentOnly',\n\t\t\t} );\n\t\t\tupdateBlockListSettings( props.clientId, {\n\t\t\t\t...getBlockListSettings( props.clientId ),\n\t\t\t\ttemplateLock: 'contentOnly',\n\t\t\t} );\n\t\t\tupdateSettings( { focusMode: focusModeToRevert.current } );\n\t\t\t__unstableSetTemporarilyEditingAsBlocks();\n\t\t}, [\n\t\t\tprops.clientId,\n\t\t\tupdateSettings,\n\t\t\tupdateBlockListSettings,\n\t\t\tgetBlockListSettings,\n\t\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\t\tupdateBlockAttributes,\n\t\t\t__unstableSetTemporarilyEditingAsBlocks,\n\t\t] );\n\n\t\tif ( ! isContentLocked && ! isEditingAsBlocks ) {\n\t\t\treturn <BlockEdit key=\"edit\" { ...props } />;\n\t\t}\n\n\t\tconst showStopEditingAsBlocks = isEditingAsBlocks && ! isContentLocked;\n\t\tconst showStartEditingAsBlocks =\n\t\t\t! isEditingAsBlocks && isContentLocked && props.isSelected;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ showStopEditingAsBlocks && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<StopEditingAsBlocksOnOutsideSelect\n\t\t\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\t\t\tstopEditingAsBlock={ stopEditingAsBlock }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tstopEditingAsBlock();\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{ __( 'Done' ) }\n\t\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t\t</BlockControls>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t{ showStartEditingAsBlocks && (\n\t\t\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\t\t\t\t\tupdateBlockAttributes( props.clientId, {\n\t\t\t\t\t\t\t\t\t\ttemplateLock: undefined,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\tupdateBlockListSettings( props.clientId, {\n\t\t\t\t\t\t\t\t\t\t...getBlockListSettings(\n\t\t\t\t\t\t\t\t\t\t\tprops.clientId\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\ttemplateLock: false,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\tfocusModeToRevert.current =\n\t\t\t\t\t\t\t\t\t\tgetSettings().focusMode;\n\t\t\t\t\t\t\t\t\tupdateSettings( { focusMode: true } );\n\t\t\t\t\t\t\t\t\t__unstableSetTemporarilyEditingAsBlocks(\n\t\t\t\t\t\t\t\t\t\tprops.clientId\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tonClose();\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{ __( 'Modify' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</BlockSettingsMenuControls>\n\t\t\t\t) }\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withContentLockControls'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/content-lock-ui/with-block-controls',\n\twithContentLockControls\n);\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IA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V;EAAG,GAED,IAAAF,QAAE,EAAE,QAAS,CACN,CAEe,CAC3B,EACD,IAAAX,MAAA,CAAAC,aAAA,EAACvB,SAAS;IAACwB,GAAG,EAAC,MAAM;IAAA,GAAMvB;EAAK,CAAI,CACnC,CAAC;AAEL,CAAC,EACD,yBACD,CAAC;AAACqC,OAAA,CAAAxC,uBAAA,GAAAA,uBAAA;AAEF,IAAAyC,gBAAS,EACR,kBAAkB,EAClB,0CAA0C,EAC1CzC,uBACD,CAAC"}
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.addAttribute = addAttribute;
8
8
  exports.addSaveProps = addSaveProps;
9
9
  exports.addTransforms = addTransforms;
10
- exports.withInspectorControl = void 0;
10
+ exports.withCustomClassNameControls = void 0;
11
11
  var _react = require("react");
12
12
  var _classnames = _interopRequireDefault(require("classnames"));
13
13
  var _hooks = require("@wordpress/hooks");
@@ -60,6 +60,7 @@ function CustomClassNameControls({
60
60
  group: "advanced"
61
61
  }, (0, _react.createElement)(_components.TextControl, {
62
62
  __nextHasNoMarginBottom: true,
63
+ __next40pxDefaultSize: true,
63
64
  autoComplete: "off",
64
65
  label: (0, _i18n.__)('Additional CSS class(es)'),
65
66
  value: attributes.className || '',
@@ -81,7 +82,7 @@ function CustomClassNameControls({
81
82
  *
82
83
  * @return {Component} Wrapped component.
83
84
  */
84
- const withInspectorControl = (0, _compose.createHigherOrderComponent)(BlockEdit => {
85
+ const withCustomClassNameControls = (0, _compose.createHigherOrderComponent)(BlockEdit => {
85
86
  return props => {
86
87
  const hasCustomClassName = (0, _blocks.hasBlockSupport)(props.name, 'customClassName', true);
87
88
  return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(BlockEdit, {
@@ -91,7 +92,7 @@ const withInspectorControl = (0, _compose.createHigherOrderComponent)(BlockEdit
91
92
  setAttributes: props.setAttributes
92
93
  }));
93
94
  };
94
- }, 'withInspectorControl');
95
+ }, 'withCustomClassNameControls');
95
96
 
96
97
  /**
97
98
  * Override props assigned to save component to inject the className, if block
@@ -104,7 +105,7 @@ const withInspectorControl = (0, _compose.createHigherOrderComponent)(BlockEdit
104
105
  *
105
106
  * @return {Object} Filtered props applied to save element.
106
107
  */
107
- exports.withInspectorControl = withInspectorControl;
108
+ exports.withCustomClassNameControls = withCustomClassNameControls;
108
109
  function addSaveProps(extraProps, blockType, attributes) {
109
110
  if ((0, _blocks.hasBlockSupport)(blockType, 'customClassName', true) && attributes.className) {
110
111
  extraProps.className = (0, _classnames.default)(extraProps.className, attributes.className);
@@ -146,8 +147,8 @@ function addTransforms(result, source, index, results) {
146
147
  }
147
148
  return result;
148
149
  }
149
- (0, _hooks.addFilter)('blocks.registerBlockType', 'core/custom-class-name/attribute', addAttribute);
150
- (0, _hooks.addFilter)('editor.BlockEdit', 'core/editor/custom-class-name/with-inspector-control', withInspectorControl);
151
- (0, _hooks.addFilter)('blocks.getSaveContent.extraProps', 'core/custom-class-name/save-props', addSaveProps);
150
+ (0, _hooks.addFilter)('blocks.registerBlockType', 'core/editor/custom-class-name/attribute', addAttribute);
151
+ (0, _hooks.addFilter)('editor.BlockEdit', 'core/editor/custom-class-name/with-inspector-controls', withCustomClassNameControls);
152
+ (0, _hooks.addFilter)('blocks.getSaveContent.extraProps', 'core/editor/custom-class-name/save-props', addSaveProps);
152
153
  (0, _hooks.addFilter)('blocks.switchToBlockType.transformedBlock', 'core/color/addTransforms', addTransforms);
153
154
  //# sourceMappingURL=custom-class-name.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_classnames","_interopRequireDefault","require","_hooks","_components","_i18n","_blocks","_compose","_components2","_blockEditingMode","addAttribute","settings","hasBlockSupport","attributes","className","type","CustomClassNameControls","setAttributes","blockEditingMode","useBlockEditingMode","_react","createElement","InspectorControls","group","TextControl","__nextHasNoMarginBottom","autoComplete","label","__","value","onChange","nextValue","undefined","help","withInspectorControl","createHigherOrderComponent","BlockEdit","props","hasCustomClassName","name","Fragment","isSelected","exports","addSaveProps","extraProps","blockType","classnames","addTransforms","result","source","index","results","length","innerBlocks","originClassName","addFilter"],"sources":["@wordpress/block-editor/src/hooks/custom-class-name.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { TextControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * Filters registered block settings, extending attributes to include `className`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( hasBlockSupport( settings, 'customClassName', true ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tclassName: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction CustomClassNameControls( { attributes, setAttributes } ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tautoComplete=\"off\"\n\t\t\t\tlabel={ __( 'Additional CSS class(es)' ) }\n\t\t\t\tvalue={ attributes.className || '' }\n\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tclassName: nextValue !== '' ? nextValue : undefined,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\thelp={ __( 'Separate multiple classes with spaces.' ) }\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning the custom class name, if block supports custom class name.\n * The control is displayed within the Advanced panel in the block inspector.\n *\n * @param {Component} BlockEdit Original component.\n *\n * @return {Component} Wrapped component.\n */\nexport const withInspectorControl = createHigherOrderComponent(\n\t( BlockEdit ) => {\n\t\treturn ( props ) => {\n\t\t\tconst hasCustomClassName = hasBlockSupport(\n\t\t\t\tprops.name,\n\t\t\t\t'customClassName',\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t\t{ hasCustomClassName && props.isSelected && (\n\t\t\t\t\t\t<CustomClassNameControls\n\t\t\t\t\t\t\tattributes={ props.attributes }\n\t\t\t\t\t\t\tsetAttributes={ props.setAttributes }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t);\n\t\t};\n\t},\n\t'withInspectorControl'\n);\n\n/**\n * Override props assigned to save component to inject the className, if block\n * supports customClassName. 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 (\n\t\thasBlockSupport( blockType, 'customClassName', true ) &&\n\t\tattributes.className\n\t) {\n\t\textraProps.className = classnames(\n\t\t\textraProps.className,\n\t\t\tattributes.className\n\t\t);\n\t}\n\n\treturn extraProps;\n}\n\nexport function addTransforms( result, source, index, results ) {\n\tif ( ! hasBlockSupport( result.name, 'customClassName', true ) ) {\n\t\treturn result;\n\t}\n\n\t// If the condition verifies we are probably in the presence of a wrapping transform\n\t// e.g: nesting paragraphs in a group or columns and in that case the class should not be kept.\n\tif ( results.length === 1 && result.innerBlocks.length === source.length ) {\n\t\treturn result;\n\t}\n\n\t// If we are transforming one block to multiple blocks or multiple blocks to one block,\n\t// we ignore the class during the transform.\n\tif (\n\t\t( results.length === 1 && source.length > 1 ) ||\n\t\t( results.length > 1 && source.length === 1 )\n\t) {\n\t\treturn result;\n\t}\n\n\t// If we are in presence of transform between one or more block in the source\n\t// that have one or more blocks in the result\n\t// we apply the class on source N to the result N,\n\t// if source N does not exists we do nothing.\n\tif ( source[ index ] ) {\n\t\tconst originClassName = source[ index ]?.attributes.className;\n\t\tif ( originClassName ) {\n\t\t\treturn {\n\t\t\t\t...result,\n\t\t\t\tattributes: {\n\t\t\t\t\t...result.attributes,\n\t\t\t\t\tclassName: originClassName,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n\treturn result;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/custom-class-name/attribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/custom-class-name/with-inspector-control',\n\twithInspectorControl\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/custom-class-name/save-props',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.switchToBlockType.transformedBlock',\n\t'core/color/addTransforms',\n\taddTransforms\n);\n"],"mappings":";;;;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAKA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASQ,YAAYA,CAAEC,QAAQ,EAAG;EACxC,IAAK,IAAAC,uBAAe,EAAED,QAAQ,EAAE,iBAAiB,EAAE,IAAK,CAAC,EAAG;IAC3D;IACAA,QAAQ,CAACE,UAAU,GAAG;MACrB,GAAGF,QAAQ,CAACE,UAAU;MACtBC,SAAS,EAAE;QACVC,IAAI,EAAE;MACP;IACD,CA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;MACtB,OAAO;QACN,GAAGN,MAAM;QACTnC,UAAU,EAAE;UACX,GAAGmC,MAAM,CAACnC,UAAU;UACpBC,SAAS,EAAEwC;QACZ;MACD,CAAC;IACF;EACD;EACA,OAAON,MAAM;AACd;AAEA,IAAAO,gBAAS,EACR,0BAA0B,EAC1B,kCAAkC,EAClC7C,YACD,CAAC;AACD,IAAA6C,gBAAS,EACR,kBAAkB,EAClB,sDAAsD,EACtDrB,oBACD,CAAC;AACD,IAAAqB,gBAAS,EACR,kCAAkC,EAClC,mCAAmC,EACnCZ,YACD,CAAC;AAED,IAAAY,gBAAS,EACR,2CAA2C,EAC3C,0BAA0B,EAC1BR,aACD,CAAC"}
1
+ {"version":3,"names":["_classnames","_interopRequireDefault","require","_hooks","_components","_i18n","_blocks","_compose","_components2","_blockEditingMode","addAttribute","settings","hasBlockSupport","attributes","className","type","CustomClassNameControls","setAttributes","blockEditingMode","useBlockEditingMode","_react","createElement","InspectorControls","group","TextControl","__nextHasNoMarginBottom","__next40pxDefaultSize","autoComplete","label","__","value","onChange","nextValue","undefined","help","withCustomClassNameControls","createHigherOrderComponent","BlockEdit","props","hasCustomClassName","name","Fragment","isSelected","exports","addSaveProps","extraProps","blockType","classnames","addTransforms","result","source","index","results","length","innerBlocks","originClassName","addFilter"],"sources":["@wordpress/block-editor/src/hooks/custom-class-name.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { TextControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * Filters registered block settings, extending attributes to include `className`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( hasBlockSupport( settings, 'customClassName', true ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tclassName: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction CustomClassNameControls( { attributes, setAttributes } ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tautoComplete=\"off\"\n\t\t\t\tlabel={ __( 'Additional CSS class(es)' ) }\n\t\t\t\tvalue={ attributes.className || '' }\n\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tclassName: nextValue !== '' ? nextValue : undefined,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\thelp={ __( 'Separate multiple classes with spaces.' ) }\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning the custom class name, if block supports custom class name.\n * The control is displayed within the Advanced panel in the block inspector.\n *\n * @param {Component} BlockEdit Original component.\n *\n * @return {Component} Wrapped component.\n */\nexport const withCustomClassNameControls = createHigherOrderComponent(\n\t( BlockEdit ) => {\n\t\treturn ( props ) => {\n\t\t\tconst hasCustomClassName = hasBlockSupport(\n\t\t\t\tprops.name,\n\t\t\t\t'customClassName',\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t\t{ hasCustomClassName && props.isSelected && (\n\t\t\t\t\t\t<CustomClassNameControls\n\t\t\t\t\t\t\tattributes={ props.attributes }\n\t\t\t\t\t\t\tsetAttributes={ props.setAttributes }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t);\n\t\t};\n\t},\n\t'withCustomClassNameControls'\n);\n\n/**\n * Override props assigned to save component to inject the className, if block\n * supports customClassName. 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 (\n\t\thasBlockSupport( blockType, 'customClassName', true ) &&\n\t\tattributes.className\n\t) {\n\t\textraProps.className = classnames(\n\t\t\textraProps.className,\n\t\t\tattributes.className\n\t\t);\n\t}\n\n\treturn extraProps;\n}\n\nexport function addTransforms( result, source, index, results ) {\n\tif ( ! hasBlockSupport( result.name, 'customClassName', true ) ) {\n\t\treturn result;\n\t}\n\n\t// If the condition verifies we are probably in the presence of a wrapping transform\n\t// e.g: nesting paragraphs in a group or columns and in that case the class should not be kept.\n\tif ( results.length === 1 && result.innerBlocks.length === source.length ) {\n\t\treturn result;\n\t}\n\n\t// If we are transforming one block to multiple blocks or multiple blocks to one block,\n\t// we ignore the class during the transform.\n\tif (\n\t\t( results.length === 1 && source.length > 1 ) ||\n\t\t( results.length > 1 && source.length === 1 )\n\t) {\n\t\treturn result;\n\t}\n\n\t// If we are in presence of transform between one or more block in the source\n\t// that have one or more blocks in the result\n\t// we apply the class on source N to the result N,\n\t// if source N does not exists we do nothing.\n\tif ( source[ index ] ) {\n\t\tconst originClassName = source[ index ]?.attributes.className;\n\t\tif ( originClassName ) {\n\t\t\treturn {\n\t\t\t\t...result,\n\t\t\t\tattributes: {\n\t\t\t\t\t...result.attributes,\n\t\t\t\t\tclassName: originClassName,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n\treturn result;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/custom-class-name/attribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/custom-class-name/with-inspector-controls',\n\twithCustomClassNameControls\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/editor/custom-class-name/save-props',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.switchToBlockType.transformedBlock',\n\t'core/color/addTransforms',\n\taddTransforms\n);\n"],"mappings":";;;;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAKA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASQ,YAAYA,CAAEC,QAAQ,EAAG;EACxC,IAAK,IAAAC,uBAAe,EAAED,QAAQ,EAAE,iBAAiB,EAAE,IAAK,CAAC,EAAG;IAC3D;IACAA,QAAQ,CAACE,UAAU,GAAG;MACrB,GAAGF,QAAQ,CAACE,UAAU;MACtBC,SAAS,EAAE;QACVC,IAAI,EAAE;MACP;IACD,CAAC;EACF;EAEA,OAAOJ,QAAQ;AAChB;AAEA,SAASK,uBAAuBA,CAAE;EAAEH,UAAU;EAAEI;AAAc,CAAC,EAAG;EACjE,MAAMC,gBAAgB,GAAG,IAAAC,qCAAmB,EAAC,CAAC;EAC9C,IAAKD,gBAAgB,KAAK,SAAS,EAAG;IACrC,OAAO,IAAI;EACZ;EAEA,OACC,IAAAE,MAAA,CAAAC,aAAA,EAACb,YAAA,CAAAc,iBAAiB;IAACC,KAAK,EAAC;EAAU,GAClC,IAAAH,MAAA,CAAAC,aAAA,EAACjB,WAAA,CAAAoB,WAAW;IACXC,uBAAuB;IACvBC,qBAAqB;IACrBC,YAAY,EAAC,KAAK;IAClBC,KAA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AAC"}
@@ -46,7 +46,7 @@ function addAttribute(settings) {
46
46
  *
47
47
  * @return {Component} Wrapped component.
48
48
  */
49
- const withInspectorControl = (0, _compose.createHigherOrderComponent)(BlockEdit => {
49
+ const withCustomFieldsControls = (0, _compose.createHigherOrderComponent)(BlockEdit => {
50
50
  return props => {
51
51
  const blockEditingMode = (0, _blockEditingMode.useBlockEditingMode)();
52
52
  const hasCustomFieldsSupport = (0, _blocks.hasBlockSupport)(props.name, '__experimentalConnections', false);
@@ -107,9 +107,9 @@ const withInspectorControl = (0, _compose.createHigherOrderComponent)(BlockEdit
107
107
  ...props
108
108
  });
109
109
  };
110
- }, 'withInspectorControl');
110
+ }, 'withCustomFieldsControls');
111
111
  if (window.__experimentalConnections) {
112
- (0, _hooks.addFilter)('blocks.registerBlockType', 'core/connections/attribute', addAttribute);
113
- (0, _hooks.addFilter)('editor.BlockEdit', 'core/connections/with-inspector-control', withInspectorControl);
112
+ (0, _hooks.addFilter)('blocks.registerBlockType', 'core/editor/connections/attribute', addAttribute);
113
+ (0, _hooks.addFilter)('editor.BlockEdit', 'core/editor/connections/with-inspector-controls', withCustomFieldsControls);
114
114
  }
115
115
  //# sourceMappingURL=custom-fields.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_hooks","require","_components","_i18n","_blocks","_compose","_components2","_blockEditingMode","addAttribute","settings","hasBlockSupport","attributes","connections","type","withInspectorControl","createHigherOrderComponent","BlockEdit","props","blockEditingMode","useBlockEditingMode","hasCustomFieldsSupport","name","includes","_react","createElement","attributeName","isSelected","Fragment","InspectorControls","PanelBody","title","__","initialOpen","TextControl","__nextHasNoMarginBottom","autoComplete","label","value","onChange","nextValue","setAttributes","undefined","placeholder","source","sprintf","window","__experimentalConnections","addFilter"],"sources":["@wordpress/block-editor/src/hooks/custom-fields.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * Filters registered block settings, extending attributes to include `connections`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttribute( settings ) {\n\tif ( hasBlockSupport( settings, '__experimentalConnections', true ) ) {\n\t\t// Gracefully handle if settings.attributes.connections is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tconnections: {\n\t\t\t\ttype: 'object',\n\t\t\t},\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 a connection to blocks that has support for connections.\n * Currently, only the `core/paragraph` block is supported and there is only a relation\n * between paragraph content and a custom field.\n *\n * @param {Component} BlockEdit Original component.\n *\n * @return {Component} Wrapped component.\n */\nconst withInspectorControl = createHigherOrderComponent( ( BlockEdit ) => {\n\treturn ( props ) => {\n\t\tconst blockEditingMode = useBlockEditingMode();\n\t\tconst hasCustomFieldsSupport = hasBlockSupport(\n\t\t\tprops.name,\n\t\t\t'__experimentalConnections',\n\t\t\tfalse\n\t\t);\n\n\t\t// Check if the current block is a paragraph or image block.\n\t\t// Currently, only these two blocks are supported.\n\t\tif ( ! [ 'core/paragraph', 'core/image' ].includes( props.name ) ) {\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t}\n\n\t\t// If the block is a paragraph or image block, we need to know which\n\t\t// attribute to use for the connection. Only the `content` attribute\n\t\t// of the paragraph block and the `url` attribute of the image block are supported.\n\t\tlet attributeName;\n\t\tif ( props.name === 'core/paragraph' ) attributeName = 'content';\n\t\tif ( props.name === 'core/image' ) attributeName = 'url';\n\n\t\tif ( hasCustomFieldsSupport && props.isSelected ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t\t<PanelBody\n\t\t\t\t\t\t\t\ttitle={ __( 'Connections' ) }\n\t\t\t\t\t\t\t\tinitialOpen={ true }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Custom field meta_key' ) }\n\t\t\t\t\t\t\t\t\tvalue={\n\t\t\t\t\t\t\t\t\t\tprops.attributes?.connections\n\t\t\t\t\t\t\t\t\t\t\t?.attributes?.[ attributeName ]\n\t\t\t\t\t\t\t\t\t\t\t?.value || ''\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\t\t\t\t\t\tif ( nextValue === '' ) {\n\t\t\t\t\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\tconnections: undefined,\n\t\t\t\t\t\t\t\t\t\t\t\t[ attributeName ]: undefined,\n\t\t\t\t\t\t\t\t\t\t\t\tplaceholder: undefined,\n\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\tconnections: {\n\t\t\t\t\t\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t// The attributeName will be either `content` or `url`.\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[ attributeName ]: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// Source will be variable, could be post_meta, user_meta, term_meta, etc.\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// Could even be a custom source like a social media attribute.\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsource: 'meta_fields',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue: nextValue,\n\t\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},\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[ attributeName ]: undefined,\n\t\t\t\t\t\t\t\t\t\t\t\tplaceholder: sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'This content will be replaced on the frontend by the value of \"%s\" custom field.',\n\t\t\t\t\t\t\t\t\t\t\t\t\tnextValue\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}\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</PanelBody>\n\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t);\n\t\t}\n\n\t\treturn <BlockEdit { ...props } />;\n\t};\n}, 'withInspectorControl' );\n\nif ( window.__experimentalConnections ) {\n\taddFilter(\n\t\t'blocks.registerBlockType',\n\t\t'core/connections/attribute',\n\t\taddAttribute\n\t);\n\taddFilter(\n\t\t'editor.BlockEdit',\n\t\t'core/connections/with-inspector-control',\n\t\twithInspectorControl\n\t);\n}\n"],"mappings":";;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAN,OAAA;AAbA;AACA;AACA;;AAOA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASO,YAAYA,CAAEC,QAAQ,EAAG;EACjC,IAAK,IAAAC,uBAAe,EAAED,QAAQ,EAAE,2BAA2B,EAAE,IAAK,CAAC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AAW,EAAG;MAAM,GAEpB,IAAAT,MAAA,CAAAC,aAAA,EAACtB,WAAA,CAAA+B,WAAW;QACXC,uBAAuB;QACvBC,YAAY,EAAC,KAAK;QAClBC,KAAK,EAAG,IAAAL,QAAE,EAAE,uBAAwB,CAAG;QACvCM,KAAK,EACJpB,KAAK,CAACN,UAAU,EAAEC,WAAW,EAC1BD,UAAU,GAAIc,aAAa,CAAE,EAC7BY,KAAK,IAAI,EACZ;QACDC,QAAQ,EAAKC,SAAS,IAAM;UAC3B,IAAKA,SAAS,KAAK,EAAE,EAAG;YACvBtB,KAAK,CAACuB,aAAa,CAAE;cACpB5B,WAAW,EAAE6B,SAAS;cACtB,CAAEhB,aAAa,GAAIgB,SAAS;cAC5BC,WAAW,EAAED;YACd,CAAE,CAAC;UACJ,CAAC,MAAM;YACNxB,KAAK,CAACuB,aAAa,CAAE;cACpB5B,WAAW,EAAE;gBACZD,UAAU,EAAE;kBACX;kBACA,CAAEc,aAAa,GAAI;oBAClB;oBACA;oBACAkB,MAAM,EAAE,aAAa;oBACrBN,KAAK,EAAEE;kBACR;gBACD;cACD,CAAC;cACD,CAAEd,aAAa,GAAIgB,SAAS;cAC5BC,WAAW,EAAE,IAAAE,aAAO,EACnB,kFAAkF,EAClFL,SACD;YACD,CAAE,CAAC;UACJ;QACD;MAAG,CACH,CACS,CACO,CAEnB,CAAC;IAEL;IAEA,OAAO,IAAAhB,MAAA,CAAAC,aAAA,EAACR,SAAS;MAAA,GAAMC;IAAK,CAAI,CAAC;EAClC,CAAC;AACF,CAAC,EAAE,sBAAuB,CAAC;AAE3B,IAAK4B,MAAM,CAACC,yBAAyB,EAAG;EACvC,IAAAC,gBAAS,EACR,0BAA0B,EAC1B,4BAA4B,EAC5BvC,YACD,CAAC;EACD,IAAAuC,gBAAS,EACR,kBAAkB,EAClB,yCAAyC,EACzCjC,oBACD,CAAC;AACF"}
1
+ {"version":3,"names":["_hooks","require","_components","_i18n","_blocks","_compose","_components2","_blockEditingMode","addAttribute","settings","hasBlockSupport","attributes","connections","type","withCustomFieldsControls","createHigherOrderComponent","BlockEdit","props","blockEditingMode","useBlockEditingMode","hasCustomFieldsSupport","name","includes","_react","createElement","attributeName","isSelected","Fragment","InspectorControls","PanelBody","title","__","initialOpen","TextControl","__nextHasNoMarginBottom","autoComplete","label","value","onChange","nextValue","setAttributes","undefined","placeholder","source","sprintf","window","__experimentalConnections","addFilter"],"sources":["@wordpress/block-editor/src/hooks/custom-fields.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * Filters registered block settings, extending attributes to include `connections`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttribute( settings ) {\n\tif ( hasBlockSupport( settings, '__experimentalConnections', true ) ) {\n\t\t// Gracefully handle if settings.attributes.connections is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tconnections: {\n\t\t\t\ttype: 'object',\n\t\t\t},\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 a connection to blocks that has support for connections.\n * Currently, only the `core/paragraph` block is supported and there is only a relation\n * between paragraph content and a custom field.\n *\n * @param {Component} BlockEdit Original component.\n *\n * @return {Component} Wrapped component.\n */\nconst withCustomFieldsControls = createHigherOrderComponent( ( BlockEdit ) => {\n\treturn ( props ) => {\n\t\tconst blockEditingMode = useBlockEditingMode();\n\t\tconst hasCustomFieldsSupport = hasBlockSupport(\n\t\t\tprops.name,\n\t\t\t'__experimentalConnections',\n\t\t\tfalse\n\t\t);\n\n\t\t// Check if the current block is a paragraph or image block.\n\t\t// Currently, only these two blocks are supported.\n\t\tif ( ! [ 'core/paragraph', 'core/image' ].includes( props.name ) ) {\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t}\n\n\t\t// If the block is a paragraph or image block, we need to know which\n\t\t// attribute to use for the connection. Only the `content` attribute\n\t\t// of the paragraph block and the `url` attribute of the image block are supported.\n\t\tlet attributeName;\n\t\tif ( props.name === 'core/paragraph' ) attributeName = 'content';\n\t\tif ( props.name === 'core/image' ) attributeName = 'url';\n\n\t\tif ( hasCustomFieldsSupport && props.isSelected ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t\t<PanelBody\n\t\t\t\t\t\t\t\ttitle={ __( 'Connections' ) }\n\t\t\t\t\t\t\t\tinitialOpen={ true }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Custom field meta_key' ) }\n\t\t\t\t\t\t\t\t\tvalue={\n\t\t\t\t\t\t\t\t\t\tprops.attributes?.connections\n\t\t\t\t\t\t\t\t\t\t\t?.attributes?.[ attributeName ]\n\t\t\t\t\t\t\t\t\t\t\t?.value || ''\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\t\t\t\t\t\tif ( nextValue === '' ) {\n\t\t\t\t\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\tconnections: undefined,\n\t\t\t\t\t\t\t\t\t\t\t\t[ attributeName ]: undefined,\n\t\t\t\t\t\t\t\t\t\t\t\tplaceholder: undefined,\n\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\tconnections: {\n\t\t\t\t\t\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t// The attributeName will be either `content` or `url`.\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[ attributeName ]: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// Source will be variable, could be post_meta, user_meta, term_meta, etc.\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// Could even be a custom source like a social media attribute.\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsource: 'meta_fields',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue: nextValue,\n\t\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},\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[ attributeName ]: undefined,\n\t\t\t\t\t\t\t\t\t\t\t\tplaceholder: sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'This content will be replaced on the frontend by the value of \"%s\" custom field.',\n\t\t\t\t\t\t\t\t\t\t\t\t\tnextValue\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}\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</PanelBody>\n\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t);\n\t\t}\n\n\t\treturn <BlockEdit { ...props } />;\n\t};\n}, 'withCustomFieldsControls' );\n\nif ( window.__experimentalConnections ) {\n\taddFilter(\n\t\t'blocks.registerBlockType',\n\t\t'core/editor/connections/attribute',\n\t\taddAttribute\n\t);\n\taddFilter(\n\t\t'editor.BlockEdit',\n\t\t'core/editor/connections/with-inspector-controls',\n\t\twithCustomFields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;UACJ;QACD;MAAG,CACH,CACS,CACO,CAEnB,CAAC;IAEL;IAEA,OAAO,IAAAhB,MAAA,CAAAC,aAAA,EAACR,SAAS;MAAA,GAAMC;IAAK,CAAI,CAAC;EAClC,CAAC;AACF,CAAC,EAAE,0BAA2B,CAAC;AAE/B,IAAK4B,MAAM,CAACC,yBAAyB,EAAG;EACvC,IAAAC,gBAAS,EACR,0BAA0B,EAC1B,mCAAmC,EACnCvC,YACD,CAAC;EACD,IAAAuC,gBAAS,EACR,kBAAkB,EAClB,iDAAiD,EACjDjC,wBACD,CAAC;AACF"}
@@ -14,7 +14,6 @@ var _blocks = require("@wordpress/blocks");
14
14
  var _compose = require("@wordpress/compose");
15
15
  var _hooks = require("@wordpress/hooks");
16
16
  var _element = require("@wordpress/element");
17
- var _data = require("@wordpress/data");
18
17
  var _components = require("../components");
19
18
  var _utils = require("../components/duotone/utils");
20
19
  var _getBlockCssSelector = require("../components/global-styles/get-block-css-selector");
@@ -23,8 +22,6 @@ var _utils3 = require("./utils");
23
22
  var _filtersPanel = _interopRequireDefault(require("../components/global-styles/filters-panel"));
24
23
  var _blockEditingMode = require("../components/block-editing-mode");
25
24
  var _useBlockRefs = require("../components/block-list/use-block-props/use-block-refs");
26
- var _store = require("../store");
27
- var _lockUnlock = require("../lock-unlock");
28
25
  /**
29
26
  * External dependencies
30
27
  */
@@ -243,21 +240,17 @@ function DuotoneStyles({
243
240
  });
244
241
  const selector = selectorsScoped.join(', ');
245
242
  const isValidFilter = Array.isArray(colors) || colors === 'unset';
246
- const {
247
- setStyleOverride,
248
- deleteStyleOverride
249
- } = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
243
+ (0, _utils3.useStyleOverride)(isValidFilter ? {
244
+ css: colors !== 'unset' ? (0, _utils.getDuotoneStylesheet)(selector, filterId) : (0, _utils.getDuotoneUnsetStylesheet)(selector),
245
+ __unstableType: 'presets'
246
+ } : undefined);
247
+ (0, _utils3.useStyleOverride)(isValidFilter ? {
248
+ assets: colors !== 'unset' ? (0, _utils.getDuotoneFilter)(filterId, colors) : '',
249
+ __unstableType: 'svgs'
250
+ } : undefined);
250
251
  const blockElement = (0, _useBlockRefs.__unstableUseBlockElement)(clientId);
251
252
  (0, _element.useEffect)(() => {
252
253
  if (!isValidFilter) return;
253
- setStyleOverride(filterId, {
254
- css: colors !== 'unset' ? (0, _utils.getDuotoneStylesheet)(selector, filterId) : (0, _utils.getDuotoneUnsetStylesheet)(selector),
255
- __unstableType: 'presets'
256
- });
257
- setStyleOverride(`duotone-${filterId}`, {
258
- assets: colors !== 'unset' ? (0, _utils.getDuotoneFilter)(filterId, colors) : '',
259
- __unstableType: 'svgs'
260
- });
261
254
 
262
255
  // Safari does not always update the duotone filter when the duotone colors
263
256
  // are changed. When using Safari, force the block element to be repainted by
@@ -275,11 +268,7 @@ function DuotoneStyles({
275
268
  blockElement.offsetHeight;
276
269
  blockElement.style.display = display;
277
270
  }
278
- return () => {
279
- deleteStyleOverride(filterId);
280
- deleteStyleOverride(`duotone-${filterId}`);
281
- };
282
- }, [isValidFilter, blockElement, colors, selector, filterId, setStyleOverride, deleteStyleOverride]);
271
+ }, [isValidFilter, blockElement]);
283
272
  return null;
284
273
  }
285
274