@wordpress/block-editor 8.1.2 → 8.2.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 (187) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +0 -24
  3. package/build/components/block-list/block.js +16 -2
  4. package/build/components/block-list/block.js.map +1 -1
  5. package/build/components/block-list/block.native.js +1 -1
  6. package/build/components/block-list/block.native.js.map +1 -1
  7. package/build/components/block-list/use-block-props/use-focus-first-element.js +3 -0
  8. package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  9. package/build/components/block-list/use-block-props/use-multi-selection.js +25 -27
  10. package/build/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
  11. package/build/components/block-settings/container.native.js +1 -5
  12. package/build/components/block-settings/container.native.js.map +1 -1
  13. package/build/components/index.js +9 -0
  14. package/build/components/index.js.map +1 -1
  15. package/build/components/index.native.js +9 -0
  16. package/build/components/index.native.js.map +1 -1
  17. package/build/components/inserter/block-patterns-tab.js +3 -3
  18. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  19. package/build/components/inserter/quick-inserter.js +19 -7
  20. package/build/components/inserter/quick-inserter.js.map +1 -1
  21. package/build/components/inserter/search-results.js +28 -11
  22. package/build/components/inserter/search-results.js.map +1 -1
  23. package/build/components/line-height-control/index.js +61 -43
  24. package/build/components/line-height-control/index.js.map +1 -1
  25. package/build/components/list-view/block-contents.js +8 -4
  26. package/build/components/list-view/block-contents.js.map +1 -1
  27. package/build/components/list-view/block-select-button.js +0 -1
  28. package/build/components/list-view/block-select-button.js.map +1 -1
  29. package/build/components/list-view/block.js +19 -8
  30. package/build/components/list-view/block.js.map +1 -1
  31. package/build/components/list-view/branch.js +2 -1
  32. package/build/components/list-view/branch.js.map +1 -1
  33. package/build/components/list-view/index.js +49 -41
  34. package/build/components/list-view/index.js.map +1 -1
  35. package/build/components/list-view/use-block-selection.js +139 -0
  36. package/build/components/list-view/use-block-selection.js.map +1 -0
  37. package/build/components/list-view/use-list-view-expand-selected-item.js +60 -0
  38. package/build/components/list-view/use-list-view-expand-selected-item.js.map +1 -0
  39. package/build/components/list-view/utils.js +29 -1
  40. package/build/components/list-view/utils.js.map +1 -1
  41. package/build/components/rich-text/index.js +7 -12
  42. package/build/components/rich-text/index.js.map +1 -1
  43. package/build/components/rich-text/use-paste-handler.js +0 -1
  44. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  45. package/build/components/writing-flow/index.js +1 -0
  46. package/build/components/writing-flow/index.js.map +1 -1
  47. package/build/components/writing-flow/use-multi-selection.js +22 -24
  48. package/build/components/writing-flow/use-multi-selection.js.map +1 -1
  49. package/build/components/writing-flow/use-select-all.js +3 -2
  50. package/build/components/writing-flow/use-select-all.js.map +1 -1
  51. package/build/hooks/custom-class-name.js +40 -0
  52. package/build/hooks/custom-class-name.js.map +1 -1
  53. package/build/hooks/line-height.js +2 -0
  54. package/build/hooks/line-height.js.map +1 -1
  55. package/build/hooks/style.js +27 -11
  56. package/build/hooks/style.js.map +1 -1
  57. package/build/layouts/flow.js +7 -5
  58. package/build/layouts/flow.js.map +1 -1
  59. package/build/store/actions.js +51 -44
  60. package/build/store/actions.js.map +1 -1
  61. package/build/store/defaults.js +1 -0
  62. package/build/store/defaults.js.map +1 -1
  63. package/build/store/index.js +1 -2
  64. package/build/store/index.js.map +1 -1
  65. package/build/store/reducer.js +2 -2
  66. package/build/store/reducer.js.map +1 -1
  67. package/build/utils/index.js +0 -14
  68. package/build/utils/index.js.map +1 -1
  69. package/build-module/components/block-list/block.js +17 -3
  70. package/build-module/components/block-list/block.js.map +1 -1
  71. package/build-module/components/block-list/block.native.js +2 -2
  72. package/build-module/components/block-list/block.native.js.map +1 -1
  73. package/build-module/components/block-list/use-block-props/use-focus-first-element.js +2 -0
  74. package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  75. package/build-module/components/block-list/use-block-props/use-multi-selection.js +23 -28
  76. package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
  77. package/build-module/components/block-settings/container.native.js +2 -6
  78. package/build-module/components/block-settings/container.native.js.map +1 -1
  79. package/build-module/components/index.js +1 -0
  80. package/build-module/components/index.js.map +1 -1
  81. package/build-module/components/index.native.js +1 -0
  82. package/build-module/components/index.native.js.map +1 -1
  83. package/build-module/components/inserter/block-patterns-tab.js +3 -3
  84. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  85. package/build-module/components/inserter/quick-inserter.js +19 -7
  86. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  87. package/build-module/components/inserter/search-results.js +28 -11
  88. package/build-module/components/inserter/search-results.js.map +1 -1
  89. package/build-module/components/line-height-control/index.js +59 -43
  90. package/build-module/components/line-height-control/index.js.map +1 -1
  91. package/build-module/components/list-view/block-contents.js +8 -4
  92. package/build-module/components/list-view/block-contents.js.map +1 -1
  93. package/build-module/components/list-view/block-select-button.js +0 -1
  94. package/build-module/components/list-view/block-select-button.js.map +1 -1
  95. package/build-module/components/list-view/block.js +19 -8
  96. package/build-module/components/list-view/block.js.map +1 -1
  97. package/build-module/components/list-view/branch.js +2 -1
  98. package/build-module/components/list-view/branch.js.map +1 -1
  99. package/build-module/components/list-view/index.js +46 -42
  100. package/build-module/components/list-view/index.js.map +1 -1
  101. package/build-module/components/list-view/use-block-selection.js +123 -0
  102. package/build-module/components/list-view/use-block-selection.js.map +1 -0
  103. package/build-module/components/list-view/use-list-view-expand-selected-item.js +50 -0
  104. package/build-module/components/list-view/use-list-view-expand-selected-item.js.map +1 -0
  105. package/build-module/components/list-view/utils.js +25 -0
  106. package/build-module/components/list-view/utils.js.map +1 -1
  107. package/build-module/components/rich-text/index.js +7 -12
  108. package/build-module/components/rich-text/index.js.map +1 -1
  109. package/build-module/components/rich-text/use-paste-handler.js +0 -1
  110. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  111. package/build-module/components/writing-flow/index.js +1 -0
  112. package/build-module/components/writing-flow/index.js.map +1 -1
  113. package/build-module/components/writing-flow/use-multi-selection.js +21 -21
  114. package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
  115. package/build-module/components/writing-flow/use-select-all.js +3 -2
  116. package/build-module/components/writing-flow/use-select-all.js.map +1 -1
  117. package/build-module/hooks/custom-class-name.js +38 -0
  118. package/build-module/hooks/custom-class-name.js.map +1 -1
  119. package/build-module/hooks/line-height.js +2 -0
  120. package/build-module/hooks/line-height.js.map +1 -1
  121. package/build-module/hooks/style.js +26 -11
  122. package/build-module/hooks/style.js.map +1 -1
  123. package/build-module/layouts/flow.js +7 -5
  124. package/build-module/layouts/flow.js.map +1 -1
  125. package/build-module/store/actions.js +48 -41
  126. package/build-module/store/actions.js.map +1 -1
  127. package/build-module/store/defaults.js +1 -0
  128. package/build-module/store/defaults.js.map +1 -1
  129. package/build-module/store/index.js +1 -2
  130. package/build-module/store/index.js.map +1 -1
  131. package/build-module/store/reducer.js +2 -2
  132. package/build-module/store/reducer.js.map +1 -1
  133. package/build-module/utils/index.js +0 -1
  134. package/build-module/utils/index.js.map +1 -1
  135. package/build-style/style-rtl.css +3 -12
  136. package/build-style/style.css +3 -12
  137. package/package.json +12 -11
  138. package/src/components/block-list/block.js +27 -3
  139. package/src/components/block-list/block.native.js +2 -1
  140. package/src/components/block-list/style.scss +3 -1
  141. package/src/components/block-list/use-block-props/use-focus-first-element.js +3 -0
  142. package/src/components/block-list/use-block-props/use-multi-selection.js +22 -30
  143. package/src/components/block-settings/container.native.js +5 -6
  144. package/src/components/index.js +1 -0
  145. package/src/components/index.native.js +1 -0
  146. package/src/components/inserter/block-patterns-tab.js +12 -16
  147. package/src/components/inserter/quick-inserter.js +31 -9
  148. package/src/components/inserter/search-results.js +54 -42
  149. package/src/components/line-height-control/README.md +13 -2
  150. package/src/components/line-height-control/index.js +63 -40
  151. package/src/components/line-height-control/stories/index.js +33 -0
  152. package/src/components/line-height-control/test/index.js +61 -0
  153. package/src/components/list-view/README.md +2 -2
  154. package/src/components/list-view/block-contents.js +10 -3
  155. package/src/components/list-view/block-select-button.js +0 -1
  156. package/src/components/list-view/block.js +29 -9
  157. package/src/components/list-view/branch.js +1 -0
  158. package/src/components/list-view/index.js +56 -30
  159. package/src/components/list-view/test/utils.js +50 -0
  160. package/src/components/list-view/use-block-selection.js +163 -0
  161. package/src/components/list-view/use-list-view-expand-selected-item.js +58 -0
  162. package/src/components/list-view/utils.js +31 -0
  163. package/src/components/rich-text/index.js +7 -14
  164. package/src/components/rich-text/use-paste-handler.js +0 -1
  165. package/src/components/writing-flow/index.js +1 -0
  166. package/src/components/writing-flow/use-multi-selection.js +17 -20
  167. package/src/components/writing-flow/use-select-all.js +6 -2
  168. package/src/hooks/custom-class-name.js +45 -0
  169. package/src/hooks/line-height.js +2 -0
  170. package/src/hooks/style.js +26 -11
  171. package/src/hooks/typography.scss +0 -4
  172. package/src/layouts/flow.js +10 -5
  173. package/src/store/actions.js +20 -10
  174. package/src/store/defaults.js +1 -0
  175. package/src/store/index.js +0 -1
  176. package/src/store/reducer.js +2 -1
  177. package/src/store/test/actions.js +1 -1
  178. package/src/store/test/reducer.js +9 -0
  179. package/src/style.scss +0 -1
  180. package/src/utils/index.js +0 -1
  181. package/build/utils/theme.js +0 -63
  182. package/build/utils/theme.js.map +0 -1
  183. package/build-module/utils/theme.js +0 -53
  184. package/build-module/utils/theme.js.map +0 -1
  185. package/src/components/line-height-control/style.scss +0 -8
  186. package/src/components/writing-flow/test/use-multi-selection.js +0 -36
  187. package/src/utils/theme.js +0 -48
@@ -30,3 +30,34 @@ export const isClientIdSelected = ( clientId, selectedBlockClientIds ) =>
30
30
  isArray( selectedBlockClientIds ) && selectedBlockClientIds.length
31
31
  ? selectedBlockClientIds.indexOf( clientId ) !== -1
32
32
  : selectedBlockClientIds === clientId;
33
+
34
+ /**
35
+ * From a start and end clientId of potentially different nesting levels,
36
+ * return the nearest-depth ids that have a common level of depth in the
37
+ * nesting hierarchy. For multiple block selection, this ensure that the
38
+ * selection is always at the same nesting level, and not split across
39
+ * separate levels.
40
+ *
41
+ * @param {string} startId The first id of a selection.
42
+ * @param {string} endId The end id of a selection, usually one that has been clicked on.
43
+ * @param {string[]} startParents An array of ancestor ids for the start id, in descending order.
44
+ * @param {string[]} endParents An array of ancestor ids for the end id, in descending order.
45
+ * @return {Object} An object containing the start and end ids.
46
+ */
47
+ export function getCommonDepthClientIds(
48
+ startId,
49
+ endId,
50
+ startParents,
51
+ endParents
52
+ ) {
53
+ const startPath = [ ...startParents, startId ];
54
+ const endPath = [ ...endParents, endId ];
55
+ const depth = Math.min( startPath.length, endPath.length ) - 1;
56
+ const start = startPath[ depth ];
57
+ const end = endPath[ depth ];
58
+
59
+ return {
60
+ start,
61
+ end,
62
+ };
63
+ }
@@ -120,12 +120,9 @@ function RichTextWrapper(
120
120
  const anchorRef = useRef();
121
121
  const { clientId } = useBlockEditContext();
122
122
  const selector = ( select ) => {
123
- const {
124
- getSelectionStart,
125
- getSelectionEnd,
126
- isMultiSelecting,
127
- hasMultiSelection,
128
- } = select( blockEditorStore );
123
+ const { getSelectionStart, getSelectionEnd } = select(
124
+ blockEditorStore
125
+ );
129
126
  const selectionStart = getSelectionStart();
130
127
  const selectionEnd = getSelectionEnd();
131
128
 
@@ -143,15 +140,12 @@ function RichTextWrapper(
143
140
  selectionStart: isSelected ? selectionStart.offset : undefined,
144
141
  selectionEnd: isSelected ? selectionEnd.offset : undefined,
145
142
  isSelected,
146
- disabled: isMultiSelecting() || hasMultiSelection(),
147
143
  };
148
144
  };
149
145
  // This selector must run on every render so the right selection state is
150
146
  // retreived from the store on merge.
151
147
  // To do: fix this somehow.
152
- const { selectionStart, selectionEnd, isSelected, disabled } = useSelect(
153
- selector
154
- );
148
+ const { selectionStart, selectionEnd, isSelected } = useSelect( selector );
155
149
  const { selectionChange } = useDispatch( blockEditorStore );
156
150
  const multilineTag = getMultilineTag( multiline );
157
151
  const adjustedAllowedFormats = getAllowedFormats( {
@@ -331,7 +325,7 @@ function RichTextWrapper(
331
325
  <TagName
332
326
  // Overridable props.
333
327
  role="textbox"
334
- aria-multiline={ true }
328
+ aria-multiline={ ! disableLineBreaks }
335
329
  aria-label={ placeholder }
336
330
  { ...props }
337
331
  { ...autocompleteProps }
@@ -379,9 +373,8 @@ function RichTextWrapper(
379
373
  anchorRef,
380
374
  forwardedRef,
381
375
  ] ) }
382
- // Do not set the attribute if disabled.
383
- contentEditable={ disabled ? undefined : true }
384
- suppressContentEditableWarning={ ! disabled }
376
+ contentEditable={ true }
377
+ suppressContentEditableWarning={ true }
385
378
  className={ classnames(
386
379
  'block-editor-rich-text__editable',
387
380
  props.className,
@@ -62,7 +62,6 @@ export function usePasteHandler( props ) {
62
62
  } = propsRef.current;
63
63
 
64
64
  if ( ! isSelected ) {
65
- event.preventDefault();
66
65
  return;
67
66
  }
68
67
 
@@ -37,6 +37,7 @@ export function useWritingFlow() {
37
37
  useRefEffect(
38
38
  ( node ) => {
39
39
  node.tabIndex = -1;
40
+ node.contentEditable = hasMultiSelection;
40
41
 
41
42
  if ( ! hasMultiSelection ) {
42
43
  return;
@@ -15,21 +15,6 @@ import { useSelect } from '@wordpress/data';
15
15
  import { store as blockEditorStore } from '../../store';
16
16
  import { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';
17
17
 
18
- export function toggleRichText( container, toggle ) {
19
- Array.from(
20
- container.querySelectorAll(
21
- // Exclude the Post Title from multi-select disable.
22
- '.rich-text:not( .editor-post-title__input )'
23
- )
24
- ).forEach( ( node ) => {
25
- if ( toggle ) {
26
- node.setAttribute( 'contenteditable', true );
27
- } else {
28
- node.removeAttribute( 'contenteditable' );
29
- }
30
- } );
31
- }
32
-
33
18
  /**
34
19
  * Returns for the deepest node at the start or end of a container node. Ignores
35
20
  * any text nodes that only contain HTML formatting whitespace.
@@ -62,6 +47,7 @@ function selector( select ) {
62
47
  getMultiSelectedBlockClientIds,
63
48
  hasMultiSelection,
64
49
  getSelectedBlockClientId,
50
+ getSelectedBlocksInitialCaretPosition,
65
51
  } = select( blockEditorStore );
66
52
 
67
53
  return {
@@ -69,11 +55,13 @@ function selector( select ) {
69
55
  multiSelectedBlockClientIds: getMultiSelectedBlockClientIds(),
70
56
  hasMultiSelection: hasMultiSelection(),
71
57
  selectedBlockClientId: getSelectedBlockClientId(),
58
+ initialPosition: getSelectedBlocksInitialCaretPosition(),
72
59
  };
73
60
  }
74
61
 
75
62
  export default function useMultiSelection() {
76
63
  const {
64
+ initialPosition,
77
65
  isMultiSelecting,
78
66
  multiSelectedBlockClientIds,
79
67
  hasMultiSelection,
@@ -93,6 +81,13 @@ export default function useMultiSelection() {
93
81
  const { ownerDocument } = node;
94
82
  const { defaultView } = ownerDocument;
95
83
 
84
+ // Allow initialPosition to bypass focus behavior. This is useful
85
+ // for the list view or other areas where we don't want to transfer
86
+ // focus to the editor canvas.
87
+ if ( initialPosition === undefined || initialPosition === null ) {
88
+ return;
89
+ }
90
+
96
91
  if ( ! hasMultiSelection || isMultiSelecting ) {
97
92
  if ( ! selectedBlockClientId || isMultiSelecting ) {
98
93
  return;
@@ -131,6 +126,12 @@ export default function useMultiSelection() {
131
126
  return;
132
127
  }
133
128
 
129
+ // Allow cross contentEditable selection by temporarily making
130
+ // all content editable. We can't rely on using the store and
131
+ // React because re-rending happens too slowly. We need to be
132
+ // able to select across instances immediately.
133
+ node.contentEditable = true;
134
+
134
135
  // For some browsers, like Safari, it is important that focus happens
135
136
  // BEFORE selection.
136
137
  node.focus();
@@ -144,11 +145,6 @@ export default function useMultiSelection() {
144
145
  const startNode = getDeepestNode( startRef.current, 'start' );
145
146
  const endNode = getDeepestNode( endRef.current, 'end' );
146
147
 
147
- // While rich text will be disabled with a delay when there is a multi
148
- // selection, we must do it immediately because it's not possible to set
149
- // selection across editable hosts.
150
- toggleRichText( node, false );
151
-
152
148
  range.setStartBefore( startNode );
153
149
  range.setEndAfter( endNode );
154
150
 
@@ -160,6 +156,7 @@ export default function useMultiSelection() {
160
156
  isMultiSelecting,
161
157
  multiSelectedBlockClientIds,
162
158
  selectedBlockClientId,
159
+ initialPosition,
163
160
  ]
164
161
  );
165
162
  }
@@ -31,11 +31,15 @@ export default function useSelectAll() {
31
31
  return;
32
32
  }
33
33
 
34
- if ( ! isEntirelySelected( event.target ) ) {
34
+ const selectedClientIds = getSelectedBlockClientIds();
35
+
36
+ if (
37
+ selectedClientIds.length < 2 &&
38
+ ! isEntirelySelected( event.target )
39
+ ) {
35
40
  return;
36
41
  }
37
42
 
38
- const selectedClientIds = getSelectedBlockClientIds();
39
43
  const [ firstSelectedClientId ] = selectedClientIds;
40
44
  const rootClientId = getBlockRootClientId( firstSelectedClientId );
41
45
  let blockClientIds = getBlockOrder( rootClientId );
@@ -112,6 +112,45 @@ export function addSaveProps( extraProps, blockType, attributes ) {
112
112
  return extraProps;
113
113
  }
114
114
 
115
+ export function addTransforms( result, source, index, results ) {
116
+ if ( ! hasBlockSupport( result.name, 'customClassName', true ) ) {
117
+ return result;
118
+ }
119
+
120
+ // If the condition verifies we are probably in the presence of a wrapping transform
121
+ // e.g: nesting paragraphs in a group or columns and in that case the class should not be kept.
122
+ if ( results.length === 1 && result.innerBlocks.length === source.length ) {
123
+ return result;
124
+ }
125
+
126
+ // If we are transforming one block to multiple blocks or multiple blocks to one block,
127
+ // we ignore the class during the transform.
128
+ if (
129
+ ( results.length === 1 && source.length > 1 ) ||
130
+ ( results.length > 1 && source.length === 1 )
131
+ ) {
132
+ return result;
133
+ }
134
+
135
+ // If we are in presence of transform between one or more block in the source
136
+ // that have one or more blocks in the result
137
+ // we apply the class on source N to the result N,
138
+ // if source N does not exists we do nothing.
139
+ if ( source[ index ] ) {
140
+ const originClassName = source[ index ]?.attributes.className;
141
+ if ( originClassName ) {
142
+ return {
143
+ ...result,
144
+ attributes: {
145
+ ...result.attributes,
146
+ className: originClassName,
147
+ },
148
+ };
149
+ }
150
+ }
151
+ return result;
152
+ }
153
+
115
154
  addFilter(
116
155
  'blocks.registerBlockType',
117
156
  'core/custom-class-name/attribute',
@@ -127,3 +166,9 @@ addFilter(
127
166
  'core/custom-class-name/save-props',
128
167
  addSaveProps
129
168
  );
169
+
170
+ addFilter(
171
+ 'blocks.switchToBlockType.transformedBlock',
172
+ 'core/color/addTransforms',
173
+ addTransforms
174
+ );
@@ -38,6 +38,8 @@ export function LineHeightEdit( props ) {
38
38
  };
39
39
  return (
40
40
  <LineHeightControl
41
+ __unstableInputWidth="100%"
42
+ __nextHasNoMarginBottom={ true }
41
43
  value={ style?.typography?.lineHeight }
42
44
  onChange={ onChange }
43
45
  />
@@ -27,6 +27,7 @@ import {
27
27
  __EXPERIMENTAL_ELEMENTS as ELEMENTS,
28
28
  } from '@wordpress/blocks';
29
29
  import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
30
+ import { getCSSRules } from '@wordpress/style-engine';
30
31
 
31
32
  /**
32
33
  * Internal dependencies
@@ -85,21 +86,35 @@ export function getInlineStyles( styles = {} ) {
85
86
  // option and backwards compatibility for border radius support.
86
87
  const styleValue = get( styles, path );
87
88
 
88
- if ( !! subPaths && ! isString( styleValue ) ) {
89
- Object.entries( subPaths ).forEach( ( entry ) => {
90
- const [ name, subPath ] = entry;
91
- const value = get( styleValue, [ subPath ] );
92
-
93
- if ( value ) {
94
- output[ name ] = compileStyleValue( value );
95
- }
96
- } );
97
- } else if ( ! ignoredStyles.includes( path.join( '.' ) ) ) {
98
- output[ propKey ] = compileStyleValue( get( styles, path ) );
89
+ if ( ! STYLE_PROPERTY[ propKey ].useEngine ) {
90
+ if ( !! subPaths && ! isString( styleValue ) ) {
91
+ Object.entries( subPaths ).forEach( ( entry ) => {
92
+ const [ name, subPath ] = entry;
93
+ const value = get( styleValue, [ subPath ] );
94
+
95
+ if ( value ) {
96
+ output[ name ] = compileStyleValue( value );
97
+ }
98
+ } );
99
+ } else if ( ! ignoredStyles.includes( path.join( '.' ) ) ) {
100
+ output[ propKey ] = compileStyleValue(
101
+ get( styles, path )
102
+ );
103
+ }
99
104
  }
100
105
  }
101
106
  } );
102
107
 
108
+ // The goal is to move everything to server side generated engine styles
109
+ // This is temporary as we absorb more and more styles into the engine.
110
+ const extraRules = getCSSRules( styles, { selector: 'self' } );
111
+ extraRules.forEach( ( rule ) => {
112
+ if ( rule.selector !== 'self' ) {
113
+ throw "This style can't be added as inline style";
114
+ }
115
+ output[ rule.key ] = rule.value;
116
+ } );
117
+
103
118
  return output;
104
119
  }
105
120
 
@@ -6,10 +6,6 @@
6
6
  margin-bottom: 0;
7
7
  }
8
8
 
9
- .block-editor-line-height-control input {
10
- max-width: 100%;
11
- }
12
-
13
9
  .single-column {
14
10
  grid-column: span 1;
15
11
  }
@@ -115,31 +115,36 @@ export default {
115
115
  let output =
116
116
  !! contentSize || !! wideSize
117
117
  ? `
118
- ${ appendSelectors( selector, '> *' ) } {
118
+ ${ appendSelectors(
119
+ selector,
120
+ '> :where(:not(.alignleft):not(.alignright))'
121
+ ) } {
119
122
  max-width: ${ contentSize ?? wideSize };
120
123
  margin-left: auto !important;
121
124
  margin-right: auto !important;
122
125
  }
123
126
 
124
- ${ appendSelectors( selector, '> [data-align="wide"]' ) } {
127
+ ${ appendSelectors( selector, '> .alignwide' ) } {
125
128
  max-width: ${ wideSize ?? contentSize };
126
129
  }
127
130
 
128
- ${ appendSelectors( selector, '> [data-align="full"]' ) } {
131
+ ${ appendSelectors( selector, '> .alignfull' ) } {
129
132
  max-width: none;
130
133
  }
131
134
  `
132
135
  : '';
133
136
 
134
137
  output += `
135
- ${ appendSelectors( selector, '> [data-align="left"]' ) } {
138
+ ${ appendSelectors( selector, '> .alignleft' ) } {
136
139
  float: left;
137
140
  margin-right: 2em;
141
+ margin-left: 0;
138
142
  }
139
143
 
140
- ${ appendSelectors( selector, '> [data-align="right"]' ) } {
144
+ ${ appendSelectors( selector, '> .alignright' ) } {
141
145
  float: right;
142
146
  margin-left: 2em;
147
+ margin-right: 0;
143
148
  }
144
149
 
145
150
  `;
@@ -259,10 +259,15 @@ export function stopMultiSelect() {
259
259
  /**
260
260
  * Action that changes block multi-selection.
261
261
  *
262
- * @param {string} start First block of the multi selection.
263
- * @param {string} end Last block of the multiselection.
262
+ * @param {string} start First block of the multi selection.
263
+ * @param {string} end Last block of the multiselection.
264
+ * @param {number|null} __experimentalInitialPosition Optional initial position. Pass as null to skip focus within editor canvas.
264
265
  */
265
- export const multiSelect = ( start, end ) => ( { select, dispatch } ) => {
266
+ export const multiSelect = (
267
+ start,
268
+ end,
269
+ __experimentalInitialPosition = 0
270
+ ) => ( { select, dispatch } ) => {
266
271
  const startBlockRootClientId = select.getBlockRootClientId( start );
267
272
  const endBlockRootClientId = select.getBlockRootClientId( end );
268
273
 
@@ -271,7 +276,12 @@ export const multiSelect = ( start, end ) => ( { select, dispatch } ) => {
271
276
  return;
272
277
  }
273
278
 
274
- dispatch( { type: 'MULTI_SELECT', start, end } );
279
+ dispatch( {
280
+ type: 'MULTI_SELECT',
281
+ start,
282
+ end,
283
+ initialPosition: __experimentalInitialPosition,
284
+ } );
275
285
 
276
286
  const blockCount = select.getSelectedBlockCount();
277
287
 
@@ -996,11 +1006,11 @@ export function selectionChange(
996
1006
  * @param {?Object} attributes Optional attributes of the block to assign.
997
1007
  * @param {?string} rootClientId Optional root client ID of block list on which
998
1008
  * to append.
999
- * @param {?number} index Optional index where to insert the default block
1000
- *
1001
- * @return {Object} Action object
1009
+ * @param {?number} index Optional index where to insert the default block.
1002
1010
  */
1003
- export function insertDefaultBlock( attributes, rootClientId, index ) {
1011
+ export const insertDefaultBlock = ( attributes, rootClientId, index ) => ( {
1012
+ dispatch,
1013
+ } ) => {
1004
1014
  // Abort if there is no default block type (if it has been unregistered).
1005
1015
  const defaultBlockName = getDefaultBlockName();
1006
1016
  if ( ! defaultBlockName ) {
@@ -1009,8 +1019,8 @@ export function insertDefaultBlock( attributes, rootClientId, index ) {
1009
1019
 
1010
1020
  const block = createBlock( defaultBlockName, attributes );
1011
1021
 
1012
- return insertBlock( block, index, rootClientId );
1013
- }
1022
+ return dispatch.insertBlock( block, index, rootClientId );
1023
+ };
1014
1024
 
1015
1025
  /**
1016
1026
  * Action that changes the nested settings of a given block.
@@ -156,6 +156,7 @@ export const SETTINGS_DEFAULTS = {
156
156
  __experimentalBlockPatterns: [],
157
157
  __experimentalBlockPatternCategories: [],
158
158
  __experimentalSpotlightEntityBlocks: [],
159
+ __experimentalGenerateAnchors: false,
159
160
  __unstableGalleryWithImageBlocks: false,
160
161
 
161
162
  // gradients setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults.
@@ -22,7 +22,6 @@ export const storeConfig = {
22
22
  reducer,
23
23
  selectors,
24
24
  actions,
25
- __experimentalUseThunks: true,
26
25
  };
27
26
 
28
27
  /**
@@ -1380,7 +1380,7 @@ export function isSelectionEnabled( state = true, action ) {
1380
1380
  }
1381
1381
 
1382
1382
  /**
1383
- * Reducer returning the intial block selection.
1383
+ * Reducer returning the initial block selection.
1384
1384
  *
1385
1385
  * Currently this in only used to restore the selection after block deletion and
1386
1386
  * pasting new content.This reducer should eventually be removed in favour of setting
@@ -1399,6 +1399,7 @@ export function initialPosition( state = null, action ) {
1399
1399
  return action.initialPosition;
1400
1400
  } else if (
1401
1401
  [
1402
+ 'MULTI_SELECT',
1402
1403
  'SELECT_BLOCK',
1403
1404
  'RESET_SELECTION',
1404
1405
  'INSERT_BLOCKS',
@@ -165,6 +165,7 @@ describe( 'actions', () => {
165
165
  type: 'MULTI_SELECT',
166
166
  start,
167
167
  end,
168
+ initialPosition: 0,
168
169
  } );
169
170
  } );
170
171
 
@@ -1166,7 +1167,6 @@ describe( 'actions', () => {
1166
1167
  actions,
1167
1168
  selectors,
1168
1169
  reducer,
1169
- __experimentalUseThunks: true,
1170
1170
  } );
1171
1171
 
1172
1172
  registerBlockType( 'core/test-block', defaultBlockSettings );
@@ -2187,6 +2187,15 @@ describe( 'state', () => {
2187
2187
 
2188
2188
  expect( state ).toBe( -1 );
2189
2189
  } );
2190
+
2191
+ it( 'should allow setting null value in multi selection', () => {
2192
+ const state = initialPosition( undefined, {
2193
+ type: 'MULTI_SELECT',
2194
+ initialPosition: null,
2195
+ } );
2196
+
2197
+ expect( state ).toBe( null );
2198
+ } );
2190
2199
  } );
2191
2200
 
2192
2201
  describe( 'isMultiSelecting()', () => {
package/src/style.scss CHANGED
@@ -36,7 +36,6 @@
36
36
  @import "./components/inner-blocks/style.scss";
37
37
  @import "./components/inserter-list-item/style.scss";
38
38
  @import "./components/justify-content-control/style.scss";
39
- @import "./components/line-height-control/style.scss";
40
39
  @import "./components/link-control/style.scss";
41
40
  @import "./components/list-view/style.scss";
42
41
  @import "./components/media-replace-flow/style.scss";
@@ -1,4 +1,3 @@
1
1
  export { default as transformStyles } from './transform-styles';
2
- export * from './theme';
3
2
  export * from './block-variation-transforms';
4
3
  export { default as getPxFromCssUnit } from './parse-css-unit-to-px';
@@ -1,63 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.validateThemeColors = validateThemeColors;
7
- exports.validateThemeGradients = validateThemeGradients;
8
-
9
- var _defaults = require("../store/defaults");
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
-
15
- /**
16
- * Given an array of theme colors checks colors for validity
17
- *
18
- * @param {Array} colors The array of theme colors
19
- *
20
- * @return {Array} The array of valid theme colors or the default colors
21
- */
22
- function validateThemeColors(colors) {
23
- if (colors === undefined) {
24
- colors = _defaults.SETTINGS_DEFAULTS.colors;
25
- } else {
26
- const validColors = colors.filter(c => c.color);
27
-
28
- if (validColors.length === 0) {
29
- colors = _defaults.SETTINGS_DEFAULTS.colors;
30
- } else if (validColors.length < colors.length) {
31
- // Filter out invalid colors
32
- colors = validColors;
33
- }
34
- }
35
-
36
- return colors;
37
- }
38
- /**
39
- * Given an array of theme gradients checks gradients for validity
40
- *
41
- * @param {Array} gradients The array of theme gradients
42
- *
43
- * @return {Array} The array of valid theme gradients or the default gradients
44
- */
45
-
46
-
47
- function validateThemeGradients(gradients) {
48
- if (gradients === undefined) {
49
- gradients = _defaults.SETTINGS_DEFAULTS.gradients;
50
- } else {
51
- const validGradients = gradients.filter(c => c.gradient);
52
-
53
- if (validGradients.length === 0) {
54
- gradients = _defaults.SETTINGS_DEFAULTS.gradients;
55
- } else if (validGradients.length < gradients.length) {
56
- // Filter out invalid gradients
57
- gradients = validGradients;
58
- }
59
- }
60
-
61
- return gradients;
62
- }
63
- //# sourceMappingURL=theme.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/utils/theme.js"],"names":["validateThemeColors","colors","undefined","SETTINGS_DEFAULTS","validColors","filter","c","color","length","validateThemeGradients","gradients","validGradients","gradient"],"mappings":";;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,mBAAT,CAA8BC,MAA9B,EAAuC;AAC7C,MAAKA,MAAM,KAAKC,SAAhB,EAA4B;AAC3BD,IAAAA,MAAM,GAAGE,4BAAkBF,MAA3B;AACA,GAFD,MAEO;AACN,UAAMG,WAAW,GAAGH,MAAM,CAACI,MAAP,CAAiBC,CAAF,IAASA,CAAC,CAACC,KAA1B,CAApB;;AACA,QAAKH,WAAW,CAACI,MAAZ,KAAuB,CAA5B,EAAgC;AAC/BP,MAAAA,MAAM,GAAGE,4BAAkBF,MAA3B;AACA,KAFD,MAEO,IAAKG,WAAW,CAACI,MAAZ,GAAqBP,MAAM,CAACO,MAAjC,EAA0C;AAChD;AACAP,MAAAA,MAAM,GAAGG,WAAT;AACA;AACD;;AACD,SAAOH,MAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASQ,sBAAT,CAAiCC,SAAjC,EAA6C;AACnD,MAAKA,SAAS,KAAKR,SAAnB,EAA+B;AAC9BQ,IAAAA,SAAS,GAAGP,4BAAkBO,SAA9B;AACA,GAFD,MAEO;AACN,UAAMC,cAAc,GAAGD,SAAS,CAACL,MAAV,CAAoBC,CAAF,IAASA,CAAC,CAACM,QAA7B,CAAvB;;AACA,QAAKD,cAAc,CAACH,MAAf,KAA0B,CAA/B,EAAmC;AAClCE,MAAAA,SAAS,GAAGP,4BAAkBO,SAA9B;AACA,KAFD,MAEO,IAAKC,cAAc,CAACH,MAAf,GAAwBE,SAAS,CAACF,MAAvC,EAAgD;AACtD;AACAE,MAAAA,SAAS,GAAGC,cAAZ;AACA;AACD;;AACD,SAAOD,SAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { SETTINGS_DEFAULTS } from '../store/defaults';\n\n/**\n * Given an array of theme colors checks colors for validity\n *\n * @param {Array} colors The array of theme colors\n *\n * @return {Array} The array of valid theme colors or the default colors\n */\nexport function validateThemeColors( colors ) {\n\tif ( colors === undefined ) {\n\t\tcolors = SETTINGS_DEFAULTS.colors;\n\t} else {\n\t\tconst validColors = colors.filter( ( c ) => c.color );\n\t\tif ( validColors.length === 0 ) {\n\t\t\tcolors = SETTINGS_DEFAULTS.colors;\n\t\t} else if ( validColors.length < colors.length ) {\n\t\t\t// Filter out invalid colors\n\t\t\tcolors = validColors;\n\t\t}\n\t}\n\treturn colors;\n}\n\n/**\n * Given an array of theme gradients checks gradients for validity\n *\n * @param {Array} gradients The array of theme gradients\n *\n * @return {Array} The array of valid theme gradients or the default gradients\n */\nexport function validateThemeGradients( gradients ) {\n\tif ( gradients === undefined ) {\n\t\tgradients = SETTINGS_DEFAULTS.gradients;\n\t} else {\n\t\tconst validGradients = gradients.filter( ( c ) => c.gradient );\n\t\tif ( validGradients.length === 0 ) {\n\t\t\tgradients = SETTINGS_DEFAULTS.gradients;\n\t\t} else if ( validGradients.length < gradients.length ) {\n\t\t\t// Filter out invalid gradients\n\t\t\tgradients = validGradients;\n\t\t}\n\t}\n\treturn gradients;\n}\n"]}
@@ -1,53 +0,0 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import { SETTINGS_DEFAULTS } from '../store/defaults';
5
- /**
6
- * Given an array of theme colors checks colors for validity
7
- *
8
- * @param {Array} colors The array of theme colors
9
- *
10
- * @return {Array} The array of valid theme colors or the default colors
11
- */
12
-
13
- export function validateThemeColors(colors) {
14
- if (colors === undefined) {
15
- colors = SETTINGS_DEFAULTS.colors;
16
- } else {
17
- const validColors = colors.filter(c => c.color);
18
-
19
- if (validColors.length === 0) {
20
- colors = SETTINGS_DEFAULTS.colors;
21
- } else if (validColors.length < colors.length) {
22
- // Filter out invalid colors
23
- colors = validColors;
24
- }
25
- }
26
-
27
- return colors;
28
- }
29
- /**
30
- * Given an array of theme gradients checks gradients for validity
31
- *
32
- * @param {Array} gradients The array of theme gradients
33
- *
34
- * @return {Array} The array of valid theme gradients or the default gradients
35
- */
36
-
37
- export function validateThemeGradients(gradients) {
38
- if (gradients === undefined) {
39
- gradients = SETTINGS_DEFAULTS.gradients;
40
- } else {
41
- const validGradients = gradients.filter(c => c.gradient);
42
-
43
- if (validGradients.length === 0) {
44
- gradients = SETTINGS_DEFAULTS.gradients;
45
- } else if (validGradients.length < gradients.length) {
46
- // Filter out invalid gradients
47
- gradients = validGradients;
48
- }
49
- }
50
-
51
- return gradients;
52
- }
53
- //# sourceMappingURL=theme.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/utils/theme.js"],"names":["SETTINGS_DEFAULTS","validateThemeColors","colors","undefined","validColors","filter","c","color","length","validateThemeGradients","gradients","validGradients","gradient"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,iBAAT,QAAkC,mBAAlC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,mBAAT,CAA8BC,MAA9B,EAAuC;AAC7C,MAAKA,MAAM,KAAKC,SAAhB,EAA4B;AAC3BD,IAAAA,MAAM,GAAGF,iBAAiB,CAACE,MAA3B;AACA,GAFD,MAEO;AACN,UAAME,WAAW,GAAGF,MAAM,CAACG,MAAP,CAAiBC,CAAF,IAASA,CAAC,CAACC,KAA1B,CAApB;;AACA,QAAKH,WAAW,CAACI,MAAZ,KAAuB,CAA5B,EAAgC;AAC/BN,MAAAA,MAAM,GAAGF,iBAAiB,CAACE,MAA3B;AACA,KAFD,MAEO,IAAKE,WAAW,CAACI,MAAZ,GAAqBN,MAAM,CAACM,MAAjC,EAA0C;AAChD;AACAN,MAAAA,MAAM,GAAGE,WAAT;AACA;AACD;;AACD,SAAOF,MAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASO,sBAAT,CAAiCC,SAAjC,EAA6C;AACnD,MAAKA,SAAS,KAAKP,SAAnB,EAA+B;AAC9BO,IAAAA,SAAS,GAAGV,iBAAiB,CAACU,SAA9B;AACA,GAFD,MAEO;AACN,UAAMC,cAAc,GAAGD,SAAS,CAACL,MAAV,CAAoBC,CAAF,IAASA,CAAC,CAACM,QAA7B,CAAvB;;AACA,QAAKD,cAAc,CAACH,MAAf,KAA0B,CAA/B,EAAmC;AAClCE,MAAAA,SAAS,GAAGV,iBAAiB,CAACU,SAA9B;AACA,KAFD,MAEO,IAAKC,cAAc,CAACH,MAAf,GAAwBE,SAAS,CAACF,MAAvC,EAAgD;AACtD;AACAE,MAAAA,SAAS,GAAGC,cAAZ;AACA;AACD;;AACD,SAAOD,SAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { SETTINGS_DEFAULTS } from '../store/defaults';\n\n/**\n * Given an array of theme colors checks colors for validity\n *\n * @param {Array} colors The array of theme colors\n *\n * @return {Array} The array of valid theme colors or the default colors\n */\nexport function validateThemeColors( colors ) {\n\tif ( colors === undefined ) {\n\t\tcolors = SETTINGS_DEFAULTS.colors;\n\t} else {\n\t\tconst validColors = colors.filter( ( c ) => c.color );\n\t\tif ( validColors.length === 0 ) {\n\t\t\tcolors = SETTINGS_DEFAULTS.colors;\n\t\t} else if ( validColors.length < colors.length ) {\n\t\t\t// Filter out invalid colors\n\t\t\tcolors = validColors;\n\t\t}\n\t}\n\treturn colors;\n}\n\n/**\n * Given an array of theme gradients checks gradients for validity\n *\n * @param {Array} gradients The array of theme gradients\n *\n * @return {Array} The array of valid theme gradients or the default gradients\n */\nexport function validateThemeGradients( gradients ) {\n\tif ( gradients === undefined ) {\n\t\tgradients = SETTINGS_DEFAULTS.gradients;\n\t} else {\n\t\tconst validGradients = gradients.filter( ( c ) => c.gradient );\n\t\tif ( validGradients.length === 0 ) {\n\t\t\tgradients = SETTINGS_DEFAULTS.gradients;\n\t\t} else if ( validGradients.length < gradients.length ) {\n\t\t\t// Filter out invalid gradients\n\t\t\tgradients = validGradients;\n\t\t}\n\t}\n\treturn gradients;\n}\n"]}