@wordpress/block-editor 12.1.0 → 12.2.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 (391) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/autocompleters/block.js +13 -5
  3. package/build/autocompleters/block.js.map +1 -1
  4. package/build/components/block-breadcrumb/index.js +6 -3
  5. package/build/components/block-breadcrumb/index.js.map +1 -1
  6. package/build/components/block-editing-mode/index.js +84 -0
  7. package/build/components/block-editing-mode/index.js.map +1 -0
  8. package/build/components/block-list/block-list-block-context.js +15 -0
  9. package/build/components/block-list/block-list-block-context.js.map +1 -0
  10. package/build/components/block-list/block.js +29 -37
  11. package/build/components/block-list/block.js.map +1 -1
  12. package/build/components/block-list/block.native.js +14 -22
  13. package/build/components/block-list/block.native.js.map +1 -1
  14. package/build/components/block-list/index.native.js +107 -108
  15. package/build/components/block-list/index.native.js.map +1 -1
  16. package/build/components/block-list/use-block-props/index.js +2 -2
  17. package/build/components/block-list/use-block-props/index.js.map +1 -1
  18. package/build/components/block-list/use-in-between-inserter.js +7 -5
  19. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  20. package/build/components/block-list-appender/index.js +15 -1
  21. package/build/components/block-list-appender/index.js.map +1 -1
  22. package/build/components/block-mobile-toolbar/block-actions-menu.native.js +19 -4
  23. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  24. package/build/components/block-styles/preview-panel.js +1 -2
  25. package/build/components/block-styles/preview-panel.js.map +1 -1
  26. package/build/components/block-switcher/block-transformations-menu.js +8 -0
  27. package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
  28. package/build/components/block-switcher/block-variation-transformations.js +125 -0
  29. package/build/components/block-switcher/block-variation-transformations.js.map +1 -0
  30. package/build/components/block-switcher/index.js +34 -12
  31. package/build/components/block-switcher/index.js.map +1 -1
  32. package/build/components/block-switcher/pattern-transformations-menu.js +3 -3
  33. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  34. package/build/components/block-toolbar/index.js +9 -7
  35. package/build/components/block-toolbar/index.js.map +1 -1
  36. package/build/components/block-tools/block-contextual-toolbar.js +5 -3
  37. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  38. package/build/components/block-tools/insertion-point.js +11 -5
  39. package/build/components/block-tools/insertion-point.js.map +1 -1
  40. package/build/components/convert-to-group-buttons/index.js +7 -2
  41. package/build/components/convert-to-group-buttons/index.js.map +1 -1
  42. package/build/components/convert-to-group-buttons/index.native.js +87 -3
  43. package/build/components/convert-to-group-buttons/index.native.js.map +1 -1
  44. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +23 -37
  45. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  46. package/build/components/global-styles/dimensions-panel.js +3 -2
  47. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  48. package/build/components/iframe/index.js +14 -7
  49. package/build/components/iframe/index.js.map +1 -1
  50. package/build/components/inner-blocks/index.js +2 -1
  51. package/build/components/inner-blocks/index.js.map +1 -1
  52. package/build/components/inner-blocks/index.native.js +7 -7
  53. package/build/components/inner-blocks/index.native.js.map +1 -1
  54. package/build/components/inner-blocks/use-nested-settings-update.js +13 -5
  55. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  56. package/build/components/inserter/index.js +3 -7
  57. package/build/components/inserter/index.js.map +1 -1
  58. package/build/components/inserter/quick-inserter.js +2 -4
  59. package/build/components/inserter/quick-inserter.js.map +1 -1
  60. package/build/components/inserter/search-results.js +19 -6
  61. package/build/components/inserter/search-results.js.map +1 -1
  62. package/build/components/list-view/appender.js +6 -1
  63. package/build/components/list-view/appender.js.map +1 -1
  64. package/build/components/list-view/block-contents.js +4 -2
  65. package/build/components/list-view/block-contents.js.map +1 -1
  66. package/build/components/list-view/block.js +21 -25
  67. package/build/components/list-view/block.js.map +1 -1
  68. package/build/components/list-view/branch.js +1 -3
  69. package/build/components/list-view/branch.js.map +1 -1
  70. package/build/components/list-view/index.js +14 -7
  71. package/build/components/list-view/index.js.map +1 -1
  72. package/build/components/list-view/use-list-view-client-ids.js +27 -3
  73. package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
  74. package/build/components/publish-date-time-picker/index.js +0 -2
  75. package/build/components/publish-date-time-picker/index.js.map +1 -1
  76. package/build/components/url-input/index.js +3 -0
  77. package/build/components/url-input/index.js.map +1 -1
  78. package/build/components/use-block-drop-zone/index.js +25 -15
  79. package/build/components/use-block-drop-zone/index.js.map +1 -1
  80. package/build/components/use-resize-canvas/index.js +8 -1
  81. package/build/components/use-resize-canvas/index.js.map +1 -1
  82. package/build/components/writing-flow/use-arrow-nav.js +13 -7
  83. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  84. package/build/hooks/align.js +3 -7
  85. package/build/hooks/align.js.map +1 -1
  86. package/build/hooks/behaviors.js +115 -0
  87. package/build/hooks/behaviors.js.map +1 -0
  88. package/build/hooks/dimensions.js +0 -30
  89. package/build/hooks/dimensions.js.map +1 -1
  90. package/build/hooks/duotone.js +4 -8
  91. package/build/hooks/duotone.js.map +1 -1
  92. package/build/hooks/index.js +2 -0
  93. package/build/hooks/index.js.map +1 -1
  94. package/build/hooks/layout.js +8 -9
  95. package/build/hooks/layout.js.map +1 -1
  96. package/build/private-apis.js +4 -7
  97. package/build/private-apis.js.map +1 -1
  98. package/build/store/private-actions.js +46 -0
  99. package/build/store/private-actions.js.map +1 -1
  100. package/build/store/private-selectors.js +88 -0
  101. package/build/store/private-selectors.js.map +1 -1
  102. package/build/store/reducer.js +36 -1
  103. package/build/store/reducer.js.map +1 -1
  104. package/build/store/selectors.js +28 -18
  105. package/build/store/selectors.js.map +1 -1
  106. package/build/utils/order-inserter-block-items.js +41 -0
  107. package/build/utils/order-inserter-block-items.js.map +1 -0
  108. package/build-module/autocompleters/block.js +12 -5
  109. package/build-module/autocompleters/block.js.map +1 -1
  110. package/build-module/components/block-breadcrumb/index.js +5 -3
  111. package/build-module/components/block-breadcrumb/index.js.map +1 -1
  112. package/build-module/components/block-editing-mode/index.js +72 -0
  113. package/build-module/components/block-editing-mode/index.js.map +1 -0
  114. package/build-module/components/block-list/block-list-block-context.js +6 -0
  115. package/build-module/components/block-list/block-list-block-context.js.map +1 -0
  116. package/build-module/components/block-list/block.js +26 -34
  117. package/build-module/components/block-list/block.js.map +1 -1
  118. package/build-module/components/block-list/block.native.js +14 -22
  119. package/build-module/components/block-list/block.native.js.map +1 -1
  120. package/build-module/components/block-list/index.native.js +108 -110
  121. package/build-module/components/block-list/index.native.js.map +1 -1
  122. package/build-module/components/block-list/use-block-props/index.js +1 -1
  123. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  124. package/build-module/components/block-list/use-in-between-inserter.js +6 -5
  125. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  126. package/build-module/components/block-list-appender/index.js +15 -1
  127. package/build-module/components/block-list-appender/index.js.map +1 -1
  128. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +18 -4
  129. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  130. package/build-module/components/block-styles/preview-panel.js +1 -2
  131. package/build-module/components/block-styles/preview-panel.js.map +1 -1
  132. package/build-module/components/block-switcher/block-transformations-menu.js +7 -0
  133. package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
  134. package/build-module/components/block-switcher/block-variation-transformations.js +108 -0
  135. package/build-module/components/block-switcher/block-variation-transformations.js.map +1 -0
  136. package/build-module/components/block-switcher/index.js +33 -12
  137. package/build-module/components/block-switcher/index.js.map +1 -1
  138. package/build-module/components/block-switcher/pattern-transformations-menu.js +3 -3
  139. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  140. package/build-module/components/block-toolbar/index.js +8 -7
  141. package/build-module/components/block-toolbar/index.js.map +1 -1
  142. package/build-module/components/block-tools/block-contextual-toolbar.js +4 -3
  143. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  144. package/build-module/components/block-tools/insertion-point.js +11 -5
  145. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  146. package/build-module/components/convert-to-group-buttons/index.js +7 -2
  147. package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
  148. package/build-module/components/convert-to-group-buttons/index.native.js +76 -1
  149. package/build-module/components/convert-to-group-buttons/index.native.js.map +1 -1
  150. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +22 -36
  151. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  152. package/build-module/components/global-styles/dimensions-panel.js +3 -2
  153. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  154. package/build-module/components/iframe/index.js +15 -8
  155. package/build-module/components/iframe/index.js.map +1 -1
  156. package/build-module/components/inner-blocks/index.js +2 -1
  157. package/build-module/components/inner-blocks/index.js.map +1 -1
  158. package/build-module/components/inner-blocks/index.native.js +7 -6
  159. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  160. package/build-module/components/inner-blocks/use-nested-settings-update.js +13 -5
  161. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  162. package/build-module/components/inserter/index.js +3 -7
  163. package/build-module/components/inserter/index.js.map +1 -1
  164. package/build-module/components/inserter/quick-inserter.js +2 -4
  165. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  166. package/build-module/components/inserter/search-results.js +16 -6
  167. package/build-module/components/inserter/search-results.js.map +1 -1
  168. package/build-module/components/list-view/appender.js +6 -2
  169. package/build-module/components/list-view/appender.js.map +1 -1
  170. package/build-module/components/list-view/block-contents.js +4 -2
  171. package/build-module/components/list-view/block-contents.js.map +1 -1
  172. package/build-module/components/list-view/block.js +20 -25
  173. package/build-module/components/list-view/block.js.map +1 -1
  174. package/build-module/components/list-view/branch.js +1 -3
  175. package/build-module/components/list-view/branch.js.map +1 -1
  176. package/build-module/components/list-view/index.js +15 -8
  177. package/build-module/components/list-view/index.js.map +1 -1
  178. package/build-module/components/list-view/use-list-view-client-ids.js +26 -3
  179. package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
  180. package/build-module/components/publish-date-time-picker/index.js +0 -2
  181. package/build-module/components/publish-date-time-picker/index.js.map +1 -1
  182. package/build-module/components/url-input/index.js +3 -0
  183. package/build-module/components/url-input/index.js.map +1 -1
  184. package/build-module/components/use-block-drop-zone/index.js +25 -16
  185. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  186. package/build-module/components/use-resize-canvas/index.js +8 -1
  187. package/build-module/components/use-resize-canvas/index.js.map +1 -1
  188. package/build-module/components/writing-flow/use-arrow-nav.js +13 -7
  189. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  190. package/build-module/hooks/align.js +3 -6
  191. package/build-module/hooks/align.js.map +1 -1
  192. package/build-module/hooks/behaviors.js +97 -0
  193. package/build-module/hooks/behaviors.js.map +1 -0
  194. package/build-module/hooks/dimensions.js +0 -28
  195. package/build-module/hooks/dimensions.js.map +1 -1
  196. package/build-module/hooks/duotone.js +3 -6
  197. package/build-module/hooks/duotone.js.map +1 -1
  198. package/build-module/hooks/index.js +1 -0
  199. package/build-module/hooks/index.js.map +1 -1
  200. package/build-module/hooks/layout.js +7 -9
  201. package/build-module/hooks/layout.js.map +1 -1
  202. package/build-module/private-apis.js +3 -5
  203. package/build-module/private-apis.js.map +1 -1
  204. package/build-module/store/private-actions.js +42 -0
  205. package/build-module/store/private-actions.js.map +1 -1
  206. package/build-module/store/private-selectors.js +79 -0
  207. package/build-module/store/private-selectors.js.map +1 -1
  208. package/build-module/store/reducer.js +34 -1
  209. package/build-module/store/reducer.js.map +1 -1
  210. package/build-module/store/selectors.js +26 -17
  211. package/build-module/store/selectors.js.map +1 -1
  212. package/build-module/utils/order-inserter-block-items.js +32 -0
  213. package/build-module/utils/order-inserter-block-items.js.map +1 -0
  214. package/build-style/content-rtl.css +32 -13
  215. package/build-style/content.css +32 -13
  216. package/build-style/default-editor-styles-rtl.css +1 -1
  217. package/build-style/default-editor-styles.css +1 -1
  218. package/build-style/style-rtl.css +19 -64
  219. package/build-style/style.css +20 -64
  220. package/package.json +32 -31
  221. package/src/autocompleters/block.js +15 -7
  222. package/src/components/block-breadcrumb/index.js +11 -3
  223. package/src/components/block-editing-mode/index.js +71 -0
  224. package/src/components/block-list/block-list-block-context.js +6 -0
  225. package/src/components/block-list/block.js +38 -56
  226. package/src/components/block-list/block.native.js +30 -41
  227. package/src/components/block-list/content.scss +5 -5
  228. package/src/components/block-list/index.native.js +164 -153
  229. package/src/components/block-list/test/index.native.js +2 -2
  230. package/src/components/block-list/use-block-props/index.js +1 -1
  231. package/src/components/block-list/use-in-between-inserter.js +7 -3
  232. package/src/components/block-list-appender/index.js +22 -4
  233. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +23 -0
  234. package/src/components/block-mover/style.scss +1 -0
  235. package/src/components/block-styles/preview-panel.js +1 -3
  236. package/src/components/block-switcher/block-transformations-menu.js +12 -0
  237. package/src/components/block-switcher/block-variation-transformations.js +115 -0
  238. package/src/components/block-switcher/index.js +38 -5
  239. package/src/components/block-switcher/pattern-transformations-menu.js +5 -5
  240. package/src/components/block-switcher/style.scss +6 -5
  241. package/src/components/block-toolbar/index.js +10 -11
  242. package/src/components/block-tools/block-contextual-toolbar.js +4 -5
  243. package/src/components/block-tools/insertion-point.js +23 -9
  244. package/src/components/button-block-appender/content.scss +22 -0
  245. package/src/components/convert-to-group-buttons/index.js +9 -2
  246. package/src/components/convert-to-group-buttons/index.native.js +79 -1
  247. package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +32 -38
  248. package/src/components/global-styles/dimensions-panel.js +3 -2
  249. package/src/components/global-styles/style.scss +3 -0
  250. package/src/components/iframe/index.js +22 -12
  251. package/src/components/inner-blocks/README.md +5 -0
  252. package/src/components/inner-blocks/index.js +2 -0
  253. package/src/components/inner-blocks/index.native.js +16 -6
  254. package/src/components/inner-blocks/use-nested-settings-update.js +20 -3
  255. package/src/components/inserter/index.js +1 -9
  256. package/src/components/inserter/quick-inserter.js +0 -2
  257. package/src/components/inserter/search-results.js +32 -6
  258. package/src/components/list-view/appender.js +3 -2
  259. package/src/components/list-view/block-contents.js +8 -2
  260. package/src/components/list-view/block.js +29 -35
  261. package/src/components/list-view/branch.js +1 -7
  262. package/src/components/list-view/index.js +17 -4
  263. package/src/components/list-view/style.scss +2 -5
  264. package/src/components/list-view/use-list-view-client-ids.js +21 -4
  265. package/src/components/publish-date-time-picker/index.js +0 -2
  266. package/src/components/url-input/README.md +6 -0
  267. package/src/components/url-input/index.js +1 -0
  268. package/src/components/use-block-drop-zone/index.js +31 -17
  269. package/src/components/use-resize-canvas/index.js +9 -1
  270. package/src/components/writing-flow/test/index.js +15 -0
  271. package/src/components/writing-flow/use-arrow-nav.js +17 -4
  272. package/src/hooks/align.js +3 -11
  273. package/src/hooks/behaviors.js +104 -0
  274. package/src/hooks/dimensions.js +0 -40
  275. package/src/hooks/duotone.js +3 -11
  276. package/src/hooks/index.js +1 -0
  277. package/src/hooks/layout.js +10 -18
  278. package/src/private-apis.js +2 -4
  279. package/src/store/private-actions.js +39 -0
  280. package/src/store/private-selectors.js +95 -0
  281. package/src/store/reducer.js +27 -0
  282. package/src/store/selectors.js +25 -15
  283. package/src/store/test/private-actions.js +32 -1
  284. package/src/store/test/private-selectors.js +158 -0
  285. package/src/store/test/reducer.js +48 -0
  286. package/src/style.scss +0 -3
  287. package/src/utils/order-inserter-block-items.js +26 -0
  288. package/build/components/block-list/block-list-compact.native.js +0 -75
  289. package/build/components/block-list/block-list-compact.native.js.map +0 -1
  290. package/build/components/off-canvas-editor/appender.js +0 -125
  291. package/build/components/off-canvas-editor/appender.js.map +0 -1
  292. package/build/components/off-canvas-editor/block-contents.js +0 -141
  293. package/build/components/off-canvas-editor/block-contents.js.map +0 -1
  294. package/build/components/off-canvas-editor/block-select-button.js +0 -126
  295. package/build/components/off-canvas-editor/block-select-button.js.map +0 -1
  296. package/build/components/off-canvas-editor/block.js +0 -297
  297. package/build/components/off-canvas-editor/block.js.map +0 -1
  298. package/build/components/off-canvas-editor/branch.js +0 -197
  299. package/build/components/off-canvas-editor/branch.js.map +0 -1
  300. package/build/components/off-canvas-editor/context.js +0 -19
  301. package/build/components/off-canvas-editor/context.js.map +0 -1
  302. package/build/components/off-canvas-editor/drop-indicator.js +0 -118
  303. package/build/components/off-canvas-editor/drop-indicator.js.map +0 -1
  304. package/build/components/off-canvas-editor/expander.js +0 -41
  305. package/build/components/off-canvas-editor/expander.js.map +0 -1
  306. package/build/components/off-canvas-editor/index.js +0 -236
  307. package/build/components/off-canvas-editor/index.js.map +0 -1
  308. package/build/components/off-canvas-editor/leaf-more-menu.js +0 -148
  309. package/build/components/off-canvas-editor/leaf-more-menu.js.map +0 -1
  310. package/build/components/off-canvas-editor/leaf.js +0 -60
  311. package/build/components/off-canvas-editor/leaf.js.map +0 -1
  312. package/build/components/off-canvas-editor/link-ui.js +0 -186
  313. package/build/components/off-canvas-editor/link-ui.js.map +0 -1
  314. package/build/components/off-canvas-editor/update-attributes.js +0 -108
  315. package/build/components/off-canvas-editor/update-attributes.js.map +0 -1
  316. package/build/components/off-canvas-editor/use-block-selection.js +0 -139
  317. package/build/components/off-canvas-editor/use-block-selection.js.map +0 -1
  318. package/build/components/off-canvas-editor/use-inserted-block.js +0 -58
  319. package/build/components/off-canvas-editor/use-inserted-block.js.map +0 -1
  320. package/build/components/off-canvas-editor/use-list-view-client-ids.js +0 -33
  321. package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +0 -1
  322. package/build/components/off-canvas-editor/use-list-view-drop-zone.js +0 -235
  323. package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +0 -1
  324. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -60
  325. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +0 -1
  326. package/build/components/off-canvas-editor/utils.js +0 -60
  327. package/build/components/off-canvas-editor/utils.js.map +0 -1
  328. package/build-module/components/block-list/block-list-compact.native.js +0 -60
  329. package/build-module/components/block-list/block-list-compact.native.js.map +0 -1
  330. package/build-module/components/off-canvas-editor/appender.js +0 -108
  331. package/build-module/components/off-canvas-editor/appender.js.map +0 -1
  332. package/build-module/components/off-canvas-editor/block-contents.js +0 -121
  333. package/build-module/components/off-canvas-editor/block-contents.js.map +0 -1
  334. package/build-module/components/off-canvas-editor/block-select-button.js +0 -107
  335. package/build-module/components/off-canvas-editor/block-select-button.js.map +0 -1
  336. package/build-module/components/off-canvas-editor/block.js +0 -273
  337. package/build-module/components/off-canvas-editor/block.js.map +0 -1
  338. package/build-module/components/off-canvas-editor/branch.js +0 -179
  339. package/build-module/components/off-canvas-editor/branch.js.map +0 -1
  340. package/build-module/components/off-canvas-editor/context.js +0 -7
  341. package/build-module/components/off-canvas-editor/context.js.map +0 -1
  342. package/build-module/components/off-canvas-editor/drop-indicator.js +0 -111
  343. package/build-module/components/off-canvas-editor/drop-indicator.js.map +0 -1
  344. package/build-module/components/off-canvas-editor/expander.js +0 -32
  345. package/build-module/components/off-canvas-editor/expander.js.map +0 -1
  346. package/build-module/components/off-canvas-editor/index.js +0 -213
  347. package/build-module/components/off-canvas-editor/index.js.map +0 -1
  348. package/build-module/components/off-canvas-editor/leaf-more-menu.js +0 -130
  349. package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +0 -1
  350. package/build-module/components/off-canvas-editor/leaf.js +0 -45
  351. package/build-module/components/off-canvas-editor/leaf.js.map +0 -1
  352. package/build-module/components/off-canvas-editor/link-ui.js +0 -166
  353. package/build-module/components/off-canvas-editor/link-ui.js.map +0 -1
  354. package/build-module/components/off-canvas-editor/update-attributes.js +0 -97
  355. package/build-module/components/off-canvas-editor/update-attributes.js.map +0 -1
  356. package/build-module/components/off-canvas-editor/use-block-selection.js +0 -124
  357. package/build-module/components/off-canvas-editor/use-block-selection.js.map +0 -1
  358. package/build-module/components/off-canvas-editor/use-inserted-block.js +0 -47
  359. package/build-module/components/off-canvas-editor/use-inserted-block.js.map +0 -1
  360. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +0 -24
  361. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +0 -1
  362. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +0 -220
  363. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +0 -1
  364. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -50
  365. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +0 -1
  366. package/build-module/components/off-canvas-editor/utils.js +0 -44
  367. package/build-module/components/off-canvas-editor/utils.js.map +0 -1
  368. package/src/components/block-list/block-list-compact.native.js +0 -63
  369. package/src/components/off-canvas-editor/README.md +0 -5
  370. package/src/components/off-canvas-editor/appender.js +0 -124
  371. package/src/components/off-canvas-editor/block-contents.js +0 -156
  372. package/src/components/off-canvas-editor/block-select-button.js +0 -128
  373. package/src/components/off-canvas-editor/block.js +0 -347
  374. package/src/components/off-canvas-editor/branch.js +0 -238
  375. package/src/components/off-canvas-editor/context.js +0 -8
  376. package/src/components/off-canvas-editor/drop-indicator.js +0 -126
  377. package/src/components/off-canvas-editor/expander.js +0 -26
  378. package/src/components/off-canvas-editor/index.js +0 -271
  379. package/src/components/off-canvas-editor/leaf-more-menu.js +0 -158
  380. package/src/components/off-canvas-editor/leaf.js +0 -52
  381. package/src/components/off-canvas-editor/link-ui.js +0 -167
  382. package/src/components/off-canvas-editor/style.scss +0 -34
  383. package/src/components/off-canvas-editor/test/use-inserted-block.js +0 -108
  384. package/src/components/off-canvas-editor/test/utils.js +0 -50
  385. package/src/components/off-canvas-editor/update-attributes.js +0 -99
  386. package/src/components/off-canvas-editor/use-block-selection.js +0 -169
  387. package/src/components/off-canvas-editor/use-inserted-block.js +0 -47
  388. package/src/components/off-canvas-editor/use-list-view-client-ids.js +0 -29
  389. package/src/components/off-canvas-editor/use-list-view-drop-zone.js +0 -260
  390. package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -58
  391. package/src/components/off-canvas-editor/utils.js +0 -58
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/index.js"],"names":["expanded","state","action","Array","isArray","clientIds","reduce","newState","id","type","BLOCK_LIST_ITEM_HEIGHT","OffCanvasEditor","ref","parentClientId","blocks","showBlockMovers","isExpanded","showAppender","LeafMoreMenu","description","onSelect","renderAdditionalBlockUI","getBlock","blockEditorStore","clientIdsTree","draggedClientIds","selectedClientIds","visibleBlockCount","shouldShowInnerBlocks","select","getGlobalBlockCount","getClientIdsOfDescendants","__unstableGetEditorMode","draggedBlockCount","length","updateBlockSelection","expandedState","setExpandedState","dropZoneRef","target","blockDropTarget","elementRef","treeGridRef","isMounted","setSelectedTreeId","firstSelectedBlockClientId","selectEditorBlock","event","blockClientId","current","fixedListWindow","useWindowing","windowOverscan","expand","collapse","expandRow","row","dataset","block","collapseRow","focusRow","startRow","endRow","shiftKey","contextValue","isTreeGridMounted"],"mappings":";;;;;;;;;AAaA;;AAVA;;AAIA;;AAKA;;AASA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAjCA;AACA;AACA;;AAqBA;AACA;AACA;AAUA,MAAMA,QAAQ,GAAG,CAAEC,KAAF,EAASC,MAAT,KAAqB;AACrC,MAAKC,KAAK,CAACC,OAAN,CAAeF,MAAM,CAACG,SAAtB,CAAL,EAAyC;AACxC,WAAO,EACN,GAAGJ,KADG;AAEN,SAAGC,MAAM,CAACG,SAAP,CAAiBC,MAAjB,CACF,CAAEC,QAAF,EAAYC,EAAZ,MAAsB,EACrB,GAAGD,QADkB;AAErB,SAAEC,EAAF,GAAQN,MAAM,CAACO,IAAP,KAAgB;AAFH,OAAtB,CADE,EAKF,EALE;AAFG,KAAP;AAUA;;AACD,SAAOR,KAAP;AACA,CAdD;;AAgBO,MAAMS,sBAAsB,GAAG,EAA/B;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACA,SAASC,eAAT,OAaCC,GAbD,EAcE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ACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACG,cACD,wEADC,CADH,CADD,CAPF,CAZD,CAXD,CADD,CALD,CADD;AAmDA;;eAEc,yBAAYvB,eAAZ,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMergeRefs,\n\t__experimentalUseFixedWindowList as useFixedWindowList,\n} from '@wordpress/compose';\nimport {\n\t__experimentalTreeGrid as TreeGrid,\n\t__experimentalTreeGridRow as TreeGridRow,\n\t__experimentalTreeGridCell as TreeGridCell,\n} from '@wordpress/components';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseReducer,\n\tforwardRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewBranch from './branch';\nimport { ListViewContext } from './context';\nimport ListViewDropIndicator from './drop-indicator';\nimport useBlockSelection from './use-block-selection';\nimport useListViewClientIds from './use-list-view-client-ids';\nimport useListViewDropZone from './use-list-view-drop-zone';\nimport useListViewExpandSelectedItem from './use-list-view-expand-selected-item';\nimport { store as blockEditorStore } from '../../store';\n\nconst expanded = ( state, action ) => {\n\tif ( Array.isArray( action.clientIds ) ) {\n\t\treturn {\n\t\t\t...state,\n\t\t\t...action.clientIds.reduce(\n\t\t\t\t( newState, id ) => ( {\n\t\t\t\t\t...newState,\n\t\t\t\t\t[ id ]: action.type === 'expand',\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t),\n\t\t};\n\t}\n\treturn state;\n};\n\nexport const BLOCK_LIST_ITEM_HEIGHT = 36;\n\n/**\n * Show a hierarchical list of blocks.\n *\n * @param {Object} props Components props.\n * @param {string} props.id An HTML element id for the root element of ListView.\n * @param {string} props.parentClientId The client id of the parent block.\n * @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.\n * @param {boolean} props.showBlockMovers Flag to enable block movers\n * @param {boolean} props.isExpanded Flag to determine whether nested levels are expanded by default.\n * @param {Object} props.LeafMoreMenu Optional more menu substitution.\n * @param {string} props.description Optional accessible description for the tree grid component.\n * @param {string} props.onSelect Optional callback to be invoked when a block is selected.\n * @param {string} props.showAppender Flag to show or hide the block appender.\n * @param {Function} props.renderAdditionalBlockUI Function that renders additional block content UI.\n * @param {Object} ref Forwarded ref.\n */\nfunction OffCanvasEditor(\n\t{\n\t\tid,\n\t\tparentClientId,\n\t\tblocks,\n\t\tshowBlockMovers = false,\n\t\tisExpanded = false,\n\t\tshowAppender = true,\n\t\tLeafMoreMenu,\n\t\tdescription = __( 'Block navigation structure' ),\n\t\tonSelect,\n\t\trenderAdditionalBlockUI,\n\t},\n\tref\n) {\n\tconst { getBlock } = useSelect( blockEditorStore );\n\tconst { clientIdsTree, draggedClientIds, selectedClientIds } =\n\t\tuseListViewClientIds( blocks );\n\n\tconst { visibleBlockCount, shouldShowInnerBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetGlobalBlockCount,\n\t\t\t\tgetClientIdsOfDescendants,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst draggedBlockCount =\n\t\t\t\tdraggedClientIds?.length > 0\n\t\t\t\t\t? getClientIdsOfDescendants( draggedClientIds ).length + 1\n\t\t\t\t\t: 0;\n\t\t\treturn {\n\t\t\t\tvisibleBlockCount: getGlobalBlockCount() - draggedBlockCount,\n\t\t\t\tshouldShowInnerBlocks: __unstableGetEditorMode() !== 'zoom-out',\n\t\t\t};\n\t\t},\n\t\t[ draggedClientIds, blocks ]\n\t);\n\n\tconst { updateBlockSelection } = useBlockSelection();\n\n\tconst [ expandedState, setExpandedState ] = useReducer( expanded, {} );\n\n\tconst { ref: dropZoneRef, target: blockDropTarget } = useListViewDropZone();\n\tconst elementRef = useRef();\n\tconst treeGridRef = useMergeRefs( [ elementRef, dropZoneRef, ref ] );\n\n\tconst isMounted = useRef( false );\n\tconst { setSelectedTreeId } = useListViewExpandSelectedItem( {\n\t\tfirstSelectedBlockClientId: selectedClientIds[ 0 ],\n\t\tsetExpandedState,\n\t} );\n\tconst selectEditorBlock = useCallback(\n\t\t( event, blockClientId ) => {\n\t\t\tupdateBlockSelection( event, blockClientId );\n\t\t\tsetSelectedTreeId( blockClientId );\n\t\t\tif ( onSelect ) {\n\t\t\t\tonSelect( getBlock( blockClientId ) );\n\t\t\t}\n\t\t},\n\t\t[ setSelectedTreeId, updateBlockSelection, onSelect, getBlock ]\n\t);\n\tuseEffect( () => {\n\t\tisMounted.current = true;\n\t}, [] );\n\n\t// List View renders a fixed number of items and relies on each having a fixed item height of 36px.\n\t// If this value changes, we should also change the itemHeight value set in useFixedWindowList.\n\t// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.\n\tconst [ fixedListWindow ] = useFixedWindowList(\n\t\telementRef,\n\t\tBLOCK_LIST_ITEM_HEIGHT,\n\t\tvisibleBlockCount,\n\t\t{\n\t\t\tuseWindowing: true,\n\t\t\twindowOverscan: 40,\n\t\t}\n\t);\n\n\tconst expand = useCallback(\n\t\t( blockClientId ) => {\n\t\t\tif ( ! blockClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( {\n\t\t\t\ttype: 'expand',\n\t\t\t\tclientIds: [ blockClientId ],\n\t\t\t} );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst collapse = useCallback(\n\t\t( blockClientId ) => {\n\t\t\tif ( ! blockClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( {\n\t\t\t\ttype: 'collapse',\n\t\t\t\tclientIds: [ blockClientId ],\n\t\t\t} );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst expandRow = useCallback(\n\t\t( row ) => {\n\t\t\texpand( row?.dataset?.block );\n\t\t},\n\t\t[ expand ]\n\t);\n\tconst collapseRow = useCallback(\n\t\t( row ) => {\n\t\t\tcollapse( row?.dataset?.block );\n\t\t},\n\t\t[ collapse ]\n\t);\n\tconst focusRow = useCallback(\n\t\t( event, startRow, endRow ) => {\n\t\t\tif ( event.shiftKey ) {\n\t\t\t\tupdateBlockSelection(\n\t\t\t\t\tevent,\n\t\t\t\t\tstartRow?.dataset?.block,\n\t\t\t\t\tendRow?.dataset?.block\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ updateBlockSelection ]\n\t);\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tisTreeGridMounted: isMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t\tLeafMoreMenu,\n\t\t\trenderAdditionalBlockUI,\n\t\t} ),\n\t\t[\n\t\t\tisMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t\tLeafMoreMenu,\n\t\t\trenderAdditionalBlockUI,\n\t\t]\n\t);\n\n\treturn (\n\t\t<AsyncModeProvider value={ true }>\n\t\t\t<ListViewDropIndicator\n\t\t\t\tlistViewRef={ elementRef }\n\t\t\t\tblockDropTarget={ blockDropTarget }\n\t\t\t/>\n\t\t\t<div className=\"offcanvas-editor-list-view-tree-wrapper\">\n\t\t\t\t<TreeGrid\n\t\t\t\t\tid={ id }\n\t\t\t\t\tclassName=\"block-editor-list-view-tree\"\n\t\t\t\t\taria-label={ __( 'Block navigation structure' ) }\n\t\t\t\t\tref={ treeGridRef }\n\t\t\t\t\tonCollapseRow={ collapseRow }\n\t\t\t\t\tonExpandRow={ expandRow }\n\t\t\t\t\tonFocusRow={ focusRow }\n\t\t\t\t\t// eslint-disable-next-line jsx-a11y/aria-props\n\t\t\t\t\taria-description={ description }\n\t\t\t\t>\n\t\t\t\t\t<ListViewContext.Provider value={ contextValue }>\n\t\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\t\tparentId={ parentClientId }\n\t\t\t\t\t\t\tblocks={ clientIdsTree }\n\t\t\t\t\t\t\tselectBlock={ selectEditorBlock }\n\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\tshouldShowInnerBlocks={ shouldShowInnerBlocks }\n\t\t\t\t\t\t\tshowAppender={ showAppender }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<TreeGridRow\n\t\t\t\t\t\t\tlevel={ 1 }\n\t\t\t\t\t\t\tsetSize={ 1 }\n\t\t\t\t\t\t\tpositionInSet={ 1 }\n\t\t\t\t\t\t\tisExpanded={ true }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ ! clientIdsTree.length && (\n\t\t\t\t\t\t\t\t<TreeGridCell withoutGridItem>\n\t\t\t\t\t\t\t\t\t<div className=\"offcanvas-editor-list-view-is-empty\">\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t'Your menu is currently empty. Add your first menu item to get started.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</TreeGridCell>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridRow>\n\t\t\t\t\t</ListViewContext.Provider>\n\t\t\t\t</TreeGrid>\n\t\t\t</div>\n\t\t</AsyncModeProvider>\n\t);\n}\n\nexport default forwardRef( OffCanvasEditor );\n"]}
@@ -1,148 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = LeafMoreMenu;
9
-
10
- var _element = require("@wordpress/element");
11
-
12
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
-
14
- var _blocks = require("@wordpress/blocks");
15
-
16
- var _icons = require("@wordpress/icons");
17
-
18
- var _components = require("@wordpress/components");
19
-
20
- var _data = require("@wordpress/data");
21
-
22
- var _i18n = require("@wordpress/i18n");
23
-
24
- var _store = require("../../store");
25
-
26
- var _blockTitle = _interopRequireDefault(require("../block-title"));
27
-
28
- var _context = require("./context");
29
-
30
- /**
31
- * WordPress dependencies
32
- */
33
-
34
- /**
35
- * Internal dependencies
36
- */
37
- const POPOVER_PROPS = {
38
- className: 'block-editor-block-settings-menu__popover',
39
- position: 'bottom right',
40
- variant: 'toolbar'
41
- };
42
- const BLOCKS_THAT_CAN_BE_CONVERTED_TO_SUBMENU = ['core/navigation-link', 'core/navigation-submenu'];
43
-
44
- function AddSubmenuItem(_ref) {
45
- let {
46
- block,
47
- onClose
48
- } = _ref;
49
- const {
50
- expandedState,
51
- expand
52
- } = (0, _context.useListViewContext)();
53
- const {
54
- insertBlock,
55
- replaceBlock,
56
- replaceInnerBlocks
57
- } = (0, _data.useDispatch)(_store.store);
58
- const clientId = block.clientId;
59
- const isDisabled = !BLOCKS_THAT_CAN_BE_CONVERTED_TO_SUBMENU.includes(block.name);
60
- return (0, _element.createElement)(_components.MenuItem, {
61
- icon: _icons.addSubmenu,
62
- disabled: isDisabled,
63
- onClick: () => {
64
- const updateSelectionOnInsert = false;
65
- const newLink = (0, _blocks.createBlock)('core/navigation-link');
66
-
67
- if (block.name === 'core/navigation-submenu') {
68
- insertBlock(newLink, block.innerBlocks.length, clientId, updateSelectionOnInsert);
69
- } else {
70
- // Convert to a submenu if the block currently isn't one.
71
- const newSubmenu = (0, _blocks.createBlock)('core/navigation-submenu', block.attributes, block.innerBlocks); // The following must happen as two independent actions.
72
- // Why? Because the offcanvas editor relies on the getLastInsertedBlocksClientIds
73
- // selector to determine which block is "active". As the UX needs the newLink to be
74
- // the "active" block it must be the last block to be inserted.
75
- // Therefore the Submenu is first created and **then** the newLink is inserted
76
- // thus ensuring it is the last inserted block.
77
-
78
- replaceBlock(clientId, newSubmenu);
79
- replaceInnerBlocks(newSubmenu.clientId, [newLink], updateSelectionOnInsert);
80
- }
81
-
82
- if (!expandedState[block.clientId]) {
83
- expand(block.clientId);
84
- }
85
-
86
- onClose();
87
- }
88
- }, (0, _i18n.__)('Add submenu link'));
89
- }
90
-
91
- function LeafMoreMenu(props) {
92
- const {
93
- block
94
- } = props;
95
- const {
96
- clientId
97
- } = block;
98
- const {
99
- moveBlocksDown,
100
- moveBlocksUp,
101
- removeBlocks
102
- } = (0, _data.useDispatch)(_store.store);
103
- const removeLabel = (0, _i18n.sprintf)(
104
- /* translators: %s: block name */
105
- (0, _i18n.__)('Remove %s'), (0, _blockTitle.default)({
106
- clientId,
107
- maximumLength: 25
108
- }));
109
- const rootClientId = (0, _data.useSelect)(select => {
110
- const {
111
- getBlockRootClientId
112
- } = select(_store.store);
113
- return getBlockRootClientId(clientId);
114
- }, [clientId]);
115
- return (0, _element.createElement)(_components.DropdownMenu, (0, _extends2.default)({
116
- icon: _icons.moreVertical,
117
- label: (0, _i18n.__)('Options'),
118
- className: "block-editor-block-settings-menu",
119
- popoverProps: POPOVER_PROPS,
120
- noIcons: true
121
- }, props), _ref2 => {
122
- let {
123
- onClose
124
- } = _ref2;
125
- return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.MenuGroup, null, (0, _element.createElement)(_components.MenuItem, {
126
- icon: _icons.chevronUp,
127
- onClick: () => {
128
- moveBlocksUp([clientId], rootClientId);
129
- onClose();
130
- }
131
- }, (0, _i18n.__)('Move up')), (0, _element.createElement)(_components.MenuItem, {
132
- icon: _icons.chevronDown,
133
- onClick: () => {
134
- moveBlocksDown([clientId], rootClientId);
135
- onClose();
136
- }
137
- }, (0, _i18n.__)('Move down')), (0, _element.createElement)(AddSubmenuItem, {
138
- block: block,
139
- onClose: onClose
140
- })), (0, _element.createElement)(_components.MenuGroup, null, (0, _element.createElement)(_components.MenuItem, {
141
- onClick: () => {
142
- removeBlocks([clientId], false);
143
- onClose();
144
- }
145
- }, removeLabel)));
146
- });
147
- }
148
- //# sourceMappingURL=leaf-more-menu.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/leaf-more-menu.js"],"names":["POPOVER_PROPS","className","position","variant","BLOCKS_THAT_CAN_BE_CONVERTED_TO_SUBMENU","AddSubmenuItem","block","onClose","expandedState","expand","insertBlock","replaceBlock","replaceInnerBlocks","blockEditorStore","clientId","isDisabled","includes","name","addSubmenu","updateSelectionOnInsert","newLink","innerBlocks","length","newSubmenu","attributes","LeafMoreMenu","props","moveBlocksDown","moveBlocksUp","removeBlocks","removeLabel","maximumLength","rootClientId","select","getBlockRootClientId","moreVertical","chevronUp","chevronDown"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AAMA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAnBA;AACA;AACA;;AAYA;AACA;AACA;AAKA,MAAMA,aAAa,GAAG;AACrBC,EAAAA,SAAS,EAAE,2CADU;AAErBC,EAAAA,QAAQ,EAAE,cAFW;AAGrBC,EAAAA,OAAO,EAAE;AAHY,CAAtB;AAMA,MAAMC,uCAAuC,GAAG,CAC/C,sBAD+C,EAE/C,yBAF+C,CAAhD;;AAKA,SAASC,cAAT,OAA8C;AAAA,MAArB;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAAqB;AAC7C,QAAM;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA;AAAjB,MAA4B,kCAAlC;AACA,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,YAAf;AAA6BC,IAAAA;AAA7B,MACL,uBAAaC,YAAb,CADD;AAGA,QAAMC,QAAQ,GAAGR,KAAK,CAACQ,QAAvB;AACA,QAAMC,UAAU,GAAG,CAAEX,uCAAuC,CAACY,QAAxC,CACpBV,KAAK,CAACW,IADc,CAArB;AAGA,SACC,4BAAC,oBAAD;AACC,IAAA,IAAI,EAAGC,iBADR;AAEC,IAAA,QAAQ,EAAGH,UAFZ;AAGC,IAAA,OAAO,EAAG,MAAM;AACf,YAAMI,uBAAuB,GAAG,KAAhC;A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WAAOqB,oBAAoB,CAAEpB,QAAF,CAA3B;AACA,GALmB,EAMpB,CAAEA,QAAF,CANoB,CAArB;AASA,SACC,4BAAC,wBAAD;AACC,IAAA,IAAI,EAAGqB,mBADR;AAEC,IAAA,KAAK,EAAG,cAAI,SAAJ,CAFT;AAGC,IAAA,SAAS,EAAC,kCAHX;AAIC,IAAA,YAAY,EAAGnC,aAJhB;AAKC,IAAA,OAAO;AALR,KAMM0B,KANN,GAQG;AAAA,QAAE;AAAEnB,MAAAA;AAAF,KAAF;AAAA,WACD,qDACC,4BAAC,qBAAD,QACC,4BAAC,oBAAD;AACC,MAAA,IAAI,EAAG6B,gBADR;AAEC,MAAA,OAAO,EAAG,MAAM;AACfR,QAAAA,YAAY,CAAE,CAAEd,QAAF,CAAF,EAAgBkB,YAAhB,CAAZ;AACAzB,QAAAA,OAAO;AACP;AALF,OAOG,cAAI,SAAJ,CAPH,CADD,EAUC,4BAAC,oBAAD;AACC,MAAA,IAAI,EAAG8B,kBADR;AAEC,MAAA,OAAO,EAAG,MAAM;AACfV,QAAAA,cAAc,CAAE,CAAEb,QAAF,CAAF,EAAgBkB,YAAhB,CAAd;AACAzB,QAAAA,OAAO;AACP;AALF,OAOG,cAAI,WAAJ,CAPH,CAVD,EAmBC,4BAAC,cAAD;AAAgB,MAAA,KAAK,EAAGD,KAAxB;AAAgC,MAAA,OAAO,EAAGC;AAA1C,MAnBD,CADD,EAsBC,4BAAC,qBAAD,QACC,4BAAC,oBAAD;AACC,MAAA,OAAO,EAAG,MAAM;AACfsB,QAAAA,YAAY,CAAE,CAAEf,QAAF,CAAF,EAAgB,KAAhB,CAAZ;AACAP,QAAAA,OAAO;AACP;AAJF,OAMGuB,WANH,CADD,CAtBD,CADC;AAAA,GARH,CADD;AA8CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport {\n\taddSubmenu,\n\tchevronUp,\n\tchevronDown,\n\tmoreVertical,\n} from '@wordpress/icons';\nimport { DropdownMenu, MenuItem, MenuGroup } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport BlockTitle from '../block-title';\nimport { useListViewContext } from './context';\n\nconst POPOVER_PROPS = {\n\tclassName: 'block-editor-block-settings-menu__popover',\n\tposition: 'bottom right',\n\tvariant: 'toolbar',\n};\n\nconst BLOCKS_THAT_CAN_BE_CONVERTED_TO_SUBMENU = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n];\n\nfunction AddSubmenuItem( { block, onClose } ) {\n\tconst { expandedState, expand } = useListViewContext();\n\tconst { insertBlock, replaceBlock, replaceInnerBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst clientId = block.clientId;\n\tconst isDisabled = ! BLOCKS_THAT_CAN_BE_CONVERTED_TO_SUBMENU.includes(\n\t\tblock.name\n\t);\n\treturn (\n\t\t<MenuItem\n\t\t\ticon={ addSubmenu }\n\t\t\tdisabled={ isDisabled }\n\t\t\tonClick={ () => {\n\t\t\t\tconst updateSelectionOnInsert = false;\n\t\t\t\tconst newLink = createBlock( 'core/navigation-link' );\n\n\t\t\t\tif ( block.name === 'core/navigation-submenu' ) {\n\t\t\t\t\tinsertBlock(\n\t\t\t\t\t\tnewLink,\n\t\t\t\t\t\tblock.innerBlocks.length,\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\tupdateSelectionOnInsert\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t// Convert to a submenu if the block currently isn't one.\n\t\t\t\t\tconst newSubmenu = createBlock(\n\t\t\t\t\t\t'core/navigation-submenu',\n\t\t\t\t\t\tblock.attributes,\n\t\t\t\t\t\tblock.innerBlocks\n\t\t\t\t\t);\n\n\t\t\t\t\t// The following must happen as two independent actions.\n\t\t\t\t\t// Why? Because the offcanvas editor relies on the getLastInsertedBlocksClientIds\n\t\t\t\t\t// selector to determine which block is \"active\". As the UX needs the newLink to be\n\t\t\t\t\t// the \"active\" block it must be the last block to be inserted.\n\t\t\t\t\t// Therefore the Submenu is first created and **then** the newLink is inserted\n\t\t\t\t\t// thus ensuring it is the last inserted block.\n\t\t\t\t\treplaceBlock( clientId, newSubmenu );\n\n\t\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\t\tnewSubmenu.clientId,\n\t\t\t\t\t\t[ newLink ],\n\t\t\t\t\t\tupdateSelectionOnInsert\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif ( ! expandedState[ block.clientId ] ) {\n\t\t\t\t\texpand( block.clientId );\n\t\t\t\t}\n\t\t\t\tonClose();\n\t\t\t} }\n\t\t>\n\t\t\t{ __( 'Add submenu link' ) }\n\t\t</MenuItem>\n\t);\n}\n\nexport default function LeafMoreMenu( props ) {\n\tconst { block } = props;\n\tconst { clientId } = block;\n\n\tconst { moveBlocksDown, moveBlocksUp, removeBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst removeLabel = sprintf(\n\t\t/* translators: %s: block name */\n\t\t__( 'Remove %s' ),\n\t\tBlockTitle( { clientId, maximumLength: 25 } )\n\t);\n\n\tconst rootClientId = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId } = select( blockEditorStore );\n\n\t\t\treturn getBlockRootClientId( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ moreVertical }\n\t\t\tlabel={ __( 'Options' ) }\n\t\t\tclassName=\"block-editor-block-settings-menu\"\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tnoIcons\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\ticon={ chevronUp }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tmoveBlocksUp( [ clientId ], rootClientId );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Move up' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\ticon={ chevronDown }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tmoveBlocksDown( [ clientId ], rootClientId );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Move down' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<AddSubmenuItem block={ block } onClose={ onClose } />\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tremoveBlocks( [ clientId ], false );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ removeLabel }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"]}
@@ -1,60 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = ListViewLeaf;
9
-
10
- var _element = require("@wordpress/element");
11
-
12
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
-
14
- var _web = require("@react-spring/web");
15
-
16
- var _classnames = _interopRequireDefault(require("classnames"));
17
-
18
- var _components = require("@wordpress/components");
19
-
20
- var _useMovingAnimation = _interopRequireDefault(require("../use-moving-animation"));
21
-
22
- /**
23
- * External dependencies
24
- */
25
-
26
- /**
27
- * WordPress dependencies
28
- */
29
-
30
- /**
31
- * Internal dependencies
32
- */
33
- const AnimatedTreeGridRow = (0, _web.animated)(_components.__experimentalTreeGridRow);
34
-
35
- function ListViewLeaf(_ref) {
36
- let {
37
- isSelected,
38
- position,
39
- level,
40
- rowCount,
41
- children,
42
- className,
43
- path,
44
- ...props
45
- } = _ref;
46
- const ref = (0, _useMovingAnimation.default)({
47
- isSelected,
48
- adjustScrolling: false,
49
- enableAnimation: true,
50
- triggerAnimationOnChange: path
51
- });
52
- return (0, _element.createElement)(AnimatedTreeGridRow, (0, _extends2.default)({
53
- ref: ref,
54
- className: (0, _classnames.default)('block-editor-list-view-leaf', 'offcanvas-editor-list-view-leaf', className),
55
- level: level,
56
- positionInSet: position,
57
- setSize: rowCount
58
- }, props), children);
59
- }
60
- //# sourceMappingURL=leaf.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/leaf.js"],"names":["AnimatedTreeGridRow","TreeGridRow","ListViewLeaf","isSelected","position","level","rowCount","children","className","path","props","ref","adjustScrolling","enableAnimation","triggerAnimationOnChange"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AAKA;;AAdA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AAGA,MAAMA,mBAAmB,GAAG,mBAAUC,qCAAV,CAA5B;;AAEe,SAASC,YAAT,OASX;AAAA,MATkC;AACrCC,IAAAA,UADqC;AAErCC,IAAAA,QAFqC;AAGrCC,IAAAA,KAHqC;AAIrCC,IAAAA,QAJqC;AAKrCC,IAAAA,QALqC;AAMrCC,IAAAA,SANqC;AAOrCC,IAAAA,IAPqC;AAQrC,OAAGC;AARkC,GASlC;AACH,QAAMC,GAAG,GAAG,iCAAoB;AAC/BR,IAAAA,UAD+B;AAE/BS,IAAAA,eAAe,EAAE,KAFc;AAG/BC,IAAAA,eAAe,EAAE,IAHc;AAI/BC,IAAAA,wBAAwB,EAAEL;AAJK,GAApB,CAAZ;AAOA,SACC,4BAAC,mBAAD;AACC,IAAA,GAAG,EAAGE,GADP;AAEC,IAAA,SAAS,EAAG,yBACX,6BADW,EAEX,iCAFW,EAGXH,SAHW,CAFb;AAOC,IAAA,KAAK,EAAGH,KAPT;AAQC,IAAA,aAAa,EAAGD,QARjB;AASC,IAAA,OAAO,EAAGE;AATX,KAUMI,KAVN,GAYGH,QAZH,CADD;AAgBA","sourcesContent":["/**\n * External dependencies\n */\nimport { animated } from '@react-spring/web';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __experimentalTreeGridRow as TreeGridRow } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport useMovingAnimation from '../use-moving-animation';\n\nconst AnimatedTreeGridRow = animated( TreeGridRow );\n\nexport default function ListViewLeaf( {\n\tisSelected,\n\tposition,\n\tlevel,\n\trowCount,\n\tchildren,\n\tclassName,\n\tpath,\n\t...props\n} ) {\n\tconst ref = useMovingAnimation( {\n\t\tisSelected,\n\t\tadjustScrolling: false,\n\t\tenableAnimation: true,\n\t\ttriggerAnimationOnChange: path,\n\t} );\n\n\treturn (\n\t\t<AnimatedTreeGridRow\n\t\t\tref={ ref }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-list-view-leaf',\n\t\t\t\t'offcanvas-editor-list-view-leaf',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\tlevel={ level }\n\t\t\tpositionInSet={ position }\n\t\t\tsetSize={ rowCount }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ children }\n\t\t</AnimatedTreeGridRow>\n\t);\n}\n"]}
@@ -1,186 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.LinkUI = LinkUI;
9
- exports.getSuggestionsQuery = getSuggestionsQuery;
10
-
11
- var _element = require("@wordpress/element");
12
-
13
- var _dom = require("@wordpress/dom");
14
-
15
- var _components = require("@wordpress/components");
16
-
17
- var _i18n = require("@wordpress/i18n");
18
-
19
- var _blocks = require("@wordpress/blocks");
20
-
21
- var _data = require("@wordpress/data");
22
-
23
- var _store = require("../../store");
24
-
25
- var _linkControl = _interopRequireDefault(require("../link-control"));
26
-
27
- var _blockIcon = _interopRequireDefault(require("../block-icon"));
28
-
29
- // Note: this file is copied directly from packages/block-library/src/navigation-link/link-ui.js
30
-
31
- /**
32
- * WordPress dependencies
33
- */
34
-
35
- /**
36
- * Internal dependencies
37
- */
38
-
39
- /**
40
- * Given the Link block's type attribute, return the query params to give to
41
- * /wp/v2/search.
42
- *
43
- * @param {string} type Link block's type attribute.
44
- * @param {string} kind Link block's entity of kind (post-type|taxonomy)
45
- * @return {{ type?: string, subtype?: string }} Search query params.
46
- */
47
- function getSuggestionsQuery(type, kind) {
48
- switch (type) {
49
- case 'post':
50
- case 'page':
51
- return {
52
- type: 'post',
53
- subtype: type
54
- };
55
-
56
- case 'category':
57
- return {
58
- type: 'term',
59
- subtype: 'category'
60
- };
61
-
62
- case 'tag':
63
- return {
64
- type: 'term',
65
- subtype: 'post_tag'
66
- };
67
-
68
- case 'post_format':
69
- return {
70
- type: 'post-format'
71
- };
72
-
73
- default:
74
- if (kind === 'taxonomy') {
75
- return {
76
- type: 'term',
77
- subtype: type
78
- };
79
- }
80
-
81
- if (kind === 'post-type') {
82
- return {
83
- type: 'post',
84
- subtype: type
85
- };
86
- }
87
-
88
- return {};
89
- }
90
- }
91
- /**
92
- * Add transforms to Link Control
93
- *
94
- * @param {Object} props Component props.
95
- * @param {string} props.clientId Block client ID.
96
- */
97
-
98
-
99
- function LinkControlTransforms(_ref) {
100
- let {
101
- clientId
102
- } = _ref;
103
- const {
104
- getBlock,
105
- blockTransforms
106
- } = (0, _data.useSelect)(select => {
107
- const {
108
- getBlock: _getBlock,
109
- getBlockRootClientId,
110
- getBlockTransformItems
111
- } = select(_store.store);
112
- return {
113
- getBlock: _getBlock,
114
- blockTransforms: getBlockTransformItems(_getBlock(clientId), getBlockRootClientId(clientId))
115
- };
116
- }, [clientId]);
117
- const {
118
- replaceBlock
119
- } = (0, _data.useDispatch)(_store.store);
120
- const featuredBlocks = ['core/page-list', 'core/site-logo', 'core/social-links', 'core/search'];
121
- const transforms = blockTransforms.filter(item => {
122
- return featuredBlocks.includes(item.name);
123
- });
124
-
125
- if (!(transforms !== null && transforms !== void 0 && transforms.length)) {
126
- return null;
127
- }
128
-
129
- if (!clientId) {
130
- return null;
131
- }
132
-
133
- return (0, _element.createElement)("div", {
134
- className: "link-control-transform"
135
- }, (0, _element.createElement)("h3", {
136
- className: "link-control-transform__subheading"
137
- }, (0, _i18n.__)('Transform')), (0, _element.createElement)("div", {
138
- className: "link-control-transform__items"
139
- }, transforms.map(item => {
140
- return (0, _element.createElement)(_components.Button, {
141
- key: `transform-${item.name}`,
142
- onClick: () => replaceBlock(clientId, (0, _blocks.switchToBlockType)(getBlock(clientId), item.name)),
143
- className: "link-control-transform__item"
144
- }, (0, _element.createElement)(_blockIcon.default, {
145
- icon: item.icon
146
- }), item.title);
147
- })));
148
- }
149
-
150
- function LinkUI(props) {
151
- const {
152
- label,
153
- url,
154
- opensInNewTab,
155
- type,
156
- kind
157
- } = props.link;
158
- const link = {
159
- url,
160
- opensInNewTab,
161
- title: label && (0, _dom.__unstableStripHTML)(label)
162
- };
163
- return (0, _element.createElement)(_components.Popover, {
164
- placement: "bottom",
165
- onClose: props.onClose,
166
- anchor: props.anchor,
167
- shift: true
168
- }, (0, _element.createElement)(_linkControl.default, {
169
- hasTextControl: true,
170
- hasRichPreviews: true,
171
- className: props.className,
172
- value: link,
173
- showInitialSuggestions: true,
174
- withCreateSuggestion: props.hasCreateSuggestion,
175
- noDirectEntry: !!type,
176
- noURLSuggestion: !!type,
177
- suggestionsQuery: getSuggestionsQuery(type, kind),
178
- onChange: props.onChange,
179
- onRemove: props.onRemove,
180
- onCancel: props.onCancel,
181
- renderControlBottom: !url ? () => (0, _element.createElement)(LinkControlTransforms, {
182
- clientId: props.clientId
183
- }) : null
184
- }));
185
- }
186
- //# sourceMappingURL=link-ui.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/link-ui.js"],"names":["getSuggestionsQuery","type","kind","subtype","LinkControlTransforms","clientId","getBlock","blockTransforms","select","_getBlock","getBlockRootClientId","getBlockTransformItems","blockEditorStore","replaceBlock","featuredBlocks","transforms","filter","item","includes","name","length","map","icon","title","LinkUI","props","label","url","opensInNewTab","link","onClose","anchor","className","hasCreateSuggestion","onChange","onRemove","onCancel"],"mappings":";;;;;;;;;;;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAhBA;;AAEA;AACA;AACA;;AAOA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,mBAAT,CAA8BC,IAA9B,EAAoCC,IAApC,EAA2C;AACjD,UAASD,IAAT;AACC,SAAK,MAAL;AACA,SAAK,MAAL;AACC,aAAO;AAAEA,QAAAA,IAAI,EAAE,MAAR;AAAgBE,QAAAA,OAAO,EAAEF;AAAzB,OAAP;;AACD,SAAK,UAAL;AACC,aAAO;AAAEA,QAAAA,IAAI,EAAE,MAAR;AAAgBE,QAAAA,OAAO,EAAE;AAAzB,OAAP;;AACD,SAAK,KAAL;AACC,aAAO;AAAEF,QAAAA,IAAI,EAAE,MAAR;AAAgBE,QAAAA,OAAO,EAAE;AAAzB,OAAP;;AACD,SAAK,aAAL;AACC,aAAO;AAAEF,QAAAA,IAAI,EAAE;AAAR,OAAP;;AACD;AACC,UAAKC,IAAI,KAAK,UAAd,EAA2B;AAC1B,eAAO;AAAED,UAAAA,IAAI,EAAE,MAAR;AAAgBE,UAAAA,OAAO,EAAEF;AAAzB,SAAP;AACA;;AACD,UAAKC,IAAI,KAAK,WAAd,EAA4B;AAC3B,eAAO;AAAED,UAAAA,IAAI,EAAE,MAAR;AAAgBE,UAAAA,OAAO,EAAEF;AAAzB,SAAP;AACA;;AACD,aAAO,EAA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AAWC,IAAA,QAAQ,EAAGT,KAAK,CAACU,QAXlB;AAYC,IAAA,QAAQ,EAAGV,KAAK,CAACW,QAZlB;AAaC,IAAA,mBAAmB,EAClB,CAAET,GAAF,GACG,MACA,4BAAC,qBAAD;AACC,MAAA,QAAQ,EAAGF,KAAK,CAACpB;AADlB,MAFH,GAMG;AApBL,IAND,CADD;AAgCA","sourcesContent":["// Note: this file is copied directly from packages/block-library/src/navigation-link/link-ui.js\n\n/**\n * WordPress dependencies\n */\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { Popover, Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { switchToBlockType } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport LinkControl from '../link-control';\nimport BlockIcon from '../block-icon';\n\n/**\n * Given the Link block's type attribute, return the query params to give to\n * /wp/v2/search.\n *\n * @param {string} type Link block's type attribute.\n * @param {string} kind Link block's entity of kind (post-type|taxonomy)\n * @return {{ type?: string, subtype?: string }} Search query params.\n */\nexport function getSuggestionsQuery( type, kind ) {\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\tcase 'page':\n\t\t\treturn { type: 'post', subtype: type };\n\t\tcase 'category':\n\t\t\treturn { type: 'term', subtype: 'category' };\n\t\tcase 'tag':\n\t\t\treturn { type: 'term', subtype: 'post_tag' };\n\t\tcase 'post_format':\n\t\t\treturn { type: 'post-format' };\n\t\tdefault:\n\t\t\tif ( kind === 'taxonomy' ) {\n\t\t\t\treturn { type: 'term', subtype: type };\n\t\t\t}\n\t\t\tif ( kind === 'post-type' ) {\n\t\t\t\treturn { type: 'post', subtype: type };\n\t\t\t}\n\t\t\treturn {};\n\t}\n}\n\n/**\n * Add transforms to Link Control\n *\n * @param {Object} props Component props.\n * @param {string} props.clientId Block client ID.\n */\nfunction LinkControlTransforms( { clientId } ) {\n\tconst { getBlock, blockTransforms } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlock: _getBlock,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockTransformItems,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tgetBlock: _getBlock,\n\t\t\t\tblockTransforms: getBlockTransformItems(\n\t\t\t\t\t_getBlock( clientId ),\n\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\n\tconst featuredBlocks = [\n\t\t'core/page-list',\n\t\t'core/site-logo',\n\t\t'core/social-links',\n\t\t'core/search',\n\t];\n\n\tconst transforms = blockTransforms.filter( ( item ) => {\n\t\treturn featuredBlocks.includes( item.name );\n\t} );\n\n\tif ( ! transforms?.length ) {\n\t\treturn null;\n\t}\n\n\tif ( ! clientId ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"link-control-transform\">\n\t\t\t<h3 className=\"link-control-transform__subheading\">\n\t\t\t\t{ __( 'Transform' ) }\n\t\t\t</h3>\n\t\t\t<div className=\"link-control-transform__items\">\n\t\t\t\t{ transforms.map( ( item ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ `transform-${ item.name }` }\n\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\treplaceBlock(\n\t\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\t\tswitchToBlockType(\n\t\t\t\t\t\t\t\t\t\tgetBlock( clientId ),\n\t\t\t\t\t\t\t\t\t\titem.name\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tclassName=\"link-control-transform__item\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockIcon icon={ item.icon } />\n\t\t\t\t\t\t\t{ item.title }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport function LinkUI( props ) {\n\tconst { label, url, opensInNewTab, type, kind } = props.link;\n\tconst link = {\n\t\turl,\n\t\topensInNewTab,\n\t\ttitle: label && stripHTML( label ),\n\t};\n\n\treturn (\n\t\t<Popover\n\t\t\tplacement=\"bottom\"\n\t\t\tonClose={ props.onClose }\n\t\t\tanchor={ props.anchor }\n\t\t\tshift\n\t\t>\n\t\t\t<LinkControl\n\t\t\t\thasTextControl\n\t\t\t\thasRichPreviews\n\t\t\t\tclassName={ props.className }\n\t\t\t\tvalue={ link }\n\t\t\t\tshowInitialSuggestions={ true }\n\t\t\t\twithCreateSuggestion={ props.hasCreateSuggestion }\n\t\t\t\tnoDirectEntry={ !! type }\n\t\t\t\tnoURLSuggestion={ !! type }\n\t\t\t\tsuggestionsQuery={ getSuggestionsQuery( type, kind ) }\n\t\t\t\tonChange={ props.onChange }\n\t\t\t\tonRemove={ props.onRemove }\n\t\t\t\tonCancel={ props.onCancel }\n\t\t\t\trenderControlBottom={\n\t\t\t\t\t! url\n\t\t\t\t\t\t? () => (\n\t\t\t\t\t\t\t\t<LinkControlTransforms\n\t\t\t\t\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: null\n\t\t\t\t}\n\t\t\t/>\n\t\t</Popover>\n\t);\n}\n"]}
@@ -1,108 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.updateAttributes = void 0;
7
-
8
- var _escapeHtml = require("@wordpress/escape-html");
9
-
10
- var _url = require("@wordpress/url");
11
-
12
- /**
13
- * WordPress dependencies
14
- */
15
-
16
- /**
17
- * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind
18
- */
19
-
20
- /**
21
- * Navigation Link Block Attributes
22
- *
23
- * @typedef {Object} WPNavigationLinkBlockAttributes
24
- *
25
- * @property {string} [label] Link text.
26
- * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.
27
- * @property {string} [type] The type such as post, page, tag, category and other custom types.
28
- * @property {string} [rel] The relationship of the linked URL.
29
- * @property {number} [id] A post or term id.
30
- * @property {boolean} [opensInNewTab] Sets link target to _blank when true.
31
- * @property {string} [url] Link href.
32
- * @property {string} [title] Link title attribute.
33
- */
34
-
35
- /**
36
- * Link Control onChange handler that updates block attributes when a setting is changed.
37
- *
38
- * @param {Object} updatedValue New block attributes to update.
39
- * @param {Function} setAttributes Block attribute update function.
40
- * @param {WPNavigationLinkBlockAttributes} blockAttributes Current block attributes.
41
- *
42
- */
43
- const updateAttributes = function () {
44
- let updatedValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
45
- let setAttributes = arguments.length > 1 ? arguments[1] : undefined;
46
- let blockAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
47
- const {
48
- label: originalLabel = '',
49
- kind: originalKind = '',
50
- type: originalType = ''
51
- } = blockAttributes;
52
- const {
53
- title: newLabel = '',
54
- // the title of any provided Post.
55
- url: newUrl = '',
56
- opensInNewTab,
57
- id,
58
- kind: newKind = originalKind,
59
- type: newType = originalType
60
- } = updatedValue;
61
- const newLabelWithoutHttp = newLabel.replace(/http(s?):\/\//gi, '');
62
- const newUrlWithoutHttp = newUrl.replace(/http(s?):\/\//gi, '');
63
- const useNewLabel = newLabel && newLabel !== originalLabel && // LinkControl without the title field relies
64
- // on the check below. Specifically, it assumes that
65
- // the URL is the same as a title.
66
- // This logic a) looks suspicious and b) should really
67
- // live in the LinkControl and not here. It's a great
68
- // candidate for future refactoring.
69
- newLabelWithoutHttp !== newUrlWithoutHttp; // Unfortunately this causes the escaping model to be inverted.
70
- // The escaped content is stored in the block attributes (and ultimately in the database),
71
- // and then the raw data is "recovered" when outputting into the DOM.
72
- // It would be preferable to store the **raw** data in the block attributes and escape it in JS.
73
- // Why? Because there isn't one way to escape data. Depending on the context, you need to do
74
- // different transforms. It doesn't make sense to me to choose one of them for the purposes of storage.
75
- // See also:
76
- // - https://github.com/WordPress/gutenberg/pull/41063
77
- // - https://github.com/WordPress/gutenberg/pull/18617.
78
-
79
- const label = useNewLabel ? (0, _escapeHtml.escapeHTML)(newLabel) : originalLabel || (0, _escapeHtml.escapeHTML)(newUrlWithoutHttp); // In https://github.com/WordPress/gutenberg/pull/24670 we decided to use "tag" in favor of "post_tag"
80
-
81
- const type = newType === 'post_tag' ? 'tag' : newType.replace('-', '_');
82
- const isBuiltInType = ['post', 'page', 'tag', 'category'].indexOf(type) > -1;
83
- const isCustomLink = !newKind && !isBuiltInType || newKind === 'custom';
84
- const kind = isCustomLink ? 'custom' : newKind;
85
- setAttributes({ // Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.
86
- ...(newUrl && {
87
- url: encodeURI((0, _url.safeDecodeURI)(newUrl))
88
- }),
89
- ...(label && {
90
- label
91
- }),
92
- ...(undefined !== opensInNewTab && {
93
- opensInNewTab
94
- }),
95
- ...(id && Number.isInteger(id) && {
96
- id
97
- }),
98
- ...(kind && {
99
- kind
100
- }),
101
- ...(type && type !== 'URL' && {
102
- type
103
- })
104
- });
105
- };
106
-
107
- exports.updateAttributes = updateAttributes;
108
- //# sourceMappingURL=update-attributes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/update-attributes.js"],"names":["updateAttributes","updatedValue","setAttributes","blockAttributes","label","originalLabel","kind","originalKind","type","originalType","title","newLabel","url","newUrl","opensInNewTab","id","newKind","newType","newLabelWithoutHttp","replace","newUrlWithoutHttp","useNewLabel","isBuiltInType","indexOf","isCustomLink","encodeURI","undefined","Number","isInteger"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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B,KAAlB,EAAyB,UAAzB,EAAsCC,OAAtC,CAA+Cf,IAA/C,IAAwD,CAAC,CAD1D;AAGA,QAAMgB,YAAY,GACf,CAAER,OAAF,IAAa,CAAEM,aAAjB,IAAoCN,OAAO,KAAK,QADjD;AAEA,QAAMV,IAAI,GAAGkB,YAAY,GAAG,QAAH,GAAcR,OAAvC;AAEAd,EAAAA,aAAa,CAAE,EACd;AACA,QAAKW,MAAM,IAAI;AAAED,MAAAA,GAAG,EAAEa,SAAS,CAAE,wBAAeZ,MAAf,CAAF;AAAhB,KAAf,CAFc;AAGd,QAAKT,KAAK,IAAI;AAAEA,MAAAA;AAAF,KAAd,CAHc;AAId,QAAKsB,SAAS,KAAKZ,aAAd,IAA+B;AAAEA,MAAAA;AAAF,KAApC,CAJc;AAKd,QAAKC,EAAE,IAAIY,MAAM,CAACC,SAAP,CAAkBb,EAAlB,CAAN,IAAgC;AAAEA,MAAAA;AAAF,KAArC,CALc;AAMd,QAAKT,IAAI,IAAI;AAAEA,MAAAA;AAAF,KAAb,CANc;AAOd,QAAKE,IAAI,IAAIA,IAAI,KAAK,KAAjB,IAA0B;AAAEA,MAAAA;AAAF,KAA/B;AAPc,GAAF,CAAb;AASA,CAlEM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { escapeHTML } from '@wordpress/escape-html';\nimport { safeDecodeURI } from '@wordpress/url';\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\n */\n/**\n * Navigation Link Block Attributes\n *\n * @typedef {Object} WPNavigationLinkBlockAttributes\n *\n * @property {string} [label] Link text.\n * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.\n * @property {string} [type] The type such as post, page, tag, category and other custom types.\n * @property {string} [rel] The relationship of the linked URL.\n * @property {number} [id] A post or term id.\n * @property {boolean} [opensInNewTab] Sets link target to _blank when true.\n * @property {string} [url] Link href.\n * @property {string} [title] Link title attribute.\n */\n/**\n * Link Control onChange handler that updates block attributes when a setting is changed.\n *\n * @param {Object} updatedValue New block attributes to update.\n * @param {Function} setAttributes Block attribute update function.\n * @param {WPNavigationLinkBlockAttributes} blockAttributes Current block attributes.\n *\n */\n\nexport const updateAttributes = (\n\tupdatedValue = {},\n\tsetAttributes,\n\tblockAttributes = {}\n) => {\n\tconst {\n\t\tlabel: originalLabel = '',\n\t\tkind: originalKind = '',\n\t\ttype: originalType = '',\n\t} = blockAttributes;\n\n\tconst {\n\t\ttitle: newLabel = '', // the title of any provided Post.\n\t\turl: newUrl = '',\n\t\topensInNewTab,\n\t\tid,\n\t\tkind: newKind = originalKind,\n\t\ttype: newType = originalType,\n\t} = updatedValue;\n\n\tconst newLabelWithoutHttp = newLabel.replace( /http(s?):\\/\\//gi, '' );\n\tconst newUrlWithoutHttp = newUrl.replace( /http(s?):\\/\\//gi, '' );\n\n\tconst useNewLabel =\n\t\tnewLabel &&\n\t\tnewLabel !== originalLabel &&\n\t\t// LinkControl without the title field relies\n\t\t// on the check below. Specifically, it assumes that\n\t\t// the URL is the same as a title.\n\t\t// This logic a) looks suspicious and b) should really\n\t\t// live in the LinkControl and not here. It's a great\n\t\t// candidate for future refactoring.\n\t\tnewLabelWithoutHttp !== newUrlWithoutHttp;\n\n\t// Unfortunately this causes the escaping model to be inverted.\n\t// The escaped content is stored in the block attributes (and ultimately in the database),\n\t// and then the raw data is \"recovered\" when outputting into the DOM.\n\t// It would be preferable to store the **raw** data in the block attributes and escape it in JS.\n\t// Why? Because there isn't one way to escape data. Depending on the context, you need to do\n\t// different transforms. It doesn't make sense to me to choose one of them for the purposes of storage.\n\t// See also:\n\t// - https://github.com/WordPress/gutenberg/pull/41063\n\t// - https://github.com/WordPress/gutenberg/pull/18617.\n\tconst label = useNewLabel\n\t\t? escapeHTML( newLabel )\n\t\t: originalLabel || escapeHTML( newUrlWithoutHttp );\n\n\t// In https://github.com/WordPress/gutenberg/pull/24670 we decided to use \"tag\" in favor of \"post_tag\"\n\tconst type = newType === 'post_tag' ? 'tag' : newType.replace( '-', '_' );\n\n\tconst isBuiltInType =\n\t\t[ 'post', 'page', 'tag', 'category' ].indexOf( type ) > -1;\n\n\tconst isCustomLink =\n\t\t( ! newKind && ! isBuiltInType ) || newKind === 'custom';\n\tconst kind = isCustomLink ? 'custom' : newKind;\n\n\tsetAttributes( {\n\t\t// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.\n\t\t...( newUrl && { url: encodeURI( safeDecodeURI( newUrl ) ) } ),\n\t\t...( label && { label } ),\n\t\t...( undefined !== opensInNewTab && { opensInNewTab } ),\n\t\t...( id && Number.isInteger( id ) && { id } ),\n\t\t...( kind && { kind } ),\n\t\t...( type && type !== 'URL' && { type } ),\n\t} );\n};\n"]}