@wordpress/block-editor 12.21.0 → 12.23.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 (408) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +4 -0
  3. package/build/components/block-actions/index.js +2 -4
  4. package/build/components/block-actions/index.js.map +1 -1
  5. package/build/components/block-heading-level-dropdown/index.js +5 -5
  6. package/build/components/block-heading-level-dropdown/index.js.map +1 -1
  7. package/build/components/block-heading-level-dropdown/index.native.js +5 -4
  8. package/build/components/block-heading-level-dropdown/index.native.js.map +1 -1
  9. package/build/components/block-list/block-crash-boundary.native.js +49 -0
  10. package/build/components/block-list/block-crash-boundary.native.js.map +1 -0
  11. package/build/components/block-list/block-crash-warning.native.js +24 -0
  12. package/build/components/block-list/block-crash-warning.native.js.map +1 -0
  13. package/build/components/block-list/block.js +11 -3
  14. package/build/components/block-list/block.js.map +1 -1
  15. package/build/components/block-list/block.native.js +7 -2
  16. package/build/components/block-list/block.native.js.map +1 -1
  17. package/build/components/block-mover/button.js +4 -1
  18. package/build/components/block-mover/button.js.map +1 -1
  19. package/build/components/block-mover/index.js +5 -1
  20. package/build/components/block-mover/index.js.map +1 -1
  21. package/build/components/block-patterns-list/index.js +4 -1
  22. package/build/components/block-patterns-list/index.js.map +1 -1
  23. package/build/components/block-settings/container.native.js +2 -1
  24. package/build/components/block-settings/container.native.js.map +1 -1
  25. package/build/components/block-settings-menu/block-settings-dropdown.js +36 -32
  26. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  27. package/build/components/block-settings-menu-controls/index.js +1 -3
  28. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  29. package/build/components/block-switcher/index.js +4 -3
  30. package/build/components/block-switcher/index.js.map +1 -1
  31. package/build/components/block-toolbar/index.js +8 -5
  32. package/build/components/block-toolbar/index.js.map +1 -1
  33. package/build/components/block-toolbar/shuffle.js +19 -10
  34. package/build/components/block-toolbar/shuffle.js.map +1 -1
  35. package/build/components/block-tools/block-selection-button.js +48 -8
  36. package/build/components/block-tools/block-selection-button.js.map +1 -1
  37. package/build/components/block-tools/index.js +14 -2
  38. package/build/components/block-tools/index.js.map +1 -1
  39. package/build/components/child-layout-control/index.js +108 -11
  40. package/build/components/child-layout-control/index.js.map +1 -1
  41. package/build/components/convert-to-group-buttons/toolbar.js +11 -0
  42. package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
  43. package/build/components/global-styles/advanced-panel.js +9 -2
  44. package/build/components/global-styles/advanced-panel.js.map +1 -1
  45. package/build/components/global-styles/background-panel.js +444 -0
  46. package/build/components/global-styles/background-panel.js.map +1 -0
  47. package/build/components/global-styles/color-panel.js +2 -1
  48. package/build/components/global-styles/color-panel.js.map +1 -1
  49. package/build/components/global-styles/dimensions-panel.js +8 -33
  50. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  51. package/build/components/global-styles/get-global-styles-changes.js +3 -0
  52. package/build/components/global-styles/get-global-styles-changes.js.map +1 -1
  53. package/build/components/global-styles/hooks.js +1 -1
  54. package/build/components/global-styles/hooks.js.map +1 -1
  55. package/build/components/global-styles/index.js +13 -0
  56. package/build/components/global-styles/index.js.map +1 -1
  57. package/build/components/global-styles/use-global-styles-output.js +16 -15
  58. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  59. package/build/components/global-styles/utils.js +2 -3
  60. package/build/components/global-styles/utils.js.map +1 -1
  61. package/build/components/iframe/index.js +43 -34
  62. package/build/components/iframe/index.js.map +1 -1
  63. package/build/components/inserter/block-patterns-explorer/index.js +3 -6
  64. package/build/components/inserter/block-patterns-explorer/index.js.map +1 -1
  65. package/build/components/inserter/block-patterns-explorer/pattern-list.js +3 -1
  66. package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  67. package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
  68. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +5 -0
  69. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
  70. package/build/components/inserter/library.js +2 -0
  71. package/build/components/inserter/library.js.map +1 -1
  72. package/build/components/inserter/menu.js +11 -11
  73. package/build/components/inserter/menu.js.map +1 -1
  74. package/build/components/inserter/mobile-tab-navigation.js +1 -1
  75. package/build/components/inserter/mobile-tab-navigation.js.map +1 -1
  76. package/build/components/inserter/search-items.js +36 -15
  77. package/build/components/inserter/search-items.js.map +1 -1
  78. package/build/components/inserter/search-results.js +2 -3
  79. package/build/components/inserter/search-results.js.map +1 -1
  80. package/build/components/inserter/tabs.js +1 -2
  81. package/build/components/inserter/tabs.js.map +1 -1
  82. package/build/components/inspector-controls-tabs/advanced-controls-panel.native.js +36 -0
  83. package/build/components/inspector-controls-tabs/advanced-controls-panel.native.js.map +1 -0
  84. package/build/components/keyboard-shortcuts/index.js +11 -0
  85. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  86. package/build/components/list-view/block-select-button.js +18 -12
  87. package/build/components/list-view/block-select-button.js.map +1 -1
  88. package/build/components/list-view/block.js +4 -11
  89. package/build/components/list-view/block.js.map +1 -1
  90. package/build/components/list-view/index.js +17 -2
  91. package/build/components/list-view/index.js.map +1 -1
  92. package/build/components/list-view/use-list-view-collapse-items.js +47 -0
  93. package/build/components/list-view/use-list-view-collapse-items.js.map +1 -0
  94. package/build/components/list-view/utils.js +5 -3
  95. package/build/components/list-view/utils.js.map +1 -1
  96. package/build/components/rich-text/index.js +14 -11
  97. package/build/components/rich-text/index.js.map +1 -1
  98. package/build/components/rich-text/index.native.js +17 -11
  99. package/build/components/rich-text/index.native.js.map +1 -1
  100. package/build/components/rich-text/native/get-format-colors.native.js +1 -1
  101. package/build/components/rich-text/native/get-format-colors.native.js.map +1 -1
  102. package/build/components/rich-text/native/index.native.js +2 -2
  103. package/build/components/rich-text/native/index.native.js.map +1 -1
  104. package/build/components/rich-text/with-deprecations.js +0 -3
  105. package/build/components/rich-text/with-deprecations.js.map +1 -1
  106. package/build/components/spacing-sizes-control/sides-dropdown/index.js +1 -1
  107. package/build/components/spacing-sizes-control/sides-dropdown/index.js.map +1 -1
  108. package/build/components/url-popover/image-url-input-ui.js +50 -36
  109. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  110. package/build/components/use-block-display-information/index.js +4 -6
  111. package/build/components/use-block-display-information/index.js.map +1 -1
  112. package/build/components/use-moving-animation/index.js +4 -0
  113. package/build/components/use-moving-animation/index.js.map +1 -1
  114. package/build/components/warning/index.native.js +9 -4
  115. package/build/components/warning/index.native.js.map +1 -1
  116. package/build/hooks/anchor.js +9 -10
  117. package/build/hooks/anchor.js.map +1 -1
  118. package/build/hooks/background.js +85 -402
  119. package/build/hooks/background.js.map +1 -1
  120. package/build/hooks/index.js +9 -1
  121. package/build/hooks/index.js.map +1 -1
  122. package/build/hooks/layout-child.js +28 -6
  123. package/build/hooks/layout-child.js.map +1 -1
  124. package/build/hooks/layout.js +21 -10
  125. package/build/hooks/layout.js.map +1 -1
  126. package/build/hooks/position.js +1 -1
  127. package/build/hooks/position.js.map +1 -1
  128. package/build/hooks/use-zoom-out.js +47 -0
  129. package/build/hooks/use-zoom-out.js.map +1 -0
  130. package/build/index.js +7 -0
  131. package/build/index.js.map +1 -1
  132. package/build/private-apis.js +6 -1
  133. package/build/private-apis.js.map +1 -1
  134. package/build/private-apis.native.js +5 -1
  135. package/build/private-apis.native.js.map +1 -1
  136. package/build/store/private-actions.js +13 -0
  137. package/build/store/private-actions.js.map +1 -1
  138. package/build/store/private-keys.js +2 -1
  139. package/build/store/private-keys.js.map +1 -1
  140. package/build/store/private-selectors.js +24 -3
  141. package/build/store/private-selectors.js.map +1 -1
  142. package/build/store/reducer.js +53 -26
  143. package/build/store/reducer.js.map +1 -1
  144. package/build/store/selectors.js +34 -32
  145. package/build/store/selectors.js.map +1 -1
  146. package/build/store/utils.js +7 -1
  147. package/build/store/utils.js.map +1 -1
  148. package/build/utils/transform-styles/index.js +2 -1
  149. package/build/utils/transform-styles/index.js.map +1 -1
  150. package/build-module/components/block-actions/index.js +2 -4
  151. package/build-module/components/block-actions/index.js.map +1 -1
  152. package/build-module/components/block-heading-level-dropdown/index.js +5 -5
  153. package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
  154. package/build-module/components/block-heading-level-dropdown/index.native.js +5 -4
  155. package/build-module/components/block-heading-level-dropdown/index.native.js.map +1 -1
  156. package/build-module/components/block-list/block-crash-boundary.native.js +42 -0
  157. package/build-module/components/block-list/block-crash-boundary.native.js.map +1 -0
  158. package/build-module/components/block-list/block-crash-warning.native.js +15 -0
  159. package/build-module/components/block-list/block-crash-warning.native.js.map +1 -0
  160. package/build-module/components/block-list/block.js +11 -3
  161. package/build-module/components/block-list/block.js.map +1 -1
  162. package/build-module/components/block-list/block.native.js +7 -2
  163. package/build-module/components/block-list/block.native.js.map +1 -1
  164. package/build-module/components/block-mover/button.js +4 -1
  165. package/build-module/components/block-mover/button.js.map +1 -1
  166. package/build-module/components/block-mover/index.js +5 -1
  167. package/build-module/components/block-mover/index.js.map +1 -1
  168. package/build-module/components/block-patterns-list/index.js +4 -1
  169. package/build-module/components/block-patterns-list/index.js.map +1 -1
  170. package/build-module/components/block-settings/container.native.js +3 -2
  171. package/build-module/components/block-settings/container.native.js.map +1 -1
  172. package/build-module/components/block-settings-menu/block-settings-dropdown.js +37 -33
  173. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  174. package/build-module/components/block-settings-menu-controls/index.js +1 -3
  175. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  176. package/build-module/components/block-switcher/index.js +4 -3
  177. package/build-module/components/block-switcher/index.js.map +1 -1
  178. package/build-module/components/block-toolbar/index.js +8 -5
  179. package/build-module/components/block-toolbar/index.js.map +1 -1
  180. package/build-module/components/block-toolbar/shuffle.js +19 -10
  181. package/build-module/components/block-toolbar/shuffle.js.map +1 -1
  182. package/build-module/components/block-tools/block-selection-button.js +50 -10
  183. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  184. package/build-module/components/block-tools/index.js +14 -2
  185. package/build-module/components/block-tools/index.js.map +1 -1
  186. package/build-module/components/child-layout-control/index.js +109 -12
  187. package/build-module/components/child-layout-control/index.js.map +1 -1
  188. package/build-module/components/convert-to-group-buttons/toolbar.js +12 -1
  189. package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
  190. package/build-module/components/global-styles/advanced-panel.js +9 -2
  191. package/build-module/components/global-styles/advanced-panel.js.map +1 -1
  192. package/build-module/components/global-styles/background-panel.js +430 -0
  193. package/build-module/components/global-styles/background-panel.js.map +1 -0
  194. package/build-module/components/global-styles/color-panel.js +2 -1
  195. package/build-module/components/global-styles/color-panel.js.map +1 -1
  196. package/build-module/components/global-styles/dimensions-panel.js +9 -34
  197. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  198. package/build-module/components/global-styles/get-global-styles-changes.js +3 -0
  199. package/build-module/components/global-styles/get-global-styles-changes.js.map +1 -1
  200. package/build-module/components/global-styles/hooks.js +1 -1
  201. package/build-module/components/global-styles/hooks.js.map +1 -1
  202. package/build-module/components/global-styles/index.js +1 -0
  203. package/build-module/components/global-styles/index.js.map +1 -1
  204. package/build-module/components/global-styles/use-global-styles-output.js +17 -16
  205. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  206. package/build-module/components/global-styles/utils.js +1 -2
  207. package/build-module/components/global-styles/utils.js.map +1 -1
  208. package/build-module/components/iframe/index.js +43 -34
  209. package/build-module/components/iframe/index.js.map +1 -1
  210. package/build-module/components/inserter/block-patterns-explorer/index.js +3 -6
  211. package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -1
  212. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +3 -1
  213. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  214. package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
  215. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +5 -0
  216. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
  217. package/build-module/components/inserter/library.js +2 -0
  218. package/build-module/components/inserter/library.js.map +1 -1
  219. package/build-module/components/inserter/menu.js +11 -11
  220. package/build-module/components/inserter/menu.js.map +1 -1
  221. package/build-module/components/inserter/mobile-tab-navigation.js +1 -1
  222. package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -1
  223. package/build-module/components/inserter/search-items.js +33 -15
  224. package/build-module/components/inserter/search-items.js.map +1 -1
  225. package/build-module/components/inserter/search-results.js +2 -3
  226. package/build-module/components/inserter/search-results.js.map +1 -1
  227. package/build-module/components/inserter/tabs.js +1 -2
  228. package/build-module/components/inserter/tabs.js.map +1 -1
  229. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.native.js +28 -0
  230. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.native.js.map +1 -0
  231. package/build-module/components/keyboard-shortcuts/index.js +11 -0
  232. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  233. package/build-module/components/list-view/block-select-button.js +19 -13
  234. package/build-module/components/list-view/block-select-button.js.map +1 -1
  235. package/build-module/components/list-view/block.js +6 -13
  236. package/build-module/components/list-view/block.js.map +1 -1
  237. package/build-module/components/list-view/index.js +17 -2
  238. package/build-module/components/list-view/index.js.map +1 -1
  239. package/build-module/components/list-view/use-list-view-collapse-items.js +40 -0
  240. package/build-module/components/list-view/use-list-view-collapse-items.js.map +1 -0
  241. package/build-module/components/list-view/utils.js +2 -1
  242. package/build-module/components/list-view/utils.js.map +1 -1
  243. package/build-module/components/rich-text/index.js +15 -12
  244. package/build-module/components/rich-text/index.js.map +1 -1
  245. package/build-module/components/rich-text/index.native.js +16 -11
  246. package/build-module/components/rich-text/index.native.js.map +1 -1
  247. package/build-module/components/rich-text/native/get-format-colors.native.js +1 -1
  248. package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -1
  249. package/build-module/components/rich-text/native/index.native.js +2 -2
  250. package/build-module/components/rich-text/native/index.native.js.map +1 -1
  251. package/build-module/components/rich-text/with-deprecations.js +0 -3
  252. package/build-module/components/rich-text/with-deprecations.js.map +1 -1
  253. package/build-module/components/spacing-sizes-control/sides-dropdown/index.js +1 -1
  254. package/build-module/components/spacing-sizes-control/sides-dropdown/index.js.map +1 -1
  255. package/build-module/components/url-popover/image-url-input-ui.js +50 -36
  256. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  257. package/build-module/components/use-block-display-information/index.js +5 -7
  258. package/build-module/components/use-block-display-information/index.js.map +1 -1
  259. package/build-module/components/use-moving-animation/index.js +4 -0
  260. package/build-module/components/use-moving-animation/index.js.map +1 -1
  261. package/build-module/components/warning/index.native.js +9 -4
  262. package/build-module/components/warning/index.native.js.map +1 -1
  263. package/build-module/hooks/anchor.js +10 -11
  264. package/build-module/hooks/anchor.js.map +1 -1
  265. package/build-module/hooks/background.js +82 -397
  266. package/build-module/hooks/background.js.map +1 -1
  267. package/build-module/hooks/index.js +3 -1
  268. package/build-module/hooks/index.js.map +1 -1
  269. package/build-module/hooks/layout-child.js +28 -6
  270. package/build-module/hooks/layout-child.js.map +1 -1
  271. package/build-module/hooks/layout.js +21 -10
  272. package/build-module/hooks/layout.js.map +1 -1
  273. package/build-module/hooks/position.js +1 -1
  274. package/build-module/hooks/position.js.map +1 -1
  275. package/build-module/hooks/use-zoom-out.js +41 -0
  276. package/build-module/hooks/use-zoom-out.js.map +1 -0
  277. package/build-module/index.js +1 -1
  278. package/build-module/index.js.map +1 -1
  279. package/build-module/private-apis.js +7 -2
  280. package/build-module/private-apis.js.map +1 -1
  281. package/build-module/private-apis.native.js +5 -1
  282. package/build-module/private-apis.native.js.map +1 -1
  283. package/build-module/store/private-actions.js +12 -0
  284. package/build-module/store/private-actions.js.map +1 -1
  285. package/build-module/store/private-keys.js +1 -0
  286. package/build-module/store/private-keys.js.map +1 -1
  287. package/build-module/store/private-selectors.js +22 -4
  288. package/build-module/store/private-selectors.js.map +1 -1
  289. package/build-module/store/reducer.js +52 -26
  290. package/build-module/store/reducer.js.map +1 -1
  291. package/build-module/store/selectors.js +35 -33
  292. package/build-module/store/selectors.js.map +1 -1
  293. package/build-module/store/utils.js +6 -1
  294. package/build-module/store/utils.js.map +1 -1
  295. package/build-module/utils/transform-styles/index.js +2 -1
  296. package/build-module/utils/transform-styles/index.js.map +1 -1
  297. package/build-style/content-rtl.css +18 -1
  298. package/build-style/content.css +18 -1
  299. package/build-style/style-rtl.css +92 -99
  300. package/build-style/style.css +92 -99
  301. package/package.json +31 -31
  302. package/src/components/block-actions/index.js +2 -8
  303. package/src/components/block-bindings-toolbar-indicator/style.scss +10 -8
  304. package/src/components/block-heading-level-dropdown/README.md +5 -5
  305. package/src/components/block-heading-level-dropdown/index.js +5 -5
  306. package/src/components/block-heading-level-dropdown/index.native.js +5 -4
  307. package/src/components/block-list/block-crash-boundary.native.js +43 -0
  308. package/src/components/block-list/block-crash-warning.native.js +19 -0
  309. package/src/components/block-list/block.js +19 -3
  310. package/src/components/block-list/block.native.js +14 -7
  311. package/src/components/block-list/content.scss +16 -0
  312. package/src/components/block-mover/button.js +4 -1
  313. package/src/components/block-mover/index.js +8 -1
  314. package/src/components/block-patterns-list/index.js +22 -17
  315. package/src/components/block-preview/style.scss +28 -0
  316. package/src/components/block-settings/container.native.js +5 -1
  317. package/src/components/block-settings-menu/block-settings-dropdown.js +49 -58
  318. package/src/components/block-settings-menu-controls/README.md +0 -9
  319. package/src/components/block-settings-menu-controls/index.js +1 -6
  320. package/src/components/block-switcher/index.js +5 -3
  321. package/src/components/block-switcher/style.scss +1 -1
  322. package/src/components/block-toolbar/index.js +25 -20
  323. package/src/components/block-toolbar/shuffle.js +20 -14
  324. package/src/components/block-toolbar/style.scss +1 -1
  325. package/src/components/block-toolbar/test/index.native.js +1 -7
  326. package/src/components/block-tools/block-selection-button.js +66 -9
  327. package/src/components/block-tools/index.js +18 -1
  328. package/src/components/button-block-appender/content.scss +5 -1
  329. package/src/components/child-layout-control/index.js +147 -35
  330. package/src/components/convert-to-group-buttons/toolbar.js +13 -1
  331. package/src/components/default-block-appender/content.scss +2 -2
  332. package/src/components/global-styles/advanced-panel.js +8 -2
  333. package/src/components/global-styles/background-panel.js +591 -0
  334. package/src/components/global-styles/color-panel.js +2 -1
  335. package/src/components/global-styles/dimensions-panel.js +9 -34
  336. package/src/components/global-styles/get-global-styles-changes.js +3 -0
  337. package/src/components/global-styles/hooks.js +1 -0
  338. package/src/components/global-styles/index.js +4 -0
  339. package/src/components/global-styles/style.scss +78 -1
  340. package/src/{hooks/test/background.js → components/global-styles/test/background-panel.js} +36 -1
  341. package/src/components/global-styles/test/get-global-styles-changes.js +22 -3
  342. package/src/components/global-styles/test/use-global-styles-output.js +40 -9
  343. package/src/components/global-styles/use-global-styles-output.js +30 -17
  344. package/src/components/global-styles/utils.js +1 -18
  345. package/src/components/iframe/index.js +79 -53
  346. package/src/components/inserter/block-patterns-explorer/index.js +2 -9
  347. package/src/components/inserter/block-patterns-explorer/pattern-list.js +7 -1
  348. package/src/components/inserter/block-patterns-tab/index.js +1 -0
  349. package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +5 -0
  350. package/src/components/inserter/library.js +4 -0
  351. package/src/components/inserter/menu.js +12 -11
  352. package/src/components/inserter/mobile-tab-navigation.js +1 -1
  353. package/src/components/inserter/search-items.js +37 -15
  354. package/src/components/inserter/search-results.js +1 -2
  355. package/src/components/inserter/style.scss +6 -12
  356. package/src/components/inserter/tabs.js +1 -2
  357. package/src/components/inspector-controls-tabs/advanced-controls-panel.native.js +31 -0
  358. package/src/components/keyboard-shortcuts/index.js +11 -0
  359. package/src/components/link-control/style.scss +0 -5
  360. package/src/components/list-view/block-select-button.js +15 -19
  361. package/src/components/list-view/block.js +12 -21
  362. package/src/components/list-view/index.js +18 -1
  363. package/src/components/list-view/style.scss +38 -28
  364. package/src/components/list-view/use-list-view-collapse-items.js +33 -0
  365. package/src/components/list-view/utils.js +4 -1
  366. package/src/components/rich-text/README.md +6 -0
  367. package/src/components/rich-text/index.js +30 -13
  368. package/src/components/rich-text/index.native.js +14 -11
  369. package/src/components/rich-text/native/get-format-colors.native.js +1 -1
  370. package/src/components/rich-text/native/index.native.js +2 -2
  371. package/src/components/rich-text/with-deprecations.js +0 -3
  372. package/src/components/spacing-sizes-control/sides-dropdown/index.js +1 -1
  373. package/src/components/url-popover/image-url-input-ui.js +68 -51
  374. package/src/components/use-block-display-information/index.js +8 -10
  375. package/src/components/use-moving-animation/index.js +1 -0
  376. package/src/components/warning/index.native.js +19 -15
  377. package/src/hooks/anchor.js +43 -61
  378. package/src/hooks/background.js +100 -516
  379. package/src/hooks/index.js +3 -0
  380. package/src/hooks/layout-child.js +44 -8
  381. package/src/hooks/layout.js +22 -18
  382. package/src/hooks/position.js +1 -1
  383. package/src/hooks/test/__snapshots__/anchor.native.js.snap +7 -0
  384. package/src/hooks/test/anchor.native.js +32 -0
  385. package/src/hooks/use-zoom-out.js +36 -0
  386. package/src/index.js +1 -0
  387. package/src/private-apis.js +13 -1
  388. package/src/private-apis.native.js +4 -0
  389. package/src/store/private-actions.js +12 -0
  390. package/src/store/private-keys.js +1 -0
  391. package/src/store/private-selectors.js +54 -27
  392. package/src/store/reducer.js +63 -41
  393. package/src/store/selectors.js +195 -180
  394. package/src/store/test/private-actions.js +10 -0
  395. package/src/store/test/private-selectors.js +13 -0
  396. package/src/store/test/reducer.js +26 -0
  397. package/src/store/test/selectors.js +90 -199
  398. package/src/store/utils.js +13 -0
  399. package/src/style.scss +0 -2
  400. package/src/utils/transform-styles/index.js +2 -1
  401. package/tsconfig.json +1 -0
  402. package/build/utils/calculate-scale.js +0 -17
  403. package/build/utils/calculate-scale.js.map +0 -1
  404. package/build-module/utils/calculate-scale.js +0 -11
  405. package/build-module/utils/calculate-scale.js.map +0 -1
  406. package/src/hooks/anchor.scss +0 -4
  407. package/src/hooks/background.scss +0 -75
  408. package/src/utils/calculate-scale.js +0 -20
@@ -29,7 +29,8 @@ const ImageURLInputUI = ({
29
29
  rel,
30
30
  showLightboxSetting,
31
31
  lightboxEnabled,
32
- onSetLightbox
32
+ onSetLightbox,
33
+ resetLightbox
33
34
  }) => {
34
35
  const [isOpen, setIsOpen] = useState(false);
35
36
  // Use internal state instead of a ref to make sure that the component
@@ -190,8 +191,52 @@ const ImageURLInputUI = ({
190
191
  onChange: onSetLinkClass
191
192
  }));
192
193
  const linkEditorValue = urlInput !== null ? urlInput : url;
193
- const showLinkEditor = (!linkEditorValue && !lightboxEnabled) === true;
194
+ const hideLightboxPanel = !lightboxEnabled || lightboxEnabled && !showLightboxSetting;
195
+ const showLinkEditor = !linkEditorValue && hideLightboxPanel;
194
196
  const urlLabel = (getLinkDestinations().find(destination => destination.linkDestination === linkDestination) || {}).title;
197
+ const PopoverChildren = () => {
198
+ if (lightboxEnabled && showLightboxSetting && !url && !isEditingLink) {
199
+ return createElement("div", {
200
+ className: "block-editor-url-popover__expand-on-click"
201
+ }, createElement(Icon, {
202
+ icon: fullscreen
203
+ }), createElement("div", {
204
+ className: "text"
205
+ }, createElement("p", null, __('Expand on click')), createElement("p", {
206
+ className: "description"
207
+ }, __('Scales the image with a lightbox effect'))), createElement(Button, {
208
+ icon: linkOff,
209
+ label: __('Disable expand on click'),
210
+ onClick: () => {
211
+ onSetLightbox(false);
212
+ },
213
+ size: "compact"
214
+ }));
215
+ } else if (!url || isEditingLink) {
216
+ return createElement(URLPopover.LinkEditor, {
217
+ className: "block-editor-format-toolbar__link-container-content",
218
+ value: linkEditorValue,
219
+ onChangeInputValue: setUrlInput,
220
+ onSubmit: onSubmitLinkChange(),
221
+ autocompleteRef: autocompleteRef
222
+ });
223
+ } else if (url && !isEditingLink) {
224
+ return createElement(Fragment, null, createElement(URLPopover.LinkViewer, {
225
+ className: "block-editor-format-toolbar__link-container-content",
226
+ url: url,
227
+ onEditLinkClick: startEditLink,
228
+ urlLabel: urlLabel
229
+ }), createElement(Button, {
230
+ icon: linkOff,
231
+ label: __('Remove link'),
232
+ onClick: () => {
233
+ onLinkRemove();
234
+ resetLightbox();
235
+ },
236
+ size: "compact"
237
+ }));
238
+ }
239
+ };
195
240
  return createElement(Fragment, null, createElement(ToolbarButton, {
196
241
  icon: linkIcon,
197
242
  className: "components-toolbar__control",
@@ -199,13 +244,13 @@ const ImageURLInputUI = ({
199
244
  "aria-expanded": isOpen,
200
245
  onClick: openLinkUI,
201
246
  ref: setPopoverAnchor,
202
- isActive: !!url || lightboxEnabled
247
+ isActive: !!url || lightboxEnabled && showLightboxSetting
203
248
  }), isOpen && createElement(URLPopover, {
204
249
  ref: wrapperRef,
205
250
  anchor: popoverAnchor,
206
251
  onFocusOutside: onFocusOutside(),
207
252
  onClose: closeLinkUI,
208
- renderSettings: !lightboxEnabled ? () => advancedOptions : null,
253
+ renderSettings: hideLightboxPanel ? () => advancedOptions : null,
209
254
  additionalControls: showLinkEditor && createElement(NavigableMenu, null, getLinkDestinations().map(link => createElement(MenuItem, {
210
255
  key: link.linkDestination,
211
256
  icon: link.icon,
@@ -232,38 +277,7 @@ const ImageURLInputUI = ({
232
277
  }
233
278
  }, __('Expand on click'))),
234
279
  offset: 13
235
- }, (!url || isEditingLink) && !lightboxEnabled && createElement(Fragment, null, createElement(URLPopover.LinkEditor, {
236
- className: "block-editor-format-toolbar__link-container-content",
237
- value: linkEditorValue,
238
- onChangeInputValue: setUrlInput,
239
- onSubmit: onSubmitLinkChange(),
240
- autocompleteRef: autocompleteRef
241
- })), url && !isEditingLink && !lightboxEnabled && createElement(Fragment, null, createElement(URLPopover.LinkViewer, {
242
- className: "block-editor-format-toolbar__link-container-content",
243
- url: url,
244
- onEditLinkClick: startEditLink,
245
- urlLabel: urlLabel
246
- }), createElement(Button, {
247
- icon: linkOff,
248
- label: __('Remove link'),
249
- onClick: onLinkRemove,
250
- size: "compact"
251
- })), !url && !isEditingLink && lightboxEnabled && createElement("div", {
252
- className: "block-editor-url-popover__expand-on-click"
253
- }, createElement(Icon, {
254
- icon: fullscreen
255
- }), createElement("div", {
256
- className: "text"
257
- }, createElement("p", null, __('Expand on click')), createElement("p", {
258
- className: "description"
259
- }, __('Scales the image with a lightbox effect'))), createElement(Button, {
260
- icon: linkOff,
261
- label: __('Disable expand on click'),
262
- onClick: () => {
263
- onSetLightbox(false);
264
- },
265
- size: "compact"
266
- }))));
280
+ }, PopoverChildren()));
267
281
  };
268
282
  export { ImageURLInputUI as __experimentalImageURLInputUI };
269
283
  //# sourceMappingURL=image-url-input-ui.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__","useRef","useEffect","useState","focus","ToolbarButton","NavigableMenu","Button","MenuItem","ToggleControl","TextControl","__experimentalVStack","VStack","Icon","link","linkIcon","image","page","fullscreen","linkOff","URLPopover","LINK_DESTINATION_NONE","LINK_DESTINATION_CUSTOM","LINK_DESTINATION_MEDIA","LINK_DESTINATION_ATTACHMENT","NEW_TAB_REL","ImageURLInputUI","linkDestination","onChangeUrl","url","mediaType","mediaUrl","mediaLink","linkTarget","linkClass","rel","showLightboxSetting","lightboxEnabled","onSetLightbox","isOpen","setIsOpen","popoverAnchor","setPopoverAnchor","openLinkUI","isEditingLink","setIsEditingLink","urlInput","setUrlInput","autocompleteRef","wrapperRef","current","nextFocusTarget","focusable","find","startEditLink","stopEditLink","closeLinkUI","getUpdatedLinkTargetSettings","value","newLinkTarget","undefined","updatedRel","rels","split","forEach","relVal","includes","push","join","filter","length","onFocusOutside","event","autocompleteElement","contains","target","onSubmitLinkChange","selectedDestination","getLinkDestinations","destination","href","lightbox","enabled","preventDefault","onLinkRemove","linkDestinations","title","icon","onSetHref","linkDestinationInput","onSetNewTab","updatedLinkTarget","onSetLinkRel","onSetLinkClass","advancedOptions","createElement","spacing","__nextHasNoMarginBottom","label","onChange","checked","linkEditorValue","showLinkEditor","urlLabel","Fragment","className","onClick","ref","isActive","anchor","onClose","renderSettings","additionalControls","map","key","iconPosition","info","offset","LinkEditor","onChangeInputValue","onSubmit","LinkViewer","onEditLinkClick","size","__experimentalImageURLInputUI"],"sources":["@wordpress/block-editor/src/components/url-popover/image-url-input-ui.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useEffect, useState } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport {\n\tToolbarButton,\n\tNavigableMenu,\n\tButton,\n\tMenuItem,\n\tToggleControl,\n\tTextControl,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport {\n\tIcon,\n\tlink as linkIcon,\n\timage,\n\tpage,\n\tfullscreen,\n\tlinkOff,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport URLPopover from './index';\n\nconst LINK_DESTINATION_NONE = 'none';\nconst LINK_DESTINATION_CUSTOM = 'custom';\nconst LINK_DESTINATION_MEDIA = 'media';\nconst LINK_DESTINATION_ATTACHMENT = 'attachment';\nconst NEW_TAB_REL = [ 'noreferrer', 'noopener' ];\n\nconst ImageURLInputUI = ( {\n\tlinkDestination,\n\tonChangeUrl,\n\turl,\n\tmediaType = 'image',\n\tmediaUrl,\n\tmediaLink,\n\tlinkTarget,\n\tlinkClass,\n\trel,\n\tshowLightboxSetting,\n\tlightboxEnabled,\n\tonSetLightbox,\n} ) => {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst openLinkUI = () => {\n\t\tsetIsOpen( true );\n\t};\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState( false );\n\tconst [ urlInput, setUrlInput ] = useState( null );\n\n\tconst autocompleteRef = useRef( null );\n\tconst wrapperRef = useRef();\n\n\tuseEffect( () => {\n\t\tif ( ! wrapperRef.current ) {\n\t\t\treturn;\n\t\t}\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperRef.current )[ 0 ] ||\n\t\t\twrapperRef.current;\n\t\tnextFocusTarget.focus();\n\t}, [ isEditingLink, url, lightboxEnabled ] );\n\n\tconst startEditLink = () => {\n\t\tif (\n\t\t\tlinkDestination === LINK_DESTINATION_MEDIA ||\n\t\t\tlinkDestination === LINK_DESTINATION_ATTACHMENT\n\t\t) {\n\t\t\tsetUrlInput( '' );\n\t\t}\n\t\tsetIsEditingLink( true );\n\t};\n\n\tconst stopEditLink = () => {\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst closeLinkUI = () => {\n\t\tsetUrlInput( null );\n\t\tstopEditLink();\n\t\tsetIsOpen( false );\n\t};\n\n\tconst getUpdatedLinkTargetSettings = ( value ) => {\n\t\tconst newLinkTarget = value ? '_blank' : undefined;\n\n\t\tlet updatedRel;\n\t\tif ( newLinkTarget ) {\n\t\t\tconst rels = ( rel ?? '' ).split( ' ' );\n\t\t\tNEW_TAB_REL.forEach( ( relVal ) => {\n\t\t\t\tif ( ! rels.includes( relVal ) ) {\n\t\t\t\t\trels.push( relVal );\n\t\t\t\t}\n\t\t\t} );\n\t\t\tupdatedRel = rels.join( ' ' );\n\t\t} else {\n\t\t\tconst rels = ( rel ?? '' )\n\t\t\t\t.split( ' ' )\n\t\t\t\t.filter(\n\t\t\t\t\t( relVal ) => NEW_TAB_REL.includes( relVal ) === false\n\t\t\t\t);\n\t\t\tupdatedRel = rels.length ? rels.join( ' ' ) : undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tlinkTarget: newLinkTarget,\n\t\t\trel: updatedRel,\n\t\t};\n\t};\n\n\tconst onFocusOutside = () => {\n\t\treturn ( event ) => {\n\t\t\t// The autocomplete suggestions list renders in a separate popover (in a portal),\n\t\t\t// so onFocusOutside fails to detect that a click on a suggestion occurred in the\n\t\t\t// LinkContainer. Detect clicks on autocomplete suggestions using a ref here, and\n\t\t\t// return to avoid the popover being closed.\n\t\t\tconst autocompleteElement = autocompleteRef.current;\n\t\t\tif (\n\t\t\t\tautocompleteElement &&\n\t\t\t\tautocompleteElement.contains( event.target )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetIsOpen( false );\n\t\t\tsetUrlInput( null );\n\t\t\tstopEditLink();\n\t\t};\n\t};\n\n\tconst onSubmitLinkChange = () => {\n\t\treturn ( event ) => {\n\t\t\tif ( urlInput ) {\n\t\t\t\t// It is possible the entered URL actually matches a named link destination.\n\t\t\t\t// This check will ensure our link destination is correct.\n\t\t\t\tconst selectedDestination =\n\t\t\t\t\tgetLinkDestinations().find(\n\t\t\t\t\t\t( destination ) => destination.url === urlInput\n\t\t\t\t\t)?.linkDestination || LINK_DESTINATION_CUSTOM;\n\n\t\t\t\tonChangeUrl( {\n\t\t\t\t\thref: urlInput,\n\t\t\t\t\tlinkDestination: selectedDestination,\n\t\t\t\t\tlightbox: { enabled: false },\n\t\t\t\t} );\n\t\t\t}\n\t\t\tstopEditLink();\n\t\t\tsetUrlInput( null );\n\t\t\tevent.preventDefault();\n\t\t};\n\t};\n\n\tconst onLinkRemove = () => {\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: LINK_DESTINATION_NONE,\n\t\t\thref: '',\n\t\t} );\n\t};\n\n\tconst getLinkDestinations = () => {\n\t\tconst linkDestinations = [\n\t\t\t{\n\t\t\t\tlinkDestination: LINK_DESTINATION_MEDIA,\n\t\t\t\ttitle: __( 'Link to image file' ),\n\t\t\t\turl: mediaType === 'image' ? mediaUrl : undefined,\n\t\t\t\ticon: image,\n\t\t\t},\n\t\t];\n\t\tif ( mediaType === 'image' && mediaLink ) {\n\t\t\tlinkDestinations.push( {\n\t\t\t\tlinkDestination: LINK_DESTINATION_ATTACHMENT,\n\t\t\t\ttitle: __( 'Link to attachment page' ),\n\t\t\t\turl: mediaType === 'image' ? mediaLink : undefined,\n\t\t\t\ticon: page,\n\t\t\t} );\n\t\t}\n\t\treturn linkDestinations;\n\t};\n\n\tconst onSetHref = ( value ) => {\n\t\tconst linkDestinations = getLinkDestinations();\n\t\tlet linkDestinationInput;\n\t\tif ( ! value ) {\n\t\t\tlinkDestinationInput = LINK_DESTINATION_NONE;\n\t\t} else {\n\t\t\tlinkDestinationInput = (\n\t\t\t\tlinkDestinations.find( ( destination ) => {\n\t\t\t\t\treturn destination.url === value;\n\t\t\t\t} ) || { linkDestination: LINK_DESTINATION_CUSTOM }\n\t\t\t).linkDestination;\n\t\t}\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: linkDestinationInput,\n\t\t\thref: value,\n\t\t} );\n\t};\n\n\tconst onSetNewTab = ( value ) => {\n\t\tconst updatedLinkTarget = getUpdatedLinkTargetSettings( value );\n\t\tonChangeUrl( updatedLinkTarget );\n\t};\n\n\tconst onSetLinkRel = ( value ) => {\n\t\tonChangeUrl( { rel: value } );\n\t};\n\n\tconst onSetLinkClass = ( value ) => {\n\t\tonChangeUrl( { linkClass: value } );\n\t};\n\n\tconst advancedOptions = (\n\t\t<VStack spacing=\"3\">\n\t\t\t<ToggleControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\tonChange={ onSetNewTab }\n\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\tvalue={ rel ?? '' }\n\t\t\t\tonChange={ onSetLinkRel }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Link CSS class' ) }\n\t\t\t\tvalue={ linkClass || '' }\n\t\t\t\tonChange={ onSetLinkClass }\n\t\t\t/>\n\t\t</VStack>\n\t);\n\n\tconst linkEditorValue = urlInput !== null ? urlInput : url;\n\tconst showLinkEditor = ( ! linkEditorValue && ! lightboxEnabled ) === true;\n\n\tconst urlLabel = (\n\t\tgetLinkDestinations().find(\n\t\t\t( destination ) => destination.linkDestination === linkDestination\n\t\t) || {}\n\t).title;\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ linkIcon }\n\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\taria-expanded={ isOpen }\n\t\t\t\tonClick={ openLinkUI }\n\t\t\t\tref={ setPopoverAnchor }\n\t\t\t\tisActive={ !! url || lightboxEnabled }\n\t\t\t/>\n\t\t\t{ isOpen && (\n\t\t\t\t<URLPopover\n\t\t\t\t\tref={ wrapperRef }\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tonFocusOutside={ onFocusOutside() }\n\t\t\t\t\tonClose={ closeLinkUI }\n\t\t\t\t\trenderSettings={\n\t\t\t\t\t\t! lightboxEnabled ? () => advancedOptions : null\n\t\t\t\t\t}\n\t\t\t\t\tadditionalControls={\n\t\t\t\t\t\tshowLinkEditor && (\n\t\t\t\t\t\t\t<NavigableMenu>\n\t\t\t\t\t\t\t\t{ getLinkDestinations().map( ( link ) => (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey={ link.linkDestination }\n\t\t\t\t\t\t\t\t\t\ticon={ link.icon }\n\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonSetHref( link.url );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ link.title }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t\t{ showLightboxSetting && (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey=\"expand-on-click\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-url-popover__expand-on-click\"\n\t\t\t\t\t\t\t\t\t\ticon={ fullscreen }\n\t\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t\t'Scale the image with a lightbox effect.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonChangeUrl( {\n\t\t\t\t\t\t\t\t\t\t\t\tlinkDestination:\n\t\t\t\t\t\t\t\t\t\t\t\t\tLINK_DESTINATION_NONE,\n\t\t\t\t\t\t\t\t\t\t\t\thref: '',\n\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t\tonSetLightbox( true );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Expand on click' ) }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\toffset={ 13 }\n\t\t\t\t>\n\t\t\t\t\t{ ( ! url || isEditingLink ) && ! lightboxEnabled && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<URLPopover.LinkEditor\n\t\t\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\t\t\tvalue={ linkEditorValue }\n\t\t\t\t\t\t\t\tonChangeInputValue={ setUrlInput }\n\t\t\t\t\t\t\t\tonSubmit={ onSubmitLinkChange() }\n\t\t\t\t\t\t\t\tautocompleteRef={ autocompleteRef }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ url && ! isEditingLink && ! lightboxEnabled && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<URLPopover.LinkViewer\n\t\t\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\t\tonEditLinkClick={ startEditLink }\n\t\t\t\t\t\t\t\turlLabel={ urlLabel }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\t\t\tonClick={ onLinkRemove }\n\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! url && ! isEditingLink && lightboxEnabled && (\n\t\t\t\t\t\t<div className=\"block-editor-url-popover__expand-on-click\">\n\t\t\t\t\t\t\t<Icon icon={ fullscreen } />\n\t\t\t\t\t\t\t<div className=\"text\">\n\t\t\t\t\t\t\t\t<p>{ __( 'Expand on click' ) }</p>\n\t\t\t\t\t\t\t\t<p className=\"description\">\n\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t'Scales the image with a lightbox effect'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\t\t\tlabel={ __( 'Disable expand on click' ) }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonSetLightbox( false );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</URLPopover>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport { ImageURLInputUI as __experimentalImageURLInputUI };\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,MAAM,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;AAChE,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SACCC,aAAa,EACbC,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,EAClC+F,aAAA;IAAGU,SAAS,EAAC;EAAa,GACvBzG,EAAE,CACH,yCACD,CACE,CACC,CAAC,EACN+F,aAAA,CAACxF,MAAM;IACNgF,IAAI,EAAGpE,OAAS;IAChB+E,KAAK,EAAGlG,EAAE,CAAE,yBAA0B,CAAG;IACzC0G,OAAO,EAAGA,CAAA,KAAM;MACfpE,aAAa,CAAE,KAAM,CAAC;IACvB,CAAG;IACHqF,IAAI,EAAC;EAAS,CACd,CACG,CAEK,CAEZ,CAAC;AAEL,CAAC;AAED,SAASjG,eAAe,IAAIkG,6BAA6B"}
1
+ {"version":3,"names":["__","useRef","useEffect","useState","focus","ToolbarButton","NavigableMenu","Button","MenuItem","ToggleControl","TextControl","__experimentalVStack","VStack","Icon","link","linkIcon","image","page","fullscreen","linkOff","URLPopover","LINK_DESTINATION_NONE","LINK_DESTINATION_CUSTOM","LINK_DESTINATION_MEDIA","LINK_DESTINATION_ATTACHMENT","NEW_TAB_REL","ImageURLInputUI","linkDestination","onChangeUrl","url","mediaType","mediaUrl","mediaLink","linkTarget","linkClass","rel","showLightboxSetting","lightboxEnabled","onSetLightbox","resetLightbox","isOpen","setIsOpen","popoverAnchor","setPopoverAnchor","openLinkUI","isEditingLink","setIsEditingLink","urlInput","setUrlInput","autocompleteRef","wrapperRef","current","nextFocusTarget","focusable","find","startEditLink","stopEditLink","closeLinkUI","getUpdatedLinkTargetSettings","value","newLinkTarget","undefined","updatedRel","rels","split","forEach","relVal","includes","push","join","filter","length","onFocusOutside","event","autocompleteElement","contains","target","onSubmitLinkChange","selectedDestination","getLinkDestinations","destination","href","lightbox","enabled","preventDefault","onLinkRemove","linkDestinations","title","icon","onSetHref","linkDestinationInput","onSetNewTab","updatedLinkTarget","onSetLinkRel","onSetLinkClass","advancedOptions","createElement","spacing","__nextHasNoMarginBottom","label","onChange","checked","linkEditorValue","hideLightboxPanel","showLinkEditor","urlLabel","PopoverChildren","className","onClick","size","LinkEditor","onChangeInputValue","onSubmit","Fragment","LinkViewer","onEditLinkClick","ref","isActive","anchor","onClose","renderSettings","additionalControls","map","key","iconPosition","info","offset","__experimentalImageURLInputUI"],"sources":["@wordpress/block-editor/src/components/url-popover/image-url-input-ui.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useEffect, useState } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport {\n\tToolbarButton,\n\tNavigableMenu,\n\tButton,\n\tMenuItem,\n\tToggleControl,\n\tTextControl,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport {\n\tIcon,\n\tlink as linkIcon,\n\timage,\n\tpage,\n\tfullscreen,\n\tlinkOff,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport URLPopover from './index';\n\nconst LINK_DESTINATION_NONE = 'none';\nconst LINK_DESTINATION_CUSTOM = 'custom';\nconst LINK_DESTINATION_MEDIA = 'media';\nconst LINK_DESTINATION_ATTACHMENT = 'attachment';\nconst NEW_TAB_REL = [ 'noreferrer', 'noopener' ];\n\nconst ImageURLInputUI = ( {\n\tlinkDestination,\n\tonChangeUrl,\n\turl,\n\tmediaType = 'image',\n\tmediaUrl,\n\tmediaLink,\n\tlinkTarget,\n\tlinkClass,\n\trel,\n\tshowLightboxSetting,\n\tlightboxEnabled,\n\tonSetLightbox,\n\tresetLightbox,\n} ) => {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst openLinkUI = () => {\n\t\tsetIsOpen( true );\n\t};\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState( false );\n\tconst [ urlInput, setUrlInput ] = useState( null );\n\n\tconst autocompleteRef = useRef( null );\n\tconst wrapperRef = useRef();\n\n\tuseEffect( () => {\n\t\tif ( ! wrapperRef.current ) {\n\t\t\treturn;\n\t\t}\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperRef.current )[ 0 ] ||\n\t\t\twrapperRef.current;\n\t\tnextFocusTarget.focus();\n\t}, [ isEditingLink, url, lightboxEnabled ] );\n\n\tconst startEditLink = () => {\n\t\tif (\n\t\t\tlinkDestination === LINK_DESTINATION_MEDIA ||\n\t\t\tlinkDestination === LINK_DESTINATION_ATTACHMENT\n\t\t) {\n\t\t\tsetUrlInput( '' );\n\t\t}\n\t\tsetIsEditingLink( true );\n\t};\n\n\tconst stopEditLink = () => {\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst closeLinkUI = () => {\n\t\tsetUrlInput( null );\n\t\tstopEditLink();\n\t\tsetIsOpen( false );\n\t};\n\n\tconst getUpdatedLinkTargetSettings = ( value ) => {\n\t\tconst newLinkTarget = value ? '_blank' : undefined;\n\n\t\tlet updatedRel;\n\t\tif ( newLinkTarget ) {\n\t\t\tconst rels = ( rel ?? '' ).split( ' ' );\n\t\t\tNEW_TAB_REL.forEach( ( relVal ) => {\n\t\t\t\tif ( ! rels.includes( relVal ) ) {\n\t\t\t\t\trels.push( relVal );\n\t\t\t\t}\n\t\t\t} );\n\t\t\tupdatedRel = rels.join( ' ' );\n\t\t} else {\n\t\t\tconst rels = ( rel ?? '' )\n\t\t\t\t.split( ' ' )\n\t\t\t\t.filter(\n\t\t\t\t\t( relVal ) => NEW_TAB_REL.includes( relVal ) === false\n\t\t\t\t);\n\t\t\tupdatedRel = rels.length ? rels.join( ' ' ) : undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tlinkTarget: newLinkTarget,\n\t\t\trel: updatedRel,\n\t\t};\n\t};\n\n\tconst onFocusOutside = () => {\n\t\treturn ( event ) => {\n\t\t\t// The autocomplete suggestions list renders in a separate popover (in a portal),\n\t\t\t// so onFocusOutside fails to detect that a click on a suggestion occurred in the\n\t\t\t// LinkContainer. Detect clicks on autocomplete suggestions using a ref here, and\n\t\t\t// return to avoid the popover being closed.\n\t\t\tconst autocompleteElement = autocompleteRef.current;\n\t\t\tif (\n\t\t\t\tautocompleteElement &&\n\t\t\t\tautocompleteElement.contains( event.target )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetIsOpen( false );\n\t\t\tsetUrlInput( null );\n\t\t\tstopEditLink();\n\t\t};\n\t};\n\n\tconst onSubmitLinkChange = () => {\n\t\treturn ( event ) => {\n\t\t\tif ( urlInput ) {\n\t\t\t\t// It is possible the entered URL actually matches a named link destination.\n\t\t\t\t// This check will ensure our link destination is correct.\n\t\t\t\tconst selectedDestination =\n\t\t\t\t\tgetLinkDestinations().find(\n\t\t\t\t\t\t( destination ) => destination.url === urlInput\n\t\t\t\t\t)?.linkDestination || LINK_DESTINATION_CUSTOM;\n\n\t\t\t\tonChangeUrl( {\n\t\t\t\t\thref: urlInput,\n\t\t\t\t\tlinkDestination: selectedDestination,\n\t\t\t\t\tlightbox: { enabled: false },\n\t\t\t\t} );\n\t\t\t}\n\t\t\tstopEditLink();\n\t\t\tsetUrlInput( null );\n\t\t\tevent.preventDefault();\n\t\t};\n\t};\n\n\tconst onLinkRemove = () => {\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: LINK_DESTINATION_NONE,\n\t\t\thref: '',\n\t\t} );\n\t};\n\n\tconst getLinkDestinations = () => {\n\t\tconst linkDestinations = [\n\t\t\t{\n\t\t\t\tlinkDestination: LINK_DESTINATION_MEDIA,\n\t\t\t\ttitle: __( 'Link to image file' ),\n\t\t\t\turl: mediaType === 'image' ? mediaUrl : undefined,\n\t\t\t\ticon: image,\n\t\t\t},\n\t\t];\n\t\tif ( mediaType === 'image' && mediaLink ) {\n\t\t\tlinkDestinations.push( {\n\t\t\t\tlinkDestination: LINK_DESTINATION_ATTACHMENT,\n\t\t\t\ttitle: __( 'Link to attachment page' ),\n\t\t\t\turl: mediaType === 'image' ? mediaLink : undefined,\n\t\t\t\ticon: page,\n\t\t\t} );\n\t\t}\n\t\treturn linkDestinations;\n\t};\n\n\tconst onSetHref = ( value ) => {\n\t\tconst linkDestinations = getLinkDestinations();\n\t\tlet linkDestinationInput;\n\t\tif ( ! value ) {\n\t\t\tlinkDestinationInput = LINK_DESTINATION_NONE;\n\t\t} else {\n\t\t\tlinkDestinationInput = (\n\t\t\t\tlinkDestinations.find( ( destination ) => {\n\t\t\t\t\treturn destination.url === value;\n\t\t\t\t} ) || { linkDestination: LINK_DESTINATION_CUSTOM }\n\t\t\t).linkDestination;\n\t\t}\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: linkDestinationInput,\n\t\t\thref: value,\n\t\t} );\n\t};\n\n\tconst onSetNewTab = ( value ) => {\n\t\tconst updatedLinkTarget = getUpdatedLinkTargetSettings( value );\n\t\tonChangeUrl( updatedLinkTarget );\n\t};\n\n\tconst onSetLinkRel = ( value ) => {\n\t\tonChangeUrl( { rel: value } );\n\t};\n\n\tconst onSetLinkClass = ( value ) => {\n\t\tonChangeUrl( { linkClass: value } );\n\t};\n\n\tconst advancedOptions = (\n\t\t<VStack spacing=\"3\">\n\t\t\t<ToggleControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\tonChange={ onSetNewTab }\n\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\tvalue={ rel ?? '' }\n\t\t\t\tonChange={ onSetLinkRel }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Link CSS class' ) }\n\t\t\t\tvalue={ linkClass || '' }\n\t\t\t\tonChange={ onSetLinkClass }\n\t\t\t/>\n\t\t</VStack>\n\t);\n\n\tconst linkEditorValue = urlInput !== null ? urlInput : url;\n\tconst hideLightboxPanel =\n\t\t! lightboxEnabled || ( lightboxEnabled && ! showLightboxSetting );\n\tconst showLinkEditor = ! linkEditorValue && hideLightboxPanel;\n\n\tconst urlLabel = (\n\t\tgetLinkDestinations().find(\n\t\t\t( destination ) => destination.linkDestination === linkDestination\n\t\t) || {}\n\t).title;\n\n\tconst PopoverChildren = () => {\n\t\tif (\n\t\t\tlightboxEnabled &&\n\t\t\tshowLightboxSetting &&\n\t\t\t! url &&\n\t\t\t! isEditingLink\n\t\t) {\n\t\t\treturn (\n\t\t\t\t<div className=\"block-editor-url-popover__expand-on-click\">\n\t\t\t\t\t<Icon icon={ fullscreen } />\n\t\t\t\t\t<div className=\"text\">\n\t\t\t\t\t\t<p>{ __( 'Expand on click' ) }</p>\n\t\t\t\t\t\t<p className=\"description\">\n\t\t\t\t\t\t\t{ __( 'Scales the image with a lightbox effect' ) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Disable expand on click' ) }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonSetLightbox( false );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t);\n\t\t} else if ( ! url || isEditingLink ) {\n\t\t\treturn (\n\t\t\t\t<URLPopover.LinkEditor\n\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\tvalue={ linkEditorValue }\n\t\t\t\t\tonChangeInputValue={ setUrlInput }\n\t\t\t\t\tonSubmit={ onSubmitLinkChange() }\n\t\t\t\t\tautocompleteRef={ autocompleteRef }\n\t\t\t\t/>\n\t\t\t);\n\t\t} else if ( url && ! isEditingLink ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<URLPopover.LinkViewer\n\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\tonEditLinkClick={ startEditLink }\n\t\t\t\t\t\turlLabel={ urlLabel }\n\t\t\t\t\t/>\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonLinkRemove();\n\t\t\t\t\t\t\tresetLightbox();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t);\n\t\t}\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ linkIcon }\n\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\taria-expanded={ isOpen }\n\t\t\t\tonClick={ openLinkUI }\n\t\t\t\tref={ setPopoverAnchor }\n\t\t\t\tisActive={\n\t\t\t\t\t!! url || ( lightboxEnabled && showLightboxSetting )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ isOpen && (\n\t\t\t\t<URLPopover\n\t\t\t\t\tref={ wrapperRef }\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tonFocusOutside={ onFocusOutside() }\n\t\t\t\t\tonClose={ closeLinkUI }\n\t\t\t\t\trenderSettings={\n\t\t\t\t\t\thideLightboxPanel ? () => advancedOptions : null\n\t\t\t\t\t}\n\t\t\t\t\tadditionalControls={\n\t\t\t\t\t\tshowLinkEditor && (\n\t\t\t\t\t\t\t<NavigableMenu>\n\t\t\t\t\t\t\t\t{ getLinkDestinations().map( ( link ) => (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey={ link.linkDestination }\n\t\t\t\t\t\t\t\t\t\ticon={ link.icon }\n\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonSetHref( link.url );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ link.title }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t\t{ showLightboxSetting && (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey=\"expand-on-click\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-url-popover__expand-on-click\"\n\t\t\t\t\t\t\t\t\t\ticon={ fullscreen }\n\t\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t\t'Scale the image with a lightbox effect.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonChangeUrl( {\n\t\t\t\t\t\t\t\t\t\t\t\tlinkDestination:\n\t\t\t\t\t\t\t\t\t\t\t\t\tLINK_DESTINATION_NONE,\n\t\t\t\t\t\t\t\t\t\t\t\thref: '',\n\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t\tonSetLightbox( true );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Expand on click' ) }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\toffset={ 13 }\n\t\t\t\t>\n\t\t\t\t\t{ PopoverChildren() }\n\t\t\t\t</URLPopover>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport { ImageURLInputUI as __experimentalImageURLInputUI };\n"],"mappings":";AAAA;AACA;A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C,MAAM;MACnBhB,OAAO,EAAGA,CAAA,KAAM;QACf5D,WAAW,CAAE,IAAK,CAAC;QACnByC,SAAS,CAAE3E,IAAI,CAACe,GAAI,CAAC;QACrB2B,YAAY,CAAC,CAAC;MACf;IAAG,GAED1C,IAAI,CAACyE,KACE,CACT,CAAC,EACDnD,mBAAmB,IACpB4D,aAAA,CAACxF,QAAQ;MACRmH,GAAG,EAAC,iBAAiB;MACrBhB,SAAS,EAAC,2CAA2C;MACrDnB,IAAI,EAAGtE,UAAY;MACnB2G,IAAI,EAAG7H,EAAE,CACR,yCACD,CAAG;MACH4H,YAAY,EAAC,MAAM;MACnBhB,OAAO,EAAGA,CAAA,KAAM;QACf5D,WAAW,CAAE,IAAK,CAAC;QACnBpB,WAAW,CAAE;UACZD,eAAe,EACdN,qBAAqB;UACtB4D,IAAI,EAAE;QACP,CAAE,CAAC;QACH3C,aAAa,CAAE,IAAK,CAAC;QACrBkB,YAAY,CAAC,CAAC;MACf;IAAG,GAEDxD,EAAE,CAAE,iBAAkB,CACf,CAEG,CAEhB;IACD8H,MAAM,EAAG;EAAI,GAEXpB,eAAe,CAAC,CACP,CAEZ,CAAC;AAEL,CAAC;AAED,SAAShF,eAAe,IAAIqG,6BAA6B"}
@@ -2,7 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useSelect } from '@wordpress/data';
5
- import { store as blocksStore, isReusableBlock, isTemplatePart } from '@wordpress/blocks';
5
+ import { store as blocksStore, isReusableBlock, isTemplatePart, __experimentalGetBlockLabel as getBlockLabel } from '@wordpress/blocks';
6
6
  import { __ } from '@wordpress/i18n';
7
7
 
8
8
  /**
@@ -62,8 +62,7 @@ export default function useBlockDisplayInformation(clientId) {
62
62
  if (!clientId) return null;
63
63
  const {
64
64
  getBlockName,
65
- getBlockAttributes,
66
- __experimentalGetReusableBlockTitle
65
+ getBlockAttributes
67
66
  } = select(blockEditorStore);
68
67
  const {
69
68
  getBlockType,
@@ -74,10 +73,9 @@ export default function useBlockDisplayInformation(clientId) {
74
73
  if (!blockType) return null;
75
74
  const attributes = getBlockAttributes(clientId);
76
75
  const match = getActiveBlockVariation(blockName, attributes);
77
- const isReusable = isReusableBlock(blockType);
78
- const resusableTitle = isReusable ? __experimentalGetReusableBlockTitle(attributes.ref) : undefined;
79
- const title = resusableTitle || blockType.title;
80
- const isSynced = isReusable || isTemplatePart(blockType);
76
+ const isSynced = isReusableBlock(blockType) || isTemplatePart(blockType);
77
+ const syncedTitle = isSynced ? getBlockLabel(blockType, attributes) : undefined;
78
+ const title = syncedTitle || blockType.title;
81
79
  const positionLabel = getPositionTypeLabel(attributes);
82
80
  const blockTypeInfo = {
83
81
  isSynced,
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","store","blocksStore","isReusableBlock","isTemplatePart","__","blockEditorStore","getPositionTypeLabel","attributes","positionType","style","position","type","useBlockDisplayInformation","clientId","select","getBlockName","getBlockAttributes","__experimentalGetReusableBlockTitle","getBlockType","getActiveBlockVariation","blockName","blockType","match","isReusable","resusableTitle","ref","undefined","title","isSynced","positionLabel","blockTypeInfo","icon","description","anchor","name","metadata"],"sources":["@wordpress/block-editor/src/components/use-block-display-information/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tstore as blocksStore,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */\n\n/**\n * Contains basic block's information for display reasons.\n *\n * @typedef {Object} WPBlockDisplayInformation\n *\n * @property {boolean} isSynced True if is a reusable block or template part\n * @property {string} title Human-readable block type label.\n * @property {WPIcon} icon Block type icon.\n * @property {string} description A detailed block type description.\n * @property {string} anchor HTML anchor.\n * @property {name} name A custom, human readable name for the block.\n */\n\n/**\n * Get the display label for a block's position type.\n *\n * @param {Object} attributes Block attributes.\n * @return {string} The position type label.\n */\nfunction getPositionTypeLabel( attributes ) {\n\tconst positionType = attributes?.style?.position?.type;\n\n\tif ( positionType === 'sticky' ) {\n\t\treturn __( 'Sticky' );\n\t}\n\n\tif ( positionType === 'fixed' ) {\n\t\treturn __( 'Fixed' );\n\t}\n\n\treturn null;\n}\n\n/**\n * Hook used to try to find a matching block variation and return\n * the appropriate information for display reasons. In order to\n * to try to find a match we need to things:\n * 1. Block's client id to extract it's current attributes.\n * 2. A block variation should have set `isActive` prop to a proper function.\n *\n * If for any reason a block variation match cannot be found,\n * the returned information come from the Block Type.\n * If no blockType is found with the provided clientId, returns null.\n *\n * @param {string} clientId Block's client id.\n * @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found.\n */\n\nexport default function useBlockDisplayInformation( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) return null;\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\t__experimentalGetReusableBlockTitle,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\t\t\tif ( ! blockType ) return null;\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst match = getActiveBlockVariation( blockName, attributes );\n\t\t\tconst isReusable = isReusableBlock( blockType );\n\t\t\tconst resusableTitle = isReusable\n\t\t\t\t? __experimentalGetReusableBlockTitle( attributes.ref )\n\t\t\t\t: undefined;\n\t\t\tconst title = resusableTitle || blockType.title;\n\t\t\tconst isSynced = isReusable || isTemplatePart( blockType );\n\t\t\tconst positionLabel = getPositionTypeLabel( attributes );\n\t\t\tconst blockTypeInfo = {\n\t\t\t\tisSynced,\n\t\t\t\ttitle,\n\t\t\t\ticon: blockType.icon,\n\t\t\t\tdescription: blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\tpositionLabel,\n\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\tname: attributes?.metadata?.name,\n\t\t\t};\n\t\t\tif ( ! match ) return blockTypeInfo;\n\n\t\t\treturn {\n\t\t\t\tisSynced,\n\t\t\t\ttitle: match.title || blockType.title,\n\t\t\t\ticon: match.icon || blockType.icon,\n\t\t\t\tdescription: match.description || blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\tpositionLabel,\n\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\tname: attributes?.metadata?.name,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,KAAK,IAAIC,WAAW,EACpBC,eAAe,EACfC,cAAc,QACR,mBAAmB;AAC1B,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASJ,KAAK,IAAIK,gBAAgB,QAAQ,aAAa;;AAEvD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,oBAAoBA,CAAEC,UAAU,EAAG;EAC3C,MAAMC,YAAY,GAAGD,UAAU,EAAEE,KAAK,EAAEC,QAAQ,EAAEC,IAAI;EAEtD,IAAKH,YAAY,KAAK,QAAQ,EAAG;IAChC,OAAOJ,EAAE,CAAE,QAAS,CAAC;EACtB;EAEA,IAAKI,YAAY,KAAK,OAAO,EAAG;IAC/B,OAAOJ,EAAE,CAAE,OAAQ,CAAC;EACrB;EAEA,OAAO,IAAI;AACZ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,eAAe,SAASQ,0BAA0BA,CAAEC,QAAQ,EAAG;EAC9D,OAAOd,SAAS,CACbe,MAAM,IAAM;IACb,IAAK,CAAED,QAAQ,EAAG,OA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S,CAACM,KAAK;MACrCI,IAAI,EAAET,KAAK,CAACS,IAAI,IAAIV,SAAS,CAACU,IAAI;MAClCC,WAAW,EAAEV,KAAK,CAACU,WAAW,IAAIX,SAAS,CAACW,WAAW;MACvDC,MAAM,EAAE1B,UAAU,EAAE0B,MAAM;MAC1BJ,aAAa;MACbrB,YAAY,EAAED,UAAU,EAAEE,KAAK,EAAEC,QAAQ,EAAEC,IAAI;MAC/CuB,IAAI,EAAE3B,UAAU,EAAE4B,QAAQ,EAAED;IAC7B,CAAC;EACF,CAAC,EACD,CAAErB,QAAQ,CACX,CAAC;AACF"}
1
+ {"version":3,"names":["useSelect","store","blocksStore","isReusableBlock","isTemplatePart","__experimentalGetBlockLabel","getBlockLabel","__","blockEditorStore","getPositionTypeLabel","attributes","positionType","style","position","type","useBlockDisplayInformation","clientId","select","getBlockName","getBlockAttributes","getBlockType","getActiveBlockVariation","blockName","blockType","match","isSynced","syncedTitle","undefined","title","positionLabel","blockTypeInfo","icon","description","anchor","name","metadata"],"sources":["@wordpress/block-editor/src/components/use-block-display-information/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tstore as blocksStore,\n\tisReusableBlock,\n\tisTemplatePart,\n\t__experimentalGetBlockLabel as getBlockLabel,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */\n\n/**\n * Contains basic block's information for display reasons.\n *\n * @typedef {Object} WPBlockDisplayInformation\n *\n * @property {boolean} isSynced True if is a reusable block or template part\n * @property {string} title Human-readable block type label.\n * @property {WPIcon} icon Block type icon.\n * @property {string} description A detailed block type description.\n * @property {string} anchor HTML anchor.\n * @property {name} name A custom, human readable name for the block.\n */\n\n/**\n * Get the display label for a block's position type.\n *\n * @param {Object} attributes Block attributes.\n * @return {string} The position type label.\n */\nfunction getPositionTypeLabel( attributes ) {\n\tconst positionType = attributes?.style?.position?.type;\n\n\tif ( positionType === 'sticky' ) {\n\t\treturn __( 'Sticky' );\n\t}\n\n\tif ( positionType === 'fixed' ) {\n\t\treturn __( 'Fixed' );\n\t}\n\n\treturn null;\n}\n\n/**\n * Hook used to try to find a matching block variation and return\n * the appropriate information for display reasons. In order to\n * to try to find a match we need to things:\n * 1. Block's client id to extract it's current attributes.\n * 2. A block variation should have set `isActive` prop to a proper function.\n *\n * If for any reason a block variation match cannot be found,\n * the returned information come from the Block Type.\n * If no blockType is found with the provided clientId, returns null.\n *\n * @param {string} clientId Block's client id.\n * @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found.\n */\n\nexport default function useBlockDisplayInformation( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) return null;\n\t\t\tconst { getBlockName, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\t\t\tif ( ! blockType ) return null;\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst match = getActiveBlockVariation( blockName, attributes );\n\t\t\tconst isSynced =\n\t\t\t\tisReusableBlock( blockType ) || isTemplatePart( blockType );\n\t\t\tconst syncedTitle = isSynced\n\t\t\t\t? getBlockLabel( blockType, attributes )\n\t\t\t\t: undefined;\n\t\t\tconst title = syncedTitle || blockType.title;\n\t\t\tconst positionLabel = getPositionTypeLabel( attributes );\n\t\t\tconst blockTypeInfo = {\n\t\t\t\tisSynced,\n\t\t\t\ttitle,\n\t\t\t\ticon: blockType.icon,\n\t\t\t\tdescription: blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\tpositionLabel,\n\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\tname: attributes?.metadata?.name,\n\t\t\t};\n\t\t\tif ( ! match ) return blockTypeInfo;\n\n\t\t\treturn {\n\t\t\t\tisSynced,\n\t\t\t\ttitle: match.title || blockType.title,\n\t\t\t\ticon: match.icon || blockType.icon,\n\t\t\t\tdescription: match.description || blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\tpositionLabel,\n\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\tname: attributes?.metadata?.name,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,KAAK,IAAIC,WAAW,EACpBC,eAAe,EACfC,cAAc,EACdC,2BAA2B,IAAIC,aAAa,QACtC,mBAAmB;AAC1B,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASN,KAAK,IAAIO,gBAAgB,QAAQ,aAAa;;AAEvD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,oBAAoBA,CAAEC,UAAU,EAAG;EAC3C,MAAMC,YAAY,GAAGD,UAAU,EAAEE,KAAK,EAAEC,QAAQ,EAAEC,IAAI;EAEtD,IAAKH,YAAY,KAAK,QAAQ,EAAG;IAChC,OAAOJ,EAAE,CAAE,QAAS,CAAC;EACtB;EAEA,IAAKI,YAAY,KAAK,OAAO,EAAG;IAC/B,OAAOJ,EAAE,CAAE,OAAQ,CAAC;EACrB;EAEA,OAAO,IAAI;AACZ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,eAAe,SAASQ,0BAA0BA,CAAEC,QAAQ,EAAG;EAC9D,OAAOhB,SAAS,CACbiB,MAAM,IAAM;IACb,IAAK,CAAED,QAAQ,EAAG,OAAO,IAAI;IAC7B,MAAM;MAAEE,YAAY;MAAEC;IAAmB,CAAC,GACzCF,MAAM,CAAET,gB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AS,CAACS,WAAW;MACvDC,MAAM,EAAEvB,UAAU,EAAEuB,MAAM;MAC1BJ,aAAa;MACblB,YAAY,EAAED,UAAU,EAAEE,KAAK,EAAEC,QAAQ,EAAEC,IAAI;MAC/CoB,IAAI,EAAExB,UAAU,EAAEyB,QAAQ,EAAED;IAC7B,CAAC;EACF,CAAC,EACD,CAAElB,QAAQ,CACX,CAAC;AACF"}
@@ -142,6 +142,10 @@ function useMovingAnimation({
142
142
  });
143
143
  return () => {
144
144
  controller.stop();
145
+ controller.set({
146
+ x: 0,
147
+ y: 0
148
+ });
145
149
  };
146
150
  }, [previous, prevRect, clientId, isTyping, getGlobalBlockCount, isBlockSelected, isFirstMultiSelectedBlock, isBlockMultiSelected, isAncestorMultiSelected]);
147
151
  return ref;
@@ -1 +1 @@
1
- {"version":3,"names":["Controller","useLayoutEffect","useMemo","useRef","getScrollContainer","useSelect","store","blockEditorStore","BLOCK_ANIMATION_THRESHOLD","getAbsolutePosition","element","top","offsetTop","left","offsetLeft","useMovingAnimation","triggerAnimationOnChange","clientId","ref","isTyping","getGlobalBlockCount","isBlockSelected","isFirstMultiSelectedBlock","isBlockMultiSelected","isAncestorMultiSelected","previous","prevRect","current","getBoundingClientRect","scrollContainer","isSelected","adjustScrolling","preserveScrollPosition","blockRect","diff","scrollTop","disableAnimation","window","matchMedia","matches","isPartOfSelection","zIndex","controller","x","y","config","mass","tension","friction","onChange","value","Math","round","finishedMoving","style","transformOrigin","transform","undefined","destination","start","from","stop"],"sources":["@wordpress/block-editor/src/components/use-moving-animation/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { Controller } from '@react-spring/web';\n\n/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useMemo, useRef } from '@wordpress/element';\nimport { getScrollContainer } from '@wordpress/dom';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * If the block count exceeds the threshold, we disable the reordering animation\n * to avoid laginess.\n */\nconst BLOCK_ANIMATION_THRESHOLD = 200;\n\nfunction getAbsolutePosition( element ) {\n\treturn {\n\t\ttop: element.offsetTop,\n\t\tleft: element.offsetLeft,\n\t};\n}\n\n/**\n * Hook used to compute the styles required to move a div into a new position.\n *\n * The way this animation works is the following:\n * - It first renders the element as if there was no animation.\n * - It takes a snapshot of the position of the block to use it\n * as a destination point for the animation.\n * - It restores the element to the previous position using a CSS transform\n * - It uses the \"resetAnimation\" flag to reset the animation\n * from the beginning in order to animate to the new destination point.\n *\n * @param {Object} $1 Options\n * @param {*} $1.triggerAnimationOnChange Variable used to trigger the animation if it changes.\n * @param {string} $1.clientId\n */\nfunction useMovingAnimation( { triggerAnimationOnChange, clientId } ) {\n\tconst ref = useRef();\n\tconst {\n\t\tisTyping,\n\t\tgetGlobalBlockCount,\n\t\tisBlockSelected,\n\t\tisFirstMultiSelectedBlock,\n\t\tisBlockMultiSelected,\n\t\tisAncestorMultiSelected,\n\t} = useSelect( blockEditorStore );\n\n\t// Whenever the trigger changes, we need to take a snapshot of the current\n\t// position of the block to use it as a destination point for the animation.\n\tconst { previous, prevRect } = useMemo(\n\t\t() => ( {\n\t\t\tprevious: ref.current && getAbsolutePosition( ref.current ),\n\t\t\tprevRect: ref.current && ref.current.getBoundingClientRect(),\n\t\t} ),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[ triggerAnimationOnChange ]\n\t);\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! previous || ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst scrollContainer = getScrollContainer( ref.current );\n\t\tconst isSelected = isBlockSelected( clientId );\n\t\tconst adjustScrolling =\n\t\t\tisSelected || isFirstMultiSelectedBlock( clientId );\n\n\t\tfunction preserveScrollPosition() {\n\t\t\tif ( adjustScrolling && prevRect ) {\n\t\t\t\tconst blockRect = ref.current.getBoundingClientRect();\n\t\t\t\tconst diff = blockRect.top - prevRect.top;\n\n\t\t\t\tif ( diff ) {\n\t\t\t\t\tscrollContainer.scrollTop += diff;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// We disable the animation if the user has a preference for reduced\n\t\t// motion, if the user is typing (insertion by Enter), or if the block\n\t\t// count exceeds the threshold (insertion caused all the blocks that\n\t\t// follow to animate).\n\t\t// To do: consider enableing the _moving_ animation even for large\n\t\t// posts, while only disabling the _insertion_ animation?\n\t\tconst disableAnimation =\n\t\t\twindow.matchMedia( '(prefers-reduced-motion: reduce)' ).matches ||\n\t\t\tisTyping() ||\n\t\t\tgetGlobalBlockCount() > BLOCK_ANIMATION_THRESHOLD;\n\n\t\tif ( disableAnimation ) {\n\t\t\t// If the animation is disabled and the scroll needs to be adjusted,\n\t\t\t// just move directly to the final scroll position.\n\t\t\tpreserveScrollPosition();\n\t\t\treturn;\n\t\t}\n\n\t\tconst isPartOfSelection =\n\t\t\tisSelected ||\n\t\t\tisBlockMultiSelected( clientId ) ||\n\t\t\tisAncestorMultiSelected( clientId );\n\t\t// Make sure the other blocks move under the selected block(s).\n\t\tconst zIndex = isPartOfSelection ? '1' : '';\n\n\t\tconst controller = new Controller( {\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t\tconfig: { mass: 5, tension: 2000, friction: 200 },\n\t\t\tonChange( { value } ) {\n\t\t\t\tif ( ! ref.current ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet { x, y } = value;\n\t\t\t\tx = Math.round( x );\n\t\t\t\ty = Math.round( y );\n\t\t\t\tconst finishedMoving = x === 0 && y === 0;\n\t\t\t\tref.current.style.transformOrigin = 'center center';\n\t\t\t\tref.current.style.transform = finishedMoving\n\t\t\t\t\t? null // Set to `null` to explicitly remove the transform.\n\t\t\t\t\t: `translate3d(${ x }px,${ y }px,0)`;\n\t\t\t\tref.current.style.zIndex = zIndex;\n\t\t\t\tpreserveScrollPosition();\n\t\t\t},\n\t\t} );\n\n\t\tref.current.style.transform = undefined;\n\t\tconst destination = getAbsolutePosition( ref.current );\n\n\t\tconst x = Math.round( previous.left - destination.left );\n\t\tconst y = Math.round( previous.top - destination.top );\n\n\t\tcontroller.start( { x: 0, y: 0, from: { x, y } } );\n\n\t\treturn () => {\n\t\t\tcontroller.stop();\n\t\t};\n\t}, [\n\t\tprevious,\n\t\tprevRect,\n\t\tclientId,\n\t\tisTyping,\n\t\tgetGlobalBlockCount,\n\t\tisBlockSelected,\n\t\tisFirstMultiSelectedBlock,\n\t\tisBlockMultiSelected,\n\t\tisAncestorMultiSelected,\n\t] );\n\n\treturn ref;\n}\n\nexport default useMovingAnimation;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,mBAAmB;;AAE9C;AACA;AACA;AACA,SAASC,eAAe,EAAEC,OAAO,EAAEC,MAAM,QAAQ,oBAAoB;AACrE,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;;AAEvD;AACA;AACA;AACA;AACA,MAAMC,yBAAyB,GAAG,GAAG;AAErC,SAASC,mBAAmBA,CAAEC,OAAO,EAAG;EACvC,OAAO;IACNC,GAAG,EAAED,OAAO,CAACE,SAAS;IACtBC,IAAI,EAAEH,OAAO,CAACI;EACf,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,kBAAkBA,CAAE;EAAEC,wBAAwB;EAAEC;AAAS,CAAC,EAAG;EACrE,MAAMC,GAAG,GAAGf,MAAM,CAAC,CAAC;EACpB,MAAM;IACLgB,QAAQ;IACRC,mBAAmB;IACnBC,eAAe;IACfC,yBAAyB;IACzBC,oBAAoB;IACpBC;EACD,CAAC,GAAGnB,SAAS,CAAEE,gBAAiB,CAAC;;EAEjC;EACA;EACA,MAAM;IAAEkB,QAAQ;IAAEC;EAAS,CAAC,GAAGxB,OAAO,CACrC,OAAQ;IACPuB,QA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KAAK,CAAE;MAAEhB,CAAC,EAAE,CAAC;MAAEC,CAAC,EAAE,CAAC;MAAEgB,IAAI,EAAE;QAAEjB,CAAC;QAAEC;MAAE;IAAE,CAAE,CAAC;IAElD,OAAO,MAAM;MACZF,UAAU,CAACmB,IAAI,CAAC,CAAC;IAClB,CAAC;EACF,CAAC,EAAE,CACFpC,QAAQ,EACRC,QAAQ,EACRT,QAAQ,EACRE,QAAQ,EACRC,mBAAmB,EACnBC,eAAe,EACfC,yBAAyB,EACzBC,oBAAoB,EACpBC,uBAAuB,CACtB,CAAC;EAEH,OAAON,GAAG;AACX;AAEA,eAAeH,kBAAkB"}
1
+ {"version":3,"names":["Controller","useLayoutEffect","useMemo","useRef","getScrollContainer","useSelect","store","blockEditorStore","BLOCK_ANIMATION_THRESHOLD","getAbsolutePosition","element","top","offsetTop","left","offsetLeft","useMovingAnimation","triggerAnimationOnChange","clientId","ref","isTyping","getGlobalBlockCount","isBlockSelected","isFirstMultiSelectedBlock","isBlockMultiSelected","isAncestorMultiSelected","previous","prevRect","current","getBoundingClientRect","scrollContainer","isSelected","adjustScrolling","preserveScrollPosition","blockRect","diff","scrollTop","disableAnimation","window","matchMedia","matches","isPartOfSelection","zIndex","controller","x","y","config","mass","tension","friction","onChange","value","Math","round","finishedMoving","style","transformOrigin","transform","undefined","destination","start","from","stop","set"],"sources":["@wordpress/block-editor/src/components/use-moving-animation/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { Controller } from '@react-spring/web';\n\n/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useMemo, useRef } from '@wordpress/element';\nimport { getScrollContainer } from '@wordpress/dom';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * If the block count exceeds the threshold, we disable the reordering animation\n * to avoid laginess.\n */\nconst BLOCK_ANIMATION_THRESHOLD = 200;\n\nfunction getAbsolutePosition( element ) {\n\treturn {\n\t\ttop: element.offsetTop,\n\t\tleft: element.offsetLeft,\n\t};\n}\n\n/**\n * Hook used to compute the styles required to move a div into a new position.\n *\n * The way this animation works is the following:\n * - It first renders the element as if there was no animation.\n * - It takes a snapshot of the position of the block to use it\n * as a destination point for the animation.\n * - It restores the element to the previous position using a CSS transform\n * - It uses the \"resetAnimation\" flag to reset the animation\n * from the beginning in order to animate to the new destination point.\n *\n * @param {Object} $1 Options\n * @param {*} $1.triggerAnimationOnChange Variable used to trigger the animation if it changes.\n * @param {string} $1.clientId\n */\nfunction useMovingAnimation( { triggerAnimationOnChange, clientId } ) {\n\tconst ref = useRef();\n\tconst {\n\t\tisTyping,\n\t\tgetGlobalBlockCount,\n\t\tisBlockSelected,\n\t\tisFirstMultiSelectedBlock,\n\t\tisBlockMultiSelected,\n\t\tisAncestorMultiSelected,\n\t} = useSelect( blockEditorStore );\n\n\t// Whenever the trigger changes, we need to take a snapshot of the current\n\t// position of the block to use it as a destination point for the animation.\n\tconst { previous, prevRect } = useMemo(\n\t\t() => ( {\n\t\t\tprevious: ref.current && getAbsolutePosition( ref.current ),\n\t\t\tprevRect: ref.current && ref.current.getBoundingClientRect(),\n\t\t} ),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[ triggerAnimationOnChange ]\n\t);\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! previous || ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst scrollContainer = getScrollContainer( ref.current );\n\t\tconst isSelected = isBlockSelected( clientId );\n\t\tconst adjustScrolling =\n\t\t\tisSelected || isFirstMultiSelectedBlock( clientId );\n\n\t\tfunction preserveScrollPosition() {\n\t\t\tif ( adjustScrolling && prevRect ) {\n\t\t\t\tconst blockRect = ref.current.getBoundingClientRect();\n\t\t\t\tconst diff = blockRect.top - prevRect.top;\n\n\t\t\t\tif ( diff ) {\n\t\t\t\t\tscrollContainer.scrollTop += diff;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// We disable the animation if the user has a preference for reduced\n\t\t// motion, if the user is typing (insertion by Enter), or if the block\n\t\t// count exceeds the threshold (insertion caused all the blocks that\n\t\t// follow to animate).\n\t\t// To do: consider enableing the _moving_ animation even for large\n\t\t// posts, while only disabling the _insertion_ animation?\n\t\tconst disableAnimation =\n\t\t\twindow.matchMedia( '(prefers-reduced-motion: reduce)' ).matches ||\n\t\t\tisTyping() ||\n\t\t\tgetGlobalBlockCount() > BLOCK_ANIMATION_THRESHOLD;\n\n\t\tif ( disableAnimation ) {\n\t\t\t// If the animation is disabled and the scroll needs to be adjusted,\n\t\t\t// just move directly to the final scroll position.\n\t\t\tpreserveScrollPosition();\n\t\t\treturn;\n\t\t}\n\n\t\tconst isPartOfSelection =\n\t\t\tisSelected ||\n\t\t\tisBlockMultiSelected( clientId ) ||\n\t\t\tisAncestorMultiSelected( clientId );\n\t\t// Make sure the other blocks move under the selected block(s).\n\t\tconst zIndex = isPartOfSelection ? '1' : '';\n\n\t\tconst controller = new Controller( {\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t\tconfig: { mass: 5, tension: 2000, friction: 200 },\n\t\t\tonChange( { value } ) {\n\t\t\t\tif ( ! ref.current ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet { x, y } = value;\n\t\t\t\tx = Math.round( x );\n\t\t\t\ty = Math.round( y );\n\t\t\t\tconst finishedMoving = x === 0 && y === 0;\n\t\t\t\tref.current.style.transformOrigin = 'center center';\n\t\t\t\tref.current.style.transform = finishedMoving\n\t\t\t\t\t? null // Set to `null` to explicitly remove the transform.\n\t\t\t\t\t: `translate3d(${ x }px,${ y }px,0)`;\n\t\t\t\tref.current.style.zIndex = zIndex;\n\t\t\t\tpreserveScrollPosition();\n\t\t\t},\n\t\t} );\n\n\t\tref.current.style.transform = undefined;\n\t\tconst destination = getAbsolutePosition( ref.current );\n\n\t\tconst x = Math.round( previous.left - destination.left );\n\t\tconst y = Math.round( previous.top - destination.top );\n\n\t\tcontroller.start( { x: 0, y: 0, from: { x, y } } );\n\n\t\treturn () => {\n\t\t\tcontroller.stop();\n\t\t\tcontroller.set( { x: 0, y: 0 } );\n\t\t};\n\t}, [\n\t\tprevious,\n\t\tprevRect,\n\t\tclientId,\n\t\tisTyping,\n\t\tgetGlobalBlockCount,\n\t\tisBlockSelected,\n\t\tisFirstMultiSelectedBlock,\n\t\tisBlockMultiSelected,\n\t\tisAncestorMultiSelected,\n\t] );\n\n\treturn ref;\n}\n\nexport default useMovingAnimation;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,mBAAmB;;AAE9C;AACA;AACA;AACA,SAASC,eAAe,EAAEC,OAAO,EAAEC,MAAM,QAAQ,oBAAoB;AACrE,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;;AAEvD;AACA;AACA;AACA;AACA,MAAMC,yBAAyB,GAAG,GAAG;AAErC,SAASC,mBAAmBA,CAAEC,OAAO,EAAG;EACvC,OAAO;IACNC,GAAG,EAAED,OAAO,CAACE,SAAS;IACtBC,IAAI,EAAEH,OAAO,CAACI;EACf,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,kBAAkBA,CAAE;EAAEC,wBAAwB;EAAEC;AAAS,CAAC,EAAG;EACrE,MAAMC,GAAG,GAAGf,MAAM,CAAC,CAAC;EACpB,MAAM;IACLgB,QAAQ;IACRC,mBAAmB;IACnBC,eAAe;IACfC,yBAAyB;IACzBC,oBAAoB;IACpBC;EACD,CAAC,GAAGnB,SAAS,CAAEE,gBAAiB,CAAC;;EAEjC;EACA;EACA,MAAM;IAAEkB,QAAQ;IAAEC;EAAS,CAAC,GAAGxB,OAAO,CACrC,OAAQ;IACPuB,QAAQ,EAAEP,GAAG,CAACS,OAAO,IAAIlB,mBAAmB,CAAES,GAAG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CAAC;MAAEgB,IAAI,EAAE;QAAEjB,CAAC;QAAEC;MAAE;IAAE,CAAE,CAAC;IAElD,OAAO,MAAM;MACZF,UAAU,CAACmB,IAAI,CAAC,CAAC;MACjBnB,UAAU,CAACoB,GAAG,CAAE;QAAEnB,CAAC,EAAE,CAAC;QAAEC,CAAC,EAAE;MAAE,CAAE,CAAC;IACjC,CAAC;EACF,CAAC,EAAE,CACFnB,QAAQ,EACRC,QAAQ,EACRT,QAAQ,EACRE,QAAQ,EACRC,mBAAmB,EACnBC,eAAe,EACfC,yBAAyB,EACzBC,oBAAoB,EACpBC,uBAAuB,CACtB,CAAC;EAEH,OAAON,GAAG;AACX;AAEA,eAAeH,kBAAkB"}
@@ -16,20 +16,25 @@ import { normalizeIconObject } from '@wordpress/blocks';
16
16
  */
17
17
  import styles from './style.scss';
18
18
  function Warning({
19
+ actions,
19
20
  title,
20
21
  message,
21
22
  icon,
22
23
  iconClass,
23
24
  preferredColorScheme,
24
25
  getStylesFromColorScheme,
26
+ containerStyle: extraContainerStyle,
27
+ titleStyle: extraTitleStyle,
28
+ messageStyle: extraMessageStyle,
25
29
  ...viewProps
26
30
  }) {
27
31
  icon = icon && normalizeIconObject(icon);
28
32
  const internalIconClass = 'warning-icon' + '-' + preferredColorScheme;
29
- const titleStyle = getStylesFromColorScheme(styles.title, styles.titleDark);
30
- const messageStyle = getStylesFromColorScheme(styles.message, styles.messageDark);
33
+ const containerStyle = [getStylesFromColorScheme(styles.container, styles.containerDark), extraContainerStyle];
34
+ const titleStyle = [getStylesFromColorScheme(styles.title, styles.titleDark), extraTitleStyle];
35
+ const messageStyle = [getStylesFromColorScheme(styles.message, styles.messageDark), extraMessageStyle];
31
36
  return createElement(View, {
32
- style: getStylesFromColorScheme(styles.container, styles.containerDark),
37
+ style: containerStyle,
33
38
  ...viewProps
34
39
  }, icon && createElement(View, {
35
40
  style: styles.icon
@@ -40,7 +45,7 @@ function Warning({
40
45
  style: titleStyle
41
46
  }, title), message && createElement(Text, {
42
47
  style: messageStyle
43
- }, message));
48
+ }, message), actions);
44
49
  }
45
50
  export default withPreferredColorScheme(Warning);
46
51
  //# sourceMappingURL=index.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["View","Text","Icon","withPreferredColorScheme","normalizeIconObject","styles","Warning","title","message","icon","iconClass","preferredColorScheme","getStylesFromColorScheme","viewProps","internalIconClass","titleStyle","titleDark","messageStyle","messageDark","createElement","style","container","containerDark","className","src"],"sources":["@wordpress/block-editor/src/components/warning/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View, Text } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Icon } from '@wordpress/components';\nimport { withPreferredColorScheme } from '@wordpress/compose';\nimport { normalizeIconObject } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nfunction Warning( {\n\ttitle,\n\tmessage,\n\ticon,\n\ticonClass,\n\tpreferredColorScheme,\n\tgetStylesFromColorScheme,\n\t...viewProps\n} ) {\n\ticon = icon && normalizeIconObject( icon );\n\tconst internalIconClass = 'warning-icon' + '-' + preferredColorScheme;\n\tconst titleStyle = getStylesFromColorScheme(\n\t\tstyles.title,\n\t\tstyles.titleDark\n\t);\n\tconst messageStyle = getStylesFromColorScheme(\n\t\tstyles.message,\n\t\tstyles.messageDark\n\t);\n\n\treturn (\n\t\t<View\n\t\t\tstyle={ getStylesFromColorScheme(\n\t\t\t\tstyles.container,\n\t\t\t\tstyles.containerDark\n\t\t\t) }\n\t\t\t{ ...viewProps }\n\t\t>\n\t\t\t{ icon && (\n\t\t\t\t<View style={ styles.icon }>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tclassName={ iconClass || internalIconClass }\n\t\t\t\t\t\ticon={ icon && icon.src ? icon.src : icon }\n\t\t\t\t\t/>\n\t\t\t\t</View>\n\t\t\t) }\n\t\t\t{ title && <Text style={ titleStyle }>{ title }</Text> }\n\t\t\t{ message && <Text style={ messageStyle }>{ message }</Text> }\n\t\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B,IAAI;IAACmB,KAAK,EAAGH;EAAc,GAAGT,OAAe,CACtD,CAAC;AAET;AAEA,eAAeL,wBAAwB,CAAEG,OAAQ,CAAC"}
1
+ {"version":3,"names":["View","Text","Icon","withPreferredColorScheme","normalizeIconObject","styles","Warning","actions","title","message","icon","iconClass","preferredColorScheme","getStylesFromColorScheme","containerStyle","extraContainerStyle","titleStyle","extraTitleStyle","messageStyle","extraMessageStyle","viewProps","internalIconClass","container","containerDark","titleDark","messageDark","createElement","style","className","src"],"sources":["@wordpress/block-editor/src/components/warning/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View, Text } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Icon } from '@wordpress/components';\nimport { withPreferredColorScheme } from '@wordpress/compose';\nimport { normalizeIconObject } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nfunction Warning( {\n\tactions,\n\ttitle,\n\tmessage,\n\ticon,\n\ticonClass,\n\tpreferredColorScheme,\n\tgetStylesFromColorScheme,\n\tcontainerStyle: extraContainerStyle,\n\ttitleStyle: extraTitleStyle,\n\tmessageStyle: extraMessageStyle,\n\t...viewProps\n} ) {\n\ticon = icon && normalizeIconObject( icon );\n\tconst internalIconClass = 'warning-icon' + '-' + preferredColorScheme;\n\n\tconst containerStyle = [\n\t\tgetStylesFromColorScheme( styles.container, styles.containerDark ),\n\t\textraContainerStyle,\n\t];\n\tconst titleStyle = [\n\t\tgetStylesFromColorScheme( styles.title, styles.titleDark ),\n\t\textraTitleStyle,\n\t];\n\tconst messageStyle = [\n\t\tgetStylesFromColorScheme( styles.message, styles.messageDark ),\n\t\textraMessageStyle,\n\t];\n\n\treturn (\n\t\t<View style={ containerStyle } { ...viewProps }>\n\t\t\t{ icon && (\n\t\t\t\t<View style={ styles.icon }>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tclassName={ iconClass || internalIconClass }\n\t\t\t\t\t\ticon={ icon && icon.src ? icon.src : icon }\n\t\t\t\t\t/>\n\t\t\t\t</View>\n\t\t\t) }\n\t\t\t{ title && <Text style={ titleStyle }>{ title }</Text> }\n\t\t\t{ message && <Text style={ messageStyle }>{ message }</Text> }\n\t\t\t{ actions }\n\t\t</View>\n\t);\n}\n\nexport default withPreferredColorScheme( Warning );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,IAAI,EAAEC,IAAI,QAAQ,cAAc;;AAEzC;AACA;AACA;AACA,SAASC,IAAI,QAAQ,uBAAuB;AAC5C,SAASC,wBAAwB,QAAQ,oBAAoB;AAC7D,SAASC,mBAAmB,QAAQ,mBAAmB;;AAEvD;AACA;AACA;AACA,OAAOC,MAAM,MAAM,cAAc;AAEjC,SAASC,OAAOA,CAAE;EACjBC,OAAO;EACPC,KAAK;EACLC,OAAO;EACPC,IAAI;EACJC,SAAS;EACTC,oBAAoB;EACpBC,wBAAwB;EACxBC,cAAc,EAAEC,mBAAmB;EACnCC,UAAU,EAAEC,eAAe;EAC3BC,YAAY,EAAEC,iBAAiB;EAC/B,GAAGC;AACJ,CAAC,EAAG;EACHV,IAAI,GAAGA,IAAI,IAAIN,mBAAmB,CAAEM,IAAK,CAAC;EAC1C,MAAMW,iBAAiB,GAAG,cAAc,GAAG,GAAG,GAAGT,oBAAoB;EAErE,MAAME,cAAc,GAAG,CACtBD,wBAAwB,CAAER,MAAM,CAACiB,SAAS,EAAEjB,MAAM,CAACkB,aAAc,CAAC,EAClER,mBAAmB,CACnB;EACD,MAAMC,UAAU,GAAG,CAClBH,wBAAwB,CAAER,MAAM,CAACG,KAAK,EAAEH,MAAM,CAACmB,SAAU,CAAC,EAC1DP,eAAe,CACf;EACD,MAAMC,YAAY,GAAG,CACpBL,wBAAwB,CAAER,MAAM,CAACI,OAAO,EAAEJ,MAAM,CAACoB,WAAY,CAAC,EAC9DN,iBAAiB,CACjB;EAED,OACCO,aAAA,CAAC1B,IAAI;IAAC2B,KAAK,EAAGb,cAAgB;IAAA,GAAMM;EAAS,GAC1CV,IAAI,IACLgB,aAAA,CAAC1B,IAAI;IAAC2B,KAAK,EAAGtB,MAAM,CAACK;EAAM,GAC1BgB,aAAA,CAACxB,IAAI;IACJ0B,SAAS,EAAGjB,SAAS,IAAIU,iBAAmB;IAC5CX,IAAI,EAAGA,IAAI,IAAIA,IAAI,CAACmB,GAAG,GAAGnB,IAAI,CAACmB,GAAG,GAAGnB;EAAM,CAC3C,CACI,CACN,EACCF,KAAK,IAAIkB,aAAA,CAACzB,IAAI;IAAC0B,KAAK,EAAGX;EAAY,GAAGR,KAAa,CAAC,EACpDC,OAAO,IAAIiB,aAAA,CAACzB,IAAI;IAAC0B,KAAK,EAAGT;EAAc,GAAGT,OAAe,CAAC,EAC1DF,OACG,CAAC;AAET;AAEA,eAAeJ,wBAAwB,CAAEG,OAAQ,CAAC"}
@@ -3,7 +3,7 @@ import { createElement, Fragment } from "react";
3
3
  * WordPress dependencies
4
4
  */
5
5
  import { addFilter } from '@wordpress/hooks';
6
- import { PanelBody, TextControl, ExternalLink } from '@wordpress/components';
6
+ import { TextControl, ExternalLink } from '@wordpress/components';
7
7
  import { __ } from '@wordpress/i18n';
8
8
  import { hasBlockSupport } from '@wordpress/blocks';
9
9
  import { Platform } from '@wordpress/element';
@@ -51,20 +51,24 @@ export function addAttribute(settings) {
51
51
  return settings;
52
52
  }
53
53
  function BlockEditAnchorControlPure({
54
- name: blockName,
55
54
  anchor,
56
55
  setAttributes
57
56
  }) {
58
57
  const blockEditingMode = useBlockEditingMode();
58
+ if (blockEditingMode !== 'default') {
59
+ return null;
60
+ }
59
61
  const isWeb = Platform.OS === 'web';
60
- const textControl = createElement(TextControl, {
62
+ return createElement(InspectorControls, {
63
+ group: "advanced"
64
+ }, createElement(TextControl, {
61
65
  __nextHasNoMarginBottom: true,
62
66
  __next40pxDefaultSize: true,
63
67
  className: "html-anchor-control",
64
68
  label: __('HTML anchor'),
65
- help: createElement(Fragment, null, __('Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'), isWeb && createElement(ExternalLink, {
69
+ help: createElement(Fragment, null, __('Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor”. Then, you’ll be able to link directly to this section of your page.'), isWeb && createElement(Fragment, null, ' ', createElement(ExternalLink, {
66
70
  href: __('https://wordpress.org/documentation/article/page-jumps/')
67
- }, __('Learn more about anchors'))),
71
+ }, __('Learn more about anchors')))),
68
72
  value: anchor || '',
69
73
  placeholder: !isWeb ? __('Add an anchor') : null,
70
74
  onChange: nextValue => {
@@ -75,12 +79,7 @@ function BlockEditAnchorControlPure({
75
79
  },
76
80
  autoCapitalize: "none",
77
81
  autoComplete: "off"
78
- });
79
- return createElement(Fragment, null, isWeb && blockEditingMode === 'default' && createElement(InspectorControls, {
80
- group: "advanced"
81
- }, textControl), !isWeb && blockName === 'core/heading' && createElement(InspectorControls, null, createElement(PanelBody, {
82
- title: __('Heading settings')
83
- }, textControl)));
82
+ }));
84
83
  }
85
84
  export default {
86
85
  addSaveProps,
@@ -1 +1 @@
1
- {"version":3,"names":["addFilter","PanelBody","TextControl","ExternalLink","__","hasBlockSupport","Platform","InspectorControls","useBlockEditingMode","ANCHOR_REGEX","ANCHOR_SCHEMA","type","source","attribute","selector","addAttribute","settings","_settings$attributes$","attributes","anchor","BlockEditAnchorControlPure","name","blockName","setAttributes","blockEditingMode","isWeb","OS","textControl","createElement","__nextHasNoMarginBottom","__next40pxDefaultSize","className","label","help","Fragment","href","value","placeholder","onChange","nextValue","replace","autoCapitalize","autoComplete","group","title","addSaveProps","edit","attributeKeys","hasSupport","extraProps","blockType","id"],"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\nconst ANCHOR_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'id',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( 'type' in ( settings.attributes?.anchor ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: ANCHOR_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockEditAnchorControlPure( {\n\tname: blockName,\n\tanchor,\n\tsetAttributes,\n} ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst isWeb = Platform.OS === 'web';\n\tconst textControl = (\n\t\t<TextControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tclassName=\"html-anchor-control\"\n\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\thelp={\n\t\t\t\t<>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-jumps/'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t}\n\t\t\tvalue={ anchor || '' }\n\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tanchor: nextValue,\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tautoCapitalize=\"none\"\n\t\t\tautoComplete=\"off\"\n\t\t/>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ isWeb && blockEditingMode === 'default' && (\n\t\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t\t{ textControl }\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t{ /*\n\t\t\t * We plan to remove scoping anchors to 'core/heading' to support\n\t\t\t * anchors for all eligble blocks. Additionally we plan to explore\n\t\t\t * leveraging InspectorAdvancedControls instead of a custom\n\t\t\t * PanelBody title. https://github.com/WordPress/gutenberg/issues/28363\n\t\t\t */ }\n\t\t\t{ ! isWeb && blockName === 'core/heading' && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Heading settings' ) }>\n\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default {\n\taddSaveProps,\n\tedit: BlockEditAnchorControlPure,\n\tattributeKeys: [ 'anchor' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'anchor' );\n\t},\n};\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,SAAS,EAAEC,WAAW,EAAEC,YAAY,QAAQ,uBAAuB;AAC5E,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,SAASC,iBAAiB,QAAQ,eAAe;AACjD,SAASC,mBAAmB,QAAQ,kCAAkC;;AAEtE;AACA;AACA;AACA;AACA;AACA,MAAMC,YAAY,GAAG,QAAQ;AAE7B,MAAMC,aAAa,GAAG;EACrBC,IAAI,EAAE,QAAQ;EACdC,MAAM,EAAE,WAAW;EACnBC,SAAS,EAAE,IAAI;EACfC,QAAQ,EAAE;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAAEC,QAAQ,EAAG;EAAA,IAAAC,qBAAA;EACxC;EACA,IAAK,MAAM,MAAAA,qBAAA,GAAMD,QAAQ,CAACE,UAAU,EAAEC,MAAM,cAAAF,qBAAA,cAAAA,qBAAA,GAAI,CAAC,CAAC,CAAE,EAAG;IACtD,OAAOD,QAAQ;EAChB;EACA,IAAKX,eAAe,CAAEW,QAAQ,EAAE,QAAS,CAAC,EAAG;IAC5C;IACAA,QAAQ,CAACE,UAAU,GAAG;MACrB,GAAGF,QAAQ,CAACE,UAAU;MACtBC,MAAM,EAAET;IACT,CAAC;EACF;EAEA,OAAOM,QAAQ;AAChB;AAEA,SAASI,0BAA0BA,CAAE;EACpCC,IAAI,EAAEC,SAAS;EACfH,MAAM;EACNI;AACD,CAAC,EAAG;EACH,MAAMC,gBAAgB,GAAGhB,mBAAmB,CAAC,CAAC;EAE9C,MAAMiB,KAAK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e,CAAEgB,IAAI,EAAE,QAAS,CAAC;EACzC;AACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASwB,YAAYA,CAAEI,UAAU,EAAEC,SAAS,EAAEhC,UAAU,EAAG;EACjE,IAAKb,eAAe,CAAE6C,SAAS,EAAE,QAAS,CAAC,EAAG;IAC7CD,UAAU,CAACE,EAAE,GAAGjC,UAAU,CAACC,MAAM,KAAK,EAAE,GAAG,IAAI,GAAGD,UAAU,CAACC,MAAM;EACpE;EAEA,OAAO8B,UAAU;AAClB;AAEAjD,SAAS,CAAE,0BAA0B,EAAE,uBAAuB,EAAEe,YAAa,CAAC"}
1
+ {"version":3,"names":["addFilter","TextControl","ExternalLink","__","hasBlockSupport","Platform","InspectorControls","useBlockEditingMode","ANCHOR_REGEX","ANCHOR_SCHEMA","type","source","attribute","selector","addAttribute","settings","_settings$attributes$","attributes","anchor","BlockEditAnchorControlPure","setAttributes","blockEditingMode","isWeb","OS","createElement","group","__nextHasNoMarginBottom","__next40pxDefaultSize","className","label","help","Fragment","href","value","placeholder","onChange","nextValue","replace","autoCapitalize","autoComplete","addSaveProps","edit","attributeKeys","hasSupport","name","extraProps","blockType","id"],"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\nconst ANCHOR_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'id',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( 'type' in ( settings.attributes?.anchor ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: ANCHOR_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockEditAnchorControlPure( { anchor, setAttributes } ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\tconst isWeb = Platform.OS === 'web';\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\tclassName=\"html-anchor-control\"\n\t\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\t\thelp={\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor”. Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{ ' ' }\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-jumps/'\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\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t\t\t</ExternalLink>\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\t\t\t\tvalue={ anchor || '' }\n\t\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tanchor: nextValue,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\tautoComplete=\"off\"\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\nexport default {\n\taddSaveProps,\n\tedit: BlockEditAnchorControlPure,\n\tattributeKeys: [ 'anchor' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'anchor' );\n\t},\n};\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,WAAW,EAAEC,YAAY,QAAQ,uBAAuB;AACjE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,SAASC,iBAAiB,QAAQ,eAAe;AACjD,SAASC,mBAAmB,QAAQ,kCAAkC;;AAEtE;AACA;AACA;AACA;AACA;AACA,MAAMC,YAAY,GAAG,QAAQ;AAE7B,MAAMC,aAAa,GAAG;EACrBC,IAAI,EAAE,QAAQ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