@wordpress/block-editor 10.5.0 → 11.0.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 (488) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/build/autocompleters/block.js +2 -6
  3. package/build/autocompleters/block.js.map +1 -1
  4. package/build/autocompleters/link.js +2 -0
  5. package/build/autocompleters/link.js.map +1 -1
  6. package/build/components/block-card/index.js +51 -3
  7. package/build/components/block-card/index.js.map +1 -1
  8. package/build/components/block-draggable/index.native.js +46 -39
  9. package/build/components/block-draggable/index.native.js.map +1 -1
  10. package/build/components/block-edit/edit.js +4 -3
  11. package/build/components/block-edit/edit.js.map +1 -1
  12. package/build/components/block-edit/edit.native.js +4 -7
  13. package/build/components/block-edit/edit.native.js.map +1 -1
  14. package/build/components/block-inspector/index.js +35 -33
  15. package/build/components/block-inspector/index.js.map +1 -1
  16. package/build/components/block-list/block-list-context.native.js +5 -8
  17. package/build/components/block-list/block-list-context.native.js.map +1 -1
  18. package/build/components/block-list/block.js +55 -24
  19. package/build/components/block-list/block.js.map +1 -1
  20. package/build/components/block-list/block.native.js +61 -28
  21. package/build/components/block-list/block.native.js.map +1 -1
  22. package/build/components/block-mobile-toolbar/block-actions-menu.native.js +12 -4
  23. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  24. package/build/components/block-pattern-setup/index.js +3 -2
  25. package/build/components/block-pattern-setup/index.js.map +1 -1
  26. package/build/components/block-patterns-list/index.js +33 -11
  27. package/build/components/block-patterns-list/index.js.map +1 -1
  28. package/build/components/block-preview/auto.js +9 -3
  29. package/build/components/block-preview/auto.js.map +1 -1
  30. package/build/components/block-preview/index.js +5 -9
  31. package/build/components/block-preview/index.js.map +1 -1
  32. package/build/components/block-settings-menu/block-settings-dropdown.js +5 -2
  33. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  34. package/build/components/block-toolbar/index.js +5 -1
  35. package/build/components/block-toolbar/index.js.map +1 -1
  36. package/build/components/block-tools/insertion-point.js +8 -49
  37. package/build/components/block-tools/insertion-point.js.map +1 -1
  38. package/build/components/block-variation-picker/index.js +1 -2
  39. package/build/components/block-variation-picker/index.js.map +1 -1
  40. package/build/components/height-control/index.js +115 -0
  41. package/build/components/height-control/index.js.map +1 -0
  42. package/build/components/iframe/index.js +11 -8
  43. package/build/components/iframe/index.js.map +1 -1
  44. package/build/components/image-editor/use-save-image.js +2 -0
  45. package/build/components/image-editor/use-save-image.js.map +1 -1
  46. package/build/components/image-editor/zoom-dropdown.js +1 -0
  47. package/build/components/image-editor/zoom-dropdown.js.map +1 -1
  48. package/build/components/index.js +9 -0
  49. package/build/components/index.js.map +1 -1
  50. package/build/components/inner-blocks/index.js +20 -6
  51. package/build/components/inner-blocks/index.js.map +1 -1
  52. package/build/components/inner-blocks/use-inner-block-template-sync.js +25 -10
  53. package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  54. package/build/components/inserter/block-patterns-explorer/sidebar.js +1 -0
  55. package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  56. package/build/components/inserter/block-patterns-tab.js +25 -46
  57. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  58. package/build/components/inserter/block-types-tab.js +3 -1
  59. package/build/components/inserter/block-types-tab.js.map +1 -1
  60. package/build/components/inserter/hooks/use-debounced-input.js +27 -0
  61. package/build/components/inserter/hooks/use-debounced-input.js.map +1 -0
  62. package/build/components/inserter/index.js +8 -3
  63. package/build/components/inserter/index.js.map +1 -1
  64. package/build/components/inserter/index.native.js +3 -4
  65. package/build/components/inserter/index.native.js.map +1 -1
  66. package/build/components/inserter/media-tab/hooks.js +103 -0
  67. package/build/components/inserter/media-tab/hooks.js.map +1 -0
  68. package/build/components/inserter/media-tab/index.js +32 -0
  69. package/build/components/inserter/media-tab/index.js.map +1 -0
  70. package/build/components/inserter/media-tab/media-list.js +100 -0
  71. package/build/components/inserter/media-tab/media-list.js.map +1 -0
  72. package/build/components/inserter/media-tab/media-panel.js +96 -0
  73. package/build/components/inserter/media-tab/media-panel.js.map +1 -0
  74. package/build/components/inserter/media-tab/media-tab.js +120 -0
  75. package/build/components/inserter/media-tab/media-tab.js.map +1 -0
  76. package/build/components/inserter/media-tab/utils.js +54 -0
  77. package/build/components/inserter/media-tab/utils.js.map +1 -0
  78. package/build/components/inserter/menu.js +35 -12
  79. package/build/components/inserter/menu.js.map +1 -1
  80. package/build/components/inserter/mobile-tab-navigation.js +70 -0
  81. package/build/components/inserter/mobile-tab-navigation.js.map +1 -0
  82. package/build/components/inserter/quick-inserter.js +1 -0
  83. package/build/components/inserter/quick-inserter.js.map +1 -1
  84. package/build/components/inserter/search-results.js +3 -1
  85. package/build/components/inserter/search-results.js.map +1 -1
  86. package/build/components/inserter/tabs.js +16 -2
  87. package/build/components/inserter/tabs.js.map +1 -1
  88. package/build/components/inserter-list-item/index.js +4 -1
  89. package/build/components/inserter-list-item/index.js.map +1 -1
  90. package/build/components/inspector-controls/groups.js +2 -0
  91. package/build/components/inspector-controls/groups.js.map +1 -1
  92. package/build/components/inspector-controls-tabs/advanced-controls-panel.js +46 -0
  93. package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
  94. package/build/components/inspector-controls-tabs/index.js +71 -0
  95. package/build/components/inspector-controls-tabs/index.js.map +1 -0
  96. package/build/components/inspector-controls-tabs/settings-tab.js +28 -0
  97. package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -0
  98. package/build/components/inspector-controls-tabs/styles-tab.js +61 -0
  99. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -0
  100. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +97 -0
  101. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
  102. package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +18 -0
  103. package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
  104. package/build/components/inspector-controls-tabs/utils.js +37 -0
  105. package/build/components/inspector-controls-tabs/utils.js.map +1 -0
  106. package/build/components/link-control/index.js +1 -0
  107. package/build/components/link-control/index.js.map +1 -1
  108. package/build/components/link-control/search-input.js +0 -1
  109. package/build/components/link-control/search-input.js.map +1 -1
  110. package/build/components/link-control/use-internal-input-value.js +3 -3
  111. package/build/components/link-control/use-internal-input-value.js.map +1 -1
  112. package/build/components/list-view/block.js +5 -2
  113. package/build/components/list-view/block.js.map +1 -1
  114. package/build/components/list-view/branch.js +13 -12
  115. package/build/components/list-view/branch.js.map +1 -1
  116. package/build/components/media-upload/index.native.js +2 -3
  117. package/build/components/media-upload/index.native.js.map +1 -1
  118. package/build/components/off-canvas-editor/appender.js +104 -0
  119. package/build/components/off-canvas-editor/appender.js.map +1 -0
  120. package/build/components/off-canvas-editor/block-edit-button.js +50 -0
  121. package/build/components/off-canvas-editor/block-edit-button.js.map +1 -0
  122. package/build/components/off-canvas-editor/block.js +36 -4
  123. package/build/components/off-canvas-editor/block.js.map +1 -1
  124. package/build/components/off-canvas-editor/branch.js +3 -5
  125. package/build/components/off-canvas-editor/branch.js.map +1 -1
  126. package/build/components/off-canvas-editor/index.js +20 -11
  127. package/build/components/off-canvas-editor/index.js.map +1 -1
  128. package/build/components/off-canvas-editor/leaf.js +1 -1
  129. package/build/components/off-canvas-editor/leaf.js.map +1 -1
  130. package/build/components/off-canvas-editor/link-ui.js +185 -0
  131. package/build/components/off-canvas-editor/link-ui.js.map +1 -0
  132. package/build/components/off-canvas-editor/update-attributes.js +108 -0
  133. package/build/components/off-canvas-editor/update-attributes.js.map +1 -0
  134. package/build/components/rich-text/format-toolbar/index.js +8 -4
  135. package/build/components/rich-text/format-toolbar/index.js.map +1 -1
  136. package/build/components/rich-text/index.js +3 -3
  137. package/build/components/rich-text/index.js.map +1 -1
  138. package/build/components/rich-text/index.native.js +0 -2
  139. package/build/components/rich-text/index.native.js.map +1 -1
  140. package/build/components/rich-text/use-insert-replacement-text.js +43 -0
  141. package/build/components/rich-text/use-insert-replacement-text.js.map +1 -0
  142. package/build/components/rich-text/use-undo-automatic-change.js +9 -1
  143. package/build/components/rich-text/use-undo-automatic-change.js.map +1 -1
  144. package/build/components/rich-text/utils.js +1 -19
  145. package/build/components/rich-text/utils.js.map +1 -1
  146. package/build/components/spacing-sizes-control/spacing-input-control.js +12 -3
  147. package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  148. package/build/components/ungroup-button/index.native.js +4 -2
  149. package/build/components/ungroup-button/index.native.js.map +1 -1
  150. package/build/components/url-input/index.js +46 -43
  151. package/build/components/url-input/index.js.map +1 -1
  152. package/build/components/use-block-display-information/index.js +8 -4
  153. package/build/components/use-block-display-information/index.js.map +1 -1
  154. package/build/components/use-setting/index.js +9 -1
  155. package/build/components/use-setting/index.js.map +1 -1
  156. package/build/hooks/child-layout.js +209 -0
  157. package/build/hooks/child-layout.js.map +1 -0
  158. package/build/hooks/content-lock-ui.js +1 -1
  159. package/build/hooks/content-lock-ui.js.map +1 -1
  160. package/build/hooks/dimensions.js +25 -7
  161. package/build/hooks/dimensions.js.map +1 -1
  162. package/build/hooks/layout.js +57 -1
  163. package/build/hooks/layout.js.map +1 -1
  164. package/build/hooks/min-height.js +4 -10
  165. package/build/hooks/min-height.js.map +1 -1
  166. package/build/store/reducer.js +393 -270
  167. package/build/store/reducer.js.map +1 -1
  168. package/build/store/selectors.js +57 -47
  169. package/build/store/selectors.js.map +1 -1
  170. package/build/utils/sorting.js +63 -0
  171. package/build/utils/sorting.js.map +1 -0
  172. package/build-module/autocompleters/block.js +2 -6
  173. package/build-module/autocompleters/block.js.map +1 -1
  174. package/build-module/autocompleters/link.js +2 -0
  175. package/build-module/autocompleters/link.js.map +1 -1
  176. package/build-module/components/block-card/index.js +45 -3
  177. package/build-module/components/block-card/index.js.map +1 -1
  178. package/build-module/components/block-draggable/index.native.js +40 -31
  179. package/build-module/components/block-draggable/index.native.js.map +1 -1
  180. package/build-module/components/block-edit/edit.js +4 -2
  181. package/build-module/components/block-edit/edit.js.map +1 -1
  182. package/build-module/components/block-edit/edit.native.js +4 -6
  183. package/build-module/components/block-edit/edit.native.js.map +1 -1
  184. package/build-module/components/block-inspector/index.js +32 -30
  185. package/build-module/components/block-inspector/index.js.map +1 -1
  186. package/build-module/components/block-list/block-list-context.native.js +5 -8
  187. package/build-module/components/block-list/block-list-context.native.js.map +1 -1
  188. package/build-module/components/block-list/block.js +55 -25
  189. package/build-module/components/block-list/block.js.map +1 -1
  190. package/build-module/components/block-list/block.native.js +61 -28
  191. package/build-module/components/block-list/block.native.js.map +1 -1
  192. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +13 -6
  193. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  194. package/build-module/components/block-pattern-setup/index.js +3 -2
  195. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  196. package/build-module/components/block-patterns-list/index.js +35 -13
  197. package/build-module/components/block-patterns-list/index.js.map +1 -1
  198. package/build-module/components/block-preview/auto.js +9 -3
  199. package/build-module/components/block-preview/auto.js.map +1 -1
  200. package/build-module/components/block-preview/index.js +5 -8
  201. package/build-module/components/block-preview/index.js.map +1 -1
  202. package/build-module/components/block-settings-menu/block-settings-dropdown.js +5 -2
  203. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  204. package/build-module/components/block-toolbar/index.js +6 -2
  205. package/build-module/components/block-toolbar/index.js.map +1 -1
  206. package/build-module/components/block-tools/insertion-point.js +8 -49
  207. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  208. package/build-module/components/block-variation-picker/index.js +1 -2
  209. package/build-module/components/block-variation-picker/index.js.map +1 -1
  210. package/build-module/components/height-control/index.js +103 -0
  211. package/build-module/components/height-control/index.js.map +1 -0
  212. package/build-module/components/iframe/index.js +11 -8
  213. package/build-module/components/iframe/index.js.map +1 -1
  214. package/build-module/components/image-editor/use-save-image.js +2 -0
  215. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  216. package/build-module/components/image-editor/zoom-dropdown.js +1 -0
  217. package/build-module/components/image-editor/zoom-dropdown.js.map +1 -1
  218. package/build-module/components/index.js +1 -0
  219. package/build-module/components/index.js.map +1 -1
  220. package/build-module/components/inner-blocks/index.js +22 -8
  221. package/build-module/components/inner-blocks/index.js.map +1 -1
  222. package/build-module/components/inner-blocks/use-inner-block-template-sync.js +23 -10
  223. package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  224. package/build-module/components/inserter/block-patterns-explorer/sidebar.js +1 -0
  225. package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  226. package/build-module/components/inserter/block-patterns-tab.js +27 -49
  227. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  228. package/build-module/components/inserter/block-types-tab.js +3 -2
  229. package/build-module/components/inserter/block-types-tab.js.map +1 -1
  230. package/build-module/components/inserter/hooks/use-debounced-input.js +18 -0
  231. package/build-module/components/inserter/hooks/use-debounced-input.js.map +1 -0
  232. package/build-module/components/inserter/index.js +8 -3
  233. package/build-module/components/inserter/index.js.map +1 -1
  234. package/build-module/components/inserter/index.native.js +3 -5
  235. package/build-module/components/inserter/index.native.js.map +1 -1
  236. package/build-module/components/inserter/media-tab/hooks.js +89 -0
  237. package/build-module/components/inserter/media-tab/hooks.js.map +1 -0
  238. package/build-module/components/inserter/media-tab/index.js +4 -0
  239. package/build-module/components/inserter/media-tab/index.js.map +1 -0
  240. package/build-module/components/inserter/media-tab/media-list.js +86 -0
  241. package/build-module/components/inserter/media-tab/media-list.js.map +1 -0
  242. package/build-module/components/inserter/media-tab/media-panel.js +77 -0
  243. package/build-module/components/inserter/media-tab/media-panel.js.map +1 -0
  244. package/build-module/components/inserter/media-tab/media-tab.js +100 -0
  245. package/build-module/components/inserter/media-tab/media-tab.js.map +1 -0
  246. package/build-module/components/inserter/media-tab/utils.js +45 -0
  247. package/build-module/components/inserter/media-tab/utils.js.map +1 -0
  248. package/build-module/components/inserter/menu.js +33 -12
  249. package/build-module/components/inserter/menu.js.map +1 -1
  250. package/build-module/components/inserter/mobile-tab-navigation.js +61 -0
  251. package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -0
  252. package/build-module/components/inserter/quick-inserter.js +1 -0
  253. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  254. package/build-module/components/inserter/search-results.js +3 -2
  255. package/build-module/components/inserter/search-results.js.map +1 -1
  256. package/build-module/components/inserter/tabs.js +15 -2
  257. package/build-module/components/inserter/tabs.js.map +1 -1
  258. package/build-module/components/inserter-list-item/index.js +5 -2
  259. package/build-module/components/inserter-list-item/index.js.map +1 -1
  260. package/build-module/components/inspector-controls/groups.js +2 -0
  261. package/build-module/components/inspector-controls/groups.js.map +1 -1
  262. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js +32 -0
  263. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
  264. package/build-module/components/inspector-controls-tabs/index.js +56 -0
  265. package/build-module/components/inspector-controls-tabs/index.js.map +1 -0
  266. package/build-module/components/inspector-controls-tabs/settings-tab.js +17 -0
  267. package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -0
  268. package/build-module/components/inspector-controls-tabs/styles-tab.js +46 -0
  269. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -0
  270. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +81 -0
  271. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
  272. package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +8 -0
  273. package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
  274. package/build-module/components/inspector-controls-tabs/utils.js +26 -0
  275. package/build-module/components/inspector-controls-tabs/utils.js.map +1 -0
  276. package/build-module/components/link-control/index.js +1 -0
  277. package/build-module/components/link-control/index.js.map +1 -1
  278. package/build-module/components/link-control/search-input.js +0 -1
  279. package/build-module/components/link-control/search-input.js.map +1 -1
  280. package/build-module/components/link-control/use-internal-input-value.js +3 -3
  281. package/build-module/components/link-control/use-internal-input-value.js.map +1 -1
  282. package/build-module/components/list-view/block.js +5 -2
  283. package/build-module/components/list-view/block.js.map +1 -1
  284. package/build-module/components/list-view/branch.js +12 -11
  285. package/build-module/components/list-view/branch.js.map +1 -1
  286. package/build-module/components/media-upload/index.native.js +2 -4
  287. package/build-module/components/media-upload/index.native.js.map +1 -1
  288. package/build-module/components/off-canvas-editor/appender.js +89 -0
  289. package/build-module/components/off-canvas-editor/appender.js.map +1 -0
  290. package/build-module/components/off-canvas-editor/block-edit-button.js +35 -0
  291. package/build-module/components/off-canvas-editor/block-edit-button.js.map +1 -0
  292. package/build-module/components/off-canvas-editor/block.js +36 -6
  293. package/build-module/components/off-canvas-editor/block.js.map +1 -1
  294. package/build-module/components/off-canvas-editor/branch.js +3 -4
  295. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  296. package/build-module/components/off-canvas-editor/index.js +20 -12
  297. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  298. package/build-module/components/off-canvas-editor/leaf.js +1 -1
  299. package/build-module/components/off-canvas-editor/leaf.js.map +1 -1
  300. package/build-module/components/off-canvas-editor/link-ui.js +165 -0
  301. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -0
  302. package/build-module/components/off-canvas-editor/update-attributes.js +97 -0
  303. package/build-module/components/off-canvas-editor/update-attributes.js.map +1 -0
  304. package/build-module/components/rich-text/format-toolbar/index.js +6 -2
  305. package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
  306. package/build-module/components/rich-text/index.js +2 -3
  307. package/build-module/components/rich-text/index.js.map +1 -1
  308. package/build-module/components/rich-text/index.native.js +0 -2
  309. package/build-module/components/rich-text/index.native.js.map +1 -1
  310. package/build-module/components/rich-text/use-insert-replacement-text.js +33 -0
  311. package/build-module/components/rich-text/use-insert-replacement-text.js.map +1 -0
  312. package/build-module/components/rich-text/use-undo-automatic-change.js +9 -1
  313. package/build-module/components/rich-text/use-undo-automatic-change.js.map +1 -1
  314. package/build-module/components/rich-text/utils.js +1 -16
  315. package/build-module/components/rich-text/utils.js.map +1 -1
  316. package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -3
  317. package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  318. package/build-module/components/ungroup-button/index.native.js +3 -2
  319. package/build-module/components/ungroup-button/index.native.js.map +1 -1
  320. package/build-module/components/url-input/index.js +46 -43
  321. package/build-module/components/url-input/index.js.map +1 -1
  322. package/build-module/components/use-block-display-information/index.js +9 -5
  323. package/build-module/components/use-block-display-information/index.js.map +1 -1
  324. package/build-module/components/use-setting/index.js +8 -1
  325. package/build-module/components/use-setting/index.js.map +1 -1
  326. package/build-module/hooks/child-layout.js +189 -0
  327. package/build-module/hooks/child-layout.js.map +1 -0
  328. package/build-module/hooks/content-lock-ui.js +1 -1
  329. package/build-module/hooks/content-lock-ui.js.map +1 -1
  330. package/build-module/hooks/dimensions.js +25 -8
  331. package/build-module/hooks/dimensions.js.map +1 -1
  332. package/build-module/hooks/layout.js +55 -0
  333. package/build-module/hooks/layout.js.map +1 -1
  334. package/build-module/hooks/min-height.js +3 -9
  335. package/build-module/hooks/min-height.js.map +1 -1
  336. package/build-module/store/reducer.js +391 -271
  337. package/build-module/store/reducer.js.map +1 -1
  338. package/build-module/store/selectors.js +54 -47
  339. package/build-module/store/selectors.js.map +1 -1
  340. package/build-module/utils/sorting.js +56 -0
  341. package/build-module/utils/sorting.js.map +1 -0
  342. package/build-style/content-rtl.css +701 -0
  343. package/build-style/content.css +701 -0
  344. package/build-style/default-editor-styles-rtl.css +14 -0
  345. package/build-style/default-editor-styles.css +14 -0
  346. package/build-style/style-rtl.css +286 -662
  347. package/build-style/style.css +286 -662
  348. package/package.json +32 -30
  349. package/src/autocompleters/block.js +2 -6
  350. package/src/autocompleters/link.js +2 -0
  351. package/src/components/alignment-control/test/index.js +4 -1
  352. package/src/components/block-alignment-control/test/index.js +4 -1
  353. package/src/components/block-card/index.js +46 -2
  354. package/src/components/block-card/style.scss +4 -0
  355. package/src/components/block-content-overlay/{style.scss → content.scss} +7 -1
  356. package/src/components/block-draggable/content.scss +20 -0
  357. package/src/components/block-draggable/index.native.js +54 -40
  358. package/src/components/block-draggable/style.scss +0 -21
  359. package/src/components/block-draggable/test/helpers.native.js +7 -9
  360. package/src/components/block-draggable/test/index.native.js +35 -45
  361. package/src/components/block-edit/edit.js +5 -2
  362. package/src/components/block-edit/edit.native.js +5 -6
  363. package/src/components/block-inspector/index.js +96 -81
  364. package/src/components/block-inspector/style.scss +9 -1
  365. package/src/components/block-list/block-list-context.native.js +5 -8
  366. package/src/components/block-list/block.js +74 -23
  367. package/src/components/block-list/block.native.js +78 -23
  368. package/src/components/block-list/{style.scss → content.scss} +1 -15
  369. package/src/components/block-list-appender/{style.scss → content.scss} +0 -0
  370. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +24 -6
  371. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +0 -2
  372. package/src/components/block-pattern-setup/index.js +2 -1
  373. package/src/components/block-patterns-list/index.js +47 -24
  374. package/src/components/block-preview/README.md +15 -10
  375. package/src/components/block-preview/auto.js +7 -1
  376. package/src/components/block-preview/content.scss +4 -0
  377. package/src/components/block-preview/index.js +7 -12
  378. package/src/components/block-preview/style.scss +0 -7
  379. package/src/components/block-preview/test/index.js +18 -35
  380. package/src/components/block-selection-clearer/test/index.js +12 -12
  381. package/src/components/block-settings-menu/block-settings-dropdown.js +32 -20
  382. package/src/components/block-switcher/test/index.js +4 -0
  383. package/src/components/block-toolbar/index.js +12 -5
  384. package/src/components/block-toolbar/style.scss +10 -0
  385. package/src/components/block-tools/insertion-point.js +3 -47
  386. package/src/components/block-tools/style.scss +12 -5
  387. package/src/components/block-variation-picker/index.js +1 -4
  388. package/src/components/block-vertical-alignment-control/test/index.js +4 -1
  389. package/src/components/default-block-appender/{style.scss → content.scss} +0 -0
  390. package/src/components/height-control/index.js +123 -0
  391. package/src/components/height-control/stories/index.js +21 -0
  392. package/src/components/height-control/style.scss +5 -0
  393. package/src/components/iframe/index.js +25 -18
  394. package/src/components/image-editor/use-save-image.js +2 -0
  395. package/src/components/image-editor/zoom-dropdown.js +1 -0
  396. package/src/components/index.js +1 -0
  397. package/src/components/inner-blocks/{style.scss → content.scss} +0 -0
  398. package/src/components/inner-blocks/index.js +23 -6
  399. package/src/components/inner-blocks/use-inner-block-template-sync.js +28 -10
  400. package/src/components/inserter/block-patterns-explorer/sidebar.js +1 -0
  401. package/src/components/inserter/block-patterns-tab.js +28 -71
  402. package/src/components/inserter/block-types-tab.js +3 -2
  403. package/src/components/inserter/hooks/use-debounced-input.js +17 -0
  404. package/src/components/inserter/index.js +10 -2
  405. package/src/components/inserter/index.native.js +1 -1
  406. package/src/components/inserter/media-tab/hooks.js +88 -0
  407. package/src/components/inserter/media-tab/index.js +3 -0
  408. package/src/components/inserter/media-tab/media-list.js +93 -0
  409. package/src/components/inserter/media-tab/media-panel.js +83 -0
  410. package/src/components/inserter/media-tab/media-tab.js +135 -0
  411. package/src/components/inserter/media-tab/utils.js +37 -0
  412. package/src/components/inserter/menu.js +55 -13
  413. package/src/components/inserter/mobile-tab-navigation.js +85 -0
  414. package/src/components/inserter/quick-inserter.js +1 -0
  415. package/src/components/inserter/search-results.js +3 -2
  416. package/src/components/inserter/stories/index.js +1 -1
  417. package/src/components/inserter/stories/{fixtures.js → utils/fixtures.js} +0 -0
  418. package/src/components/inserter/style.scss +176 -11
  419. package/src/components/inserter/tabs.js +12 -1
  420. package/src/components/inserter-list-item/index.js +11 -1
  421. package/src/components/inserter-list-item/style.scss +26 -0
  422. package/src/components/inspector-controls/groups.js +2 -0
  423. package/src/components/inspector-controls-tabs/advanced-controls-panel.js +37 -0
  424. package/src/components/inspector-controls-tabs/index.js +62 -0
  425. package/src/components/inspector-controls-tabs/settings-tab.js +18 -0
  426. package/src/components/inspector-controls-tabs/styles-tab.js +51 -0
  427. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +89 -0
  428. package/src/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +9 -0
  429. package/src/components/inspector-controls-tabs/utils.js +28 -0
  430. package/src/components/line-height-control/test/index.js +5 -5
  431. package/src/components/link-control/README.md +1 -1
  432. package/src/components/link-control/index.js +1 -0
  433. package/src/components/link-control/search-input.js +0 -1
  434. package/src/components/link-control/test/index.js +188 -401
  435. package/src/components/link-control/use-internal-input-value.js +3 -3
  436. package/src/components/list-view/block.js +3 -0
  437. package/src/components/list-view/branch.js +10 -8
  438. package/src/components/list-view/style.scss +20 -9
  439. package/src/components/media-placeholder/{style.scss → content.scss} +0 -0
  440. package/src/components/media-replace-flow/test/index.js +37 -9
  441. package/src/components/media-upload/test/index.native.js +2 -0
  442. package/src/components/off-canvas-editor/appender.js +93 -0
  443. package/src/components/off-canvas-editor/block-edit-button.js +27 -0
  444. package/src/components/off-canvas-editor/block.js +88 -22
  445. package/src/components/off-canvas-editor/branch.js +3 -5
  446. package/src/components/off-canvas-editor/index.js +59 -33
  447. package/src/components/off-canvas-editor/leaf.js +5 -1
  448. package/src/components/off-canvas-editor/link-ui.js +166 -0
  449. package/src/components/off-canvas-editor/style.scss +17 -388
  450. package/src/components/off-canvas-editor/update-attributes.js +99 -0
  451. package/src/components/plain-text/{style.scss → content.scss} +0 -0
  452. package/src/components/recursion-provider/test/index.js +27 -29
  453. package/src/components/rich-text/content.scss +42 -0
  454. package/src/components/rich-text/format-toolbar/index.js +6 -4
  455. package/src/components/rich-text/index.js +2 -2
  456. package/src/components/rich-text/index.native.js +0 -2
  457. package/src/components/rich-text/style.scss +0 -43
  458. package/src/components/rich-text/use-insert-replacement-text.js +31 -0
  459. package/src/components/rich-text/use-undo-automatic-change.js +7 -1
  460. package/src/components/rich-text/utils.js +2 -21
  461. package/src/components/spacing-sizes-control/spacing-input-control.js +9 -0
  462. package/src/components/ungroup-button/index.native.js +6 -2
  463. package/src/components/url-input/index.js +57 -73
  464. package/src/components/url-popover/test/__snapshots__/index.js.snap +8 -6
  465. package/src/components/url-popover/test/index.js +21 -9
  466. package/src/components/use-block-display-information/index.js +14 -5
  467. package/src/components/use-setting/index.js +13 -1
  468. package/src/components/use-setting/test/index.js +99 -0
  469. package/src/content.scss +10 -0
  470. package/src/hooks/child-layout.js +190 -0
  471. package/src/hooks/content-lock-ui.js +1 -1
  472. package/src/hooks/dimensions.js +45 -7
  473. package/src/hooks/layout.js +60 -0
  474. package/src/hooks/min-height.js +2 -19
  475. package/src/store/reducer.js +459 -423
  476. package/src/store/selectors.js +56 -57
  477. package/src/store/test/performance.js +71 -0
  478. package/src/store/test/reducer.js +623 -491
  479. package/src/store/test/selectors.js +1820 -1306
  480. package/src/style.scss +4 -7
  481. package/src/utils/sorting.js +54 -0
  482. package/src/utils/test/sorting.js +49 -0
  483. package/tsconfig.tsbuildinfo +1 -1
  484. package/build/components/block-preview/live.js +0 -30
  485. package/build/components/block-preview/live.js.map +0 -1
  486. package/build-module/components/block-preview/live.js +0 -20
  487. package/build-module/components/block-preview/live.js.map +0 -1
  488. package/src/components/block-preview/live.js +0 -19
@@ -1,397 +1,26 @@
1
- .block-editor-list-view-tree {
2
- width: 100%;
3
- border-collapse: collapse;
1
+ .offcanvas-editor__appender .block-editor-inserter__toggle {
2
+ background-color: #1e1e1e;
3
+ color: #fff;
4
+ margin: $grid-unit-10 0 0 28px;
5
+ border-radius: 2px;
6
+ height: 24px;
7
+ min-width: 24px;
4
8
  padding: 0;
5
- margin: 0;
6
9
 
7
- // Move upwards when in modal.
8
- .components-modal__content & {
9
- margin: (-$grid-unit-15) (-$grid-unit-15 * 0.5) 0;
10
- width: calc(100% + #{ $grid-unit-15 });
11
- }
12
- }
13
-
14
- .block-editor-list-view-leaf {
15
- // Use position relative for row animation.
16
- position: relative;
17
-
18
- // The background has to be applied to the td, not tr, or border-radius won't work.
19
- &.is-selected td {
10
+ &:hover,
11
+ &:focus {
20
12
  background: var(--wp-admin-theme-color);
21
- }
22
- &.is-selected .block-editor-list-view-block-contents,
23
- &.is-selected .components-button.has-icon {
24
- color: $white;
25
- }
26
- &.is-selected .block-editor-list-view-block-contents {
27
- // Hide selection styles while a user is dragging blocks/files etc.
28
- .is-dragging-components-draggable & {
29
- background: none;
30
- color: $gray-900;
31
- }
32
- }
33
- &.is-selected .block-editor-list-view-block-contents:focus {
34
- &::after {
35
- box-shadow:
36
- inset 0 0 0 1px $white,
37
- 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
38
- }
39
- }
40
- &.is-selected .block-editor-list-view-block__menu:focus {
41
- box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $white;
42
- }
43
-
44
- &.is-dragging {
45
- display: none;
46
- }
47
-
48
- // Border radius for corners of the selected item.
49
- &.is-first-selected td:first-child {
50
- border-top-left-radius: $radius-block-ui;
51
- }
52
- &.is-first-selected td:last-child {
53
- border-top-right-radius: $radius-block-ui;
54
- }
55
- &.is-last-selected td:first-child {
56
- border-bottom-left-radius: $radius-block-ui;
57
- }
58
- &.is-last-selected td:last-child {
59
- border-bottom-right-radius: $radius-block-ui;
60
- }
61
- &.is-branch-selected:not(.is-selected) {
62
- // Lighten a CSS variable without introducing a new SASS variable
63
- background:
64
- linear-gradient(transparentize($white, 0.1), transparentize($white, 0.1)),
65
- linear-gradient(var(--wp-admin-theme-color), var(--wp-admin-theme-color));
66
- }
67
- &.is-branch-selected.is-first-selected td:first-child {
68
- border-top-left-radius: $radius-block-ui;
69
- }
70
- &.is-branch-selected.is-first-selected td:last-child {
71
- border-top-right-radius: $radius-block-ui;
72
- }
73
- &[aria-expanded="false"] {
74
- &.is-branch-selected.is-first-selected td:first-child {
75
- border-top-left-radius: $radius-block-ui;
76
- }
77
- &.is-branch-selected.is-first-selected td:last-child {
78
- border-top-right-radius: $radius-block-ui;
79
- }
80
- &.is-branch-selected.is-last-selected td:first-child {
81
- border-bottom-left-radius: $radius-block-ui;
82
- }
83
- &.is-branch-selected.is-last-selected td:last-child {
84
- border-bottom-right-radius: $radius-block-ui;
85
- }
86
- }
87
- &.is-branch-selected:not(.is-selected) td {
88
- border-radius: 0;
89
- }
90
-
91
-
92
- // List View renders a fixed number of items and relies on each item having a fixed height of 36px.
93
- // If this value changes, we should also change the itemHeight value set in useFixedWindowList.
94
- // See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.
95
- .block-editor-list-view-block-contents {
96
- display: flex;
97
- align-items: center;
98
- width: 100%;
99
- height: auto;
100
- padding: ($grid-unit-15 * 0.5) $grid-unit-05 ($grid-unit-15 * 0.5) 0;
101
- text-align: left;
102
- color: $gray-900;
103
- border-radius: $radius-block-ui;
104
- position: relative;
105
- white-space: nowrap;
106
-
107
- &.is-dropping-before::before {
108
- content: "";
109
- position: absolute;
110
- pointer-events: none;
111
- transition: border-color 0.1s linear, border-style 0.1s linear, box-shadow 0.1s linear;
112
- top: -2px;
113
- right: 0;
114
- left: 0;
115
- border-top: 4px solid var(--wp-admin-theme-color);
116
- }
117
-
118
- .components-modal__content & {
119
- padding-left: 0;
120
- padding-right: 0;
121
- }
122
- }
123
-
124
- .block-editor-list-view-block-contents:focus {
125
- box-shadow: none;
126
-
127
- &::after {
128
- content: "";
129
- position: absolute;
130
- top: 0;
131
- right: -(24px + 5px); // Icon size + padding.
132
- bottom: 0;
133
- left: 0;
134
- border-radius: inherit;
135
- box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
136
- z-index: 2;
137
- pointer-events: none;
138
-
139
- // Hide focus styles while a user is dragging blocks/files etc.
140
- .is-dragging-components-draggable & {
141
- box-shadow: none;
142
- }
143
- }
144
- }
145
- // Fix focus styling width when one row has fewer cells.
146
- &.has-single-cell .block-editor-list-view-block-contents:focus::after {
147
- right: 0;
148
- }
149
-
150
- .block-editor-list-view-block__menu:focus {
151
- box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
152
- z-index: 1;
153
-
154
- // Hide focus styles while a user is dragging blocks/files etc.
155
- .is-dragging-components-draggable & {
156
- box-shadow: none;
157
- }
158
- }
159
-
160
- &.is-visible .block-editor-list-view-block-contents {
161
- opacity: 1;
162
- @include edit-post__fade-in-animation;
163
- }
164
-
165
- .block-editor-block-icon {
166
- align-self: flex-start;
167
- margin-right: $grid-unit-10;
168
- width: $icon-size;
169
- }
170
-
171
- .block-editor-list-view-block__menu-cell,
172
- .block-editor-list-view-block__mover-cell,
173
- .block-editor-list-view-block__contents-cell {
174
- padding-top: 0;
175
- padding-bottom: 0;
176
- }
177
-
178
- .block-editor-list-view-block__menu-cell,
179
- .block-editor-list-view-block__mover-cell {
180
- line-height: 0;
181
- width: $button-size;
182
- vertical-align: middle;
183
- @include reduce-motion("transition");
184
-
185
- > * {
186
- opacity: 0;
187
- }
188
-
189
- // Show on hover, visible, and show above to keep the hit area size.
190
- &:hover,
191
- &.is-visible {
192
- position: relative;
193
- z-index: 1;
194
-
195
- > * {
196
- opacity: 1;
197
- @include edit-post__fade-in-animation;
198
- }
199
- }
200
-
201
- &,
202
- .components-button.has-icon {
203
- width: 24px;
204
- min-width: 24px;
205
- padding: 0;
206
- }
207
- }
208
-
209
- .block-editor-list-view-block__menu-cell {
210
- padding-right: $grid-unit-05;
211
-
212
- .components-button.has-icon {
213
- height: 24px;
214
- }
215
- }
216
-
217
- .block-editor-list-view-block__mover-cell-alignment-wrapper {
218
- display: flex;
219
- height: 100%;
220
- flex-direction: column;
221
- align-items: center;
222
- }
223
-
224
- // Keep the tap target large but the focus target small.
225
- .block-editor-block-mover-button {
226
- position: relative;
227
- width: $button-size;
228
- height: $button-size-small;
229
-
230
- // Position the icon.
231
- svg {
232
- position: relative;
233
- height: $button-size-small;
234
- }
235
-
236
- &.is-up-button {
237
- margin-top: -$grid-unit-15 * 0.5;
238
- align-items: flex-end;
239
- svg {
240
- bottom: -$grid-unit-05;
241
- }
242
- }
243
-
244
- &.is-down-button {
245
- margin-bottom: -$grid-unit-15 * 0.5;
246
- align-items: flex-start;
247
- svg {
248
- top: -$grid-unit-05;
249
- }
250
- }
251
-
252
- // Tweak size and position of focus ring.
253
- &::before {
254
- height: 16px;
255
- min-width: 100%;
256
- left: 0;
257
- right: 0;
258
- }
259
- }
260
-
261
- .block-editor-inserter__toggle {
262
- background: $gray-900;
263
- color: $white;
264
- height: $grid-unit-30;
265
- margin: 6px 6px 6px 1px;
266
- min-width: $grid-unit-30;
267
-
268
- &:active {
269
- color: $white;
270
- }
271
- }
272
-
273
- .block-editor-list-view-block-select-button__label-wrapper {
274
- min-width: 120px;
275
- }
276
-
277
- .block-editor-list-view-block-select-button__title {
278
- flex: 1;
279
- position: relative;
280
-
281
- .components-truncate {
282
- position: absolute;
283
- width: 100%;
284
- transform: translateY(-50%);
285
- }
286
- }
287
-
288
- .block-editor-list-view-block-select-button__anchor-wrapper {
289
- position: relative;
290
- max-width: min(110px, 40%);
291
- width: 100%;
292
- }
293
-
294
- .block-editor-list-view-block-select-button__anchor {
295
- position: absolute;
296
- right: 0;
297
- transform: translateY(-50%);
298
- background: rgba($black, 0.1);
299
- border-radius: $radius-block-ui;
300
- padding: 2px 6px;
301
- max-width: 100%;
302
- box-sizing: border-box;
303
- }
304
-
305
- &.is-selected .block-editor-list-view-block-select-button__anchor {
306
- background: rgba($black, 0.3);
307
- }
308
-
309
- .block-editor-list-view-block-select-button__lock {
310
- line-height: 0;
311
- width: 24px;
312
- min-width: 24px;
313
- margin-left: auto;
314
- padding: 0;
315
- vertical-align: middle;
13
+ color: #fff;
316
14
  }
317
15
  }
318
16
 
319
- .block-editor-list-view-block-select-button__description,
320
- .block-editor-list-view-appender__description {
321
- display: none;
17
+ .offcanvas-editor-list-view-tree-wrapper {
18
+ max-width: 100%;
19
+ overflow-x: auto;
322
20
  }
323
21
 
324
- .block-editor-list-view-block__contents-cell,
325
- .block-editor-list-view-appender__cell {
326
- .block-editor-list-view-block__contents-container,
327
- .block-editor-list-view-appender__container {
328
- display: flex;
329
- }
22
+ .offcanvas-editor-list-view-leaf {
23
+ display: block;
24
+ // sidebar width - tab panel padding
25
+ max-width: $sidebar-width - (2 * $grid-unit-20);
330
26
  }
331
-
332
- // Chevron container metrics.
333
- .block-editor-list-view__expander {
334
- height: $icon-size;
335
- margin-left: $grid-unit-05;
336
- width: $icon-size;
337
- }
338
-
339
- // First level of indentation is aria-level 2, max indent is 8.
340
- // Indent is a full icon size, plus 4px which optically aligns child icons to the text label above.
341
- $block-navigation-max-indent: 8;
342
- .block-editor-list-view-leaf[aria-level] .block-editor-list-view__expander {
343
- margin-left: ( $icon-size ) * $block-navigation-max-indent + 4 * ( $block-navigation-max-indent - 1 );
344
- }
345
-
346
- .block-editor-list-view-leaf:not([aria-level="1"]) {
347
- .block-editor-list-view__expander {
348
- margin-right: 4px;
349
- }
350
- }
351
-
352
- @for $i from 0 to $block-navigation-max-indent {
353
- .block-editor-list-view-leaf[aria-level="#{ $i + 1 }"] .block-editor-list-view__expander {
354
- @if $i - 1 >= 0 {
355
- margin-left: ( $icon-size * $i ) + 4 * ($i - 1);
356
- }
357
- @else {
358
- margin-left: ( $icon-size * $i );
359
- }
360
- }
361
- }
362
-
363
- .block-editor-list-view-leaf .block-editor-list-view__expander {
364
- visibility: hidden;
365
- }
366
-
367
- // Point downwards when open.
368
- .block-editor-list-view-leaf[aria-expanded="true"] .block-editor-list-view__expander svg {
369
- visibility: visible;
370
- transition: transform 0.2s ease;
371
- transform: rotate(90deg);
372
- @include reduce-motion("transition");
373
- }
374
-
375
- // Point rightwards when closed
376
- .block-editor-list-view-leaf[aria-expanded="false"] .block-editor-list-view__expander svg {
377
- visibility: visible;
378
- transform: rotate(0deg);
379
- transition: transform 0.2s ease;
380
- @include reduce-motion("transition");
381
- }
382
-
383
- .block-editor-list-view-drop-indicator {
384
- pointer-events: none;
385
-
386
- .block-editor-list-view-drop-indicator__line {
387
- background: var(--wp-admin-theme-color);
388
- height: $border-width;
389
- }
390
- }
391
-
392
- .block-editor-list-view-placeholder {
393
- padding: 0;
394
- margin: 0;
395
- height: 36px;
396
- }
397
-
@@ -0,0 +1,99 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { escapeHTML } from '@wordpress/escape-html';
5
+ import { safeDecodeURI } from '@wordpress/url';
6
+
7
+ /**
8
+ * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind
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
+ * Link Control onChange handler that updates block attributes when a setting is changed.
26
+ *
27
+ * @param {Object} updatedValue New block attributes to update.
28
+ * @param {Function} setAttributes Block attribute update function.
29
+ * @param {WPNavigationLinkBlockAttributes} blockAttributes Current block attributes.
30
+ *
31
+ */
32
+
33
+ export const updateAttributes = (
34
+ updatedValue = {},
35
+ setAttributes,
36
+ blockAttributes = {}
37
+ ) => {
38
+ const {
39
+ label: originalLabel = '',
40
+ kind: originalKind = '',
41
+ type: originalType = '',
42
+ } = blockAttributes;
43
+
44
+ const {
45
+ title: newLabel = '', // the title of any provided Post.
46
+ url: newUrl = '',
47
+ opensInNewTab,
48
+ id,
49
+ kind: newKind = originalKind,
50
+ type: newType = originalType,
51
+ } = updatedValue;
52
+
53
+ const newLabelWithoutHttp = newLabel.replace( /http(s?):\/\//gi, '' );
54
+ const newUrlWithoutHttp = newUrl.replace( /http(s?):\/\//gi, '' );
55
+
56
+ const useNewLabel =
57
+ newLabel &&
58
+ newLabel !== originalLabel &&
59
+ // LinkControl without the title field relies
60
+ // on the check below. Specifically, it assumes that
61
+ // the URL is the same as a title.
62
+ // This logic a) looks suspicious and b) should really
63
+ // live in the LinkControl and not here. It's a great
64
+ // candidate for future refactoring.
65
+ newLabelWithoutHttp !== newUrlWithoutHttp;
66
+
67
+ // Unfortunately this causes the escaping model to be inverted.
68
+ // The escaped content is stored in the block attributes (and ultimately in the database),
69
+ // and then the raw data is "recovered" when outputting into the DOM.
70
+ // It would be preferable to store the **raw** data in the block attributes and escape it in JS.
71
+ // Why? Because there isn't one way to escape data. Depending on the context, you need to do
72
+ // different transforms. It doesn't make sense to me to choose one of them for the purposes of storage.
73
+ // See also:
74
+ // - https://github.com/WordPress/gutenberg/pull/41063
75
+ // - https://github.com/WordPress/gutenberg/pull/18617.
76
+ const label = useNewLabel
77
+ ? escapeHTML( newLabel )
78
+ : originalLabel || escapeHTML( newUrlWithoutHttp );
79
+
80
+ // In https://github.com/WordPress/gutenberg/pull/24670 we decided to use "tag" in favor of "post_tag"
81
+ const type = newType === 'post_tag' ? 'tag' : newType.replace( '-', '_' );
82
+
83
+ const isBuiltInType =
84
+ [ 'post', 'page', 'tag', 'category' ].indexOf( type ) > -1;
85
+
86
+ const isCustomLink =
87
+ ( ! newKind && ! isBuiltInType ) || newKind === 'custom';
88
+ const kind = isCustomLink ? 'custom' : newKind;
89
+
90
+ setAttributes( {
91
+ // Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.
92
+ ...( newUrl && { url: encodeURI( safeDecodeURI( newUrl ) ) } ),
93
+ ...( label && { label } ),
94
+ ...( undefined !== opensInNewTab && { opensInNewTab } ),
95
+ ...( id && Number.isInteger( id ) && { id } ),
96
+ ...( kind && { kind } ),
97
+ ...( type && type !== 'URL' && { type } ),
98
+ } );
99
+ };
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { render } from '@testing-library/react';
4
+ import { render, screen } from '@testing-library/react';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -19,12 +19,12 @@ function Edit( { attributes: { uniqueId } } ) {
19
19
  const hasRecursion = useHasRecursion( uniqueId );
20
20
 
21
21
  if ( hasRecursion ) {
22
- return <div className={ `wp-block__${ name }--halted` }>Halt</div>;
22
+ return <div data-testid={ `wp-block__${ name }--halted` }>Halt</div>;
23
23
  }
24
24
 
25
25
  return (
26
26
  <RecursionProvider uniqueId={ uniqueId }>
27
- <div className={ `wp-block__${ name }` }>
27
+ <div data-testid={ `wp-block__${ name }` }>
28
28
  { uniqueId === 'SIMPLE' && <p>Done</p> }
29
29
  { uniqueId === 'SINGLY-RECURSIVE' && (
30
30
  <Edit attributes={ { uniqueId } } />
@@ -51,76 +51,74 @@ describe( 'useHasRecursion/RecursionProvider', () => {
51
51
  const context = { name: 'reusable-block' };
52
52
 
53
53
  it( 'allows a single block to render', () => {
54
- const { container } = render(
54
+ render(
55
55
  <BlockEditContextProvider value={ context }>
56
56
  <Edit attributes={ { uniqueId: 'SIMPLE' } } />
57
57
  </BlockEditContextProvider>
58
58
  );
59
59
  expect(
60
- container.querySelectorAll( '.wp-block__reusable-block' )
61
- ).toHaveLength( 1 );
60
+ screen.getByTestId( 'wp-block__reusable-block' )
61
+ ).toBeVisible();
62
62
  expect(
63
- container.querySelectorAll( '.wp-block__reusable-block--halted' )
64
- ).toHaveLength( 0 );
63
+ screen.queryByTestId( 'wp-block__reusable-block--halted' )
64
+ ).not.toBeInTheDocument();
65
65
  } );
66
66
 
67
67
  it( 'allows equal but sibling blocks to render', () => {
68
- const { container } = render(
68
+ render(
69
69
  <BlockEditContextProvider value={ context }>
70
70
  <Edit attributes={ { uniqueId: 'SIMPLE' } } />
71
71
  <Edit attributes={ { uniqueId: 'SIMPLE' } } />
72
72
  </BlockEditContextProvider>
73
73
  );
74
74
  expect(
75
- container.querySelectorAll( '.wp-block__reusable-block' )
75
+ screen.getAllByTestId( 'wp-block__reusable-block' )
76
76
  ).toHaveLength( 2 );
77
77
  expect(
78
- container.querySelectorAll( '.wp-block__reusable-block--halted' )
79
- ).toHaveLength( 0 );
78
+ screen.queryByTestId( 'wp-block__reusable-block--halted' )
79
+ ).not.toBeInTheDocument();
80
80
  } );
81
81
 
82
82
  it( 'prevents a block from rendering itself', () => {
83
- const { container } = render(
83
+ render(
84
84
  <BlockEditContextProvider value={ context }>
85
85
  <Edit attributes={ { uniqueId: 'SINGLY-RECURSIVE' } } />
86
86
  </BlockEditContextProvider>
87
87
  );
88
88
  expect(
89
- container.querySelectorAll( '.wp-block__reusable-block' )
90
- ).toHaveLength( 1 );
89
+ screen.getByTestId( 'wp-block__reusable-block' )
90
+ ).toBeVisible();
91
91
  expect(
92
- container.querySelectorAll( '.wp-block__reusable-block--halted' )
93
- ).toHaveLength( 1 );
92
+ screen.getByTestId( 'wp-block__reusable-block--halted' )
93
+ ).toBeVisible();
94
94
  } );
95
95
 
96
96
  it( 'prevents a block from rendering itself only when the same block type', () => {
97
- const { container } = render(
97
+ render(
98
98
  <BlockEditContextProvider value={ context }>
99
99
  <Edit attributes={ { uniqueId: 'ANOTHER-BLOCK-SAME-ID' } } />
100
100
  </BlockEditContextProvider>
101
101
  );
102
102
  expect(
103
- container.querySelectorAll( '.wp-block__reusable-block' )
104
- ).toHaveLength( 1 );
103
+ screen.getByTestId( 'wp-block__reusable-block' )
104
+ ).toBeVisible();
105
+ expect( screen.getByTestId( 'wp-block__another-block' ) ).toBeVisible();
105
106
  expect(
106
- container.querySelectorAll( '.wp-block__another-block' )
107
- ).toHaveLength( 1 );
108
- expect(
109
- container.querySelectorAll( '.wp-block__another-block--halted' )
110
- ).toHaveLength( 1 );
107
+ screen.getByTestId( 'wp-block__another-block--halted' )
108
+ ).toBeVisible();
111
109
  } );
112
110
 
113
111
  it( 'prevents mutual recursion between two blocks', () => {
114
- const { container } = render(
112
+ render(
115
113
  <BlockEditContextProvider value={ context }>
116
114
  <Edit attributes={ { uniqueId: 'MUTUALLY-RECURSIVE-1' } } />
117
115
  </BlockEditContextProvider>
118
116
  );
119
117
  expect(
120
- container.querySelectorAll( '.wp-block__reusable-block' )
118
+ screen.getAllByTestId( 'wp-block__reusable-block' )
121
119
  ).toHaveLength( 2 );
122
120
  expect(
123
- container.querySelectorAll( '.wp-block__reusable-block--halted' )
124
- ).toHaveLength( 1 );
121
+ screen.getByTestId( 'wp-block__reusable-block--halted' )
122
+ ).toBeVisible();
125
123
  } );
126
124
  } );
@@ -0,0 +1,42 @@
1
+ .rich-text {
2
+ [data-rich-text-placeholder] {
3
+ pointer-events: none;
4
+ }
5
+
6
+ [data-rich-text-placeholder]::after {
7
+ content: attr(data-rich-text-placeholder);
8
+ // Use opacity to work in various editor styles.
9
+ // We don't specify the color here, because blocks or editor styles might provide their own.
10
+ opacity: 0.62;
11
+ }
12
+
13
+ &:focus {
14
+ // Removes outline added by the browser.
15
+ outline: none;
16
+
17
+ [data-rich-text-format-boundary] {
18
+ border-radius: 2px;
19
+ }
20
+ }
21
+ }
22
+
23
+ .block-editor-rich-text__editable {
24
+ > p:first-child {
25
+ margin-top: 0;
26
+ }
27
+ }
28
+
29
+ // Captions may have lighter (gray) text, or be shown on a range of different background luminosites.
30
+ // To ensure legibility, we increase the default placeholder opacity to ensure contrast.
31
+ figcaption.block-editor-rich-text__editable [data-rich-text-placeholder]::before {
32
+ opacity: 0.8;
33
+ }
34
+
35
+ [data-rich-text-script] {
36
+ display: inline;
37
+
38
+ &::before {
39
+ content: "</>";
40
+ background: rgb(255, 255, 0);
41
+ }
42
+ }