@wordpress/block-library 9.34.1-next.2f1c7c01b.0 → 9.35.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 (149) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/block/edit.js +2 -2
  3. package/build/block/edit.js.map +2 -2
  4. package/build/block-keyboard-shortcuts/index.js +17 -7
  5. package/build/block-keyboard-shortcuts/index.js.map +2 -2
  6. package/build/cover/deprecated.js +15 -3
  7. package/build/cover/deprecated.js.map +2 -2
  8. package/build/cover/edit/inspector-controls.js +1 -1
  9. package/build/cover/edit/inspector-controls.js.map +2 -2
  10. package/build/cover/transforms.js +10 -2
  11. package/build/cover/transforms.js.map +2 -2
  12. package/build/embed/icons.js +2 -2
  13. package/build/embed/icons.js.map +2 -2
  14. package/build/embed/variations.js +3 -3
  15. package/build/embed/variations.js.map +2 -2
  16. package/build/heading/index.js +3 -1
  17. package/build/heading/index.js.map +3 -3
  18. package/build/heading/transforms.js +10 -3
  19. package/build/heading/transforms.js.map +2 -2
  20. package/build/heading/variations.js +55 -0
  21. package/build/heading/variations.js.map +7 -0
  22. package/build/html/edit.js +54 -44
  23. package/build/html/edit.js.map +3 -3
  24. package/build/html/modal.js +328 -0
  25. package/build/html/modal.js.map +7 -0
  26. package/build/html/utils.js +72 -0
  27. package/build/html/utils.js.map +7 -0
  28. package/build/navigation-link/edit.js +25 -10
  29. package/build/navigation-link/edit.js.map +2 -2
  30. package/build/navigation-link/link-ui/index.js +8 -3
  31. package/build/navigation-link/link-ui/index.js.map +2 -2
  32. package/build/navigation-link/shared/controls.js +42 -7
  33. package/build/navigation-link/shared/controls.js.map +2 -2
  34. package/build/navigation-link/shared/use-entity-binding.js +31 -2
  35. package/build/navigation-link/shared/use-entity-binding.js.map +3 -3
  36. package/build/paragraph/block.json +1 -3
  37. package/build/paragraph/deprecated.js +65 -12
  38. package/build/paragraph/deprecated.js.map +2 -2
  39. package/build/paragraph/edit.js +14 -25
  40. package/build/paragraph/edit.js.map +2 -2
  41. package/build/paragraph/index.js +3 -1
  42. package/build/paragraph/index.js.map +3 -3
  43. package/build/paragraph/save.js +3 -3
  44. package/build/paragraph/save.js.map +2 -2
  45. package/build/paragraph/transforms.js +7 -1
  46. package/build/paragraph/transforms.js.map +2 -2
  47. package/build/paragraph/variations.js +57 -0
  48. package/build/paragraph/variations.js.map +7 -0
  49. package/build-module/block/edit.js +2 -2
  50. package/build-module/block/edit.js.map +2 -2
  51. package/build-module/block-keyboard-shortcuts/index.js +17 -7
  52. package/build-module/block-keyboard-shortcuts/index.js.map +2 -2
  53. package/build-module/cover/deprecated.js +15 -3
  54. package/build-module/cover/deprecated.js.map +2 -2
  55. package/build-module/cover/edit/inspector-controls.js +1 -1
  56. package/build-module/cover/edit/inspector-controls.js.map +2 -2
  57. package/build-module/cover/transforms.js +10 -2
  58. package/build-module/cover/transforms.js.map +2 -2
  59. package/build-module/embed/icons.js +2 -2
  60. package/build-module/embed/icons.js.map +2 -2
  61. package/build-module/embed/variations.js +3 -3
  62. package/build-module/embed/variations.js.map +2 -2
  63. package/build-module/heading/index.js +3 -1
  64. package/build-module/heading/index.js.map +2 -2
  65. package/build-module/heading/transforms.js +10 -3
  66. package/build-module/heading/transforms.js.map +2 -2
  67. package/build-module/heading/variations.js +34 -0
  68. package/build-module/heading/variations.js.map +7 -0
  69. package/build-module/html/edit.js +62 -51
  70. package/build-module/html/edit.js.map +2 -2
  71. package/build-module/html/modal.js +304 -0
  72. package/build-module/html/modal.js.map +7 -0
  73. package/build-module/html/utils.js +46 -0
  74. package/build-module/html/utils.js.map +7 -0
  75. package/build-module/navigation-link/edit.js +25 -10
  76. package/build-module/navigation-link/edit.js.map +2 -2
  77. package/build-module/navigation-link/link-ui/index.js +8 -3
  78. package/build-module/navigation-link/link-ui/index.js.map +2 -2
  79. package/build-module/navigation-link/shared/controls.js +42 -7
  80. package/build-module/navigation-link/shared/controls.js.map +2 -2
  81. package/build-module/navigation-link/shared/use-entity-binding.js +35 -3
  82. package/build-module/navigation-link/shared/use-entity-binding.js.map +2 -2
  83. package/build-module/paragraph/block.json +1 -3
  84. package/build-module/paragraph/deprecated.js +65 -12
  85. package/build-module/paragraph/deprecated.js.map +2 -2
  86. package/build-module/paragraph/edit.js +14 -26
  87. package/build-module/paragraph/edit.js.map +2 -2
  88. package/build-module/paragraph/index.js +3 -1
  89. package/build-module/paragraph/index.js.map +2 -2
  90. package/build-module/paragraph/save.js +3 -3
  91. package/build-module/paragraph/save.js.map +2 -2
  92. package/build-module/paragraph/transforms.js +7 -1
  93. package/build-module/paragraph/transforms.js.map +2 -2
  94. package/build-module/paragraph/variations.js +36 -0
  95. package/build-module/paragraph/variations.js.map +7 -0
  96. package/build-style/accordion-heading/style-rtl.css +19 -3
  97. package/build-style/accordion-heading/style.css +19 -3
  98. package/build-style/accordion-panel/style-rtl.css +4 -1
  99. package/build-style/accordion-panel/style.css +4 -1
  100. package/build-style/common-rtl.css +3 -3
  101. package/build-style/common.css +3 -3
  102. package/build-style/editor-rtl.css +62 -21
  103. package/build-style/editor.css +62 -21
  104. package/build-style/embed/style-rtl.css +5 -0
  105. package/build-style/embed/style.css +5 -0
  106. package/build-style/html/editor-rtl.css +55 -21
  107. package/build-style/html/editor.css +55 -21
  108. package/build-style/navigation-link/editor-rtl.css +7 -0
  109. package/build-style/navigation-link/editor.css +7 -0
  110. package/build-style/style-rtl.css +31 -7
  111. package/build-style/style.css +31 -7
  112. package/package.json +37 -37
  113. package/src/accordion-heading/style.scss +40 -7
  114. package/src/accordion-panel/style.scss +6 -1
  115. package/src/block/edit.js +2 -2
  116. package/src/block-keyboard-shortcuts/index.js +23 -9
  117. package/src/common.scss +6 -5
  118. package/src/cover/deprecated.js +15 -3
  119. package/src/cover/edit/inspector-controls.js +1 -1
  120. package/src/cover/transforms.js +10 -2
  121. package/src/embed/icons.js +2 -4
  122. package/src/embed/style.scss +6 -0
  123. package/src/embed/variations.js +3 -3
  124. package/src/heading/index.js +2 -0
  125. package/src/heading/transforms.js +10 -3
  126. package/src/heading/variations.js +37 -0
  127. package/src/html/edit.js +62 -56
  128. package/src/html/editor.scss +69 -10
  129. package/src/html/modal.js +290 -0
  130. package/src/html/test/utils.js +234 -0
  131. package/src/html/utils.js +75 -0
  132. package/src/navigation-link/edit.js +44 -13
  133. package/src/navigation-link/editor.scss +7 -0
  134. package/src/navigation-link/index.php +65 -2
  135. package/src/navigation-link/link-ui/index.js +9 -8
  136. package/src/navigation-link/shared/controls.js +70 -12
  137. package/src/navigation-link/shared/test/controls.js +5 -0
  138. package/src/navigation-link/shared/test/use-entity-binding.js +14 -1
  139. package/src/navigation-link/shared/use-entity-binding.js +57 -9
  140. package/src/paragraph/block.json +1 -3
  141. package/src/paragraph/deprecated.js +87 -20
  142. package/src/paragraph/edit.js +7 -18
  143. package/src/paragraph/edit.native.js +18 -6
  144. package/src/paragraph/index.js +2 -0
  145. package/src/paragraph/save.js +4 -3
  146. package/src/paragraph/test/edit.native.js +5 -5
  147. package/src/paragraph/transforms.js +7 -1
  148. package/src/paragraph/variations.js +39 -0
  149. package/tsconfig.tsbuildinfo +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-library",
3
- "version": "9.34.1-next.2f1c7c01b.0",
3
+ "version": "9.35.0",
4
4
  "description": "Block library for the WordPress editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -82,41 +82,41 @@
82
82
  "{src,build,build-module}/*/init.js"
83
83
  ],
84
84
  "dependencies": {
85
- "@wordpress/a11y": "^4.34.1-next.2f1c7c01b.0",
86
- "@wordpress/api-fetch": "^7.34.1-next.2f1c7c01b.0",
87
- "@wordpress/autop": "^4.34.1-next.2f1c7c01b.0",
88
- "@wordpress/base-styles": "^6.10.1-next.2f1c7c01b.0",
89
- "@wordpress/blob": "^4.34.1-next.2f1c7c01b.0",
90
- "@wordpress/block-editor": "^15.7.1-next.2f1c7c01b.0",
91
- "@wordpress/blocks": "^15.7.1-next.2f1c7c01b.0",
92
- "@wordpress/components": "^30.7.2-next.2f1c7c01b.0",
93
- "@wordpress/compose": "^7.34.1-next.2f1c7c01b.0",
94
- "@wordpress/core-data": "^7.34.1-next.2f1c7c01b.0",
95
- "@wordpress/data": "^10.34.1-next.2f1c7c01b.0",
96
- "@wordpress/date": "^5.34.1-next.2f1c7c01b.0",
97
- "@wordpress/deprecated": "^4.34.1-next.2f1c7c01b.0",
98
- "@wordpress/dom": "^4.34.1-next.2f1c7c01b.0",
99
- "@wordpress/element": "^6.34.1-next.2f1c7c01b.0",
100
- "@wordpress/escape-html": "^3.34.1-next.2f1c7c01b.0",
101
- "@wordpress/hooks": "^4.34.1-next.2f1c7c01b.0",
102
- "@wordpress/html-entities": "^4.34.1-next.2f1c7c01b.0",
103
- "@wordpress/i18n": "^6.7.1-next.2f1c7c01b.0",
104
- "@wordpress/icons": "^11.1.1-next.2f1c7c01b.0",
105
- "@wordpress/interactivity": "^6.34.1-next.2f1c7c01b.0",
106
- "@wordpress/interactivity-router": "^2.34.1-next.2f1c7c01b.0",
107
- "@wordpress/keyboard-shortcuts": "^5.34.1-next.2f1c7c01b.0",
108
- "@wordpress/keycodes": "^4.34.1-next.2f1c7c01b.0",
109
- "@wordpress/latex-to-mathml": "^1.2.1-next.2f1c7c01b.0",
110
- "@wordpress/notices": "^5.34.1-next.2f1c7c01b.0",
111
- "@wordpress/patterns": "^2.34.1-next.2f1c7c01b.0",
112
- "@wordpress/primitives": "^4.34.1-next.2f1c7c01b.0",
113
- "@wordpress/private-apis": "^1.34.1-next.2f1c7c01b.0",
114
- "@wordpress/reusable-blocks": "^5.34.1-next.2f1c7c01b.0",
115
- "@wordpress/rich-text": "^7.34.1-next.2f1c7c01b.0",
116
- "@wordpress/server-side-render": "^6.10.1-next.2f1c7c01b.0",
117
- "@wordpress/url": "^4.34.1-next.2f1c7c01b.0",
118
- "@wordpress/viewport": "^6.34.1-next.2f1c7c01b.0",
119
- "@wordpress/wordcount": "^4.34.1-next.2f1c7c01b.0",
85
+ "@wordpress/a11y": "^4.35.0",
86
+ "@wordpress/api-fetch": "^7.35.0",
87
+ "@wordpress/autop": "^4.35.0",
88
+ "@wordpress/base-styles": "^6.11.0",
89
+ "@wordpress/blob": "^4.35.0",
90
+ "@wordpress/block-editor": "^15.8.0",
91
+ "@wordpress/blocks": "^15.8.0",
92
+ "@wordpress/components": "^30.8.0",
93
+ "@wordpress/compose": "^7.35.0",
94
+ "@wordpress/core-data": "^7.35.0",
95
+ "@wordpress/data": "^10.35.0",
96
+ "@wordpress/date": "^5.35.0",
97
+ "@wordpress/deprecated": "^4.35.0",
98
+ "@wordpress/dom": "^4.35.0",
99
+ "@wordpress/element": "^6.35.0",
100
+ "@wordpress/escape-html": "^3.35.0",
101
+ "@wordpress/hooks": "^4.35.0",
102
+ "@wordpress/html-entities": "^4.35.0",
103
+ "@wordpress/i18n": "^6.8.0",
104
+ "@wordpress/icons": "^11.2.0",
105
+ "@wordpress/interactivity": "^6.35.0",
106
+ "@wordpress/interactivity-router": "^2.35.0",
107
+ "@wordpress/keyboard-shortcuts": "^5.35.0",
108
+ "@wordpress/keycodes": "^4.35.0",
109
+ "@wordpress/latex-to-mathml": "^1.3.0",
110
+ "@wordpress/notices": "^5.35.0",
111
+ "@wordpress/patterns": "^2.35.0",
112
+ "@wordpress/primitives": "^4.35.0",
113
+ "@wordpress/private-apis": "^1.35.0",
114
+ "@wordpress/reusable-blocks": "^5.35.0",
115
+ "@wordpress/rich-text": "^7.35.0",
116
+ "@wordpress/server-side-render": "^6.11.0",
117
+ "@wordpress/url": "^4.35.0",
118
+ "@wordpress/viewport": "^6.35.0",
119
+ "@wordpress/wordcount": "^4.35.0",
120
120
  "change-case": "^4.1.2",
121
121
  "clsx": "^2.1.1",
122
122
  "colord": "^2.7.0",
@@ -134,5 +134,5 @@
134
134
  "publishConfig": {
135
135
  "access": "public"
136
136
  },
137
- "gitHead": "c6ddcdf455bc02567a2c9e03de6862a2061b85e8"
137
+ "gitHead": "77aa1f194edceafe8ac2a1b9438bf84b557e76e3"
138
138
  }
@@ -1,3 +1,17 @@
1
+ // In many classic themes, selectors like `.entry-content h1` are used,
2
+ // potentially applying relatively high specificity (such as `0-1-1`) to
3
+ // heading elements. To properly override those styles, use a selector
4
+ // with a specificity of `0-2-0`.
5
+ .wp-block-accordion-heading.wp-block-accordion-heading {
6
+ // Some themes may have an explicit width. Since it's unpredictable
7
+ // what CSS specificity should be used to override them, ensure 100%
8
+ // width using min-width instead.
9
+ min-width: 100%;
10
+ // Some classic themes apply default margins to heading elements,
11
+ // so those styles need to be reset.
12
+ margin: 0;
13
+ }
14
+
1
15
  .wp-block-accordion-heading__toggle {
2
16
  font-family: inherit;
3
17
  font-size: inherit;
@@ -8,26 +22,45 @@
8
22
  text-decoration: inherit;
9
23
  word-spacing: inherit;
10
24
  font-style: inherit;
11
- background: none;
12
25
  border: none;
13
- color: inherit;
14
26
  padding: var(--wp--preset--spacing--20, 1em) 0;
15
27
  cursor: pointer;
16
28
  overflow: hidden;
17
29
  display: flex;
18
30
  align-items: center;
19
31
  text-align: inherit;
20
- position: relative;
21
32
  width: 100%;
22
33
 
34
+ // Some themes may apply colors to button elements with a particularly
35
+ // high CSS specificity. Since it's impossible to predict this specificity,
36
+ // we reset the colors using `!important`.
37
+ background-color: inherit !important;
38
+ color: inherit !important;
39
+
23
40
  &:not(:focus-visible) {
24
41
  outline: none;
25
42
  }
26
43
 
27
- &:hover {
28
- .wp-block-accordion-heading__toggle-title {
29
- text-decoration: underline;
30
- }
44
+ &:hover,
45
+ &:focus {
46
+ // Some themes may apply styles when a button element is hovered
47
+ // over or focused. This is not intended for accordion toggle
48
+ // buttons, so we reset it here.
49
+ text-decoration: none;
50
+ background-color: inherit !important;
51
+ box-shadow: none;
52
+ color: inherit;
53
+ border: none;
54
+ padding: var(--wp--preset--spacing--20, 1em) 0;
55
+ }
56
+
57
+ &:focus-visible {
58
+ outline: auto;
59
+ outline-offset: 0;
60
+ }
61
+
62
+ &:hover .wp-block-accordion-heading__toggle-title {
63
+ text-decoration: underline;
31
64
  }
32
65
  }
33
66
 
@@ -1,4 +1,9 @@
1
- .wp-block-accordion-panel {
1
+ // Some classic themes may use selectors like `.wp-block .wp-block`
2
+ // and apply some kind of width to the blocks. To properly override
3
+ // those styles, use a selector with a specificity of `0-2-0`.
4
+ .wp-block-accordion-panel.wp-block-accordion-panel {
5
+ min-width: 100%;
6
+
2
7
  // Prevent blockGap from Accordion Content block from adding extra margin between accordions.
3
8
  &[inert],
4
9
  &[aria-hidden="true"] {
package/src/block/edit.js CHANGED
@@ -124,7 +124,7 @@ function ReusableBlockControl( {
124
124
  return (
125
125
  <>
126
126
  { canUserEdit && !! handleEditOriginal && (
127
- <BlockControls>
127
+ <BlockControls group="other">
128
128
  <ToolbarGroup>
129
129
  <ToolbarButton onClick={ handleEditOriginal }>
130
130
  { __( 'Edit original' ) }
@@ -134,7 +134,7 @@ function ReusableBlockControl( {
134
134
  ) }
135
135
 
136
136
  { canOverrideBlocks && (
137
- <BlockControls>
137
+ <BlockControls group="other">
138
138
  <ToolbarGroup>
139
139
  <ToolbarButton
140
140
  onClick={ resetContent }
@@ -46,19 +46,33 @@ function BlockKeyboardShortcuts() {
46
46
  ) {
47
47
  return;
48
48
  }
49
+ const newAttributes = {
50
+ content: attributes.content,
51
+ };
49
52
 
50
- const textAlign =
51
- blockName === 'core/paragraph' ? 'align' : 'textAlign';
52
- const destinationTextAlign =
53
- destinationBlockName === 'core/paragraph' ? 'align' : 'textAlign';
53
+ // Read textAlign from source block (could be in old or new format)
54
+ const sourceTextAlign =
55
+ attributes.textAlign || attributes.style?.typography?.textAlign;
56
+
57
+ // When destination is heading, preserve heading format (textAlign attribute + level)
58
+ // When destination is paragraph, use block support format (style.typography.textAlign)
59
+ if ( destinationBlockName === 'core/heading' ) {
60
+ newAttributes.level = level;
61
+ if ( sourceTextAlign ) {
62
+ newAttributes.textAlign = sourceTextAlign;
63
+ }
64
+ } else if ( sourceTextAlign ) {
65
+ // Destination is paragraph
66
+ newAttributes.style = {
67
+ typography: {
68
+ textAlign: sourceTextAlign,
69
+ },
70
+ };
71
+ }
54
72
 
55
73
  replaceBlocks(
56
74
  currentClientId,
57
- createBlock( destinationBlockName, {
58
- level,
59
- content: attributes.content,
60
- ...{ [ destinationTextAlign ]: attributes[ textAlign ] },
61
- } )
75
+ createBlock( destinationBlockName, newAttributes )
62
76
  );
63
77
  };
64
78
 
package/src/common.scss CHANGED
@@ -35,16 +35,17 @@
35
35
  }
36
36
 
37
37
  // Text alignments.
38
- .has-text-align-center {
38
+ // The :root prefix increases CSS specificity from 0-1-0 to 0-2-0,
39
+ // ensuring that block instance-level text alignment overrides take
40
+ // precedence over global styles.
41
+ :root .has-text-align-center {
39
42
  text-align: center;
40
43
  }
41
-
42
- .has-text-align-left {
44
+ :root .has-text-align-left {
43
45
  /*rtl:ignore*/
44
46
  text-align: left;
45
47
  }
46
-
47
- .has-text-align-right {
48
+ :root .has-text-align-right {
48
49
  /*rtl:ignore*/
49
50
  text-align: right;
50
51
  }
@@ -1847,7 +1847,11 @@ const v3 = {
1847
1847
  [
1848
1848
  createBlock( 'core/paragraph', {
1849
1849
  content: attributes.title,
1850
- align: attributes.contentAlign,
1850
+ style: {
1851
+ typography: {
1852
+ textAlign: attributes.contentAlign,
1853
+ },
1854
+ },
1851
1855
  fontSize: 'large',
1852
1856
  placeholder: __( 'Write title…' ),
1853
1857
  } ),
@@ -1933,7 +1937,11 @@ const v2 = {
1933
1937
  [
1934
1938
  createBlock( 'core/paragraph', {
1935
1939
  content: attributes.title,
1936
- align: attributes.contentAlign,
1940
+ style: {
1941
+ typography: {
1942
+ textAlign: attributes.contentAlign,
1943
+ },
1944
+ },
1937
1945
  fontSize: 'large',
1938
1946
  placeholder: __( 'Write title…' ),
1939
1947
  } ),
@@ -1993,7 +2001,11 @@ const v1 = {
1993
2001
  [
1994
2002
  createBlock( 'core/paragraph', {
1995
2003
  content: attributes.title,
1996
- align: attributes.contentAlign,
2004
+ style: {
2005
+ typography: {
2006
+ textAlign: attributes.contentAlign,
2007
+ },
2008
+ },
1997
2009
  fontSize: 'large',
1998
2010
  placeholder: __( 'Write title…' ),
1999
2011
  } ),
@@ -196,7 +196,7 @@ export default function CoverInspectorControls( {
196
196
  return (
197
197
  <>
198
198
  <InspectorControls>
199
- { !! url && (
199
+ { ( !! url || useFeaturedImage ) && (
200
200
  <ToolsPanel
201
201
  label={ __( 'Settings' ) }
202
202
  resetAll={ () => {
@@ -37,7 +37,11 @@ const transforms = {
37
37
  createBlock( 'core/paragraph', {
38
38
  content: caption,
39
39
  fontSize: 'large',
40
- align: 'center',
40
+ style: {
41
+ typography: {
42
+ textAlign: 'center',
43
+ },
44
+ },
41
45
  } ),
42
46
  ]
43
47
  ),
@@ -60,7 +64,11 @@ const transforms = {
60
64
  createBlock( 'core/paragraph', {
61
65
  content: caption,
62
66
  fontSize: 'large',
63
- align: 'center',
67
+ style: {
68
+ typography: {
69
+ textAlign: 'center',
70
+ },
71
+ },
64
72
  } ),
65
73
  ]
66
74
  ),
@@ -24,12 +24,10 @@ export const embedVideoIcon = (
24
24
  </SVG>
25
25
  );
26
26
  export const embedTwitterIcon = {
27
- foreground: '#1da1f2',
27
+ foreground: '#000000',
28
28
  src: (
29
29
  <SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
30
- <G>
31
- <Path d="M22.23 5.924c-.736.326-1.527.547-2.357.646.847-.508 1.498-1.312 1.804-2.27-.793.47-1.67.812-2.606.996C18.325 4.498 17.258 4 16.078 4c-2.266 0-4.103 1.837-4.103 4.103 0 .322.036.635.106.935-3.41-.17-6.433-1.804-8.457-4.287-.353.607-.556 1.312-.556 2.064 0 1.424.724 2.68 1.825 3.415-.673-.022-1.305-.207-1.86-.514v.052c0 1.988 1.415 3.647 3.293 4.023-.344.095-.707.145-1.08.145-.265 0-.522-.026-.773-.074.522 1.63 2.038 2.817 3.833 2.85-1.404 1.1-3.174 1.757-5.096 1.757-.332 0-.66-.02-.98-.057 1.816 1.164 3.973 1.843 6.29 1.843 7.547 0 11.675-6.252 11.675-11.675 0-.178-.004-.355-.012-.53.802-.578 1.497-1.3 2.047-2.124z"></Path>
32
- </G>
30
+ <Path d="M13.982 10.622 20.54 3h-1.554l-5.693 6.618L8.745 3H3.5l6.876 10.007L3.5 21h1.554l6.012-6.989L15.868 21h5.245l-7.131-10.378Zm-2.128 2.474-.697-.997-5.543-7.93H8l4.474 6.4.697.996 5.815 8.318h-2.387l-4.745-6.787Z" />
33
31
  </SVG>
34
32
  ),
35
33
  };
@@ -22,6 +22,12 @@
22
22
  min-height: 240px;
23
23
  }
24
24
 
25
+ // Allow embeds to grow and shrink inside flex group blocks (Stack/Row), preventing collapse while fitting available space.
26
+ .wp-block-group.is-layout-flex .wp-block-embed {
27
+ flex: 1 1 0%;
28
+ min-width: 0;
29
+ }
30
+
25
31
  .wp-block-embed {
26
32
  overflow-wrap: break-word; // Break long strings of text without spaces so they don't overflow the block.
27
33
 
@@ -48,10 +48,10 @@ function getTitle( providerName ) {
48
48
  const variations = [
49
49
  {
50
50
  name: 'twitter',
51
- title: getTitle( 'Twitter' ),
51
+ title: getTitle( 'X' ),
52
52
  icon: embedTwitterIcon,
53
- keywords: [ 'tweet', __( 'social' ) ],
54
- description: __( 'Embed a tweet.' ),
53
+ keywords: [ 'x', 'twitter', 'tweet', __( 'social' ) ],
54
+ description: __( 'Embed an X post.' ),
55
55
  patterns: [ /^https?:\/\/(www\.)?twitter\.com\/.+/i ],
56
56
  attributes: { providerNameSlug: 'twitter', responsive: true },
57
57
  },
@@ -13,6 +13,7 @@ import edit from './edit';
13
13
  import metadata from './block.json';
14
14
  import save from './save';
15
15
  import transforms from './transforms';
16
+ import variations from './variations';
16
17
 
17
18
  const { name } = metadata;
18
19
 
@@ -65,6 +66,7 @@ export const settings = {
65
66
  },
66
67
  edit,
67
68
  save,
69
+ variations,
68
70
  };
69
71
 
70
72
  export const init = () => initBlock( { name, metadata, settings } );
@@ -17,7 +17,8 @@ const transforms = {
17
17
  blocks: [ 'core/paragraph' ],
18
18
  transform: ( attributes ) =>
19
19
  attributes.map( ( _attributes ) => {
20
- const { content, anchor, align: textAlign } = _attributes;
20
+ const { content, anchor, style } = _attributes;
21
+ const textAlign = style?.typography?.textAlign;
21
22
  return createBlock( 'core/heading', {
22
23
  ...getTransformedAttributes(
23
24
  _attributes,
@@ -92,7 +93,7 @@ const transforms = {
92
93
  blocks: [ 'core/paragraph' ],
93
94
  transform: ( attributes ) =>
94
95
  attributes.map( ( _attributes ) => {
95
- const { content, textAlign: align } = _attributes;
96
+ const { content, textAlign } = _attributes;
96
97
  return createBlock( 'core/paragraph', {
97
98
  ...getTransformedAttributes(
98
99
  _attributes,
@@ -102,7 +103,13 @@ const transforms = {
102
103
  } )
103
104
  ),
104
105
  content,
105
- align,
106
+ ...( textAlign && {
107
+ style: {
108
+ typography: {
109
+ textAlign,
110
+ },
111
+ },
112
+ } ),
106
113
  } );
107
114
  } ),
108
115
  },
@@ -0,0 +1,37 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import { Path, SVG } from '@wordpress/primitives';
6
+ import { heading } from '@wordpress/icons';
7
+
8
+ const variations = [
9
+ {
10
+ name: 'heading',
11
+ title: __( 'Heading' ),
12
+ description: __(
13
+ 'Introduce new sections and organize content to help visitors (and search engines) understand the structure of your content.'
14
+ ),
15
+ isDefault: true,
16
+ scope: [ 'inserter', 'transform' ],
17
+ attributes: { fitText: undefined },
18
+ icon: heading,
19
+ },
20
+ // There is a hardcoded workaround in packages/block-editor/src/store/selectors.js
21
+ // to make Stretchy variations appear as the last of their sections in the inserter.
22
+ {
23
+ name: 'stretchy-heading',
24
+ title: __( 'Stretchy Heading' ),
25
+ description: __( 'Heading that resizes to fit its container.' ),
26
+ icon: (
27
+ <SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
28
+ <Path d="m3 18.6 6-4.7 6 4.7V5H3v13.6Zm16.2-9.8v1.5h2.2L17.7 14l1.1 1.1 3.7-3.7v2.2H24V8.8h-4.8Z" />
29
+ </SVG>
30
+ ),
31
+ attributes: { fitText: true },
32
+ scope: [ 'inserter', 'transform' ],
33
+ isActive: ( blockAttributes ) => blockAttributes.fitText === true,
34
+ },
35
+ ];
36
+
37
+ export default variations;
package/src/html/edit.js CHANGED
@@ -2,88 +2,94 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
- import { useContext, useState } from '@wordpress/element';
5
+ import { useState } from '@wordpress/element';
6
6
  import {
7
7
  BlockControls,
8
- PlainText,
8
+ BlockIcon,
9
+ InspectorControls,
9
10
  useBlockProps,
10
- store as blockEditorStore,
11
11
  } from '@wordpress/block-editor';
12
12
  import {
13
13
  ToolbarButton,
14
- Disabled,
15
14
  ToolbarGroup,
16
- VisuallyHidden,
15
+ Placeholder,
16
+ Button,
17
+ __experimentalVStack as VStack,
17
18
  } from '@wordpress/components';
18
- import { useSelect } from '@wordpress/data';
19
- import { useInstanceId } from '@wordpress/compose';
19
+ import { code } from '@wordpress/icons';
20
20
 
21
21
  /**
22
22
  * Internal dependencies
23
23
  */
24
24
  import Preview from './preview';
25
+ import HTMLEditModal from './modal';
25
26
 
26
27
  export default function HTMLEdit( { attributes, setAttributes, isSelected } ) {
27
- const [ isPreview, setIsPreview ] = useState();
28
- const isDisabled = useContext( Disabled.Context );
29
-
30
- const instanceId = useInstanceId( HTMLEdit, 'html-edit-desc' );
31
-
32
- const isPreviewMode = useSelect( ( select ) => {
33
- return select( blockEditorStore ).getSettings().isPreviewMode;
34
- }, [] );
35
-
36
- function switchToPreview() {
37
- setIsPreview( true );
38
- }
39
-
40
- function switchToHTML() {
41
- setIsPreview( false );
42
- }
43
-
28
+ const [ isModalOpen, setIsModalOpen ] = useState( false );
44
29
  const blockProps = useBlockProps( {
45
30
  className: 'block-library-html__edit',
46
- 'aria-describedby': isPreview ? instanceId : undefined,
47
31
  } );
48
32
 
33
+ // Show placeholder when content is empty
34
+ if ( ! attributes.content?.trim() ) {
35
+ return (
36
+ <div { ...blockProps }>
37
+ <Placeholder
38
+ icon={ <BlockIcon icon={ code } /> }
39
+ label={ __( 'Custom HTML' ) }
40
+ instructions={ __(
41
+ 'Add custom HTML code and preview how it looks.'
42
+ ) }
43
+ >
44
+ <Button
45
+ __next40pxDefaultSize
46
+ variant="primary"
47
+ onClick={ () => setIsModalOpen( true ) }
48
+ >
49
+ { __( 'Edit HTML' ) }
50
+ </Button>
51
+ </Placeholder>
52
+ <HTMLEditModal
53
+ isOpen={ isModalOpen }
54
+ onRequestClose={ () => setIsModalOpen( false ) }
55
+ content={ attributes.content }
56
+ setAttributes={ setAttributes }
57
+ />
58
+ </div>
59
+ );
60
+ }
61
+
49
62
  return (
50
63
  <div { ...blockProps }>
51
64
  <BlockControls>
52
65
  <ToolbarGroup>
53
- <ToolbarButton
54
- isPressed={ ! isPreview }
55
- onClick={ switchToHTML }
56
- >
57
- HTML
58
- </ToolbarButton>
59
- <ToolbarButton
60
- isPressed={ isPreview }
61
- onClick={ switchToPreview }
62
- >
63
- { __( 'Preview' ) }
66
+ <ToolbarButton onClick={ () => setIsModalOpen( true ) }>
67
+ { __( 'Edit code' ) }
64
68
  </ToolbarButton>
65
69
  </ToolbarGroup>
66
70
  </BlockControls>
67
- { isPreview || isPreviewMode || isDisabled ? (
68
- <>
69
- <Preview
70
- content={ attributes.content }
71
- isSelected={ isSelected }
72
- />
73
- <VisuallyHidden id={ instanceId }>
74
- { __(
75
- 'HTML preview is not yet fully accessible. Please switch screen reader to virtualized mode to navigate the below iFrame.'
76
- ) }
77
- </VisuallyHidden>
78
- </>
79
- ) : (
80
- <PlainText
81
- value={ attributes.content }
82
- onChange={ ( content ) => setAttributes( { content } ) }
83
- placeholder={ __( 'Write HTML…' ) }
84
- aria-label={ __( 'HTML' ) }
85
- />
86
- ) }
71
+ <InspectorControls>
72
+ <VStack
73
+ className="block-editor-block-inspector-edit-contents"
74
+ expanded
75
+ >
76
+ <Button
77
+ className="block-editor-block-inspector-edit-contents__button"
78
+ __next40pxDefaultSize
79
+ variant="secondary"
80
+ onClick={ () => setIsModalOpen( true ) }
81
+ >
82
+ { __( 'Edit code' ) }
83
+ </Button>
84
+ </VStack>
85
+ </InspectorControls>
86
+ <Preview content={ attributes.content } isSelected={ isSelected } />
87
+ <HTMLEditModal
88
+ isOpen={ isModalOpen }
89
+ onRequestClose={ () => setIsModalOpen( false ) }
90
+ content={ attributes.content }
91
+ setAttributes={ setAttributes }
92
+ />
87
93
  </div>
88
94
  );
89
95
  }