@wordpress/block-library 8.7.0 → 8.9.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 (416) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/column/index.js +2 -1
  3. package/build/column/index.js.map +1 -1
  4. package/build/columns/edit.js +24 -6
  5. package/build/columns/edit.js.map +1 -1
  6. package/build/columns/index.js +2 -1
  7. package/build/columns/index.js.map +1 -1
  8. package/build/columns/utils.js +4 -9
  9. package/build/columns/utils.js.map +1 -1
  10. package/build/cover/edit/index.js +46 -50
  11. package/build/cover/edit/index.js.map +1 -1
  12. package/build/cover/edit/{resizable-cover.js → resizable-cover-popover.js} +32 -6
  13. package/build/cover/edit/resizable-cover-popover.js.map +1 -0
  14. package/build/cover/index.js +12 -0
  15. package/build/cover/index.js.map +1 -1
  16. package/build/cover/transforms.js +10 -7
  17. package/build/cover/transforms.js.map +1 -1
  18. package/build/details/edit.js +67 -0
  19. package/build/details/edit.js.map +1 -0
  20. package/build/details/index.js +110 -0
  21. package/build/details/index.js.map +1 -0
  22. package/build/details/save.js +33 -0
  23. package/build/details/save.js.map +1 -0
  24. package/build/details-content/edit.js +34 -0
  25. package/build/details-content/edit.js.map +1 -0
  26. package/build/details-content/index.js +94 -0
  27. package/build/details-content/index.js.map +1 -0
  28. package/build/details-content/save.js +20 -0
  29. package/build/details-content/save.js.map +1 -0
  30. package/build/details-summary/edit.js +42 -0
  31. package/build/details-summary/edit.js.map +1 -0
  32. package/build/details-summary/index.js +97 -0
  33. package/build/details-summary/index.js.map +1 -0
  34. package/build/details-summary/save.js +24 -0
  35. package/build/details-summary/save.js.map +1 -0
  36. package/build/embed/deprecated.js +4 -1
  37. package/build/embed/deprecated.js.map +1 -1
  38. package/build/embed/embed-link-settings.native.js +1 -1
  39. package/build/embed/embed-link-settings.native.js.map +1 -1
  40. package/build/embed/embed-placeholder.js +1 -1
  41. package/build/embed/embed-placeholder.js.map +1 -1
  42. package/build/embed/index.js +4 -1
  43. package/build/embed/index.js.map +1 -1
  44. package/build/embed/transforms.js +4 -1
  45. package/build/embed/transforms.js.map +1 -1
  46. package/build/embed/util.js +4 -1
  47. package/build/embed/util.js.map +1 -1
  48. package/build/file/edit.native.js +0 -2
  49. package/build/file/edit.native.js.map +1 -1
  50. package/build/gallery/use-get-media.native.js +2 -1
  51. package/build/gallery/use-get-media.native.js.map +1 -1
  52. package/build/group/edit.js +3 -1
  53. package/build/group/edit.js.map +1 -1
  54. package/build/group/index.js +3 -0
  55. package/build/group/index.js.map +1 -1
  56. package/build/image/edit.js +16 -13
  57. package/build/image/edit.js.map +1 -1
  58. package/build/image/index.js +5 -3
  59. package/build/image/index.js.map +1 -1
  60. package/build/index.js +24 -6
  61. package/build/index.js.map +1 -1
  62. package/build/index.native.js +9 -5
  63. package/build/index.native.js.map +1 -1
  64. package/build/media-text/edit.js +4 -2
  65. package/build/media-text/edit.js.map +1 -1
  66. package/build/media-text/index.js +3 -0
  67. package/build/media-text/index.js.map +1 -1
  68. package/build/media-text/media-container.js +2 -6
  69. package/build/media-text/media-container.js.map +1 -1
  70. package/build/media-text/media-container.native.js +3 -3
  71. package/build/media-text/media-container.native.js.map +1 -1
  72. package/build/navigation/deprecated.js +8 -11
  73. package/build/navigation/deprecated.js.map +1 -1
  74. package/build/navigation/edit/index.js +32 -64
  75. package/build/navigation/edit/index.js.map +1 -1
  76. package/build/navigation/edit/unsaved-inner-blocks.js +1 -14
  77. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  78. package/build/post-author/index.js +0 -1
  79. package/build/post-author/index.js.map +1 -1
  80. package/build/post-date/edit.js +4 -2
  81. package/build/post-date/edit.js.map +1 -1
  82. package/build/post-excerpt/edit.js +2 -2
  83. package/build/post-excerpt/edit.js.map +1 -1
  84. package/build/post-featured-image/dimension-controls.js +2 -1
  85. package/build/post-featured-image/dimension-controls.js.map +1 -1
  86. package/build/post-featured-image/edit.js +16 -27
  87. package/build/post-featured-image/edit.js.map +1 -1
  88. package/build/post-time-to-read/edit.js +1 -1
  89. package/build/post-time-to-read/edit.js.map +1 -1
  90. package/build/post-time-to-read/index.js +7 -0
  91. package/build/post-time-to-read/index.js.map +1 -1
  92. package/build/query/deprecated.js +8 -6
  93. package/build/query/deprecated.js.map +1 -1
  94. package/build/query/edit/inspector-controls/create-new-post-link.js +41 -0
  95. package/build/query/edit/inspector-controls/create-new-post-link.js.map +1 -0
  96. package/build/query/edit/inspector-controls/index.js +14 -6
  97. package/build/query/edit/inspector-controls/index.js.map +1 -1
  98. package/build/query/edit/pattern-selection-modal.js +2 -1
  99. package/build/query/edit/pattern-selection-modal.js.map +1 -1
  100. package/build/query/index.js +5 -12
  101. package/build/query/index.js.map +1 -1
  102. package/build/site-logo/edit.js +114 -16
  103. package/build/site-logo/edit.js.map +1 -1
  104. package/build/site-logo/index.js +1 -1
  105. package/build/social-link/icons/chain.js +1 -1
  106. package/build/social-link/icons/chain.js.map +1 -1
  107. package/build/social-link/icons/mail.js +1 -1
  108. package/build/social-link/icons/mail.js.map +1 -1
  109. package/build/spacer/controls.js +25 -6
  110. package/build/spacer/controls.js.map +1 -1
  111. package/build/spacer/edit.js +129 -13
  112. package/build/spacer/edit.js.map +1 -1
  113. package/build/spacer/save.js +2 -2
  114. package/build/spacer/save.js.map +1 -1
  115. package/build/table/state.js +35 -35
  116. package/build/table/state.js.map +1 -1
  117. package/build/template-part/edit/index.js +2 -1
  118. package/build/template-part/edit/index.js.map +1 -1
  119. package/build/template-part/edit/utils/hooks.js +2 -2
  120. package/build/template-part/edit/utils/hooks.js.map +1 -1
  121. package/build/term-description/index.js +1 -2
  122. package/build/term-description/index.js.map +1 -1
  123. package/build/utils/migrate-font-family.js +12 -5
  124. package/build/utils/migrate-font-family.js.map +1 -1
  125. package/build/video/edit.native.js +4 -3
  126. package/build/video/edit.native.js.map +1 -1
  127. package/build-module/column/index.js +2 -1
  128. package/build-module/column/index.js.map +1 -1
  129. package/build-module/columns/edit.js +24 -6
  130. package/build-module/columns/edit.js.map +1 -1
  131. package/build-module/columns/index.js +2 -1
  132. package/build-module/columns/index.js.map +1 -1
  133. package/build-module/columns/utils.js +4 -8
  134. package/build-module/columns/utils.js.map +1 -1
  135. package/build-module/cover/edit/index.js +48 -52
  136. package/build-module/cover/edit/index.js.map +1 -1
  137. package/build-module/cover/edit/{resizable-cover.js → resizable-cover-popover.js} +31 -6
  138. package/build-module/cover/edit/resizable-cover-popover.js.map +1 -0
  139. package/build-module/cover/index.js +12 -0
  140. package/build-module/cover/index.js.map +1 -1
  141. package/build-module/cover/transforms.js +5 -1
  142. package/build-module/cover/transforms.js.map +1 -1
  143. package/build-module/details/edit.js +52 -0
  144. package/build-module/details/edit.js.map +1 -0
  145. package/build-module/details/index.js +91 -0
  146. package/build-module/details/index.js.map +1 -0
  147. package/build-module/details/save.js +20 -0
  148. package/build-module/details/save.js.map +1 -0
  149. package/build-module/details-content/edit.js +23 -0
  150. package/build-module/details-content/edit.js.map +1 -0
  151. package/build-module/details-content/index.js +76 -0
  152. package/build-module/details-content/index.js.map +1 -0
  153. package/build-module/details-content/save.js +11 -0
  154. package/build-module/details-content/save.js.map +1 -0
  155. package/build-module/details-summary/edit.js +30 -0
  156. package/build-module/details-summary/edit.js.map +1 -0
  157. package/build-module/details-summary/index.js +79 -0
  158. package/build-module/details-summary/index.js.map +1 -0
  159. package/build-module/details-summary/save.js +16 -0
  160. package/build-module/details-summary/save.js.map +1 -0
  161. package/build-module/embed/deprecated.js +4 -1
  162. package/build-module/embed/deprecated.js.map +1 -1
  163. package/build-module/embed/embed-link-settings.native.js +1 -1
  164. package/build-module/embed/embed-link-settings.native.js.map +1 -1
  165. package/build-module/embed/embed-placeholder.js +1 -1
  166. package/build-module/embed/embed-placeholder.js.map +1 -1
  167. package/build-module/embed/index.js +4 -1
  168. package/build-module/embed/index.js.map +1 -1
  169. package/build-module/embed/transforms.js +4 -1
  170. package/build-module/embed/transforms.js.map +1 -1
  171. package/build-module/embed/util.js +4 -1
  172. package/build-module/embed/util.js.map +1 -1
  173. package/build-module/file/edit.native.js +0 -2
  174. package/build-module/file/edit.native.js.map +1 -1
  175. package/build-module/gallery/use-get-media.native.js +2 -1
  176. package/build-module/gallery/use-get-media.native.js.map +1 -1
  177. package/build-module/group/edit.js +3 -1
  178. package/build-module/group/edit.js.map +1 -1
  179. package/build-module/group/index.js +3 -0
  180. package/build-module/group/index.js.map +1 -1
  181. package/build-module/image/edit.js +16 -13
  182. package/build-module/image/edit.js.map +1 -1
  183. package/build-module/image/index.js +5 -3
  184. package/build-module/image/index.js.map +1 -1
  185. package/build-module/index.js +21 -6
  186. package/build-module/index.js.map +1 -1
  187. package/build-module/index.native.js +9 -5
  188. package/build-module/index.native.js.map +1 -1
  189. package/build-module/media-text/edit.js +4 -2
  190. package/build-module/media-text/edit.js.map +1 -1
  191. package/build-module/media-text/index.js +3 -0
  192. package/build-module/media-text/index.js.map +1 -1
  193. package/build-module/media-text/media-container.js +1 -5
  194. package/build-module/media-text/media-container.js.map +1 -1
  195. package/build-module/media-text/media-container.native.js +1 -1
  196. package/build-module/media-text/media-container.native.js.map +1 -1
  197. package/build-module/navigation/deprecated.js +8 -10
  198. package/build-module/navigation/deprecated.js.map +1 -1
  199. package/build-module/navigation/edit/index.js +31 -63
  200. package/build-module/navigation/edit/index.js.map +1 -1
  201. package/build-module/navigation/edit/unsaved-inner-blocks.js +1 -14
  202. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  203. package/build-module/post-author/index.js +0 -1
  204. package/build-module/post-author/index.js.map +1 -1
  205. package/build-module/post-date/edit.js +4 -2
  206. package/build-module/post-date/edit.js.map +1 -1
  207. package/build-module/post-excerpt/edit.js +2 -2
  208. package/build-module/post-excerpt/edit.js.map +1 -1
  209. package/build-module/post-featured-image/dimension-controls.js +2 -1
  210. package/build-module/post-featured-image/dimension-controls.js.map +1 -1
  211. package/build-module/post-featured-image/edit.js +16 -27
  212. package/build-module/post-featured-image/edit.js.map +1 -1
  213. package/build-module/post-time-to-read/edit.js +1 -1
  214. package/build-module/post-time-to-read/edit.js.map +1 -1
  215. package/build-module/post-time-to-read/index.js +7 -0
  216. package/build-module/post-time-to-read/index.js.map +1 -1
  217. package/build-module/query/deprecated.js +5 -2
  218. package/build-module/query/deprecated.js.map +1 -1
  219. package/build-module/query/edit/inspector-controls/create-new-post-link.js +33 -0
  220. package/build-module/query/edit/inspector-controls/create-new-post-link.js.map +1 -0
  221. package/build-module/query/edit/inspector-controls/index.js +12 -7
  222. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  223. package/build-module/query/edit/pattern-selection-modal.js +2 -1
  224. package/build-module/query/edit/pattern-selection-modal.js.map +1 -1
  225. package/build-module/query/index.js +5 -10
  226. package/build-module/query/index.js.map +1 -1
  227. package/build-module/site-logo/edit.js +115 -18
  228. package/build-module/site-logo/edit.js.map +1 -1
  229. package/build-module/site-logo/index.js +1 -1
  230. package/build-module/social-link/icons/chain.js +1 -1
  231. package/build-module/social-link/icons/chain.js.map +1 -1
  232. package/build-module/social-link/icons/mail.js +1 -1
  233. package/build-module/social-link/icons/mail.js.map +1 -1
  234. package/build-module/spacer/controls.js +27 -9
  235. package/build-module/spacer/controls.js.map +1 -1
  236. package/build-module/spacer/edit.js +129 -14
  237. package/build-module/spacer/edit.js.map +1 -1
  238. package/build-module/spacer/save.js +3 -3
  239. package/build-module/spacer/save.js.map +1 -1
  240. package/build-module/table/state.js +35 -33
  241. package/build-module/table/state.js.map +1 -1
  242. package/build-module/template-part/edit/index.js +2 -1
  243. package/build-module/template-part/edit/index.js.map +1 -1
  244. package/build-module/template-part/edit/utils/hooks.js +2 -2
  245. package/build-module/template-part/edit/utils/hooks.js.map +1 -1
  246. package/build-module/term-description/index.js +1 -2
  247. package/build-module/term-description/index.js.map +1 -1
  248. package/build-module/utils/migrate-font-family.js +9 -1
  249. package/build-module/utils/migrate-font-family.js.map +1 -1
  250. package/build-module/video/edit.native.js +4 -3
  251. package/build-module/video/edit.native.js.map +1 -1
  252. package/build-style/columns/style-rtl.css +4 -1
  253. package/build-style/columns/style.css +4 -1
  254. package/build-style/common-rtl.css +1 -1
  255. package/build-style/common.css +1 -1
  256. package/build-style/cover/editor-rtl.css +9 -10
  257. package/build-style/cover/editor.css +9 -10
  258. package/build-style/cover/style-rtl.css +1 -1
  259. package/build-style/cover/style.css +1 -1
  260. package/build-style/details/style-rtl.css +91 -0
  261. package/build-style/details/style.css +91 -0
  262. package/build-style/details-summary/editor-rtl.css +91 -0
  263. package/build-style/details-summary/editor.css +91 -0
  264. package/build-style/details-summary/style-rtl.css +91 -0
  265. package/build-style/details-summary/style.css +91 -0
  266. package/build-style/editor-rtl.css +97 -74
  267. package/build-style/editor.css +97 -74
  268. package/build-style/file/style-rtl.css +4 -3
  269. package/build-style/file/style.css +4 -3
  270. package/build-style/html/editor-rtl.css +2 -2
  271. package/build-style/html/editor.css +2 -2
  272. package/build-style/image/editor-rtl.css +1 -1
  273. package/build-style/image/editor.css +1 -1
  274. package/build-style/post-excerpt/style-rtl.css +1 -1
  275. package/build-style/post-excerpt/style.css +1 -1
  276. package/build-style/pullquote/style-rtl.css +4 -1
  277. package/build-style/pullquote/style.css +4 -1
  278. package/build-style/query/editor-rtl.css +8 -12
  279. package/build-style/query/editor.css +8 -12
  280. package/build-style/search/style-rtl.css +2 -0
  281. package/build-style/search/style.css +2 -0
  282. package/build-style/shortcode/editor-rtl.css +15 -35
  283. package/build-style/shortcode/editor.css +15 -35
  284. package/build-style/site-logo/editor-rtl.css +46 -0
  285. package/build-style/site-logo/editor.css +46 -0
  286. package/build-style/spacer/editor-rtl.css +4 -2
  287. package/build-style/spacer/editor.css +4 -2
  288. package/build-style/style-rtl.css +25 -8
  289. package/build-style/style.css +25 -8
  290. package/build-style/template-part/editor-rtl.css +8 -12
  291. package/build-style/template-part/editor.css +8 -12
  292. package/package.json +31 -31
  293. package/src/buttons/test/__snapshots__/edit.native.js.snap +18 -0
  294. package/src/buttons/test/edit.native.js +123 -2
  295. package/src/column/block.json +2 -1
  296. package/src/columns/block.json +2 -1
  297. package/src/columns/edit.js +33 -9
  298. package/src/columns/style.scss +5 -1
  299. package/src/columns/utils.js +8 -9
  300. package/src/common.scss +1 -1
  301. package/src/cover/block.json +12 -0
  302. package/src/cover/edit/index.js +44 -37
  303. package/src/cover/edit/resizable-cover-popover.js +82 -0
  304. package/src/cover/editor.scss +20 -13
  305. package/src/cover/index.php +9 -10
  306. package/src/cover/style.scss +1 -1
  307. package/src/cover/test/edit.js +1 -1
  308. package/src/cover/transforms.js +4 -1
  309. package/src/details/block.json +54 -0
  310. package/src/details/edit.js +59 -0
  311. package/src/details/index.js +35 -0
  312. package/src/details/save.js +15 -0
  313. package/src/details/style.scss +3 -0
  314. package/src/details-content/block.json +50 -0
  315. package/src/details-content/edit.js +29 -0
  316. package/src/details-content/index.js +23 -0
  317. package/src/details-content/save.js +12 -0
  318. package/src/details-summary/block.json +53 -0
  319. package/src/details-summary/edit.js +27 -0
  320. package/src/details-summary/editor.scss +3 -0
  321. package/src/details-summary/index.js +23 -0
  322. package/src/details-summary/save.js +13 -0
  323. package/src/details-summary/style.scss +3 -0
  324. package/src/editor.scss +1 -0
  325. package/src/embed/block.json +4 -1
  326. package/src/embed/embed-link-settings.native.js +1 -1
  327. package/src/embed/embed-placeholder.js +1 -1
  328. package/src/file/edit.native.js +0 -2
  329. package/src/file/style.scss +5 -2
  330. package/src/gallery/test/index.native.js +4 -4
  331. package/src/gallery/test/use-get-media.native.js +24 -0
  332. package/src/gallery/use-get-media.native.js +1 -1
  333. package/src/group/block.json +3 -0
  334. package/src/group/edit.js +8 -2
  335. package/src/heading/test/__snapshots__/index.native.js.snap +12 -0
  336. package/src/heading/test/index.native.js +71 -0
  337. package/src/html/editor.scss +2 -21
  338. package/src/image/block.json +5 -3
  339. package/src/image/edit.js +21 -17
  340. package/src/image/editor.scss +1 -1
  341. package/src/index.js +13 -3
  342. package/src/index.native.js +9 -5
  343. package/src/list/test/edit.native.js +7 -7
  344. package/src/media-text/block.json +3 -0
  345. package/src/media-text/edit.js +2 -1
  346. package/src/media-text/media-container.js +1 -5
  347. package/src/media-text/media-container.native.js +1 -1
  348. package/src/navigation/deprecated.js +15 -19
  349. package/src/navigation/edit/index.js +32 -106
  350. package/src/navigation/edit/unsaved-inner-blocks.js +34 -46
  351. package/src/navigation/index.php +15 -12
  352. package/src/paragraph/test/edit.native.js +616 -1
  353. package/src/post-author/block.json +0 -1
  354. package/src/post-date/edit.js +4 -0
  355. package/src/post-date/index.php +17 -8
  356. package/src/post-excerpt/edit.js +1 -1
  357. package/src/post-excerpt/index.php +3 -3
  358. package/src/post-excerpt/style.scss +2 -1
  359. package/src/post-featured-image/dimension-controls.js +5 -1
  360. package/src/post-featured-image/edit.js +14 -34
  361. package/src/post-featured-image/index.php +1 -1
  362. package/src/post-time-to-read/block.json +7 -0
  363. package/src/post-time-to-read/edit.js +1 -1
  364. package/src/post-time-to-read/index.php +3 -3
  365. package/src/preformatted/test/__snapshots__/edit.native.js.snap +2 -2
  366. package/src/preformatted/test/edit.native.js +42 -2
  367. package/src/pullquote/style.scss +5 -1
  368. package/src/pullquote/test/edit.native.js +65 -0
  369. package/src/query/deprecated.js +4 -1
  370. package/src/query/edit/inspector-controls/create-new-post-link.js +26 -0
  371. package/src/query/edit/inspector-controls/index.js +13 -6
  372. package/src/query/edit/pattern-selection-modal.js +1 -0
  373. package/src/query/editor.scss +8 -11
  374. package/src/query/index.js +1 -7
  375. package/src/quote/test/edit.native.js +88 -0
  376. package/src/search/index.php +1 -1
  377. package/src/search/style.scss +3 -0
  378. package/src/shortcode/editor.scss +6 -5
  379. package/src/site-logo/block.json +1 -1
  380. package/src/site-logo/edit.js +123 -9
  381. package/src/site-logo/editor.scss +57 -0
  382. package/src/social-link/icons/chain.js +1 -1
  383. package/src/social-link/icons/mail.js +1 -1
  384. package/src/social-link/index.php +2 -2
  385. package/src/spacer/controls.js +42 -17
  386. package/src/spacer/edit.js +176 -18
  387. package/src/spacer/editor.scss +2 -1
  388. package/src/spacer/save.js +3 -3
  389. package/src/style.scss +2 -0
  390. package/src/table/state.js +83 -66
  391. package/src/template-part/edit/index.js +1 -0
  392. package/src/template-part/edit/utils/hooks.js +2 -2
  393. package/src/template-part/editor.scss +9 -11
  394. package/src/term-description/block.json +1 -2
  395. package/src/utils/migrate-font-family.js +8 -1
  396. package/src/verse/test/edit.native.js +28 -0
  397. package/src/video/edit.native.js +2 -2
  398. package/tsconfig.json +1 -0
  399. package/build/cover/edit/resizable-cover.js.map +0 -1
  400. package/build/media-text/media-container-icon.js +0 -27
  401. package/build/media-text/media-container-icon.js.map +0 -1
  402. package/build/query/hooks.js +0 -72
  403. package/build/query/hooks.js.map +0 -1
  404. package/build/utils/clean-empty-object.js +0 -34
  405. package/build/utils/clean-empty-object.js.map +0 -1
  406. package/build-module/cover/edit/resizable-cover.js.map +0 -1
  407. package/build-module/media-text/media-container-icon.js +0 -17
  408. package/build-module/media-text/media-container-icon.js.map +0 -1
  409. package/build-module/query/hooks.js +0 -59
  410. package/build-module/query/hooks.js.map +0 -1
  411. package/build-module/utils/clean-empty-object.js +0 -25
  412. package/build-module/utils/clean-empty-object.js.map +0 -1
  413. package/src/cover/edit/resizable-cover.js +0 -61
  414. package/src/media-text/media-container-icon.js +0 -12
  415. package/src/query/hooks.js +0 -53
  416. package/src/utils/clean-empty-object.js +0 -28
@@ -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
+ typeInRichText,
9
+ fireEvent,
10
+ getEditorHtml,
11
+ initializeEditor,
12
+ render,
13
+ setupCoreBlocks,
14
+ waitFor,
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,599 @@ 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
+ typeInRichText(
59
+ paragraphTextInput,
60
+ 'A quick brown fox jumps over the lazy dog.',
61
+ { finalSelectionStart: 2, finalSelectionEnd: 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
+ typeInRichText(
84
+ paragraphTextInput,
85
+ 'A quick brown fox jumps over the lazy dog.',
86
+ { finalSelectionStart: 2, finalSelectionEnd: 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
+ typeInRichText(
109
+ paragraphTextInput,
110
+ 'A quick brown fox jumps over the lazy dog.',
111
+ { finalSelectionStart: 2, finalSelectionEnd: 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
+ typeInRichText(
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
+ typeInRichText(
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
+ typeInRichText(
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
+ typeInRichText( paragraphTextInput, string, {
212
+ finalSelectionStart: string.length / 2,
213
+ finalSelectionEnd: 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
+ typeInRichText(
283
+ paragraphTextInput,
284
+ 'A quick brown fox jumps over the lazy dog.',
285
+ {
286
+ finalSelectionStart: 2,
287
+ finalSelectionEnd: 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
+ typeInRichText(
329
+ paragraphTextInput,
330
+ 'A quick brown fox jumps over the lazy dog.',
331
+ {
332
+ finalSelectionStart: 2,
333
+ finalSelectionEnd: 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
+ typeInRichText( paragraphTextInput, ' some text ', {
366
+ finalSelectionStart: 5,
367
+ finalSelectionEnd: 14,
368
+ } );
369
+ fireEvent.press( screen.getByLabelText( 'Italic' ) );
370
+
371
+ // Assert
372
+ expect( getEditorHtml() ).toMatchInlineSnapshot( `
373
+ "<!-- wp:paragraph -->
374
+ <p> <em>some text</em> </p>
375
+ <!-- /wp:paragraph -->"
376
+ ` );
377
+ } );
378
+
379
+ it( 'should set a text color', async () => {
380
+ // Arrange
381
+ const screen = await initializeEditor();
382
+ await addBlock( screen, 'Paragraph' );
383
+
384
+ // Act
385
+ const paragraphBlock = getBlock( screen, 'Paragraph' );
386
+ fireEvent.press( paragraphBlock );
387
+ const paragraphTextInput =
388
+ within( paragraphBlock ).getByPlaceholderText( 'Start writing…' );
389
+ typeInRichText(
390
+ paragraphTextInput,
391
+ 'A quick brown fox jumps over the lazy dog.'
392
+ );
393
+ // Open Block Settings.
394
+ fireEvent.press( screen.getByLabelText( 'Open Settings' ) );
395
+
396
+ // Wait for Block Settings to be visible.
397
+ const blockSettingsModal = screen.getByTestId( 'block-settings-modal' );
398
+ await waitFor( () => blockSettingsModal.props.isVisible );
399
+
400
+ // Open Text color settings
401
+ fireEvent.press( screen.getByLabelText( 'Text, Default' ) );
402
+
403
+ // Tap one color
404
+ fireEvent.press( screen.getByLabelText( 'Pale pink' ) );
405
+
406
+ // Dismiss the Block Settings modal.
407
+ fireEvent( blockSettingsModal, 'backdropPress' );
408
+
409
+ // Assert
410
+ expect( getEditorHtml() ).toMatchInlineSnapshot( `
411
+ "<!-- wp:paragraph {"textColor":"pale-pink"} -->
412
+ <p class="has-pale-pink-color has-text-color">A quick brown fox jumps over the lazy dog.</p>
413
+ <!-- /wp:paragraph -->"
414
+ ` );
415
+ } );
416
+
417
+ it( 'should set a background color', async () => {
418
+ // Arrange
419
+ const screen = await initializeEditor();
420
+ await addBlock( screen, 'Paragraph' );
421
+
422
+ // Act
423
+ const paragraphBlock = getBlock( screen, 'Paragraph' );
424
+ fireEvent.press( paragraphBlock );
425
+ const paragraphTextInput =
426
+ within( paragraphBlock ).getByPlaceholderText( 'Start writing…' );
427
+ typeInRichText(
428
+ paragraphTextInput,
429
+ 'A quick brown fox jumps over the lazy dog.'
430
+ );
431
+ // Open Block Settings.
432
+ fireEvent.press( screen.getByLabelText( 'Open Settings' ) );
433
+
434
+ // Wait for Block Settings to be visible.
435
+ const blockSettingsModal = screen.getByTestId( 'block-settings-modal' );
436
+ await waitFor( () => blockSettingsModal.props.isVisible );
437
+
438
+ // Open Background color settings
439
+ fireEvent.press( screen.getByLabelText( 'Background, Default' ) );
440
+
441
+ // Tap one color
442
+ fireEvent.press( screen.getByLabelText( 'Luminous vivid orange' ) );
443
+
444
+ // Dismiss the Block Settings modal.
445
+ fireEvent( blockSettingsModal, 'backdropPress' );
446
+
447
+ // Assert
448
+ expect( getEditorHtml() ).toMatchInlineSnapshot( `
449
+ "<!-- wp:paragraph {"backgroundColor":"luminous-vivid-orange"} -->
450
+ <p class="has-luminous-vivid-orange-background-color has-background">A quick brown fox jumps over the lazy dog.</p>
451
+ <!-- /wp:paragraph -->"
452
+ ` );
453
+ } );
454
+
455
+ it( 'should set a text and background color', async () => {
456
+ // Arrange
457
+ const screen = await initializeEditor();
458
+ await addBlock( screen, 'Paragraph' );
459
+
460
+ // Act
461
+ const paragraphBlock = getBlock( screen, 'Paragraph' );
462
+ fireEvent.press( paragraphBlock );
463
+ const paragraphTextInput =
464
+ within( paragraphBlock ).getByPlaceholderText( 'Start writing…' );
465
+ typeInRichText(
466
+ paragraphTextInput,
467
+ 'A quick brown fox jumps over the lazy dog.'
468
+ );
469
+ // Open Block Settings.
470
+ fireEvent.press( screen.getByLabelText( 'Open Settings' ) );
471
+
472
+ // Wait for Block Settings to be visible.
473
+ const blockSettingsModal = screen.getByTestId( 'block-settings-modal' );
474
+ await waitFor( () => blockSettingsModal.props.isVisible );
475
+
476
+ // Open Text color settings
477
+ fireEvent.press( screen.getByLabelText( 'Text, Default' ) );
478
+
479
+ // Tap one color
480
+ fireEvent.press( screen.getByLabelText( 'White' ) );
481
+
482
+ // Go back to the settings menu
483
+ fireEvent.press( screen.getByLabelText( 'Go back' ) );
484
+
485
+ // Open Background color settings
486
+ fireEvent.press( screen.getByLabelText( 'Background, Default' ) );
487
+
488
+ // Tap one color
489
+ fireEvent.press( screen.getByLabelText( 'Luminous vivid orange' ) );
490
+
491
+ // Dismiss the Block Settings modal.
492
+ fireEvent( blockSettingsModal, 'backdropPress' );
493
+
494
+ // Assert
495
+ expect( getEditorHtml() ).toMatchInlineSnapshot( `
496
+ "<!-- wp:paragraph {"backgroundColor":"luminous-vivid-orange","textColor":"white"} -->
497
+ <p class="has-white-color has-luminous-vivid-orange-background-color has-text-color has-background">A quick brown fox jumps over the lazy dog.</p>
498
+ <!-- /wp:paragraph -->"
499
+ ` );
500
+ } );
501
+
502
+ it( 'should remove text and background colors', async () => {
503
+ // Arrange
504
+ const screen = await initializeEditor( {
505
+ initialHtml: `<!-- wp:paragraph {"backgroundColor":"luminous-vivid-orange","textColor":"white"} -->
506
+ <p class="has-white-color has-luminous-vivid-orange-background-color has-text-color has-background">A quick brown fox jumps over the lazy dog.</p>
507
+ <!-- /wp:paragraph -->`,
508
+ } );
509
+
510
+ // Act
511
+ const paragraphBlock = getBlock( screen, 'Paragraph' );
512
+ fireEvent.press( paragraphBlock );
513
+
514
+ // Open Block Settings.
515
+ fireEvent.press( screen.getByLabelText( 'Open Settings' ) );
516
+
517
+ // Wait for Block Settings to be visible.
518
+ const blockSettingsModal = screen.getByTestId( 'block-settings-modal' );
519
+ await waitFor( () => blockSettingsModal.props.isVisible );
520
+
521
+ // Open Text color settings
522
+ fireEvent.press( screen.getByLabelText( 'Text. Empty' ) );
523
+
524
+ // Reset color
525
+ fireEvent.press( await screen.findByText( 'Reset' ) );
526
+
527
+ // Go back to the settings menu
528
+ fireEvent.press( screen.getByLabelText( 'Go back' ) );
529
+
530
+ // Open Background color settings
531
+ fireEvent.press( screen.getByLabelText( 'Background. Empty' ) );
532
+
533
+ // Reset color
534
+ fireEvent.press( await screen.findByText( 'Reset' ) );
535
+
536
+ // Dismiss the Block Settings modal.
537
+ fireEvent( blockSettingsModal, 'backdropPress' );
538
+
539
+ // Assert
540
+ expect( getEditorHtml() ).toMatchInlineSnapshot( `
541
+ "<!-- wp:paragraph -->
542
+ <p>A quick brown fox jumps over the lazy dog.</p>
543
+ <!-- /wp:paragraph -->"
544
+ ` );
545
+ } );
546
+
547
+ it( 'should not have a gradient background color option', async () => {
548
+ // Arrange
549
+ const screen = await initializeEditor();
550
+ await addBlock( screen, 'Paragraph' );
551
+
552
+ // Act
553
+ const paragraphBlock = getBlock( screen, 'Paragraph' );
554
+ fireEvent.press( paragraphBlock );
555
+ const paragraphTextInput =
556
+ within( paragraphBlock ).getByPlaceholderText( 'Start writing…' );
557
+ typeInRichText(
558
+ paragraphTextInput,
559
+ 'A quick brown fox jumps over the lazy dog.'
560
+ );
561
+ // Open Block Settings.
562
+ fireEvent.press( screen.getByLabelText( 'Open Settings' ) );
563
+
564
+ // Wait for Block Settings to be visible.
565
+ const blockSettingsModal = screen.getByTestId( 'block-settings-modal' );
566
+ await waitFor( () => blockSettingsModal.props.isVisible );
567
+
568
+ // Open Background color settings
569
+ fireEvent.press( screen.getByLabelText( 'Background, Default' ) );
570
+
571
+ // Assert
572
+ const colorButton = screen.getByLabelText( 'Luminous vivid orange' );
573
+ expect( colorButton ).toBeDefined();
574
+
575
+ const gradientButton = screen.queryByLabelText( 'Gradient' );
576
+ expect( gradientButton ).toBeNull();
577
+ } );
578
+
579
+ it( 'should set a theme text color', async () => {
580
+ // Arrange
581
+ const screen = await initializeEditor( { withGlobalStyles: true } );
582
+ await addBlock( screen, 'Paragraph' );
583
+
584
+ // Act
585
+ const paragraphBlock = getBlock( screen, 'Paragraph' );
586
+ fireEvent.press( paragraphBlock );
587
+ const paragraphTextInput =
588
+ within( paragraphBlock ).getByPlaceholderText( 'Start writing…' );
589
+ typeInRichText(
590
+ paragraphTextInput,
591
+ 'A quick brown fox jumps over the lazy dog.'
592
+ );
593
+ // Open Block Settings.
594
+ fireEvent.press( screen.getByLabelText( 'Open Settings' ) );
595
+
596
+ // Wait for Block Settings to be visible.
597
+ const blockSettingsModal = screen.getByTestId( 'block-settings-modal' );
598
+ await waitFor( () => blockSettingsModal.props.isVisible );
599
+
600
+ // Open Text color settings
601
+ fireEvent.press( screen.getByLabelText( 'Text, Default' ) );
602
+
603
+ // Tap one color
604
+ fireEvent.press( screen.getByLabelText( 'Tertiary' ) );
605
+
606
+ // Dismiss the Block Settings modal.
607
+ fireEvent( blockSettingsModal, 'backdropPress' );
608
+
609
+ // Assert
610
+ expect( getEditorHtml() ).toMatchInlineSnapshot( `
611
+ "<!-- wp:paragraph {"textColor":"tertiary"} -->
612
+ <p class="has-tertiary-color has-text-color">A quick brown fox jumps over the lazy dog.</p>
613
+ <!-- /wp:paragraph -->"
614
+ ` );
615
+ } );
616
+
617
+ it( 'should show the contrast check warning', async () => {
618
+ // Arrange
619
+ const screen = await initializeEditor( {
620
+ initialHtml: `<!-- wp:paragraph {"backgroundColor":"white","textColor":"white"} -->
621
+ <p class="has-white-color has-white-background-color has-text-color has-background">A quick brown fox jumps over the lazy dog.</p>
622
+ <!-- /wp:paragraph -->`,
623
+ } );
624
+
625
+ // Act
626
+ const paragraphBlock = getBlock( screen, 'Paragraph' );
627
+ fireEvent.press( paragraphBlock );
628
+
629
+ // Open Block Settings.
630
+ fireEvent.press( screen.getByLabelText( 'Open Settings' ) );
631
+
632
+ // Wait for Block Settings to be visible.
633
+ const blockSettingsModal = screen.getByTestId( 'block-settings-modal' );
634
+ await waitFor( () => blockSettingsModal.props.isVisible );
635
+
636
+ // Assert
637
+ const contrastCheckElement = screen.getByText(
638
+ /This color combination/
639
+ );
640
+ expect( contrastCheckElement ).toBeDefined();
641
+ } );
27
642
  } );
@@ -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
  }
@@ -37,6 +37,7 @@ export default function PostDateEdit( {
37
37
  const blockProps = useBlockProps( {
38
38
  className: classnames( {
39
39
  [ `has-text-align-${ textAlign }` ]: textAlign,
40
+ [ `wp-block-post-date__modified-date` ]: displayType === 'modified',
40
41
  } ),
41
42
  } );
42
43
 
@@ -175,6 +176,9 @@ export default function PostDateEdit( {
175
176
  } )
176
177
  }
177
178
  checked={ displayType === 'modified' }
179
+ help={ __(
180
+ 'Only shows if the post has been modified'
181
+ ) }
178
182
  />
179
183
  </PanelBody>
180
184
  </InspectorControls>
@@ -18,25 +18,34 @@ function render_block_core_post_date( $attributes, $content, $block ) {
18
18
  return '';
19
19
  }
20
20
 
21
- $post_ID = $block->context['postId'];
21
+ $post_ID = $block->context['postId'];
22
+ $formatted_date = get_the_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $post_ID );
23
+ $unformatted_date = esc_attr( get_the_date( 'c', $post_ID ) );
24
+ $classes = array();
22
25
 
23
- $classes = array();
24
26
  if ( isset( $attributes['textAlign'] ) ) {
25
27
  $classes[] = 'has-text-align-' . $attributes['textAlign'];
26
28
  }
27
29
  if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
28
30
  $classes[] = 'has-link-color';
29
31
  }
30
- $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
31
32
 
33
+ /*
34
+ * If the "Display last modified date" setting is enabled,
35
+ * only display the modified date if it is later than the publishing date.
36
+ */
32
37
  if ( isset( $attributes['displayType'] ) && 'modified' === $attributes['displayType'] ) {
33
- $formatted_date = get_the_modified_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $post_ID );
34
- $unformatted_date = esc_attr( get_the_modified_date( 'c', $post_ID ) );
35
- } else {
36
- $formatted_date = get_the_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $post_ID );
37
- $unformatted_date = esc_attr( get_the_date( 'c', $post_ID ) );
38
+ if ( get_the_modified_date( 'Ymdhi', $post_ID ) > get_the_date( 'Ymdhi', $post_ID ) ) {
39
+ $formatted_date = get_the_modified_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $post_ID );
40
+ $unformatted_date = esc_attr( get_the_modified_date( 'c', $post_ID ) );
41
+ $classes[] = 'wp-block-post-date__modified-date';
42
+ } else {
43
+ return '';
44
+ }
38
45
  }
39
46
 
47
+ $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
48
+
40
49
  if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
41
50
  $formatted_date = sprintf( '<a href="%1s">%2s</a>', get_the_permalink( $post_ID ), $formatted_date );
42
51
  }