@wordpress/block-library 8.6.0 → 8.8.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 (425) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/buttons/index.js +1 -0
  3. package/build/buttons/index.js.map +1 -1
  4. package/build/buttons/transforms.js +1 -0
  5. package/build/buttons/transforms.js.map +1 -1
  6. package/build/column/index.js +2 -1
  7. package/build/column/index.js.map +1 -1
  8. package/build/columns/edit.js +28 -8
  9. package/build/columns/edit.js.map +1 -1
  10. package/build/columns/index.js +6 -1
  11. package/build/columns/index.js.map +1 -1
  12. package/build/columns/utils.js +4 -9
  13. package/build/columns/utils.js.map +1 -1
  14. package/build/cover/edit/index.js +46 -50
  15. package/build/cover/edit/index.js.map +1 -1
  16. package/build/cover/edit/inspector-controls.js +2 -2
  17. package/build/cover/edit/inspector-controls.js.map +1 -1
  18. package/build/cover/edit/{resizable-cover.js → resizable-cover-popover.js} +32 -6
  19. package/build/cover/edit/resizable-cover-popover.js.map +1 -0
  20. package/build/cover/index.js +12 -0
  21. package/build/cover/index.js.map +1 -1
  22. package/build/details/edit.js +67 -0
  23. package/build/details/edit.js.map +1 -0
  24. package/build/details/index.js +110 -0
  25. package/build/details/index.js.map +1 -0
  26. package/build/details/save.js +33 -0
  27. package/build/details/save.js.map +1 -0
  28. package/build/details-content/edit.js +34 -0
  29. package/build/details-content/edit.js.map +1 -0
  30. package/build/details-content/index.js +94 -0
  31. package/build/details-content/index.js.map +1 -0
  32. package/build/details-content/save.js +20 -0
  33. package/build/details-content/save.js.map +1 -0
  34. package/build/details-summary/edit.js +42 -0
  35. package/build/details-summary/edit.js.map +1 -0
  36. package/build/details-summary/index.js +97 -0
  37. package/build/details-summary/index.js.map +1 -0
  38. package/build/details-summary/save.js +24 -0
  39. package/build/details-summary/save.js.map +1 -0
  40. package/build/embed/deprecated.js +4 -1
  41. package/build/embed/deprecated.js.map +1 -1
  42. package/build/embed/embed-link-settings.native.js +1 -1
  43. package/build/embed/embed-link-settings.native.js.map +1 -1
  44. package/build/embed/embed-placeholder.js +1 -1
  45. package/build/embed/embed-placeholder.js.map +1 -1
  46. package/build/embed/index.js +4 -1
  47. package/build/embed/index.js.map +1 -1
  48. package/build/embed/transforms.js +4 -1
  49. package/build/embed/transforms.js.map +1 -1
  50. package/build/embed/util.js +4 -1
  51. package/build/embed/util.js.map +1 -1
  52. package/build/file/edit.native.js +0 -2
  53. package/build/file/edit.native.js.map +1 -1
  54. package/build/gallery/edit.js +8 -5
  55. package/build/gallery/edit.js.map +1 -1
  56. package/build/gallery/use-get-media.native.js +2 -1
  57. package/build/gallery/use-get-media.native.js.map +1 -1
  58. package/build/gallery/use-image-sizes.js +1 -1
  59. package/build/gallery/use-image-sizes.js.map +1 -1
  60. package/build/group/deprecated.js +4 -2
  61. package/build/group/deprecated.js.map +1 -1
  62. package/build/group/edit.js +22 -5
  63. package/build/group/edit.js.map +1 -1
  64. package/build/group/placeholder.js +11 -1
  65. package/build/group/placeholder.js.map +1 -1
  66. package/build/group/variations.js +23 -3
  67. package/build/group/variations.js.map +1 -1
  68. package/build/image/edit.js +1 -1
  69. package/build/image/edit.js.map +1 -1
  70. package/build/image/edit.native.js +1 -1
  71. package/build/image/edit.native.js.map +1 -1
  72. package/build/image/image.js +8 -6
  73. package/build/image/image.js.map +1 -1
  74. package/build/image/index.js +9 -2
  75. package/build/image/index.js.map +1 -1
  76. package/build/index.js +24 -6
  77. package/build/index.js.map +1 -1
  78. package/build/latest-posts/edit.js +1 -0
  79. package/build/latest-posts/edit.js.map +1 -1
  80. package/build/media-text/deprecated.js +228 -18
  81. package/build/media-text/deprecated.js.map +1 -1
  82. package/build/media-text/edit.js +3 -3
  83. package/build/media-text/edit.js.map +1 -1
  84. package/build/media-text/index.js +1 -1
  85. package/build/media-text/media-container.js +2 -6
  86. package/build/media-text/media-container.js.map +1 -1
  87. package/build/media-text/media-container.native.js +3 -3
  88. package/build/media-text/media-container.native.js.map +1 -1
  89. package/build/navigation/deprecated.js +8 -11
  90. package/build/navigation/deprecated.js.map +1 -1
  91. package/build/navigation/edit/index.js +1 -12
  92. package/build/navigation/edit/index.js.map +1 -1
  93. package/build/navigation/edit/inner-blocks.js +1 -4
  94. package/build/navigation/edit/inner-blocks.js.map +1 -1
  95. package/build/navigation/edit/unsaved-inner-blocks.js +1 -14
  96. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  97. package/build/navigation/index.js +0 -1
  98. package/build/navigation/index.js.map +1 -1
  99. package/build/post-author/index.js +0 -1
  100. package/build/post-author/index.js.map +1 -1
  101. package/build/post-date/edit.js +2 -1
  102. package/build/post-date/edit.js.map +1 -1
  103. package/build/post-date/index.js +4 -1
  104. package/build/post-date/index.js.map +1 -1
  105. package/build/post-date/variations.js +28 -0
  106. package/build/post-date/variations.js.map +1 -0
  107. package/build/post-excerpt/edit.js +39 -10
  108. package/build/post-excerpt/edit.js.map +1 -1
  109. package/build/post-featured-image/dimension-controls.js +4 -3
  110. package/build/post-featured-image/dimension-controls.js.map +1 -1
  111. package/build/post-featured-image/edit.js +8 -22
  112. package/build/post-featured-image/edit.js.map +1 -1
  113. package/build/post-template/index.js +1 -1
  114. package/build/post-time-to-read/edit.js +1 -1
  115. package/build/post-time-to-read/edit.js.map +1 -1
  116. package/build/post-time-to-read/index.js +24 -1
  117. package/build/post-time-to-read/index.js.map +1 -1
  118. package/build/quote/index.js +1 -0
  119. package/build/quote/index.js.map +1 -1
  120. package/build/spacer/controls.js +25 -6
  121. package/build/spacer/controls.js.map +1 -1
  122. package/build/spacer/edit.js +27 -7
  123. package/build/spacer/edit.js.map +1 -1
  124. package/build/spacer/save.js +2 -2
  125. package/build/spacer/save.js.map +1 -1
  126. package/build/table/state.js +35 -35
  127. package/build/table/state.js.map +1 -1
  128. package/build/term-description/index.js +1 -2
  129. package/build/term-description/index.js.map +1 -1
  130. package/build/utils/clean-empty-object.js +5 -2
  131. package/build/utils/clean-empty-object.js.map +1 -1
  132. package/build-module/buttons/index.js +1 -0
  133. package/build-module/buttons/index.js.map +1 -1
  134. package/build-module/buttons/transforms.js +1 -0
  135. package/build-module/buttons/transforms.js.map +1 -1
  136. package/build-module/column/index.js +2 -1
  137. package/build-module/column/index.js.map +1 -1
  138. package/build-module/columns/edit.js +28 -8
  139. package/build-module/columns/edit.js.map +1 -1
  140. package/build-module/columns/index.js +6 -1
  141. package/build-module/columns/index.js.map +1 -1
  142. package/build-module/columns/utils.js +4 -8
  143. package/build-module/columns/utils.js.map +1 -1
  144. package/build-module/cover/edit/index.js +48 -52
  145. package/build-module/cover/edit/index.js.map +1 -1
  146. package/build-module/cover/edit/inspector-controls.js +2 -2
  147. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  148. package/build-module/cover/edit/{resizable-cover.js → resizable-cover-popover.js} +31 -6
  149. package/build-module/cover/edit/resizable-cover-popover.js.map +1 -0
  150. package/build-module/cover/index.js +12 -0
  151. package/build-module/cover/index.js.map +1 -1
  152. package/build-module/details/edit.js +52 -0
  153. package/build-module/details/edit.js.map +1 -0
  154. package/build-module/details/index.js +91 -0
  155. package/build-module/details/index.js.map +1 -0
  156. package/build-module/details/save.js +20 -0
  157. package/build-module/details/save.js.map +1 -0
  158. package/build-module/details-content/edit.js +23 -0
  159. package/build-module/details-content/edit.js.map +1 -0
  160. package/build-module/details-content/index.js +76 -0
  161. package/build-module/details-content/index.js.map +1 -0
  162. package/build-module/details-content/save.js +11 -0
  163. package/build-module/details-content/save.js.map +1 -0
  164. package/build-module/details-summary/edit.js +30 -0
  165. package/build-module/details-summary/edit.js.map +1 -0
  166. package/build-module/details-summary/index.js +79 -0
  167. package/build-module/details-summary/index.js.map +1 -0
  168. package/build-module/details-summary/save.js +16 -0
  169. package/build-module/details-summary/save.js.map +1 -0
  170. package/build-module/embed/deprecated.js +4 -1
  171. package/build-module/embed/deprecated.js.map +1 -1
  172. package/build-module/embed/embed-link-settings.native.js +1 -1
  173. package/build-module/embed/embed-link-settings.native.js.map +1 -1
  174. package/build-module/embed/embed-placeholder.js +1 -1
  175. package/build-module/embed/embed-placeholder.js.map +1 -1
  176. package/build-module/embed/index.js +4 -1
  177. package/build-module/embed/index.js.map +1 -1
  178. package/build-module/embed/transforms.js +4 -1
  179. package/build-module/embed/transforms.js.map +1 -1
  180. package/build-module/embed/util.js +4 -1
  181. package/build-module/embed/util.js.map +1 -1
  182. package/build-module/file/edit.native.js +0 -2
  183. package/build-module/file/edit.native.js.map +1 -1
  184. package/build-module/gallery/edit.js +8 -5
  185. package/build-module/gallery/edit.js.map +1 -1
  186. package/build-module/gallery/use-get-media.native.js +2 -1
  187. package/build-module/gallery/use-get-media.native.js.map +1 -1
  188. package/build-module/gallery/use-image-sizes.js +1 -1
  189. package/build-module/gallery/use-image-sizes.js.map +1 -1
  190. package/build-module/group/deprecated.js +4 -2
  191. package/build-module/group/deprecated.js.map +1 -1
  192. package/build-module/group/edit.js +21 -5
  193. package/build-module/group/edit.js.map +1 -1
  194. package/build-module/group/placeholder.js +11 -1
  195. package/build-module/group/placeholder.js.map +1 -1
  196. package/build-module/group/variations.js +24 -1
  197. package/build-module/group/variations.js.map +1 -1
  198. package/build-module/image/edit.js +1 -1
  199. package/build-module/image/edit.js.map +1 -1
  200. package/build-module/image/edit.native.js +1 -1
  201. package/build-module/image/edit.native.js.map +1 -1
  202. package/build-module/image/image.js +8 -6
  203. package/build-module/image/image.js.map +1 -1
  204. package/build-module/image/index.js +9 -2
  205. package/build-module/image/index.js.map +1 -1
  206. package/build-module/index.js +21 -6
  207. package/build-module/index.js.map +1 -1
  208. package/build-module/latest-posts/edit.js +1 -0
  209. package/build-module/latest-posts/edit.js.map +1 -1
  210. package/build-module/media-text/deprecated.js +227 -18
  211. package/build-module/media-text/deprecated.js.map +1 -1
  212. package/build-module/media-text/edit.js +3 -3
  213. package/build-module/media-text/edit.js.map +1 -1
  214. package/build-module/media-text/index.js +1 -1
  215. package/build-module/media-text/media-container.js +1 -5
  216. package/build-module/media-text/media-container.js.map +1 -1
  217. package/build-module/media-text/media-container.native.js +1 -1
  218. package/build-module/media-text/media-container.native.js.map +1 -1
  219. package/build-module/navigation/deprecated.js +8 -10
  220. package/build-module/navigation/deprecated.js.map +1 -1
  221. package/build-module/navigation/edit/index.js +1 -12
  222. package/build-module/navigation/edit/index.js.map +1 -1
  223. package/build-module/navigation/edit/inner-blocks.js +1 -4
  224. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  225. package/build-module/navigation/edit/unsaved-inner-blocks.js +1 -14
  226. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  227. package/build-module/navigation/index.js +0 -1
  228. package/build-module/navigation/index.js.map +1 -1
  229. package/build-module/post-author/index.js +0 -1
  230. package/build-module/post-author/index.js.map +1 -1
  231. package/build-module/post-date/edit.js +2 -1
  232. package/build-module/post-date/edit.js.map +1 -1
  233. package/build-module/post-date/index.js +3 -1
  234. package/build-module/post-date/index.js.map +1 -1
  235. package/build-module/post-date/variations.js +18 -0
  236. package/build-module/post-date/variations.js.map +1 -0
  237. package/build-module/post-excerpt/edit.js +38 -11
  238. package/build-module/post-excerpt/edit.js.map +1 -1
  239. package/build-module/post-featured-image/dimension-controls.js +4 -3
  240. package/build-module/post-featured-image/dimension-controls.js.map +1 -1
  241. package/build-module/post-featured-image/edit.js +8 -22
  242. package/build-module/post-featured-image/edit.js.map +1 -1
  243. package/build-module/post-template/index.js +1 -1
  244. package/build-module/post-time-to-read/edit.js +1 -1
  245. package/build-module/post-time-to-read/edit.js.map +1 -1
  246. package/build-module/post-time-to-read/index.js +24 -1
  247. package/build-module/post-time-to-read/index.js.map +1 -1
  248. package/build-module/quote/index.js +1 -0
  249. package/build-module/quote/index.js.map +1 -1
  250. package/build-module/spacer/controls.js +27 -9
  251. package/build-module/spacer/controls.js.map +1 -1
  252. package/build-module/spacer/edit.js +27 -8
  253. package/build-module/spacer/edit.js.map +1 -1
  254. package/build-module/spacer/save.js +3 -3
  255. package/build-module/spacer/save.js.map +1 -1
  256. package/build-module/table/state.js +35 -33
  257. package/build-module/table/state.js.map +1 -1
  258. package/build-module/term-description/index.js +1 -2
  259. package/build-module/term-description/index.js.map +1 -1
  260. package/build-module/utils/clean-empty-object.js +6 -3
  261. package/build-module/utils/clean-empty-object.js.map +1 -1
  262. package/build-style/categories/editor-rtl.css +5 -0
  263. package/build-style/categories/editor.css +5 -0
  264. package/build-style/categories/style-rtl.css +4 -0
  265. package/build-style/categories/style.css +4 -0
  266. package/build-style/columns/style-rtl.css +4 -1
  267. package/build-style/columns/style.css +4 -1
  268. package/build-style/common-rtl.css +1 -1
  269. package/build-style/common.css +1 -1
  270. package/build-style/cover/editor-rtl.css +11 -12
  271. package/build-style/cover/editor.css +11 -12
  272. package/build-style/cover/style-rtl.css +3 -2
  273. package/build-style/cover/style.css +3 -2
  274. package/build-style/details/style-rtl.css +91 -0
  275. package/build-style/details/style.css +91 -0
  276. package/build-style/details-summary/editor-rtl.css +91 -0
  277. package/build-style/details-summary/editor.css +91 -0
  278. package/build-style/details-summary/style-rtl.css +91 -0
  279. package/build-style/details-summary/style.css +91 -0
  280. package/build-style/editor-rtl.css +40 -48
  281. package/build-style/editor.css +40 -48
  282. package/build-style/file/style-rtl.css +4 -3
  283. package/build-style/file/style.css +4 -3
  284. package/build-style/navigation/style-rtl.css +2 -0
  285. package/build-style/navigation/style.css +2 -0
  286. package/build-style/post-excerpt/style-rtl.css +1 -1
  287. package/build-style/post-excerpt/style.css +1 -1
  288. package/build-style/post-featured-image/editor-rtl.css +1 -0
  289. package/build-style/post-featured-image/editor.css +1 -0
  290. package/build-style/post-template/style-rtl.css +1 -1
  291. package/build-style/post-template/style.css +1 -1
  292. package/build-style/post-time-to-read/style-rtl.css +91 -0
  293. package/build-style/post-time-to-read/style.css +91 -0
  294. package/build-style/pullquote/style-rtl.css +4 -1
  295. package/build-style/pullquote/style.css +4 -1
  296. package/build-style/search/style-rtl.css +8 -7
  297. package/build-style/search/style.css +8 -7
  298. package/build-style/shortcode/editor-rtl.css +15 -34
  299. package/build-style/shortcode/editor.css +15 -34
  300. package/build-style/spacer/editor-rtl.css +4 -2
  301. package/build-style/spacer/editor.css +4 -2
  302. package/build-style/style-rtl.css +44 -17
  303. package/build-style/style.css +44 -17
  304. package/package.json +31 -31
  305. package/src/buttons/block.json +1 -0
  306. package/src/categories/editor.scss +5 -0
  307. package/src/categories/style.scss +4 -0
  308. package/src/column/block.json +2 -1
  309. package/src/columns/block.json +6 -1
  310. package/src/columns/edit.js +35 -10
  311. package/src/columns/style.scss +5 -1
  312. package/src/columns/utils.js +8 -9
  313. package/src/comments/index.php +1 -0
  314. package/src/common.scss +1 -1
  315. package/src/cover/block.json +12 -0
  316. package/src/cover/edit/index.js +44 -37
  317. package/src/cover/edit/inspector-controls.js +4 -5
  318. package/src/cover/edit/resizable-cover-popover.js +82 -0
  319. package/src/cover/editor.scss +20 -13
  320. package/src/cover/index.php +9 -10
  321. package/src/cover/style.scss +2 -1
  322. package/src/cover/test/__snapshots__/transforms.native.js.snap +2 -2
  323. package/src/cover/test/edit.js +324 -0
  324. package/src/details/block.json +54 -0
  325. package/src/details/edit.js +59 -0
  326. package/src/details/index.js +35 -0
  327. package/src/details/save.js +15 -0
  328. package/src/details/style.scss +3 -0
  329. package/src/details-content/block.json +50 -0
  330. package/src/details-content/edit.js +29 -0
  331. package/src/details-content/index.js +23 -0
  332. package/src/details-content/save.js +12 -0
  333. package/src/details-summary/block.json +53 -0
  334. package/src/details-summary/edit.js +27 -0
  335. package/src/details-summary/editor.scss +3 -0
  336. package/src/details-summary/index.js +23 -0
  337. package/src/details-summary/save.js +13 -0
  338. package/src/details-summary/style.scss +3 -0
  339. package/src/editor.scss +1 -0
  340. package/src/embed/block.json +4 -1
  341. package/src/embed/embed-link-settings.native.js +1 -1
  342. package/src/embed/embed-placeholder.js +1 -1
  343. package/src/file/edit.native.js +0 -2
  344. package/src/file/style.scss +5 -2
  345. package/src/gallery/edit.js +5 -2
  346. package/src/gallery/test/use-get-media.native.js +24 -0
  347. package/src/gallery/use-get-media.native.js +1 -1
  348. package/src/gallery/use-image-sizes.js +1 -1
  349. package/src/group/deprecated.js +4 -2
  350. package/src/group/edit.js +27 -9
  351. package/src/group/placeholder.js +13 -1
  352. package/src/group/variations.js +14 -1
  353. package/src/home-link/index.php +2 -2
  354. package/src/image/block.json +9 -2
  355. package/src/image/edit.js +1 -1
  356. package/src/image/edit.native.js +1 -1
  357. package/src/image/image.js +15 -7
  358. package/src/image/index.php +7 -2
  359. package/src/image/test/__snapshots__/transforms.native.js.snap +1 -1
  360. package/src/index.js +13 -3
  361. package/src/latest-comments/style.scss +1 -1
  362. package/src/latest-posts/edit.js +3 -0
  363. package/src/media-text/block.json +1 -1
  364. package/src/media-text/deprecated.js +235 -3
  365. package/src/media-text/edit.js +7 -6
  366. package/src/media-text/media-container.js +1 -5
  367. package/src/media-text/media-container.native.js +1 -1
  368. package/src/media-text/test/__snapshots__/transforms.native.js.snap +4 -4
  369. package/src/navigation/block.json +0 -1
  370. package/src/navigation/deprecated.js +15 -19
  371. package/src/navigation/edit/index.js +0 -13
  372. package/src/navigation/edit/inner-blocks.js +0 -3
  373. package/src/navigation/edit/unsaved-inner-blocks.js +34 -46
  374. package/src/navigation/index.php +0 -4
  375. package/src/navigation/style.scss +6 -4
  376. package/src/navigation-link/index.php +2 -1
  377. package/src/navigation-submenu/index.php +30 -76
  378. package/src/paragraph/test/edit.native.js +356 -1
  379. package/src/post-author/block.json +0 -1
  380. package/src/post-author/index.php +1 -1
  381. package/src/post-date/edit.js +4 -1
  382. package/src/post-date/index.js +2 -0
  383. package/src/post-date/variations.js +20 -0
  384. package/src/post-excerpt/edit.js +48 -16
  385. package/src/post-excerpt/index.php +3 -3
  386. package/src/post-excerpt/style.scss +2 -1
  387. package/src/post-featured-image/dimension-controls.js +7 -3
  388. package/src/post-featured-image/edit.js +8 -29
  389. package/src/post-featured-image/editor.scss +1 -0
  390. package/src/post-template/block.json +1 -1
  391. package/src/post-template/style.scss +1 -1
  392. package/src/post-time-to-read/block.json +24 -1
  393. package/src/post-time-to-read/edit.js +1 -1
  394. package/src/post-time-to-read/index.php +3 -3
  395. package/src/post-time-to-read/style.scss +4 -0
  396. package/src/preformatted/test/__snapshots__/edit.native.js.snap +2 -2
  397. package/src/preformatted/test/edit.native.js +45 -2
  398. package/src/pullquote/style.scss +5 -1
  399. package/src/pullquote/test/edit.native.js +70 -0
  400. package/src/query-title/index.php +2 -5
  401. package/src/quote/block.json +1 -0
  402. package/src/quote/test/edit.native.js +92 -0
  403. package/src/search/index.php +1 -1
  404. package/src/search/style.scss +16 -12
  405. package/src/shortcode/editor.scss +26 -5
  406. package/src/spacer/controls.js +42 -17
  407. package/src/spacer/edit.js +41 -9
  408. package/src/spacer/editor.scss +2 -1
  409. package/src/spacer/save.js +3 -3
  410. package/src/style.scss +3 -0
  411. package/src/table/state.js +83 -66
  412. package/src/term-description/block.json +1 -2
  413. package/src/utils/clean-empty-object.js +4 -4
  414. package/src/verse/test/edit.native.js +33 -0
  415. package/src/video/test/__snapshots__/transforms.native.js.snap +1 -1
  416. package/tsconfig.tsbuildinfo +1 -1
  417. package/build/cover/edit/resizable-cover.js.map +0 -1
  418. package/build/media-text/media-container-icon.js +0 -27
  419. package/build/media-text/media-container-icon.js.map +0 -1
  420. package/build-module/cover/edit/resizable-cover.js.map +0 -1
  421. package/build-module/media-text/media-container-icon.js +0 -17
  422. package/build-module/media-text/media-container-icon.js.map +0 -1
  423. package/src/cover/edit/resizable-cover.js +0 -61
  424. package/src/cover/test/block-controls.js +0 -62
  425. package/src/media-text/media-container-icon.js +0 -12
@@ -29,9 +29,6 @@ const ALLOWED_BLOCKS = [
29
29
 
30
30
  const DEFAULT_BLOCK = {
31
31
  name: 'core/navigation-link',
32
- attributes: {
33
- type: 'page',
34
- },
35
32
  };
36
33
 
37
34
  export default function NavigationInnerBlocks( {
@@ -120,53 +120,41 @@ export default function UnsavedInnerBlocks( {
120
120
  const { hasResolvedNavigationMenus } = useNavigationMenu();
121
121
 
122
122
  // Automatically save the uncontrolled blocks.
123
- useEffect(
124
- () => {
125
- // The block will be disabled when used in a BlockPreview.
126
- // In this case avoid automatic creation of a wp_navigation post.
127
- // Otherwise the user will be spammed with lots of menus!
128
- //
129
- // Also ensure other navigation menus have loaded so an
130
- // accurate name can be created.
131
- //
132
- // Don't try saving when another save is already
133
- // in progress.
134
- //
135
- // And finally only create the menu when the block is selected,
136
- // which is an indication they want to start editing.
137
- if (
138
- isDisabled ||
139
- isSaving ||
140
- ! hasResolvedDraftNavigationMenus ||
141
- ! hasResolvedNavigationMenus ||
142
- ! hasSelection ||
143
- ! innerBlocksAreDirty
144
- ) {
145
- return;
146
- }
123
+ useEffect( () => {
124
+ // The block will be disabled when used in a BlockPreview.
125
+ // In this case avoid automatic creation of a wp_navigation post.
126
+ // Otherwise the user will be spammed with lots of menus!
127
+ //
128
+ // Also ensure other navigation menus have loaded so an
129
+ // accurate name can be created.
130
+ //
131
+ // Don't try saving when another save is already
132
+ // in progress.
133
+ //
134
+ // And finally only create the menu when the block is selected,
135
+ // which is an indication they want to start editing.
136
+ if (
137
+ isDisabled ||
138
+ isSaving ||
139
+ ! hasResolvedDraftNavigationMenus ||
140
+ ! hasResolvedNavigationMenus ||
141
+ ! hasSelection ||
142
+ ! innerBlocksAreDirty
143
+ ) {
144
+ return;
145
+ }
147
146
 
148
- createNavigationMenu( null, blocks );
149
- },
150
- /* The dependency "blocks" is intentionally omitted here.
151
- * This is because making blocks a dependency would cause
152
- * createNavigationMenu to run on every block change whereas
153
- * we only want it to run when the blocks are first detected
154
- * as dirty.
155
- * A better solution might be to add a hard saving lock using
156
- * a ref to avoid having to disbale theses eslint rules.
157
- */
158
- /* eslint-disable react-hooks/exhaustive-deps */
159
- [
160
- createNavigationMenu,
161
- isDisabled,
162
- isSaving,
163
- hasResolvedDraftNavigationMenus,
164
- hasResolvedNavigationMenus,
165
- innerBlocksAreDirty,
166
- hasSelection,
167
- ]
168
- /* eslint-enable react-hooks/exhaustive-deps */
169
- );
147
+ createNavigationMenu( null, blocks );
148
+ }, [
149
+ blocks,
150
+ createNavigationMenu,
151
+ isDisabled,
152
+ isSaving,
153
+ hasResolvedDraftNavigationMenus,
154
+ hasResolvedNavigationMenus,
155
+ innerBlocksAreDirty,
156
+ hasSelection,
157
+ ] );
170
158
 
171
159
  const Wrapper = isSaving ? Disabled : 'div';
172
160
 
@@ -471,10 +471,6 @@ function block_core_navigation_get_fallback_blocks() {
471
471
  $fallback_blocks = ! empty( $maybe_fallback ) ? $maybe_fallback : $fallback_blocks;
472
472
  }
473
473
 
474
- // Normalizing blocks may result in an empty array of blocks if they were all `null` blocks.
475
- // In this case default empty blocks.
476
- $fallback_blocks = ! empty( $maybe_fallback ) ? $maybe_fallback : array();
477
-
478
474
  /**
479
475
  * Filters the fallback experience for the Navigation block.
480
476
  *
@@ -689,10 +689,12 @@ button.wp-block-navigation-item__content {
689
689
  .wp-block-navigation__responsive-close {
690
690
  width: 100%;
691
691
 
692
- // Try to inherit wide-width when defined, so the X can align to a top-right aligned menu.
693
- max-width: var(--wp--style--global--wide-size, 100%);
694
- margin-left: auto;
695
- margin-right: auto;
692
+ .has-modal-open & {
693
+ // Try to inherit wide-width when defined, so the X can align to a top-right aligned menu.
694
+ max-width: var(--wp--style--global--wide-size, 100%);
695
+ margin-left: auto;
696
+ margin-right: auto;
697
+ }
696
698
 
697
699
  // This element is not keyboard accessible, and is focusable only using the mouse.
698
700
  // It is part of the MicroModal library that adds a scrim outside of a modal dialog that is not fullscreen,
@@ -181,7 +181,8 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
181
181
 
182
182
  $css_classes = trim( implode( ' ', $classes ) );
183
183
  $has_submenu = count( $block->inner_blocks ) > 0;
184
- $is_active = ! empty( $attributes['id'] ) && ( get_queried_object_id() === (int) $attributes['id'] );
184
+ $kind = empty( $attributes['kind'] ) ? 'post_type' : str_replace( '-', '_', $attributes['kind'] );
185
+ $is_active = ! empty( $attributes['id'] ) && get_queried_object_id() === (int) $attributes['id'] && ! empty( get_queried_object()->$kind );
185
186
 
186
187
  $wrapper_attributes = get_block_wrapper_attributes(
187
188
  array(
@@ -14,66 +14,6 @@
14
14
  * @param bool $is_sub_menu Whether the block is a sub-menu.
15
15
  * @return array Colors CSS classes and inline styles.
16
16
  */
17
- function block_core_navigation_submenu_build_css_colors( $context, $attributes, $is_sub_menu = false ) {
18
- $colors = array(
19
- 'css_classes' => array(),
20
- 'inline_styles' => '',
21
- );
22
-
23
- // Text color.
24
- $named_text_color = null;
25
- $custom_text_color = null;
26
-
27
- if ( $is_sub_menu && array_key_exists( 'customOverlayTextColor', $context ) ) {
28
- $custom_text_color = $context['customOverlayTextColor'];
29
- } elseif ( $is_sub_menu && array_key_exists( 'overlayTextColor', $context ) ) {
30
- $named_text_color = $context['overlayTextColor'];
31
- } elseif ( array_key_exists( 'customTextColor', $context ) ) {
32
- $custom_text_color = $context['customTextColor'];
33
- } elseif ( array_key_exists( 'textColor', $context ) ) {
34
- $named_text_color = $context['textColor'];
35
- } elseif ( isset( $context['style']['color']['text'] ) ) {
36
- $custom_text_color = $context['style']['color']['text'];
37
- }
38
-
39
- // If has text color.
40
- if ( ! is_null( $named_text_color ) ) {
41
- // Add the color class.
42
- array_push( $colors['css_classes'], 'has-text-color', sprintf( 'has-%s-color', $named_text_color ) );
43
- } elseif ( ! is_null( $custom_text_color ) ) {
44
- // Add the custom color inline style.
45
- $colors['css_classes'][] = 'has-text-color';
46
- $colors['inline_styles'] .= sprintf( 'color: %s;', $custom_text_color );
47
- }
48
-
49
- // Background color.
50
- $named_background_color = null;
51
- $custom_background_color = null;
52
-
53
- if ( $is_sub_menu && array_key_exists( 'customOverlayBackgroundColor', $context ) ) {
54
- $custom_background_color = $context['customOverlayBackgroundColor'];
55
- } elseif ( $is_sub_menu && array_key_exists( 'overlayBackgroundColor', $context ) ) {
56
- $named_background_color = $context['overlayBackgroundColor'];
57
- } elseif ( array_key_exists( 'customBackgroundColor', $context ) ) {
58
- $custom_background_color = $context['customBackgroundColor'];
59
- } elseif ( array_key_exists( 'backgroundColor', $context ) ) {
60
- $named_background_color = $context['backgroundColor'];
61
- } elseif ( isset( $context['style']['color']['background'] ) ) {
62
- $custom_background_color = $context['style']['color']['background'];
63
- }
64
-
65
- // If has background color.
66
- if ( ! is_null( $named_background_color ) ) {
67
- // Add the background-color class.
68
- array_push( $colors['css_classes'], 'has-background', sprintf( 'has-%s-background-color', $named_background_color ) );
69
- } elseif ( ! is_null( $custom_background_color ) ) {
70
- // Add the custom background-color inline style.
71
- $colors['css_classes'][] = 'has-background';
72
- $colors['inline_styles'] .= sprintf( 'background-color: %s;', $custom_background_color );
73
- }
74
-
75
- return $colors;
76
- }
77
17
 
78
18
  /**
79
19
  * Build an array with CSS classes and inline styles defining the font sizes
@@ -129,7 +69,6 @@ function block_core_navigation_submenu_render_submenu_icon() {
129
69
  * @return string Returns the post content with the legacy widget added.
130
70
  */
131
71
  function render_block_core_navigation_submenu( $attributes, $content, $block ) {
132
-
133
72
  $navigation_link_has_id = isset( $attributes['id'] ) && is_numeric( $attributes['id'] );
134
73
  $is_post_type = isset( $attributes['kind'] ) && 'post-type' === $attributes['kind'];
135
74
  $is_post_type = $is_post_type || isset( $attributes['type'] ) && ( 'post' === $attributes['type'] || 'page' === $attributes['type'] );
@@ -144,17 +83,13 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
144
83
  return '';
145
84
  }
146
85
 
147
- $colors = block_core_navigation_submenu_build_css_colors( $block->context, $attributes );
148
86
  $font_sizes = block_core_navigation_submenu_build_css_font_sizes( $block->context );
149
- $classes = array_merge(
150
- $colors['css_classes'],
151
- $font_sizes['css_classes']
152
- );
153
- $style_attribute = ( $colors['inline_styles'] . $font_sizes['inline_styles'] );
87
+ $style_attribute = $font_sizes['inline_styles'];
154
88
 
155
- $css_classes = trim( implode( ' ', $classes ) );
89
+ $css_classes = trim( implode( ' ', $font_sizes['css_classes'] ) );
156
90
  $has_submenu = count( $block->inner_blocks ) > 0;
157
- $is_active = ! empty( $attributes['id'] ) && ( get_queried_object_id() === (int) $attributes['id'] );
91
+ $kind = empty( $attributes['kind'] ) ? 'post_type' : str_replace( '-', '_', $attributes['kind'] );
92
+ $is_active = ! empty( $attributes['id'] ) && get_queried_object_id() === (int) $attributes['id'] && ! empty( get_queried_object()->$kind );
158
93
 
159
94
  $show_submenu_indicators = isset( $block->context['showSubmenuIcon'] ) && $block->context['showSubmenuIcon'];
160
95
  $open_on_click = isset( $block->context['openSubmenusOnClick'] ) && $block->context['openSubmenusOnClick'];
@@ -249,14 +184,33 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
249
184
  }
250
185
 
251
186
  if ( $has_submenu ) {
252
- $colors = block_core_navigation_submenu_build_css_colors( $block->context, $attributes, $has_submenu );
253
- $classes = array_merge(
254
- array( 'wp-block-navigation__submenu-container' ),
255
- $colors['css_classes']
256
- );
257
- $css_classes = trim( implode( ' ', $classes ) );
187
+ // Copy some attributes from the parent block to this one.
188
+ // Ideally this would happen in the client when the block is created.
189
+ if ( array_key_exists( 'overlayTextColor', $block->context ) ) {
190
+ $attributes['textColor'] = $block->context['overlayTextColor'];
191
+ }
192
+ if ( array_key_exists( 'overlayBackgroundColor', $block->context ) ) {
193
+ $attributes['backgroundColor'] = $block->context['overlayBackgroundColor'];
194
+ }
195
+ if ( array_key_exists( 'customOverlayTextColor', $block->context ) ) {
196
+ $attributes['style']['color']['text'] = $block->context['customOverlayTextColor'];
197
+ }
198
+ if ( array_key_exists( 'customOverlayBackgroundColor', $block->context ) ) {
199
+ $attributes['style']['color']['background'] = $block->context['customOverlayBackgroundColor'];
200
+ }
258
201
 
259
- $style_attribute = $colors['inline_styles'];
202
+ // This allows us to be able to get a response from gutenberg_apply_colors_support.
203
+ $block->block_type->supports['color'] = true;
204
+ $colors_supports = gutenberg_apply_colors_support( $block->block_type, $attributes );
205
+ $css_classes = 'wp-block-navigation__submenu-container';
206
+ if ( array_key_exists( 'class', $colors_supports ) ) {
207
+ $css_classes .= ' ' . $colors_supports['class'];
208
+ }
209
+
210
+ $style_attribute = '';
211
+ if ( array_key_exists( 'style', $colors_supports ) ) {
212
+ $style_attribute = $colors_supports['style'];
213
+ }
260
214
 
261
215
  $inner_blocks_html = '';
262
216
  foreach ( $block->inner_blocks as $inner_block ) {
@@ -1,13 +1,33 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { render } from 'test/helpers';
4
+ import {
5
+ act,
6
+ addBlock,
7
+ getBlock,
8
+ changeTextOfRichText,
9
+ changeAndSelectTextOfRichText,
10
+ fireEvent,
11
+ getEditorHtml,
12
+ initializeEditor,
13
+ render,
14
+ setupCoreBlocks,
15
+ within,
16
+ } from 'test/helpers';
17
+ import Clipboard from '@react-native-clipboard/clipboard';
18
+
19
+ /**
20
+ * WordPress dependencies
21
+ */
22
+ import { ENTER } from '@wordpress/keycodes';
5
23
 
6
24
  /**
7
25
  * Internal dependencies
8
26
  */
9
27
  import Paragraph from '../edit';
10
28
 
29
+ setupCoreBlocks();
30
+
11
31
  const getTestComponentWithContent = ( content ) => {
12
32
  return render(
13
33
  <Paragraph
@@ -24,4 +44,339 @@ describe( 'Paragraph block', () => {
24
44
  const screen = getTestComponentWithContent( '' );
25
45
  expect( screen.container ).toBeTruthy();
26
46
  } );
47
+
48
+ it( 'should bold text', async () => {
49
+ // Arrange
50
+ const screen = await initializeEditor();
51
+ await addBlock( screen, 'Paragraph' );
52
+
53
+ // Act
54
+ const paragraphBlock = getBlock( screen, 'Paragraph' );
55
+ fireEvent.press( paragraphBlock );
56
+ const paragraphTextInput =
57
+ within( paragraphBlock ).getByPlaceholderText( 'Start writing…' );
58
+ changeAndSelectTextOfRichText(
59
+ paragraphTextInput,
60
+ 'A quick brown fox jumps over the lazy dog.',
61
+ { selectionStart: 2, selectionEnd: 7 }
62
+ );
63
+ fireEvent.press( screen.getByLabelText( 'Bold' ) );
64
+
65
+ // Assert
66
+ expect( getEditorHtml() ).toMatchInlineSnapshot( `
67
+ "<!-- wp:paragraph -->
68
+ <p>A <strong>quick</strong> brown fox jumps over the lazy dog.</p>
69
+ <!-- /wp:paragraph -->"
70
+ ` );
71
+ } );
72
+
73
+ it( 'should italicize text', async () => {
74
+ // Arrange
75
+ const screen = await initializeEditor();
76
+ await addBlock( screen, 'Paragraph' );
77
+
78
+ // Act
79
+ const paragraphBlock = getBlock( screen, 'Paragraph' );
80
+ fireEvent.press( paragraphBlock );
81
+ const paragraphTextInput =
82
+ within( paragraphBlock ).getByPlaceholderText( 'Start writing…' );
83
+ changeAndSelectTextOfRichText(
84
+ paragraphTextInput,
85
+ 'A quick brown fox jumps over the lazy dog.',
86
+ { selectionStart: 2, selectionEnd: 7 }
87
+ );
88
+ fireEvent.press( screen.getByLabelText( 'Italic' ) );
89
+
90
+ // Assert
91
+ expect( getEditorHtml() ).toMatchInlineSnapshot( `
92
+ "<!-- wp:paragraph -->
93
+ <p>A <em>quick</em> brown fox jumps over the lazy dog.</p>
94
+ <!-- /wp:paragraph -->"
95
+ ` );
96
+ } );
97
+
98
+ it( 'should strikethrough text', async () => {
99
+ // Arrange
100
+ const screen = await initializeEditor();
101
+ await addBlock( screen, 'Paragraph' );
102
+
103
+ // Act
104
+ const paragraphBlock = getBlock( screen, 'Paragraph' );
105
+ fireEvent.press( paragraphBlock );
106
+ const paragraphTextInput =
107
+ within( paragraphBlock ).getByPlaceholderText( 'Start writing…' );
108
+ changeAndSelectTextOfRichText(
109
+ paragraphTextInput,
110
+ 'A quick brown fox jumps over the lazy dog.',
111
+ { selectionStart: 2, selectionEnd: 7 }
112
+ );
113
+ fireEvent.press( screen.getByLabelText( 'Strikethrough' ) );
114
+
115
+ // Assert
116
+ expect( getEditorHtml() ).toMatchInlineSnapshot( `
117
+ "<!-- wp:paragraph -->
118
+ <p>A <s>quick</s> brown fox jumps over the lazy dog.</p>
119
+ <!-- /wp:paragraph -->"
120
+ ` );
121
+ } );
122
+
123
+ it( 'should left align text', async () => {
124
+ // Arrange
125
+ const screen = await initializeEditor();
126
+ await addBlock( screen, 'Paragraph' );
127
+
128
+ // Act
129
+ const paragraphBlock = getBlock( screen, 'Paragraph' );
130
+ fireEvent.press( paragraphBlock );
131
+ const paragraphTextInput =
132
+ within( paragraphBlock ).getByPlaceholderText( 'Start writing…' );
133
+ changeTextOfRichText(
134
+ paragraphTextInput,
135
+ 'A quick brown fox jumps over the lazy dog.'
136
+ );
137
+ fireEvent.press( screen.getByLabelText( 'Align text' ) );
138
+ fireEvent.press( screen.getByLabelText( 'Align text left' ) );
139
+
140
+ // Assert
141
+ expect( getEditorHtml() ).toMatchInlineSnapshot( `
142
+ "<!-- wp:paragraph {"align":"left"} -->
143
+ <p class="has-text-align-left">A quick brown fox jumps over the lazy dog.</p>
144
+ <!-- /wp:paragraph -->"
145
+ ` );
146
+ } );
147
+
148
+ it( 'should center align text', async () => {
149
+ // Arrange
150
+ const screen = await initializeEditor();
151
+ await addBlock( screen, 'Paragraph' );
152
+
153
+ // Act
154
+ const paragraphBlock = getBlock( screen, 'Paragraph' );
155
+ fireEvent.press( paragraphBlock );
156
+ const paragraphTextInput =
157
+ within( paragraphBlock ).getByPlaceholderText( 'Start writing…' );
158
+ changeTextOfRichText(
159
+ paragraphTextInput,
160
+ 'A quick brown fox jumps over the lazy dog.'
161
+ );
162
+ fireEvent.press( screen.getByLabelText( 'Align text' ) );
163
+ fireEvent.press( screen.getByLabelText( 'Align text center' ) );
164
+
165
+ // Assert
166
+ expect( getEditorHtml() ).toMatchInlineSnapshot( `
167
+ "<!-- wp:paragraph {"align":"center"} -->
168
+ <p class="has-text-align-center">A quick brown fox jumps over the lazy dog.</p>
169
+ <!-- /wp:paragraph -->"
170
+ ` );
171
+ } );
172
+
173
+ it( 'should right align text', async () => {
174
+ // Arrange
175
+ const screen = await initializeEditor();
176
+ await addBlock( screen, 'Paragraph' );
177
+
178
+ // Act
179
+ const paragraphBlock = getBlock( screen, 'Paragraph' );
180
+ fireEvent.press( paragraphBlock );
181
+ const paragraphTextInput =
182
+ within( paragraphBlock ).getByPlaceholderText( 'Start writing…' );
183
+ changeTextOfRichText(
184
+ paragraphTextInput,
185
+ 'A quick brown fox jumps over the lazy dog.'
186
+ );
187
+ fireEvent.press( screen.getByLabelText( 'Align text' ) );
188
+ fireEvent.press( screen.getByLabelText( 'Align text right' ) );
189
+
190
+ // Assert
191
+ expect( getEditorHtml() ).toMatchInlineSnapshot( `
192
+ "<!-- wp:paragraph {"align":"right"} -->
193
+ <p class="has-text-align-right">A quick brown fox jumps over the lazy dog.</p>
194
+ <!-- /wp:paragraph -->"
195
+ ` );
196
+ } );
197
+
198
+ it( 'should preserve alignment when split', async () => {
199
+ // Arrange
200
+ const screen = await initializeEditor();
201
+ await addBlock( screen, 'Paragraph' );
202
+
203
+ // Act
204
+ const paragraphBlock = getBlock( screen, 'Paragraph' );
205
+ fireEvent.press( paragraphBlock );
206
+ fireEvent.press( screen.getByLabelText( 'Align text' ) );
207
+ fireEvent.press( screen.getByLabelText( 'Align text center' ) );
208
+ const paragraphTextInput =
209
+ within( paragraphBlock ).getByPlaceholderText( 'Start writing…' );
210
+ const string = 'A quick brown fox jumps over the lazy dog.';
211
+ changeAndSelectTextOfRichText( paragraphTextInput, string, {
212
+ selectionStart: string.length / 2,
213
+ selectionEnd: string.length / 2,
214
+ } );
215
+ fireEvent( paragraphTextInput, 'onKeyDown', {
216
+ nativeEvent: {},
217
+ preventDefault() {},
218
+ keyCode: ENTER,
219
+ } );
220
+
221
+ // Assert
222
+ expect( getEditorHtml() ).toMatchInlineSnapshot( `
223
+ "<!-- wp:paragraph {"align":"center"} -->
224
+ <p class="has-text-align-center">A quick brown fox jum</p>
225
+ <!-- /wp:paragraph -->
226
+
227
+ <!-- wp:paragraph {"align":"center"} -->
228
+ <p class="has-text-align-center">ps over the lazy dog.</p>
229
+ <!-- /wp:paragraph -->"
230
+ ` );
231
+ } );
232
+
233
+ it( 'should link text without selection', async () => {
234
+ // Arrange
235
+ const screen = await initializeEditor();
236
+ await addBlock( screen, 'Paragraph' );
237
+
238
+ // Act
239
+ const paragraphBlock = getBlock( screen, 'Paragraph' );
240
+ fireEvent.press( paragraphBlock );
241
+ // Await React Navigation: https://github.com/WordPress/gutenberg/issues/35685#issuecomment-961919931
242
+ await act( () => fireEvent.press( screen.getByLabelText( 'Link' ) ) );
243
+ // Await React Navigation: https://github.com/WordPress/gutenberg/issues/35685#issuecomment-961919931
244
+ await act( () =>
245
+ fireEvent.press(
246
+ screen.getByLabelText( 'Link to, Search or type URL' )
247
+ )
248
+ );
249
+ fireEvent.changeText(
250
+ screen.getByPlaceholderText( 'Search or type URL' ),
251
+ 'wordpress.org'
252
+ );
253
+ fireEvent.changeText(
254
+ screen.getByPlaceholderText( 'Add link text' ),
255
+ 'WordPress'
256
+ );
257
+ jest.useFakeTimers();
258
+ fireEvent.press( screen.getByLabelText( 'Apply' ) );
259
+ // Await link picker navigation delay
260
+ act( () => jest.runOnlyPendingTimers() );
261
+
262
+ // Assert
263
+ expect( getEditorHtml() ).toMatchInlineSnapshot( `
264
+ "<!-- wp:paragraph -->
265
+ <p><a href="http://wordpress.org">WordPress</a></p>
266
+ <!-- /wp:paragraph -->"
267
+ ` );
268
+
269
+ jest.useRealTimers();
270
+ } );
271
+
272
+ it( 'should link text with selection', async () => {
273
+ // Arrange
274
+ const screen = await initializeEditor();
275
+ await addBlock( screen, 'Paragraph' );
276
+
277
+ // Act
278
+ const paragraphBlock = getBlock( screen, 'Paragraph' );
279
+ fireEvent.press( paragraphBlock );
280
+ const paragraphTextInput =
281
+ within( paragraphBlock ).getByPlaceholderText( 'Start writing…' );
282
+ changeAndSelectTextOfRichText(
283
+ paragraphTextInput,
284
+ 'A quick brown fox jumps over the lazy dog.',
285
+ {
286
+ selectionStart: 2,
287
+ selectionEnd: 7,
288
+ }
289
+ );
290
+ // Await React Navigation: https://github.com/WordPress/gutenberg/issues/35685#issuecomment-961919931
291
+ await act( () => fireEvent.press( screen.getByLabelText( 'Link' ) ) );
292
+ // Await React Navigation: https://github.com/WordPress/gutenberg/issues/35685#issuecomment-961919931
293
+ await act( () =>
294
+ fireEvent.press(
295
+ screen.getByLabelText( 'Link to, Search or type URL' )
296
+ )
297
+ );
298
+ fireEvent.changeText(
299
+ screen.getByPlaceholderText( 'Search or type URL' ),
300
+ 'wordpress.org'
301
+ );
302
+ jest.useFakeTimers();
303
+ fireEvent.press( screen.getByLabelText( 'Apply' ) );
304
+ // Await link picker navigation delay
305
+ act( () => jest.runOnlyPendingTimers() );
306
+
307
+ // Assert
308
+ expect( getEditorHtml() ).toMatchInlineSnapshot( `
309
+ "<!-- wp:paragraph -->
310
+ <p>A <a href="http://wordpress.org">quick</a> brown fox jumps over the lazy dog.</p>
311
+ <!-- /wp:paragraph -->"
312
+ ` );
313
+
314
+ jest.useRealTimers();
315
+ } );
316
+
317
+ it( 'should link text with clipboard contents', async () => {
318
+ // Arrange
319
+ Clipboard.getString.mockResolvedValue( 'https://wordpress.org' );
320
+ const screen = await initializeEditor();
321
+ await addBlock( screen, 'Paragraph' );
322
+
323
+ // Act
324
+ const paragraphBlock = getBlock( screen, 'Paragraph' );
325
+ fireEvent.press( paragraphBlock );
326
+ const paragraphTextInput =
327
+ within( paragraphBlock ).getByPlaceholderText( 'Start writing…' );
328
+ changeAndSelectTextOfRichText(
329
+ paragraphTextInput,
330
+ 'A quick brown fox jumps over the lazy dog.',
331
+ {
332
+ selectionStart: 2,
333
+ selectionEnd: 7,
334
+ }
335
+ );
336
+ // Await React Navigation: https://github.com/WordPress/gutenberg/issues/35685#issuecomment-961919931
337
+ await act( () => fireEvent.press( screen.getByLabelText( 'Link' ) ) );
338
+ // Await React Navigation: https://github.com/WordPress/gutenberg/issues/35685#issuecomment-961919931
339
+ await act( () =>
340
+ fireEvent.press(
341
+ screen.getByLabelText( 'Link to, Search or type URL' )
342
+ )
343
+ );
344
+
345
+ // Assert
346
+ expect( getEditorHtml() ).toMatchInlineSnapshot( `
347
+ "<!-- wp:paragraph -->
348
+ <p>A <a href="https://wordpress.org">quick</a> brown fox jumps over the lazy dog.</p>
349
+ <!-- /wp:paragraph -->"
350
+ ` );
351
+
352
+ Clipboard.getString.mockReset();
353
+ } );
354
+
355
+ it( 'should not remove leading or trailing whitespace when formatting', async () => {
356
+ // Arrange
357
+ const screen = await initializeEditor();
358
+ await addBlock( screen, 'Paragraph' );
359
+
360
+ // Act
361
+ const paragraphBlock = getBlock( screen, 'Paragraph' );
362
+ fireEvent.press( paragraphBlock );
363
+ const paragraphTextInput =
364
+ within( paragraphBlock ).getByPlaceholderText( 'Start writing…' );
365
+ changeAndSelectTextOfRichText(
366
+ paragraphTextInput,
367
+ ' some text ',
368
+ {
369
+ selectionStart: 5,
370
+ selectionEnd: 14,
371
+ }
372
+ );
373
+ fireEvent.press( screen.getByLabelText( 'Italic' ) );
374
+
375
+ // Assert
376
+ expect( getEditorHtml() ).toMatchInlineSnapshot( `
377
+ "<!-- wp:paragraph -->
378
+ <p> <em>some text</em> </p>
379
+ <!-- /wp:paragraph -->"
380
+ ` );
381
+ } );
27
382
  } );
@@ -64,6 +64,5 @@
64
64
  }
65
65
  }
66
66
  },
67
- "editorStyle": "wp-block-post-author-editor",
68
67
  "style": "wp-block-post-author"
69
68
  }
@@ -32,7 +32,7 @@ function render_block_core_post_author( $attributes, $content, $block ) {
32
32
  $link = get_author_posts_url( $author_id );
33
33
  $author_name = get_the_author_meta( 'display_name', $author_id );
34
34
  if ( ! empty( $attributes['isLink'] && ! empty( $attributes['linkTarget'] ) ) ) {
35
- $author_name = sprintf( '<a href="%1s" target="%2s">%2s</a>', esc_url( $link ), esc_attr( $attributes['linkTarget'] ), $author_name );
35
+ $author_name = sprintf( '<a href="%1$s" target="%2$s">%3$s</a>', esc_url( $link ), esc_attr( $attributes['linkTarget'] ), $author_name );
36
36
  }
37
37
 
38
38
  $byline = ! empty( $attributes['byline'] ) ? $attributes['byline'] : false;