@wordpress/block-library 9.27.1-next.46f643fa0.0 → 9.28.1-next.0f6f9d12c.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 (271) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/accordion-header/edit.js +118 -0
  3. package/build/accordion-header/edit.js.map +1 -0
  4. package/build/accordion-header/index.js +124 -0
  5. package/build/accordion-header/index.js.map +1 -0
  6. package/build/accordion-header/init.js +12 -0
  7. package/build/accordion-header/init.js.map +1 -0
  8. package/build/accordion-header/save.js +81 -0
  9. package/build/accordion-header/save.js.map +1 -0
  10. package/build/accordion-item/edit.js +129 -0
  11. package/build/accordion-item/edit.js.map +1 -0
  12. package/build/accordion-item/icons.js +30 -0
  13. package/build/accordion-item/icons.js.map +1 -0
  14. package/build/accordion-item/index.js +79 -0
  15. package/build/accordion-item/index.js.map +1 -0
  16. package/build/accordion-item/init.js +12 -0
  17. package/build/accordion-item/init.js.map +1 -0
  18. package/build/accordion-item/save.js +37 -0
  19. package/build/accordion-item/save.js.map +1 -0
  20. package/build/accordion-panel/edit.js +59 -0
  21. package/build/accordion-panel/edit.js.map +1 -0
  22. package/build/accordion-panel/index.js +108 -0
  23. package/build/accordion-panel/index.js.map +1 -0
  24. package/build/accordion-panel/init.js +12 -0
  25. package/build/accordion-panel/init.js.map +1 -0
  26. package/build/accordion-panel/save.js +46 -0
  27. package/build/accordion-panel/save.js.map +1 -0
  28. package/build/accordions/edit.js +123 -0
  29. package/build/accordions/edit.js.map +1 -0
  30. package/build/accordions/index.js +103 -0
  31. package/build/accordions/index.js.map +1 -0
  32. package/build/accordions/init.js +12 -0
  33. package/build/accordions/init.js.map +1 -0
  34. package/build/accordions/save.js +36 -0
  35. package/build/accordions/save.js.map +1 -0
  36. package/build/accordions/view.js +49 -0
  37. package/build/accordions/view.js.map +1 -0
  38. package/build/cover/edit/index.js +1 -1
  39. package/build/cover/edit/index.js.map +1 -1
  40. package/build/cover/edit/inspector-controls.js +1 -1
  41. package/build/cover/edit/inspector-controls.js.map +1 -1
  42. package/build/cover/index.js +2 -1
  43. package/build/cover/index.js.map +1 -1
  44. package/build/file/edit.js +4 -2
  45. package/build/file/edit.js.map +1 -1
  46. package/build/file/edit.native.js +1 -1
  47. package/build/file/edit.native.js.map +1 -1
  48. package/build/file/transforms.js +6 -6
  49. package/build/file/transforms.js.map +1 -1
  50. package/build/file/utils/index.js +5 -0
  51. package/build/file/utils/index.js.map +1 -1
  52. package/build/freeform/edit.js +6 -0
  53. package/build/freeform/edit.js.map +1 -1
  54. package/build/gallery/use-get-media.js +3 -3
  55. package/build/gallery/use-get-media.js.map +1 -1
  56. package/build/gallery/use-get-media.native.js +3 -3
  57. package/build/gallery/use-get-media.native.js.map +1 -1
  58. package/build/image/edit.native.js +2 -2
  59. package/build/image/edit.native.js.map +1 -1
  60. package/build/image/image.js +1 -1
  61. package/build/image/image.js.map +1 -1
  62. package/build/index.js +10 -0
  63. package/build/index.js.map +1 -1
  64. package/build/list-item/edit.js +3 -0
  65. package/build/list-item/edit.js.map +1 -1
  66. package/build/media-text/edit.js +2 -2
  67. package/build/media-text/edit.js.map +1 -1
  68. package/build/media-text/media-container.js +2 -1
  69. package/build/media-text/media-container.js.map +1 -1
  70. package/build/media-text/transforms.js +7 -3
  71. package/build/media-text/transforms.js.map +1 -1
  72. package/build/more/edit.js +13 -28
  73. package/build/more/edit.js.map +1 -1
  74. package/build/post-comments-count/index.js +3 -0
  75. package/build/post-comments-count/index.js.map +1 -1
  76. package/build/post-comments-link/index.js +3 -0
  77. package/build/post-comments-link/index.js.map +1 -1
  78. package/build/post-featured-image/edit.js +2 -2
  79. package/build/post-featured-image/edit.js.map +1 -1
  80. package/build/query-title/edit.js +52 -2
  81. package/build/query-title/edit.js.map +1 -1
  82. package/build/query-title/index.js +1 -0
  83. package/build/query-title/index.js.map +1 -1
  84. package/build/query-title/use-post-type-label.js +42 -0
  85. package/build/query-title/use-post-type-label.js.map +1 -0
  86. package/build/query-title/variations.js +10 -0
  87. package/build/query-title/variations.js.map +1 -1
  88. package/build/site-logo/edit.js +58 -43
  89. package/build/site-logo/edit.js.map +1 -1
  90. package/build/site-title/edit.js +9 -3
  91. package/build/site-title/edit.js.map +1 -1
  92. package/build/social-link/icons/tiktok.js +2 -2
  93. package/build/social-link/icons/tiktok.js.map +1 -1
  94. package/build/utils/poster-image.js +54 -6
  95. package/build/utils/poster-image.js.map +1 -1
  96. package/build-module/accordion-header/edit.js +108 -0
  97. package/build-module/accordion-header/edit.js.map +1 -0
  98. package/build-module/accordion-header/index.js +116 -0
  99. package/build-module/accordion-header/index.js.map +1 -0
  100. package/build-module/accordion-header/init.js +6 -0
  101. package/build-module/accordion-header/init.js.map +1 -0
  102. package/build-module/accordion-header/save.js +71 -0
  103. package/build-module/accordion-header/save.js.map +1 -0
  104. package/build-module/accordion-item/edit.js +120 -0
  105. package/build-module/accordion-item/edit.js.map +1 -0
  106. package/build-module/accordion-item/icons.js +22 -0
  107. package/build-module/accordion-item/icons.js.map +1 -0
  108. package/build-module/accordion-item/index.js +71 -0
  109. package/build-module/accordion-item/index.js.map +1 -0
  110. package/build-module/accordion-item/init.js +6 -0
  111. package/build-module/accordion-item/init.js.map +1 -0
  112. package/build-module/accordion-item/save.js +28 -0
  113. package/build-module/accordion-item/save.js.map +1 -0
  114. package/build-module/accordion-panel/edit.js +50 -0
  115. package/build-module/accordion-panel/edit.js.map +1 -0
  116. package/build-module/accordion-panel/index.js +100 -0
  117. package/build-module/accordion-panel/index.js.map +1 -0
  118. package/build-module/accordion-panel/init.js +6 -0
  119. package/build-module/accordion-panel/init.js.map +1 -0
  120. package/build-module/accordion-panel/save.js +37 -0
  121. package/build-module/accordion-panel/save.js.map +1 -0
  122. package/build-module/accordions/edit.js +116 -0
  123. package/build-module/accordions/edit.js.map +1 -0
  124. package/build-module/accordions/index.js +95 -0
  125. package/build-module/accordions/index.js.map +1 -0
  126. package/build-module/accordions/init.js +6 -0
  127. package/build-module/accordions/init.js.map +1 -0
  128. package/build-module/accordions/save.js +27 -0
  129. package/build-module/accordions/save.js.map +1 -0
  130. package/build-module/accordions/view.js +46 -0
  131. package/build-module/accordions/view.js.map +1 -0
  132. package/build-module/cover/edit/index.js +1 -1
  133. package/build-module/cover/edit/index.js.map +1 -1
  134. package/build-module/cover/edit/inspector-controls.js +1 -1
  135. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  136. package/build-module/cover/index.js +2 -1
  137. package/build-module/cover/index.js.map +1 -1
  138. package/build-module/file/edit.js +4 -2
  139. package/build-module/file/edit.js.map +1 -1
  140. package/build-module/file/edit.native.js +1 -1
  141. package/build-module/file/edit.native.js.map +1 -1
  142. package/build-module/file/transforms.js +6 -6
  143. package/build-module/file/transforms.js.map +1 -1
  144. package/build-module/file/utils/index.js +5 -0
  145. package/build-module/file/utils/index.js.map +1 -1
  146. package/build-module/freeform/edit.js +6 -0
  147. package/build-module/freeform/edit.js.map +1 -1
  148. package/build-module/gallery/use-get-media.js +3 -3
  149. package/build-module/gallery/use-get-media.js.map +1 -1
  150. package/build-module/gallery/use-get-media.native.js +3 -3
  151. package/build-module/gallery/use-get-media.native.js.map +1 -1
  152. package/build-module/image/edit.native.js +2 -2
  153. package/build-module/image/edit.native.js.map +1 -1
  154. package/build-module/image/image.js +1 -1
  155. package/build-module/image/image.js.map +1 -1
  156. package/build-module/index.js +10 -0
  157. package/build-module/index.js.map +1 -1
  158. package/build-module/list-item/edit.js +3 -0
  159. package/build-module/list-item/edit.js.map +1 -1
  160. package/build-module/media-text/edit.js +2 -2
  161. package/build-module/media-text/edit.js.map +1 -1
  162. package/build-module/media-text/media-container.js +2 -1
  163. package/build-module/media-text/media-container.js.map +1 -1
  164. package/build-module/media-text/transforms.js +7 -3
  165. package/build-module/media-text/transforms.js.map +1 -1
  166. package/build-module/more/edit.js +15 -29
  167. package/build-module/more/edit.js.map +1 -1
  168. package/build-module/post-comments-count/index.js +3 -0
  169. package/build-module/post-comments-count/index.js.map +1 -1
  170. package/build-module/post-comments-link/index.js +3 -0
  171. package/build-module/post-comments-link/index.js.map +1 -1
  172. package/build-module/post-featured-image/edit.js +2 -2
  173. package/build-module/post-featured-image/edit.js.map +1 -1
  174. package/build-module/query-title/edit.js +52 -2
  175. package/build-module/query-title/edit.js.map +1 -1
  176. package/build-module/query-title/index.js +1 -0
  177. package/build-module/query-title/index.js.map +1 -1
  178. package/build-module/query-title/use-post-type-label.js +36 -0
  179. package/build-module/query-title/use-post-type-label.js.map +1 -0
  180. package/build-module/query-title/variations.js +10 -0
  181. package/build-module/query-title/variations.js.map +1 -1
  182. package/build-module/site-logo/edit.js +59 -44
  183. package/build-module/site-logo/edit.js.map +1 -1
  184. package/build-module/site-title/edit.js +10 -4
  185. package/build-module/site-title/edit.js.map +1 -1
  186. package/build-module/social-link/icons/tiktok.js +2 -2
  187. package/build-module/social-link/icons/tiktok.js.map +1 -1
  188. package/build-module/utils/poster-image.js +57 -9
  189. package/build-module/utils/poster-image.js.map +1 -1
  190. package/build-style/accordions/style-rtl.css +223 -0
  191. package/build-style/accordions/style.css +223 -0
  192. package/build-style/editor-rtl.css +23 -26
  193. package/build-style/editor.css +23 -26
  194. package/build-style/gallery/style-rtl.css +1 -2
  195. package/build-style/gallery/style.css +1 -2
  196. package/build-style/image/style-rtl.css +1 -2
  197. package/build-style/image/style.css +1 -2
  198. package/build-style/more/editor-rtl.css +3 -11
  199. package/build-style/more/editor.css +3 -11
  200. package/build-style/post-featured-image/editor-rtl.css +1 -2
  201. package/build-style/post-featured-image/editor.css +1 -2
  202. package/build-style/style-rtl.css +90 -4
  203. package/build-style/style.css +90 -4
  204. package/package.json +36 -35
  205. package/src/accordion-header/block.json +93 -0
  206. package/src/accordion-header/edit.js +128 -0
  207. package/src/accordion-header/index.js +24 -0
  208. package/src/accordion-header/init.js +6 -0
  209. package/src/accordion-header/save.js +79 -0
  210. package/src/accordion-item/block.json +45 -0
  211. package/src/accordion-item/edit.js +149 -0
  212. package/src/accordion-item/icons.js +23 -0
  213. package/src/accordion-item/index.js +24 -0
  214. package/src/accordion-item/index.php +73 -0
  215. package/src/accordion-item/init.js +6 -0
  216. package/src/accordion-item/save.js +25 -0
  217. package/src/accordion-panel/block.json +74 -0
  218. package/src/accordion-panel/edit.js +61 -0
  219. package/src/accordion-panel/index.js +24 -0
  220. package/src/accordion-panel/init.js +6 -0
  221. package/src/accordion-panel/save.js +51 -0
  222. package/src/accordions/block.json +69 -0
  223. package/src/accordions/edit.js +133 -0
  224. package/src/accordions/index.js +24 -0
  225. package/src/accordions/index.php +61 -0
  226. package/src/accordions/init.js +6 -0
  227. package/src/accordions/save.js +23 -0
  228. package/src/accordions/style.scss +91 -0
  229. package/src/accordions/view.js +38 -0
  230. package/src/block/index.php +35 -20
  231. package/src/cover/block.json +2 -1
  232. package/src/cover/edit/index.js +8 -3
  233. package/src/cover/edit/inspector-controls.js +6 -1
  234. package/src/file/edit.js +9 -4
  235. package/src/file/edit.native.js +5 -1
  236. package/src/file/index.php +28 -22
  237. package/src/file/transforms.js +6 -6
  238. package/src/file/utils/index.js +5 -0
  239. package/src/form-input/index.php +4 -2
  240. package/src/freeform/edit.js +7 -0
  241. package/src/gallery/use-get-media.js +9 -5
  242. package/src/gallery/use-get-media.native.js +10 -6
  243. package/src/image/edit.native.js +4 -2
  244. package/src/image/image.js +6 -1
  245. package/src/image/index.php +1 -1
  246. package/src/image/test/edit.native.js +16 -10
  247. package/src/index.js +12 -0
  248. package/src/list-item/edit.js +3 -0
  249. package/src/loginout/index.php +4 -2
  250. package/src/media-text/edit.js +16 -6
  251. package/src/media-text/media-container.js +1 -0
  252. package/src/media-text/transforms.js +5 -1
  253. package/src/more/edit.js +27 -33
  254. package/src/more/editor.scss +3 -12
  255. package/src/post-comments-count/block.json +3 -0
  256. package/src/post-comments-link/block.json +3 -0
  257. package/src/post-date/index.php +28 -32
  258. package/src/post-excerpt/index.php +16 -12
  259. package/src/post-featured-image/edit.js +2 -2
  260. package/src/query-title/block.json +1 -0
  261. package/src/query-title/edit.js +58 -1
  262. package/src/query-title/index.php +30 -5
  263. package/src/query-title/use-post-type-label.js +34 -0
  264. package/src/query-title/variations.js +13 -0
  265. package/src/site-logo/edit.js +44 -16
  266. package/src/site-title/edit.js +24 -16
  267. package/src/social-link/icons/tiktok.js +2 -2
  268. package/src/social-link/index.php +1 -1
  269. package/src/style.scss +1 -0
  270. package/src/utils/poster-image.js +62 -17
  271. package/src/utils/poster-image.scss +23 -16
@@ -0,0 +1,69 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 3,
4
+ "name": "core/accordions",
5
+ "title": "Accordions",
6
+ "category": "design",
7
+ "description": "A group of Accordion headers and associated expandable content.",
8
+ "example": {},
9
+ "__experimental": true,
10
+ "supports": {
11
+ "html": false,
12
+ "align": [ "wide", "full" ],
13
+ "background": {
14
+ "backgroundImage": true,
15
+ "backgroundSize": true,
16
+ "__experimentalDefaultControls": {
17
+ "backgroundImage": true
18
+ }
19
+ },
20
+ "color": {
21
+ "background": true,
22
+ "gradient": true
23
+ },
24
+ "__experimentalBorder": {
25
+ "color": true,
26
+ "radius": true,
27
+ "style": true,
28
+ "width": true,
29
+ "__experimentalDefaultControls": {
30
+ "color": true,
31
+ "radius": true,
32
+ "style": true,
33
+ "width": true
34
+ }
35
+ },
36
+ "spacing": {
37
+ "padding": true,
38
+ "margin": [ "top", "bottom" ],
39
+ "blockGap": true
40
+ },
41
+ "shadow": true,
42
+ "layout": true,
43
+ "interactivity": true
44
+ },
45
+ "attributes": {
46
+ "iconPosition": {
47
+ "type": "string",
48
+ "default": "right"
49
+ },
50
+ "showIcon": {
51
+ "type": "boolean",
52
+ "default": true
53
+ },
54
+ "autoclose": {
55
+ "type": "boolean",
56
+ "default": false
57
+ },
58
+ "allowedBlocks": {
59
+ "type": "array"
60
+ }
61
+ },
62
+ "providesContext": {
63
+ "core/accordion-icon-position": "iconPosition",
64
+ "core/accordion-show-icon": "showIcon"
65
+ },
66
+ "allowedBlocks": [ "core/accordion-item" ],
67
+ "textdomain": "default",
68
+ "style": "wp-block-accordions"
69
+ }
@@ -0,0 +1,133 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ useBlockProps,
6
+ useInnerBlocksProps,
7
+ InspectorControls,
8
+ } from '@wordpress/block-editor';
9
+ import { __ } from '@wordpress/i18n';
10
+ import {
11
+ ToggleControl,
12
+ __experimentalToggleGroupControl as ToggleGroupControl,
13
+ __experimentalToggleGroupControlOption as ToggleGroupControlOption,
14
+ __experimentalToolsPanel as ToolsPanel,
15
+ __experimentalToolsPanelItem as ToolsPanelItem,
16
+ } from '@wordpress/components';
17
+
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
22
+
23
+ const ACCORDION_BLOCK_NAME = 'core/accordion-item';
24
+ const ACCORDION_BLOCK = {
25
+ name: ACCORDION_BLOCK_NAME,
26
+ };
27
+
28
+ export default function Edit( {
29
+ attributes: { autoclose, iconPosition, showIcon },
30
+ setAttributes,
31
+ } ) {
32
+ const blockProps = useBlockProps();
33
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
34
+
35
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
36
+ template: [ [ ACCORDION_BLOCK_NAME ], [ ACCORDION_BLOCK_NAME ] ],
37
+ defaultBlock: ACCORDION_BLOCK,
38
+ directInsert: true,
39
+ templateInsertUpdatesSelection: true,
40
+ } );
41
+
42
+ return (
43
+ <>
44
+ <InspectorControls key="setting">
45
+ <ToolsPanel
46
+ label={ __( 'Settings' ) }
47
+ resetAll={ () => {
48
+ setAttributes( {
49
+ autoclose: false,
50
+ showIcon: true,
51
+ iconPosition: 'right',
52
+ } );
53
+ } }
54
+ dropdownMenuProps={ dropdownMenuProps }
55
+ >
56
+ <ToolsPanelItem
57
+ label={ __( 'Auto-close' ) }
58
+ isShownByDefault
59
+ hasValue={ () => !! autoclose }
60
+ onDeselect={ () =>
61
+ setAttributes( { autoclose: false } )
62
+ }
63
+ >
64
+ <ToggleControl
65
+ isBlock
66
+ __nextHasNoMarginBottom
67
+ label={ __( 'Auto-close' ) }
68
+ onChange={ ( value ) => {
69
+ setAttributes( {
70
+ autoclose: value,
71
+ } );
72
+ } }
73
+ checked={ autoclose }
74
+ help={ __(
75
+ 'Automatically close accordions when a new one is opened.'
76
+ ) }
77
+ />
78
+ </ToolsPanelItem>
79
+ <ToolsPanelItem
80
+ label={ __( 'Show icon' ) }
81
+ isShownByDefault
82
+ hasValue={ () => ! showIcon }
83
+ onDeselect={ () => setAttributes( { showIcon: true } ) }
84
+ >
85
+ <ToggleControl
86
+ isBlock
87
+ __nextHasNoMarginBottom
88
+ label={ __( 'Show icon' ) }
89
+ onChange={ ( value ) => {
90
+ setAttributes( {
91
+ showIcon: value,
92
+ } );
93
+ } }
94
+ checked={ showIcon }
95
+ help={ __(
96
+ 'Display a plus icon next to the accordion header.'
97
+ ) }
98
+ />
99
+ </ToolsPanelItem>
100
+ <ToolsPanelItem
101
+ label={ __( 'Icon Position' ) }
102
+ isShownByDefault
103
+ hasValue={ () => iconPosition !== 'right' }
104
+ onDeselect={ () =>
105
+ setAttributes( { iconPosition: 'right' } )
106
+ }
107
+ >
108
+ <ToggleGroupControl
109
+ __nextHasNoMarginBottom
110
+ __next40pxDefaultSize
111
+ isBlock
112
+ label={ __( 'Icon Position' ) }
113
+ value={ iconPosition }
114
+ onChange={ ( value ) => {
115
+ setAttributes( { iconPosition: value } );
116
+ } }
117
+ >
118
+ <ToggleGroupControlOption
119
+ label={ __( 'Left' ) }
120
+ value="left"
121
+ />
122
+ <ToggleGroupControlOption
123
+ label={ __( 'Right' ) }
124
+ value="right"
125
+ />
126
+ </ToggleGroupControl>
127
+ </ToolsPanelItem>
128
+ </ToolsPanel>
129
+ </InspectorControls>
130
+ <div { ...innerBlocksProps } />
131
+ </>
132
+ );
133
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { accordion } from '@wordpress/icons';
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+ import edit from './edit';
9
+ import save from './save';
10
+ import metadata from './block.json';
11
+ import initBlock from '../utils/init-block';
12
+
13
+ const { name } = metadata;
14
+
15
+ export { metadata, name };
16
+
17
+ export const settings = {
18
+ icon: accordion,
19
+ example: {},
20
+ edit,
21
+ save,
22
+ };
23
+
24
+ export const init = () => initBlock( { name, metadata, settings } );
@@ -0,0 +1,61 @@
1
+ <?php
2
+ /**
3
+ * Server-side rendering of the `core/accordions` block.
4
+ *
5
+ * @package WordPress
6
+ * @since 6.6.0
7
+ *
8
+ * @param array $attributes The block attributes.
9
+ * @param string $content The block content.
10
+ *
11
+ * @return string Returns the updated markup.
12
+ */
13
+ function render_block_core_accordions( $attributes, $content ) {
14
+ if ( ! $content ) {
15
+ return $content;
16
+ }
17
+
18
+ $suffix = wp_scripts_get_suffix();
19
+ if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
20
+ $module_url = gutenberg_url( '/build-module/block-library/accordions/view.min.js' );
21
+ }
22
+
23
+ wp_register_script_module(
24
+ '@wordpress/block-library/accordions',
25
+ isset( $module_url ) ? $module_url : includes_url( "blocks/accordions/view{$suffix}.js" ),
26
+ array( '@wordpress/interactivity' ),
27
+ defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' )
28
+ );
29
+
30
+ wp_enqueue_script_module( '@wordpress/block-library/accordions' );
31
+
32
+ $p = new WP_HTML_Tag_Processor( $content );
33
+ $autoclose = $attributes['autoclose'] ? 'true' : 'false';
34
+ $icon = $attributes['icon'] ?? 'plus';
35
+ $icon_position = $attributes['iconPosition'] ?? 'right';
36
+
37
+ if ( $p->next_tag( array( 'class_name' => 'wp-block-accordions' ) ) ) {
38
+ $p->set_attribute( 'data-wp-interactive', 'core/accordion' );
39
+ $p->set_attribute( 'data-wp-context', '{ "autoclose": ' . $autoclose . ', "isOpen": [], "icon": "' . $icon . '", "iconPosition": "' . $icon_position . '" }' );
40
+
41
+ // Only modify content if directives have been set.
42
+ $content = $p->get_updated_html();
43
+ }
44
+
45
+ return $content;
46
+ }
47
+
48
+ /**
49
+ * Registers the `core/accordions` block on server.
50
+ *
51
+ * @since 6.6.0
52
+ */
53
+ function register_block_core_accordions() {
54
+ register_block_type_from_metadata(
55
+ __DIR__ . '/accordions',
56
+ array(
57
+ 'render_callback' => 'render_block_core_accordions',
58
+ )
59
+ );
60
+ }
61
+ add_action( 'init', 'register_block_core_accordions' );
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { init } from './';
5
+
6
+ export default init();
@@ -0,0 +1,23 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import clsx from 'clsx';
5
+ /**
6
+ * WordPress dependencies
7
+ */
8
+ import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
9
+
10
+ export default function save( { attributes } ) {
11
+ const { iconPosition } = attributes;
12
+ const blockProps = useBlockProps.save();
13
+ const className = clsx(
14
+ {
15
+ 'icon-position-left': iconPosition === 'left',
16
+ },
17
+ blockProps.className
18
+ );
19
+
20
+ return (
21
+ <div { ...useInnerBlocksProps.save( { ...blockProps, className } ) } />
22
+ );
23
+ }
@@ -0,0 +1,91 @@
1
+ .wp-block-accordion-item {
2
+ display: grid;
3
+ grid-template-rows: max-content 0fr;
4
+ }
5
+
6
+ .wp-block-accordion-item.is-open {
7
+ grid-template-rows: max-content 1fr;
8
+ }
9
+
10
+ .accordion-item__heading {
11
+ margin-block-start: 0;
12
+ margin-block-end: 0;
13
+ }
14
+
15
+ .accordion-item__toggle {
16
+ font-family: inherit;
17
+ font-size: inherit;
18
+ font-weight: inherit;
19
+ line-height: inherit;
20
+ letter-spacing: inherit;
21
+ text-transform: inherit;
22
+ text-decoration: inherit;
23
+ word-spacing: inherit;
24
+ background: none;
25
+ border: none;
26
+ color: inherit;
27
+ padding: var(--wp--preset--spacing--20, 1em) 0;
28
+ cursor: pointer;
29
+ outline: none;
30
+ display: flex;
31
+ align-items: center;
32
+ text-align: inherit;
33
+ position: relative;
34
+ width: 100%;
35
+ }
36
+
37
+ .accordion-item__toggle > span {
38
+ width: 100%;
39
+ }
40
+
41
+ .is-layout-flow > .wp-block-accordion-panel,
42
+ .wp-block-accordion-panel {
43
+ overflow: hidden;
44
+ margin: 0;
45
+ }
46
+
47
+ .accordion-panel__wrapper {
48
+ padding-bottom: var(--wp--preset--spacing--20, 1em);
49
+ }
50
+
51
+ /* No icon block style */
52
+ .is-style-no-icon .accordion-item__toggle-icon {
53
+ background-color: unset;
54
+ }
55
+
56
+ .wp-block-accordion-header.icon-position-left .accordion-item__toggle {
57
+ /* stylelint-disable-next-line declaration-property-value-allowed-list -- This should be refactored to not use the row-reverse value. */
58
+ flex-direction: row-reverse;
59
+ }
60
+
61
+ /* RTL language support */
62
+ [dir="rtl"] .wp-block-accordion-header:not(.icon-position-left) .accordion-item__toggle {
63
+ /* stylelint-disable-next-line declaration-property-value-allowed-list -- Automatically adjust icon position for RTL languages. */
64
+ flex-direction: row-reverse;
65
+ }
66
+
67
+ [dir="rtl"] .wp-block-accordion-header.icon-position-left .accordion-item__toggle {
68
+ flex-direction: row;
69
+ }
70
+
71
+ .accordion-item__toggle:focus-visible {
72
+ outline: 2px solid -webkit-focus-ring-color;
73
+ outline-offset: 2px;
74
+ }
75
+
76
+ /* Add transitions only for users who do not prefer reduced motion */
77
+ @media (prefers-reduced-motion: no-preference) {
78
+ .wp-block-accordion-item .accordion-item__toggle-icon {
79
+ transition: transform 0.2s ease-in-out;
80
+ }
81
+
82
+ .wp-block-accordion-item {
83
+ transition: grid-template-rows 0.3s ease-out;
84
+ }
85
+ }
86
+
87
+ .is-open {
88
+ .accordion-item__toggle-icon.has-icon-plus {
89
+ transform: rotate(45deg);
90
+ }
91
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store, getContext } from '@wordpress/interactivity';
5
+
6
+ const { state } = store( 'core/accordion', {
7
+ state: {
8
+ get isOpen() {
9
+ const { isOpen, id } = getContext();
10
+ return isOpen.includes( id );
11
+ },
12
+ },
13
+ actions: {
14
+ toggle: () => {
15
+ const context = getContext();
16
+ const { id, autoclose } = context;
17
+
18
+ if ( autoclose ) {
19
+ context.isOpen = state.isOpen ? [] : [ id ];
20
+ } else if ( state.isOpen ) {
21
+ context.isOpen = context.isOpen.filter(
22
+ ( item ) => item !== id
23
+ );
24
+ } else {
25
+ context.isOpen.push( id );
26
+ }
27
+ },
28
+ },
29
+ callbacks: {
30
+ initIsOpen: () => {
31
+ const context = getContext();
32
+ const { id, openByDefault } = context;
33
+ if ( openByDefault ) {
34
+ context.isOpen.push( id );
35
+ }
36
+ },
37
+ },
38
+ } );
@@ -1,4 +1,4 @@
1
- <?php
1
+ <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName // Needed for WP_Block_Cloner helper class.
2
2
  /**
3
3
  * Server-side rendering of the `core/block` block.
4
4
  *
@@ -16,7 +16,7 @@
16
16
  *
17
17
  * @return string Rendered HTML of the referenced block.
18
18
  */
19
- function render_block_core_block( $attributes ) {
19
+ function render_block_core_block( $attributes, $content, $block_instance ) {
20
20
  static $seen_refs = array();
21
21
 
22
22
  if ( empty( $attributes['ref'] ) ) {
@@ -73,30 +73,45 @@ function render_block_core_block( $attributes ) {
73
73
  $attributes['content'] = $attributes['overrides'];
74
74
  }
75
75
 
76
+ // Apply Block Hooks.
77
+ $content = apply_block_hooks_to_content_from_post_object( $content, $reusable_block );
78
+
76
79
  /**
77
- * We set the `pattern/overrides` context through the `render_block_context`
78
- * filter so that it is available when a pattern's inner blocks are
79
- * rendering via do_blocks given it only receives the inner content.
80
+ * We attach the blocks from $content as inner blocks to the Synced Pattern block instance.
81
+ * This ensures that block context available to the Synced Pattern block instance is provided to
82
+ * those blocks.
80
83
  */
81
- $has_pattern_overrides = isset( $attributes['content'] ) && null !== get_block_bindings_source( 'core/pattern-overrides' );
82
- if ( $has_pattern_overrides ) {
83
- $filter_block_context = static function ( $context ) use ( $attributes ) {
84
- $context['pattern/overrides'] = $attributes['content'];
85
- return $context;
86
- };
87
- add_filter( 'render_block_context', $filter_block_context, 1 );
84
+ $block_instance->parsed_block['innerBlocks'] = parse_blocks( $content );
85
+ $block_instance->parsed_block['innerContent'] = array_fill( 0, count( $block_instance->parsed_block['innerBlocks'] ), null );
86
+ if ( method_exists( $block_instance, 'refresh_context_dependents' ) ) {
87
+ // WP_Block::refresh_context_dependents() was introduced in WordPress 6.8.
88
+ $block_instance->refresh_context_dependents();
89
+ } else {
90
+ // This branch can be removed once Gutenberg requires WordPress 6.8 or later.
91
+ if ( ! class_exists( 'WP_Block_Cloner' ) ) {
92
+ // phpcs:ignore Gutenberg.Commenting.SinceTag.MissingClassSinceTag
93
+ class WP_Block_Cloner extends WP_Block {
94
+ /**
95
+ * Static methods of subclasses have access to protected properties
96
+ * of instances of the parent class.
97
+ * In this case, this gives us access to `available_context` and `registry`.
98
+ */
99
+ // phpcs:ignore Gutenberg.Commenting.SinceTag.MissingMethodSinceTag
100
+ public static function clone_instance( $instance ) {
101
+ return new WP_Block(
102
+ $instance->parsed_block,
103
+ $instance->available_context,
104
+ $instance->registry
105
+ );
106
+ }
107
+ }
108
+ }
109
+ $block_instance = WP_Block_Cloner::clone_instance( $block_instance );
88
110
  }
89
111
 
90
- // Apply Block Hooks.
91
- $content = apply_block_hooks_to_content_from_post_object( $content, $reusable_block );
92
-
93
- $content = do_blocks( $content );
112
+ $content = $block_instance->render( array( 'dynamic' => false ) );
94
113
  unset( $seen_refs[ $attributes['ref'] ] );
95
114
 
96
- if ( $has_pattern_overrides ) {
97
- remove_filter( 'render_block_context', $filter_block_context, 1 );
98
- }
99
-
100
115
  return $content;
101
116
  }
102
117
 
@@ -8,7 +8,8 @@
8
8
  "textdomain": "default",
9
9
  "attributes": {
10
10
  "url": {
11
- "type": "string"
11
+ "type": "string",
12
+ "role": "content"
12
13
  },
13
14
  "useFeaturedImage": {
14
15
  "type": "boolean",
@@ -120,9 +120,14 @@ function CoverEdit( {
120
120
  return {
121
121
  media:
122
122
  featuredImage && useFeaturedImage
123
- ? select( coreStore ).getMedia( featuredImage, {
124
- context: 'view',
125
- } )
123
+ ? select( coreStore ).getEntityRecord(
124
+ 'postType',
125
+ 'attachment',
126
+ featuredImage,
127
+ {
128
+ context: 'view',
129
+ }
130
+ )
126
131
  : undefined,
127
132
  };
128
133
  },
@@ -131,7 +131,12 @@ export default function CoverInspectorControls( {
131
131
  const image = useSelect(
132
132
  ( select ) =>
133
133
  id && isImageBackground
134
- ? select( coreStore ).getMedia( id, { context: 'view' } )
134
+ ? select( coreStore ).getEntityRecord(
135
+ 'postType',
136
+ 'attachment',
137
+ id,
138
+ { context: 'view' }
139
+ )
135
140
  : null,
136
141
  [ id, isImageBackground ]
137
142
  );
package/src/file/edit.js CHANGED
@@ -80,7 +80,11 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
80
80
  media:
81
81
  id === undefined
82
82
  ? undefined
83
- : select( coreStore ).getMedia( id ),
83
+ : select( coreStore ).getEntityRecord(
84
+ 'postType',
85
+ 'attachment',
86
+ id
87
+ ),
84
88
  } ),
85
89
  [ id ]
86
90
  );
@@ -128,9 +132,10 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
128
132
  return;
129
133
  }
130
134
 
131
- const isPdf = getFilename( newMedia.url )
132
- .toLowerCase()
133
- .endsWith( '.pdf' );
135
+ const isPdf =
136
+ // Media Library and REST API use different properties for mime type.
137
+ ( newMedia.mime || newMedia.mime_type ) === 'application/pdf' ||
138
+ getFilename( newMedia.url ).toLowerCase().endsWith( '.pdf' );
134
139
  const pdfAttributes = {
135
140
  displayPreview: isPdf
136
141
  ? attributes.displayPreview ?? true
@@ -583,7 +583,11 @@ export default compose( [
583
583
  const isNotFileHref = id && getProtocol( href ) !== 'file:';
584
584
  return {
585
585
  media: isNotFileHref
586
- ? select( coreStore ).getMedia( id )
586
+ ? select( coreStore ).getEntityRecord(
587
+ 'postType',
588
+ 'attachment',
589
+ id
590
+ )
587
591
  : undefined,
588
592
  isSidebarOpened: isSelected && isEditorSidebarOpened(),
589
593
  wasBlockJustInserted: select(
@@ -16,33 +16,39 @@
16
16
  * @return string Returns the block content.
17
17
  */
18
18
  function render_block_core_file( $attributes, $content ) {
19
+ if ( empty( $attributes['displayPreview'] ) ) {
20
+ return $content;
21
+ }
22
+
19
23
  // If it's interactive, enqueue the script module and add the directives.
20
- if ( ! empty( $attributes['displayPreview'] ) ) {
21
- wp_enqueue_script_module( '@wordpress/block-library/file/view' );
24
+ wp_enqueue_script_module( '@wordpress/block-library/file/view' );
22
25
 
23
- $processor = new WP_HTML_Tag_Processor( $content );
24
- $processor->next_tag();
26
+ $processor = new WP_HTML_Tag_Processor( $content );
27
+ if ( $processor->next_tag() ) {
25
28
  $processor->set_attribute( 'data-wp-interactive', 'core/file' );
26
- $processor->next_tag( 'object' );
27
- $processor->set_attribute( 'data-wp-bind--hidden', '!state.hasPdfPreview' );
28
- $processor->set_attribute( 'hidden', true );
29
-
30
- $filename = $processor->get_attribute( 'aria-label' );
31
- $has_filename = ! empty( $filename ) && 'PDF embed' !== $filename;
32
- $label = $has_filename ? sprintf(
33
- /* translators: %s: filename. */
34
- __( 'Embed of %s.' ),
35
- $filename
36
- ) : __( 'PDF embed' );
37
-
38
- // Update object's aria-label attribute if present in block HTML.
39
- // Match an aria-label attribute from an object tag.
40
- $processor->set_attribute( 'aria-label', $label );
41
-
42
- return $processor->get_updated_html();
43
29
  }
44
30
 
45
- return $content;
31
+ // If there are no OBJECT elements, something might have already modified the block.
32
+ if ( ! $processor->next_tag( 'OBJECT' ) ) {
33
+ return $content;
34
+ }
35
+
36
+ $processor->set_attribute( 'data-wp-bind--hidden', '!state.hasPdfPreview' );
37
+ $processor->set_attribute( 'hidden', true );
38
+
39
+ $filename = $processor->get_attribute( 'aria-label' );
40
+ $has_filename = is_string( $filename ) && ! empty( $filename ) && 'PDF embed' !== $filename;
41
+ $label = $has_filename ? sprintf(
42
+ /* translators: %s: filename. */
43
+ __( 'Embed of %s.' ),
44
+ $filename
45
+ ) : __( 'PDF embed' );
46
+
47
+ // Update object's aria-label attribute if present in block HTML.
48
+ // Match an aria-label attribute from an object tag.
49
+ $processor->set_attribute( 'aria-label', $label );
50
+
51
+ return $processor->get_updated_html();
46
52
  }
47
53
 
48
54
  /**