@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,166 +0,0 @@
1
- import { createElement } from "@wordpress/element";
2
- // Note: this file is copied directly from packages/block-library/src/navigation-link/link-ui.js
3
-
4
- /**
5
- * WordPress dependencies
6
- */
7
- import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
8
- import { Popover, Button } from '@wordpress/components';
9
- import { __ } from '@wordpress/i18n';
10
- import { switchToBlockType } from '@wordpress/blocks';
11
- import { useSelect, useDispatch } from '@wordpress/data';
12
- /**
13
- * Internal dependencies
14
- */
15
-
16
- import { store as blockEditorStore } from '../../store';
17
- import LinkControl from '../link-control';
18
- import BlockIcon from '../block-icon';
19
- /**
20
- * Given the Link block's type attribute, return the query params to give to
21
- * /wp/v2/search.
22
- *
23
- * @param {string} type Link block's type attribute.
24
- * @param {string} kind Link block's entity of kind (post-type|taxonomy)
25
- * @return {{ type?: string, subtype?: string }} Search query params.
26
- */
27
-
28
- export function getSuggestionsQuery(type, kind) {
29
- switch (type) {
30
- case 'post':
31
- case 'page':
32
- return {
33
- type: 'post',
34
- subtype: type
35
- };
36
-
37
- case 'category':
38
- return {
39
- type: 'term',
40
- subtype: 'category'
41
- };
42
-
43
- case 'tag':
44
- return {
45
- type: 'term',
46
- subtype: 'post_tag'
47
- };
48
-
49
- case 'post_format':
50
- return {
51
- type: 'post-format'
52
- };
53
-
54
- default:
55
- if (kind === 'taxonomy') {
56
- return {
57
- type: 'term',
58
- subtype: type
59
- };
60
- }
61
-
62
- if (kind === 'post-type') {
63
- return {
64
- type: 'post',
65
- subtype: type
66
- };
67
- }
68
-
69
- return {};
70
- }
71
- }
72
- /**
73
- * Add transforms to Link Control
74
- *
75
- * @param {Object} props Component props.
76
- * @param {string} props.clientId Block client ID.
77
- */
78
-
79
- function LinkControlTransforms(_ref) {
80
- let {
81
- clientId
82
- } = _ref;
83
- const {
84
- getBlock,
85
- blockTransforms
86
- } = useSelect(select => {
87
- const {
88
- getBlock: _getBlock,
89
- getBlockRootClientId,
90
- getBlockTransformItems
91
- } = select(blockEditorStore);
92
- return {
93
- getBlock: _getBlock,
94
- blockTransforms: getBlockTransformItems(_getBlock(clientId), getBlockRootClientId(clientId))
95
- };
96
- }, [clientId]);
97
- const {
98
- replaceBlock
99
- } = useDispatch(blockEditorStore);
100
- const featuredBlocks = ['core/page-list', 'core/site-logo', 'core/social-links', 'core/search'];
101
- const transforms = blockTransforms.filter(item => {
102
- return featuredBlocks.includes(item.name);
103
- });
104
-
105
- if (!(transforms !== null && transforms !== void 0 && transforms.length)) {
106
- return null;
107
- }
108
-
109
- if (!clientId) {
110
- return null;
111
- }
112
-
113
- return createElement("div", {
114
- className: "link-control-transform"
115
- }, createElement("h3", {
116
- className: "link-control-transform__subheading"
117
- }, __('Transform')), createElement("div", {
118
- className: "link-control-transform__items"
119
- }, transforms.map(item => {
120
- return createElement(Button, {
121
- key: `transform-${item.name}`,
122
- onClick: () => replaceBlock(clientId, switchToBlockType(getBlock(clientId), item.name)),
123
- className: "link-control-transform__item"
124
- }, createElement(BlockIcon, {
125
- icon: item.icon
126
- }), item.title);
127
- })));
128
- }
129
-
130
- export function LinkUI(props) {
131
- const {
132
- label,
133
- url,
134
- opensInNewTab,
135
- type,
136
- kind
137
- } = props.link;
138
- const link = {
139
- url,
140
- opensInNewTab,
141
- title: label && stripHTML(label)
142
- };
143
- return createElement(Popover, {
144
- placement: "bottom",
145
- onClose: props.onClose,
146
- anchor: props.anchor,
147
- shift: true
148
- }, createElement(LinkControl, {
149
- hasTextControl: true,
150
- hasRichPreviews: true,
151
- className: props.className,
152
- value: link,
153
- showInitialSuggestions: true,
154
- withCreateSuggestion: props.hasCreateSuggestion,
155
- noDirectEntry: !!type,
156
- noURLSuggestion: !!type,
157
- suggestionsQuery: getSuggestionsQuery(type, kind),
158
- onChange: props.onChange,
159
- onRemove: props.onRemove,
160
- onCancel: props.onCancel,
161
- renderControlBottom: !url ? () => createElement(LinkControlTransforms, {
162
- clientId: props.clientId
163
- }) : null
164
- }));
165
- }
166
- //# sourceMappingURL=link-ui.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/link-ui.js"],"names":["__unstableStripHTML","stripHTML","Popover","Button","__","switchToBlockType","useSelect","useDispatch","store","blockEditorStore","LinkControl","BlockIcon","getSuggestionsQuery","type","kind","subtype","LinkControlTransforms","clientId","getBlock","blockTransforms","select","_getBlock","getBlockRootClientId","getBlockTransformItems","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":";AAAA;;AAEA;AACA;AACA;AACA,SAASA,mBAAmB,IAAIC,SAAhC,QAAiD,gBAAjD;AACA,SAASC,OAAT,EAAkBC,MAAlB,QAAgC,uBAAhC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,iBAAT,QAAkC,mBAAlC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AACA,OAAOC,SAAP,MAAsB,eAAtB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,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,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AAA,KAAK,EAAGH,IAJT;AAKC,IAAA,sBAAsB,EAAG,IAL1B;AAMC,IAAA,oBAAoB,EAAGJ,KAAK,CAACQ,mBAN9B;AAOC,IAAA,aAAa,EAAG,CAAC,CAAE/B,IAPpB;AAQC,IAAA,eAAe,EAAG,CAAC,CAAEA,IARtB;AASC,IAAA,gBAAgB,EAAGD,mBAAmB,CAAEC,IAAF,EAAQC,IAAR,CATvC;AAUC,IAAA,QAAQ,EAAGsB,KAAK,CAACS,QAVlB;AAWC,IAAA,QAAQ,EAAGT,KAAK,CAACU,QAXlB;AAYC,IAAA,QAAQ,EAAGV,KAAK,CAACW,QAZlB;AAaC,IAAA,mBAAmB,EAClB,CAAET,GAAF,GACG,MACA,cAAC,qBAAD;AACC,MAAA,QAAQ,EAAGF,KAAK,CAACnB;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,97 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { escapeHTML } from '@wordpress/escape-html';
5
- import { safeDecodeURI } from '@wordpress/url';
6
- /**
7
- * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind
8
- */
9
-
10
- /**
11
- * Navigation Link Block Attributes
12
- *
13
- * @typedef {Object} WPNavigationLinkBlockAttributes
14
- *
15
- * @property {string} [label] Link text.
16
- * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.
17
- * @property {string} [type] The type such as post, page, tag, category and other custom types.
18
- * @property {string} [rel] The relationship of the linked URL.
19
- * @property {number} [id] A post or term id.
20
- * @property {boolean} [opensInNewTab] Sets link target to _blank when true.
21
- * @property {string} [url] Link href.
22
- * @property {string} [title] Link title attribute.
23
- */
24
-
25
- /**
26
- * Link Control onChange handler that updates block attributes when a setting is changed.
27
- *
28
- * @param {Object} updatedValue New block attributes to update.
29
- * @param {Function} setAttributes Block attribute update function.
30
- * @param {WPNavigationLinkBlockAttributes} blockAttributes Current block attributes.
31
- *
32
- */
33
-
34
- export const updateAttributes = function () {
35
- let updatedValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
36
- let setAttributes = arguments.length > 1 ? arguments[1] : undefined;
37
- let blockAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
38
- const {
39
- label: originalLabel = '',
40
- kind: originalKind = '',
41
- type: originalType = ''
42
- } = blockAttributes;
43
- const {
44
- title: newLabel = '',
45
- // the title of any provided Post.
46
- url: newUrl = '',
47
- opensInNewTab,
48
- id,
49
- kind: newKind = originalKind,
50
- type: newType = originalType
51
- } = updatedValue;
52
- const newLabelWithoutHttp = newLabel.replace(/http(s?):\/\//gi, '');
53
- const newUrlWithoutHttp = newUrl.replace(/http(s?):\/\//gi, '');
54
- const useNewLabel = newLabel && newLabel !== originalLabel && // LinkControl without the title field relies
55
- // on the check below. Specifically, it assumes that
56
- // the URL is the same as a title.
57
- // This logic a) looks suspicious and b) should really
58
- // live in the LinkControl and not here. It's a great
59
- // candidate for future refactoring.
60
- newLabelWithoutHttp !== newUrlWithoutHttp; // Unfortunately this causes the escaping model to be inverted.
61
- // The escaped content is stored in the block attributes (and ultimately in the database),
62
- // and then the raw data is "recovered" when outputting into the DOM.
63
- // It would be preferable to store the **raw** data in the block attributes and escape it in JS.
64
- // Why? Because there isn't one way to escape data. Depending on the context, you need to do
65
- // different transforms. It doesn't make sense to me to choose one of them for the purposes of storage.
66
- // See also:
67
- // - https://github.com/WordPress/gutenberg/pull/41063
68
- // - https://github.com/WordPress/gutenberg/pull/18617.
69
-
70
- const label = useNewLabel ? escapeHTML(newLabel) : originalLabel || escapeHTML(newUrlWithoutHttp); // In https://github.com/WordPress/gutenberg/pull/24670 we decided to use "tag" in favor of "post_tag"
71
-
72
- const type = newType === 'post_tag' ? 'tag' : newType.replace('-', '_');
73
- const isBuiltInType = ['post', 'page', 'tag', 'category'].indexOf(type) > -1;
74
- const isCustomLink = !newKind && !isBuiltInType || newKind === 'custom';
75
- const kind = isCustomLink ? 'custom' : newKind;
76
- setAttributes({ // Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.
77
- ...(newUrl && {
78
- url: encodeURI(safeDecodeURI(newUrl))
79
- }),
80
- ...(label && {
81
- label
82
- }),
83
- ...(undefined !== opensInNewTab && {
84
- opensInNewTab
85
- }),
86
- ...(id && Number.isInteger(id) && {
87
- id
88
- }),
89
- ...(kind && {
90
- kind
91
- }),
92
- ...(type && type !== 'URL' && {
93
- type
94
- })
95
- });
96
- };
97
- //# sourceMappingURL=update-attributes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/update-attributes.js"],"names":["escapeHTML","safeDecodeURI","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":"AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,wBAA3B;AACA,SAASC,aAAT,QAA8B,gBAA9B;AAEA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,gBAAgB,GAAG,YAI3B;AAAA,MAHJC,YAGI,uEAHW,EAGX;AAAA,MAFJC,aAEI;AAAA,MADJC,eACI,uEADc,EACd;AACJ,QAAM;AACLC,IAAAA,KAAK,EAAEC,aAAa,GAAG,EADlB;AAELC,IAAAA,IAAI,EAAEC,YAAY,GAAG,EAFhB;AAGLC,IAAAA,IAAI,EAAEC,YAAY,GAAG;AAHhB,MAIFN,eAJJ;AAMA,QAAM;AACLO,IAAAA,KAAK,EAAEC,QAAQ,GAAG,EADb;AACiB;AACtBC,IAAAA,GAAG,EAAEC,MAAM,GAAG,EAFT;AAGLC,IAAAA,aAHK;AAILC,IAAAA,EAJK;AAKLT,IAAAA,IAAI,EAAEU,OAAO,GAAGT,YALX;AAMLC,IAAAA,IAAI,EAAES,OAAO,GAAGR;AANX,MAOFR,YAPJ;AASA,QAAMiB,mBAAmB,GAAGP,QAAQ,CAACQ,OAAT,CAAkB,iBAAlB,EAAqC,EAArC,CAA5B;AACA,QAAMC,iBAAiB,GAAGP,MAAM,CAACM,OAAP,CAAgB,iBAAhB,EAAmC,EAAnC,CAA1B;AAEA,QAAME,WAAW,GAChBV,QAAQ,IACRA,QAAQ,KAAKN,aADb,IAEA;AACA;AACA;AACA;AACA;AACA;AACAa,EAAAA,mBAAmB,KAAKE,iBATzB,CAnBI,CA8BJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,QAAMhB,KAAK,GAAGiB,WAAW,GACtBvB,UAAU,CAAEa,QAAF,CADY,GAEtBN,aAAa,IAAIP,UAAU,CAAEsB,iBAAF,CAF9B,CAvCI,CA2CJ;;AACA,QAAMZ,IAAI,GAAGS,OAAO,KAAK,UAAZ,GAAyB,KAAzB,GAAiCA,OAAO,CAACE,OAAR,CAAiB,GAAjB,EAAsB,GAAtB,CAA9C;AAEA,QAAMG,aAAa,GAClB,CAAE,MAAF,EAAU,MAAV,EAAkB,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,CAAE1B,aAAa,CAAEc,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"]}
@@ -1,124 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { speak } from '@wordpress/a11y';
5
- import { __, sprintf } from '@wordpress/i18n';
6
- import { useDispatch, useSelect } from '@wordpress/data';
7
- import { useCallback } from '@wordpress/element';
8
- import { UP, DOWN, HOME, END } from '@wordpress/keycodes';
9
- import { store as blocksStore } from '@wordpress/blocks';
10
- /**
11
- * Internal dependencies
12
- */
13
-
14
- import { store as blockEditorStore } from '../../store';
15
- import { getCommonDepthClientIds } from './utils';
16
- export default function useBlockSelection() {
17
- const {
18
- clearSelectedBlock,
19
- multiSelect,
20
- selectBlock
21
- } = useDispatch(blockEditorStore);
22
- const {
23
- getBlockName,
24
- getBlockParents,
25
- getBlockSelectionStart,
26
- getBlockSelectionEnd,
27
- getSelectedBlockClientIds,
28
- hasMultiSelection,
29
- hasSelectedBlock
30
- } = useSelect(blockEditorStore);
31
- const {
32
- getBlockType
33
- } = useSelect(blocksStore);
34
- const updateBlockSelection = useCallback(async (event, clientId, destinationClientId) => {
35
- if (!(event !== null && event !== void 0 && event.shiftKey)) {
36
- selectBlock(clientId);
37
- return;
38
- } // To handle multiple block selection via the `SHIFT` key, prevent
39
- // the browser default behavior of opening the link in a new window.
40
-
41
-
42
- event.preventDefault();
43
- const isKeyPress = event.type === 'keydown' && (event.keyCode === UP || event.keyCode === DOWN || event.keyCode === HOME || event.keyCode === END); // Handle clicking on a block when no blocks are selected, and return early.
44
-
45
- if (!isKeyPress && !hasSelectedBlock() && !hasMultiSelection()) {
46
- selectBlock(clientId, null);
47
- return;
48
- }
49
-
50
- const selectedBlocks = getSelectedBlockClientIds();
51
- const clientIdWithParents = [...getBlockParents(clientId), clientId];
52
-
53
- if (isKeyPress && !selectedBlocks.some(blockId => clientIdWithParents.includes(blockId))) {
54
- // Ensure that shift-selecting blocks via the keyboard only
55
- // expands the current selection if focusing over already
56
- // selected blocks. Otherwise, clear the selection so that
57
- // a user can create a new selection entirely by keyboard.
58
- await clearSelectedBlock();
59
- }
60
-
61
- let startTarget = getBlockSelectionStart();
62
- let endTarget = clientId; // Handle keyboard behavior for selecting multiple blocks.
63
-
64
- if (isKeyPress) {
65
- if (!hasSelectedBlock() && !hasMultiSelection()) {
66
- // Set the starting point of the selection to the currently
67
- // focused block, if there are no blocks currently selected.
68
- // This ensures that as the selection is expanded or contracted,
69
- // the starting point of the selection is anchored to that block.
70
- startTarget = clientId;
71
- }
72
-
73
- if (destinationClientId) {
74
- // If the user presses UP or DOWN, we want to ensure that the block they're
75
- // moving to is the target for selection, and not the currently focused one.
76
- endTarget = destinationClientId;
77
- }
78
- }
79
-
80
- const startParents = getBlockParents(startTarget);
81
- const endParents = getBlockParents(endTarget);
82
- const {
83
- start,
84
- end
85
- } = getCommonDepthClientIds(startTarget, endTarget, startParents, endParents);
86
- await multiSelect(start, end, null); // Announce deselected block, or number of deselected blocks if
87
- // the total number of blocks deselected is greater than one.
88
-
89
- const updatedSelectedBlocks = getSelectedBlockClientIds(); // If the selection is greater than 1 and the Home or End keys
90
- // were used to generate the selection, then skip announcing the
91
- // deselected blocks.
92
-
93
- if ((event.keyCode === HOME || event.keyCode === END) && updatedSelectedBlocks.length > 1) {
94
- return;
95
- }
96
-
97
- const selectionDiff = selectedBlocks.filter(blockId => !updatedSelectedBlocks.includes(blockId));
98
- let label;
99
-
100
- if (selectionDiff.length === 1) {
101
- var _getBlockType;
102
-
103
- const title = (_getBlockType = getBlockType(getBlockName(selectionDiff[0]))) === null || _getBlockType === void 0 ? void 0 : _getBlockType.title;
104
-
105
- if (title) {
106
- label = sprintf(
107
- /* translators: %s: block name */
108
- __('%s deselected.'), title);
109
- }
110
- } else if (selectionDiff.length > 1) {
111
- label = sprintf(
112
- /* translators: %s: number of deselected blocks */
113
- __('%s blocks deselected.'), selectionDiff.length);
114
- }
115
-
116
- if (label) {
117
- speak(label);
118
- }
119
- }, [clearSelectedBlock, getBlockName, getBlockType, getBlockParents, getBlockSelectionStart, getBlockSelectionEnd, getSelectedBlockClientIds, hasMultiSelection, hasSelectedBlock, multiSelect, selectBlock]);
120
- return {
121
- updateBlockSelection
122
- };
123
- }
124
- //# sourceMappingURL=use-block-selection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/use-block-selection.js"],"names":["speak","__","sprintf","useDispatch","useSelect","useCallback","UP","DOWN","HOME","END","store","blocksStore","blockEditorStore","getCommonDepthClientIds","useBlockSelection","clearSelectedBlock","multiSelect","selectBlock","getBlockName","getBlockParents","getBlockSelectionStart","getBlockSelectionEnd","getSelectedBlockClientIds","hasMultiSelection","hasSelectedBlock","getBlockType","updateBlockSelection","event","clientId","destinationClientId","shiftKey","preventDefault","isKeyPress","type","keyCode","selectedBlocks","clientIdWithParents","some","blockId","includes","startTarget","endTarget","startParents","endParents","start","end","updatedSelectedBlocks","length","sel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ACA,UAAMC,qBAAqB,GAAGxB,yBAAyB,EAAvD,CA9EiD,CAgFjD;AACA;AACA;;AACA,QACC,CAAEK,KAAK,CAACO,OAAN,KAAkB1B,IAAlB,IAA0BmB,KAAK,CAACO,OAAN,KAAkBzB,GAA9C,KACAqC,qBAAqB,CAACC,MAAtB,GAA+B,CAFhC,EAGE;AACD;AACA;;AAED,UAAMC,aAAa,GAAGb,cAAc,CAACc,MAAf,CACnBX,OAAF,IAAe,CAAEQ,qBAAqB,CAACP,QAAtB,CAAgCD,OAAhC,CADI,CAAtB;AAIA,QAAIY,KAAJ;;AACA,QAAKF,aAAa,CAACD,MAAd,KAAyB,CAA9B,EAAkC;AAAA;;AACjC,YAAMI,KAAK,oBAAG1B,YAAY,CACzBP,YAAY,CAAE8B,aAAa,CAAE,CAAF,CAAf,CADa,CAAf,kDAAG,cAEXG,KAFH;;AAGA,UAAKA,KAAL,EAAa;AACZD,QAAAA,KAAK,GAAGhD,OAAO;AACd;AACAD,QAAAA,EAAE,CAAE,gBAAF,CAFY,EAGdkD,KAHc,CAAf;AAKA;AACD,KAXD,MAWO,IAAKH,aAAa,CAACD,MAAd,GAAuB,CAA5B,EAAgC;AACtCG,MAAAA,KAAK,GAAGhD,OAAO;AACd;AACAD,MAAAA,EAAE,CAAE,uBAAF,CAFY,EAGd+C,aAAa,CAACD,MAHA,CAAf;AAKA;;AAED,QAAKG,KAAL,EAAa;AACZlD,MAAAA,KAAK,CAAEkD,KAAF,CAAL;AACA;AACD,GAtHsC,EAuHvC,CACCnC,kBADD,EAECG,YAFD,EAGCO,YAHD,EAICN,eAJD,EAKCC,sBALD,EAMCC,oBAND,EAOCC,yBAPD,EAQCC,iBARD,EASCC,gBATD,EAUCR,WAVD,EAWCC,WAXD,CAvHuC,CAAxC;AAsIA,SAAO;AACNS,IAAAA;AADM,GAAP;AAGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\nimport { UP, DOWN, HOME, END } from '@wordpress/keycodes';\nimport { store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getCommonDepthClientIds } from './utils';\n\nexport default function useBlockSelection() {\n\tconst { clearSelectedBlock, multiSelect, selectBlock } =\n\t\tuseDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlockName,\n\t\tgetBlockParents,\n\t\tgetBlockSelectionStart,\n\t\tgetBlockSelectionEnd,\n\t\tgetSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\thasSelectedBlock,\n\t} = useSelect( blockEditorStore );\n\n\tconst { getBlockType } = useSelect( blocksStore );\n\n\tconst updateBlockSelection = useCallback(\n\t\tasync ( event, clientId, destinationClientId ) => {\n\t\t\tif ( ! event?.shiftKey ) {\n\t\t\t\tselectBlock( clientId );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// To handle multiple block selection via the `SHIFT` key, prevent\n\t\t\t// the browser default behavior of opening the link in a new window.\n\t\t\tevent.preventDefault();\n\n\t\t\tconst isKeyPress =\n\t\t\t\tevent.type === 'keydown' &&\n\t\t\t\t( event.keyCode === UP ||\n\t\t\t\t\tevent.keyCode === DOWN ||\n\t\t\t\t\tevent.keyCode === HOME ||\n\t\t\t\t\tevent.keyCode === END );\n\n\t\t\t// Handle clicking on a block when no blocks are selected, and return early.\n\t\t\tif (\n\t\t\t\t! isKeyPress &&\n\t\t\t\t! hasSelectedBlock() &&\n\t\t\t\t! hasMultiSelection()\n\t\t\t) {\n\t\t\t\tselectBlock( clientId, null );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectedBlocks = getSelectedBlockClientIds();\n\t\t\tconst clientIdWithParents = [\n\t\t\t\t...getBlockParents( clientId ),\n\t\t\t\tclientId,\n\t\t\t];\n\n\t\t\tif (\n\t\t\t\tisKeyPress &&\n\t\t\t\t! selectedBlocks.some( ( blockId ) =>\n\t\t\t\t\tclientIdWithParents.includes( blockId )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// Ensure that shift-selecting blocks via the keyboard only\n\t\t\t\t// expands the current selection if focusing over already\n\t\t\t\t// selected blocks. Otherwise, clear the selection so that\n\t\t\t\t// a user can create a new selection entirely by keyboard.\n\t\t\t\tawait clearSelectedBlock();\n\t\t\t}\n\n\t\t\tlet startTarget = getBlockSelectionStart();\n\t\t\tlet endTarget = clientId;\n\n\t\t\t// Handle keyboard behavior for selecting multiple blocks.\n\t\t\tif ( isKeyPress ) {\n\t\t\t\tif ( ! hasSelectedBlock() && ! hasMultiSelection() ) {\n\t\t\t\t\t// Set the starting point of the selection to the currently\n\t\t\t\t\t// focused block, if there are no blocks currently selected.\n\t\t\t\t\t// This ensures that as the selection is expanded or contracted,\n\t\t\t\t\t// the starting point of the selection is anchored to that block.\n\t\t\t\t\tstartTarget = clientId;\n\t\t\t\t}\n\t\t\t\tif ( destinationClientId ) {\n\t\t\t\t\t// If the user presses UP or DOWN, we want to ensure that the block they're\n\t\t\t\t\t// moving to is the target for selection, and not the currently focused one.\n\t\t\t\t\tendTarget = destinationClientId;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst startParents = getBlockParents( startTarget );\n\t\t\tconst endParents = getBlockParents( endTarget );\n\n\t\t\tconst { start, end } = getCommonDepthClientIds(\n\t\t\t\tstartTarget,\n\t\t\t\tendTarget,\n\t\t\t\tstartParents,\n\t\t\t\tendParents\n\t\t\t);\n\t\t\tawait multiSelect( start, end, null );\n\n\t\t\t// Announce deselected block, or number of deselected blocks if\n\t\t\t// the total number of blocks deselected is greater than one.\n\t\t\tconst updatedSelectedBlocks = getSelectedBlockClientIds();\n\n\t\t\t// If the selection is greater than 1 and the Home or End keys\n\t\t\t// were used to generate the selection, then skip announcing the\n\t\t\t// deselected blocks.\n\t\t\tif (\n\t\t\t\t( event.keyCode === HOME || event.keyCode === END ) &&\n\t\t\t\tupdatedSelectedBlocks.length > 1\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectionDiff = selectedBlocks.filter(\n\t\t\t\t( blockId ) => ! updatedSelectedBlocks.includes( blockId )\n\t\t\t);\n\n\t\t\tlet label;\n\t\t\tif ( selectionDiff.length === 1 ) {\n\t\t\t\tconst title = getBlockType(\n\t\t\t\t\tgetBlockName( selectionDiff[ 0 ] )\n\t\t\t\t)?.title;\n\t\t\t\tif ( title ) {\n\t\t\t\t\tlabel = sprintf(\n\t\t\t\t\t\t/* translators: %s: block name */\n\t\t\t\t\t\t__( '%s deselected.' ),\n\t\t\t\t\t\ttitle\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else if ( selectionDiff.length > 1 ) {\n\t\t\t\tlabel = sprintf(\n\t\t\t\t\t/* translators: %s: number of deselected blocks */\n\t\t\t\t\t__( '%s blocks deselected.' ),\n\t\t\t\t\tselectionDiff.length\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif ( label ) {\n\t\t\t\tspeak( label );\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tclearSelectedBlock,\n\t\t\tgetBlockName,\n\t\t\tgetBlockType,\n\t\t\tgetBlockParents,\n\t\t\tgetBlockSelectionStart,\n\t\t\tgetBlockSelectionEnd,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\thasMultiSelection,\n\t\t\thasSelectedBlock,\n\t\t\tmultiSelect,\n\t\t\tselectBlock,\n\t\t]\n\t);\n\n\treturn {\n\t\tupdateBlockSelection,\n\t};\n}\n"]}
@@ -1,47 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useSelect, useDispatch } from '@wordpress/data';
5
- /**
6
- * Internal dependencies
7
- */
8
-
9
- import { store as blockEditorStore } from '../../store';
10
- export const useInsertedBlock = insertedBlockClientId => {
11
- const {
12
- insertedBlockAttributes,
13
- insertedBlockName
14
- } = useSelect(select => {
15
- const {
16
- getBlockName,
17
- getBlockAttributes
18
- } = select(blockEditorStore);
19
- return {
20
- insertedBlockAttributes: getBlockAttributes(insertedBlockClientId),
21
- insertedBlockName: getBlockName(insertedBlockClientId)
22
- };
23
- }, [insertedBlockClientId]);
24
- const {
25
- updateBlockAttributes
26
- } = useDispatch(blockEditorStore);
27
-
28
- const setInsertedBlockAttributes = _updatedAttributes => {
29
- if (!insertedBlockClientId) return;
30
- updateBlockAttributes(insertedBlockClientId, _updatedAttributes);
31
- };
32
-
33
- if (!insertedBlockClientId) {
34
- return {
35
- insertedBlockAttributes: undefined,
36
- insertedBlockName: undefined,
37
- setInsertedBlockAttributes
38
- };
39
- }
40
-
41
- return {
42
- insertedBlockAttributes,
43
- insertedBlockName,
44
- setInsertedBlockAttributes
45
- };
46
- };
47
- //# sourceMappingURL=use-inserted-block.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/use-inserted-block.js"],"names":["useSelect","useDispatch","store","blockEditorStore","useInsertedBlock","insertedBlockClientId","insertedBlockAttributes","insertedBlockName","select","getBlockName","getBlockAttributes","updateBlockAttributes","setInsertedBlockAttributes","_updatedAttributes","undefined"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,OAAO,MAAMC,gBAAgB,GAAKC,qBAAF,IAA6B;AAC5D,QAAM;AAAEC,IAAAA,uBAAF;AAA2BC,IAAAA;AAA3B,MAAiDP,SAAS,CAC7DQ,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,YAAF;AAAgBC,MAAAA;AAAhB,QACLF,MAAM,CAAEL,gBAAF,CADP;AAGA,WAAO;AACNG,MAAAA,uBAAuB,EAAEI,kBAAkB,CAC1CL,qBAD0C,CADrC;AAINE,MAAAA,iBAAiB,EAAEE,YAAY,CAAEJ,qBAAF;AAJzB,KAAP;AAMA,GAX8D,EAY/D,CAAEA,qBAAF,CAZ+D,CAAhE;AAeA,QAAM;AAAEM,IAAAA;AAAF,MAA4BV,WAAW,CAAEE,gBAAF,CAA7C;;AAEA,QAAMS,0BAA0B,GAAKC,kBAAF,IAA0B;AAC5D,QAAK,CAAER,qBAAP,EAA+B;AAC/BM,IAAAA,qBAAqB,CAAEN,qBAAF,EAAyBQ,kBAAzB,CAArB;AACA,GAHD;;AAKA,MAAK,CAAER,qBAAP,EAA+B;AAC9B,WAAO;AACNC,MAAAA,uBAAuB,EAAEQ,SADnB;AAENP,MAAAA,iBAAiB,EAAEO,SAFb;AAGNF,MAAAA;AAHM,KAAP;AAKA;;AAED,SAAO;AACNN,IAAAA,uBADM;AAENC,IAAAA,iBAFM;AAGNK,IAAAA;AAHM,GAAP;AAKA,CApCM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nexport const useInsertedBlock = ( insertedBlockClientId ) => {\n\tconst { insertedBlockAttributes, insertedBlockName } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockName, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tinsertedBlockAttributes: getBlockAttributes(\n\t\t\t\t\tinsertedBlockClientId\n\t\t\t\t),\n\t\t\t\tinsertedBlockName: getBlockName( insertedBlockClientId ),\n\t\t\t};\n\t\t},\n\t\t[ insertedBlockClientId ]\n\t);\n\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tconst setInsertedBlockAttributes = ( _updatedAttributes ) => {\n\t\tif ( ! insertedBlockClientId ) return;\n\t\tupdateBlockAttributes( insertedBlockClientId, _updatedAttributes );\n\t};\n\n\tif ( ! insertedBlockClientId ) {\n\t\treturn {\n\t\t\tinsertedBlockAttributes: undefined,\n\t\t\tinsertedBlockName: undefined,\n\t\t\tsetInsertedBlockAttributes,\n\t\t};\n\t}\n\n\treturn {\n\t\tinsertedBlockAttributes,\n\t\tinsertedBlockName,\n\t\tsetInsertedBlockAttributes,\n\t};\n};\n"]}
@@ -1,24 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useSelect } from '@wordpress/data';
5
- /**
6
- * Internal dependencies
7
- */
8
-
9
- import { store as blockEditorStore } from '../../store';
10
- export default function useListViewClientIds(blocks) {
11
- return useSelect(select => {
12
- const {
13
- getDraggedBlockClientIds,
14
- getSelectedBlockClientIds,
15
- __unstableGetClientIdsTree
16
- } = select(blockEditorStore);
17
- return {
18
- selectedClientIds: getSelectedBlockClientIds(),
19
- draggedClientIds: getDraggedBlockClientIds(),
20
- clientIdsTree: blocks ? blocks : __unstableGetClientIdsTree()
21
- };
22
- }, [blocks]);
23
- }
24
- //# sourceMappingURL=use-list-view-client-ids.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/use-list-view-client-ids.js"],"names":["useSelect","store","blockEditorStore","useListViewClientIds","blocks","select","getDraggedBlockClientIds","getSelectedBlockClientIds","__unstableGetClientIdsTree","selectedClientIds","draggedClientIds","clientIdsTree"],"mappings":"AAAA;AACA;AACA;AAEA,SAASA,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,eAAe,SAASC,oBAAT,CAA+BC,MAA/B,EAAwC;AACtD,SAAOJ,SAAS,CACbK,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,wBADK;AAELC,MAAAA,yBAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAEH,gBAAF,CAJV;AAMA,WAAO;AACNO,MAAAA,iBAAiB,EAAEF,yBAAyB,EADtC;AAENG,MAAAA,gBAAgB,EAAEJ,wBAAwB,EAFpC;AAGNK,MAAAA,aAAa,EAAEP,MAAM,GAAGA,MAAH,GAAYI,0BAA0B;AAHrD,KAAP;AAKA,GAbc,EAcf,CAAEJ,MAAF,CAde,CAAhB;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\n\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nexport default function useListViewClientIds( blocks ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetDraggedBlockClientIds,\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\t__unstableGetClientIdsTree,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tselectedClientIds: getSelectedBlockClientIds(),\n\t\t\t\tdraggedClientIds: getDraggedBlockClientIds(),\n\t\t\t\tclientIdsTree: blocks ? blocks : __unstableGetClientIdsTree(),\n\t\t\t};\n\t\t},\n\t\t[ blocks ]\n\t);\n}\n"]}