@wordpress/edit-site 5.0.0 → 5.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.
- package/CHANGELOG.md +14 -1
- package/LICENSE.md +1 -1
- package/build/components/add-new-template/new-template-part.js +21 -1
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/utils.js +9 -1
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +0 -1
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/block-editor/index.js +17 -52
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/block-editor/resize-handle.js +2 -1
- package/build/components/block-editor/resize-handle.js.map +1 -1
- package/build/components/editor/index.js +5 -17
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/block-preview-panel.js +27 -6
- package/build/components/global-styles/block-preview-panel.js.map +1 -1
- package/build/components/global-styles/border-panel.js +5 -5
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/context-menu.js +9 -1
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/custom-css.js +1 -0
- package/build/components/global-styles/custom-css.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +16 -11
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +3 -2
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +6 -6
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +4 -1
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-block.js +2 -6
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-border.js +12 -2
- package/build/components/global-styles/screen-border.js.map +1 -1
- package/build/components/global-styles/screen-button-color.js +3 -4
- package/build/components/global-styles/screen-button-color.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +53 -25
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-heading-color.js +9 -10
- package/build/components/global-styles/screen-heading-color.js.map +1 -1
- package/build/components/global-styles/screen-layout.js +12 -2
- package/build/components/global-styles/screen-layout.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +8 -8
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-root.js +7 -2
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +4 -4
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +11 -1
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/screen-variations.js +71 -0
- package/build/components/global-styles/screen-variations.js.map +1 -0
- package/build/components/global-styles/typography-panel.js +9 -8
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +17 -5
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/ui.js +85 -18
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +119 -33
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +60 -3
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/global-styles/variations-panel.js +85 -0
- package/build/components/global-styles/variations-panel.js.map +1 -0
- package/build/components/header-edit-mode/document-actions/index.js +10 -41
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/layout/index.js +129 -87
- package/build/components/layout/index.js.map +1 -1
- package/build/components/sidebar/index.js +5 -1
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/index.js +3 -1
- package/build/components/sidebar-edit-mode/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js +2 -0
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +1 -1
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js +10 -0
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +1 -31
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +3 -22
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/site-hub/index.js +149 -0
- package/build/components/site-hub/index.js.map +1 -0
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +54 -0
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -0
- package/build/components/template-details/edit-template-title.js +1 -0
- package/build/components/template-details/edit-template-title.js.map +1 -1
- package/build/components/template-details/template-part-area-selector.js +1 -0
- package/build/components/template-details/template-part-area-selector.js.map +1 -1
- package/build/components/use-edited-entity-record/index.js +60 -0
- package/build/components/use-edited-entity-record/index.js.map +1 -0
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +144 -0
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -0
- package/build/index.js +5 -0
- package/build/index.js.map +1 -1
- package/build/store/reducer.js +1 -1
- package/build/store/reducer.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +20 -1
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +5 -0
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +0 -1
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/block-editor/index.js +19 -50
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/block-editor/resize-handle.js +2 -1
- package/build-module/components/block-editor/resize-handle.js.map +1 -1
- package/build-module/components/editor/index.js +2 -13
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/block-preview-panel.js +26 -6
- package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +5 -5
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +7 -1
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/custom-css.js +1 -0
- package/build-module/components/global-styles/custom-css.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +16 -11
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +3 -2
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +6 -6
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +3 -1
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-block.js +2 -5
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-border.js +10 -2
- package/build-module/components/global-styles/screen-border.js.map +1 -1
- package/build-module/components/global-styles/screen-button-color.js +3 -4
- package/build-module/components/global-styles/screen-button-color.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +51 -25
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-heading-color.js +9 -10
- package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
- package/build-module/components/global-styles/screen-layout.js +10 -2
- package/build-module/components/global-styles/screen-layout.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +8 -8
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +8 -3
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +4 -4
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +9 -1
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/screen-variations.js +54 -0
- package/build-module/components/global-styles/screen-variations.js.map +1 -0
- package/build-module/components/global-styles/typography-panel.js +9 -8
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +17 -5
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/ui.js +84 -19
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +121 -35
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +56 -3
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/global-styles/variations-panel.js +68 -0
- package/build-module/components/global-styles/variations-panel.js.map +1 -0
- package/build-module/components/header-edit-mode/document-actions/index.js +10 -38
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/layout/index.js +129 -88
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +4 -1
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/index.js +3 -1
- package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js +2 -0
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js +11 -1
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +2 -27
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +5 -23
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +127 -0
- package/build-module/components/site-hub/index.js.map +1 -0
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +43 -0
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -0
- package/build-module/components/template-details/edit-template-title.js +1 -0
- package/build-module/components/template-details/edit-template-title.js.map +1 -1
- package/build-module/components/template-details/template-part-area-selector.js +1 -0
- package/build-module/components/template-details/template-part-area-selector.js.map +1 -1
- package/build-module/components/use-edited-entity-record/index.js +48 -0
- package/build-module/components/use-edited-entity-record/index.js.map +1 -0
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +132 -0
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -0
- package/build-module/index.js +4 -0
- package/build-module/index.js.map +1 -1
- package/build-module/store/reducer.js +1 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-style/style-rtl.css +190 -125
- package/build-style/style.css +190 -125
- package/package.json +30 -29
- package/src/components/add-new-template/new-template-part.js +23 -1
- package/src/components/add-new-template/utils.js +14 -0
- package/src/components/block-editor/editor-canvas.js +0 -1
- package/src/components/block-editor/index.js +14 -59
- package/src/components/block-editor/resize-handle.js +6 -2
- package/src/components/block-editor/style.scss +43 -7
- package/src/components/editor/index.js +2 -17
- package/src/components/global-styles/block-preview-panel.js +37 -10
- package/src/components/global-styles/border-panel.js +8 -5
- package/src/components/global-styles/context-menu.js +6 -0
- package/src/components/global-styles/custom-css.js +1 -0
- package/src/components/global-styles/dimensions-panel.js +32 -15
- package/src/components/global-styles/global-styles-provider.js +11 -5
- package/src/components/global-styles/screen-background-color.js +12 -6
- package/src/components/global-styles/screen-block-list.js +6 -1
- package/src/components/global-styles/screen-block.js +1 -4
- package/src/components/global-styles/screen-border.js +8 -3
- package/src/components/global-styles/screen-button-color.js +2 -4
- package/src/components/global-styles/screen-colors.js +84 -20
- package/src/components/global-styles/screen-heading-color.js +8 -10
- package/src/components/global-styles/screen-layout.js +11 -3
- package/src/components/global-styles/screen-link-color.js +19 -8
- package/src/components/global-styles/screen-root.js +34 -27
- package/src/components/global-styles/screen-text-color.js +7 -4
- package/src/components/global-styles/screen-typography.js +13 -3
- package/src/components/global-styles/screen-variations.js +47 -0
- package/src/components/global-styles/style.scss +9 -0
- package/src/components/global-styles/test/typography-utils.js +72 -23
- package/src/components/global-styles/test/use-global-styles-output.js +1 -1
- package/src/components/global-styles/typography-panel.js +31 -8
- package/src/components/global-styles/typography-utils.js +24 -4
- package/src/components/global-styles/ui.js +101 -13
- package/src/components/global-styles/use-global-styles-output.js +137 -14
- package/src/components/global-styles/utils.js +56 -3
- package/src/components/global-styles/variations-panel.js +78 -0
- package/src/components/header-edit-mode/document-actions/index.js +18 -37
- package/src/components/header-edit-mode/style.scss +1 -0
- package/src/components/layout/index.js +217 -172
- package/src/components/layout/style.scss +98 -66
- package/src/components/list/style.scss +1 -8
- package/src/components/sidebar/index.js +4 -1
- package/src/components/sidebar-edit-mode/index.js +1 -1
- package/src/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js +2 -0
- package/src/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js +10 -0
- package/src/components/sidebar-edit-mode/navigation-menu-sidebar/style.scss +4 -0
- package/src/components/sidebar-navigation-screen/style.scss +2 -4
- package/src/components/sidebar-navigation-screen-main/index.js +1 -29
- package/src/components/sidebar-navigation-screen-templates/index.js +9 -27
- package/src/components/site-hub/index.js +161 -0
- package/src/components/site-hub/style.scss +31 -0
- package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +40 -0
- package/src/components/template-details/edit-template-title.js +1 -0
- package/src/components/template-details/template-part-area-selector.js +1 -0
- package/src/components/use-edited-entity-record/index.js +37 -0
- package/src/hooks/index.js +1 -0
- package/src/hooks/push-changes-to-global-styles/index.js +162 -0
- package/src/hooks/push-changes-to-global-styles/style.scss +4 -0
- package/src/index.js +2 -0
- package/src/store/reducer.js +1 -1
- package/src/style.scss +2 -0
- package/build/components/site-title/index.js +0 -55
- package/build/components/site-title/index.js.map +0 -1
- package/build-module/components/site-title/index.js +0 -43
- package/build-module/components/site-title/index.js.map +0 -1
- package/src/components/site-title/index.js +0 -39
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { get, isEmpty, kebabCase,
|
|
4
|
+
import { get, isEmpty, kebabCase, set } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,
|
|
11
11
|
__EXPERIMENTAL_ELEMENTS as ELEMENTS,
|
|
12
12
|
getBlockTypes,
|
|
13
|
+
store as blocksStore,
|
|
13
14
|
} from '@wordpress/blocks';
|
|
14
15
|
import { useSelect } from '@wordpress/data';
|
|
15
16
|
import { useContext, useMemo } from '@wordpress/element';
|
|
@@ -171,6 +172,29 @@ function flattenTree( input = {}, prefix, token ) {
|
|
|
171
172
|
return result;
|
|
172
173
|
}
|
|
173
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Gets variation selector string from feature selector.
|
|
177
|
+
*
|
|
178
|
+
* @param {string} featureSelector The feature selector.
|
|
179
|
+
*
|
|
180
|
+
* @param {string} styleVariationSelector The style variation selector.
|
|
181
|
+
* @return {string} Combined selector string.
|
|
182
|
+
*
|
|
183
|
+
*/
|
|
184
|
+
function concatFeatureVariationSelectorString(
|
|
185
|
+
featureSelector,
|
|
186
|
+
styleVariationSelector
|
|
187
|
+
) {
|
|
188
|
+
const featureSelectors = featureSelector.split( ',' );
|
|
189
|
+
const combinedSelectors = [];
|
|
190
|
+
featureSelectors.forEach( ( selector ) => {
|
|
191
|
+
combinedSelectors.push(
|
|
192
|
+
`${ styleVariationSelector.trim() }${ selector.trim() }`
|
|
193
|
+
);
|
|
194
|
+
} );
|
|
195
|
+
return combinedSelectors.join( ', ' );
|
|
196
|
+
}
|
|
197
|
+
|
|
174
198
|
/**
|
|
175
199
|
* Transform given style tree into a set of style declarations.
|
|
176
200
|
*
|
|
@@ -449,17 +473,19 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
|
|
|
449
473
|
}
|
|
450
474
|
|
|
451
475
|
const pickStyleKeys = ( treeToPickFrom ) =>
|
|
452
|
-
|
|
453
|
-
[
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
476
|
+
Object.fromEntries(
|
|
477
|
+
Object.entries( treeToPickFrom ?? {} ).filter( ( [ key ] ) =>
|
|
478
|
+
[
|
|
479
|
+
'border',
|
|
480
|
+
'color',
|
|
481
|
+
'dimensions',
|
|
482
|
+
'spacing',
|
|
483
|
+
'typography',
|
|
484
|
+
'filter',
|
|
485
|
+
'outline',
|
|
486
|
+
'shadow',
|
|
487
|
+
].includes( key )
|
|
488
|
+
)
|
|
463
489
|
);
|
|
464
490
|
|
|
465
491
|
// Top-level.
|
|
@@ -484,6 +510,16 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
|
|
|
484
510
|
Object.entries( tree.styles?.blocks ?? {} ).forEach(
|
|
485
511
|
( [ blockName, node ] ) => {
|
|
486
512
|
const blockStyles = pickStyleKeys( node );
|
|
513
|
+
|
|
514
|
+
if ( node?.variations ) {
|
|
515
|
+
const variations = {};
|
|
516
|
+
Object.keys( node.variations ).forEach( ( variation ) => {
|
|
517
|
+
variations[ variation ] = pickStyleKeys(
|
|
518
|
+
node.variations[ variation ]
|
|
519
|
+
);
|
|
520
|
+
} );
|
|
521
|
+
blockStyles.variations = variations;
|
|
522
|
+
}
|
|
487
523
|
if (
|
|
488
524
|
!! blockStyles &&
|
|
489
525
|
!! blockSelectors?.[ blockName ]?.selector
|
|
@@ -499,6 +535,8 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
|
|
|
499
535
|
styles: blockStyles,
|
|
500
536
|
featureSelectors:
|
|
501
537
|
blockSelectors[ blockName ].featureSelectors,
|
|
538
|
+
styleVariationSelectors:
|
|
539
|
+
blockSelectors[ blockName ].styleVariationSelectors,
|
|
502
540
|
} );
|
|
503
541
|
}
|
|
504
542
|
|
|
@@ -647,6 +685,7 @@ export const toStyles = (
|
|
|
647
685
|
fallbackGapValue,
|
|
648
686
|
hasLayoutSupport,
|
|
649
687
|
featureSelectors,
|
|
688
|
+
styleVariationSelectors,
|
|
650
689
|
} ) => {
|
|
651
690
|
// Process styles for block support features with custom feature level
|
|
652
691
|
// CSS selectors set.
|
|
@@ -673,6 +712,69 @@ export const toStyles = (
|
|
|
673
712
|
);
|
|
674
713
|
}
|
|
675
714
|
|
|
715
|
+
if ( styleVariationSelectors ) {
|
|
716
|
+
Object.entries( styleVariationSelectors ).forEach(
|
|
717
|
+
( [ styleVariationName, styleVariationSelector ] ) => {
|
|
718
|
+
if ( styles?.variations?.[ styleVariationName ] ) {
|
|
719
|
+
// If the block uses any custom selectors for block support, add those first.
|
|
720
|
+
if ( featureSelectors ) {
|
|
721
|
+
Object.entries( featureSelectors ).forEach(
|
|
722
|
+
( [ featureName, featureSelector ] ) => {
|
|
723
|
+
if (
|
|
724
|
+
styles?.variations?.[
|
|
725
|
+
styleVariationName
|
|
726
|
+
]?.[ featureName ]
|
|
727
|
+
) {
|
|
728
|
+
const featureStyles = {
|
|
729
|
+
[ featureName ]:
|
|
730
|
+
styles.variations[
|
|
731
|
+
styleVariationName
|
|
732
|
+
][ featureName ],
|
|
733
|
+
};
|
|
734
|
+
const featureDeclarations =
|
|
735
|
+
getStylesDeclarations(
|
|
736
|
+
featureStyles
|
|
737
|
+
);
|
|
738
|
+
delete styles.variations[
|
|
739
|
+
styleVariationName
|
|
740
|
+
][ featureName ];
|
|
741
|
+
|
|
742
|
+
if (
|
|
743
|
+
!! featureDeclarations.length
|
|
744
|
+
) {
|
|
745
|
+
ruleset =
|
|
746
|
+
ruleset +
|
|
747
|
+
`${ concatFeatureVariationSelectorString(
|
|
748
|
+
featureSelector,
|
|
749
|
+
styleVariationSelector
|
|
750
|
+
) }{${ featureDeclarations.join(
|
|
751
|
+
';'
|
|
752
|
+
) } }`;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
);
|
|
757
|
+
}
|
|
758
|
+
// Otherwise add regular selectors.
|
|
759
|
+
const styleVariationDeclarations =
|
|
760
|
+
getStylesDeclarations(
|
|
761
|
+
styles?.variations?.[ styleVariationName ],
|
|
762
|
+
styleVariationSelector,
|
|
763
|
+
useRootPaddingAlign,
|
|
764
|
+
tree
|
|
765
|
+
);
|
|
766
|
+
if ( !! styleVariationDeclarations.length ) {
|
|
767
|
+
ruleset =
|
|
768
|
+
ruleset +
|
|
769
|
+
`${ styleVariationSelector }{${ styleVariationDeclarations.join(
|
|
770
|
+
';'
|
|
771
|
+
) }}`;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
);
|
|
776
|
+
}
|
|
777
|
+
|
|
676
778
|
const duotoneStyles = {};
|
|
677
779
|
if ( styles?.filter ) {
|
|
678
780
|
duotoneStyles.filter = styles.filter;
|
|
@@ -802,7 +904,7 @@ export function toSvgFilters( tree, blockSelectors ) {
|
|
|
802
904
|
} );
|
|
803
905
|
}
|
|
804
906
|
|
|
805
|
-
export const getBlockSelectors = ( blockTypes ) => {
|
|
907
|
+
export const getBlockSelectors = ( blockTypes, getBlockStyles ) => {
|
|
806
908
|
const result = {};
|
|
807
909
|
blockTypes.forEach( ( blockType ) => {
|
|
808
910
|
const name = blockType.name;
|
|
@@ -815,6 +917,15 @@ export const getBlockSelectors = ( blockTypes ) => {
|
|
|
815
917
|
const fallbackGapValue =
|
|
816
918
|
blockType?.supports?.spacing?.blockGap?.__experimentalDefault;
|
|
817
919
|
|
|
920
|
+
const blockStyleVariations = getBlockStyles( name );
|
|
921
|
+
const styleVariationSelectors = {};
|
|
922
|
+
if ( blockStyleVariations?.length ) {
|
|
923
|
+
blockStyleVariations.forEach( ( variation ) => {
|
|
924
|
+
const styleVariationSelector = `.is-style-${ variation.name }${ selector }`;
|
|
925
|
+
styleVariationSelectors[ variation.name ] =
|
|
926
|
+
styleVariationSelector;
|
|
927
|
+
} );
|
|
928
|
+
}
|
|
818
929
|
// For each block support feature add any custom selectors.
|
|
819
930
|
const featureSelectors = {};
|
|
820
931
|
Object.entries( BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS ).forEach(
|
|
@@ -840,6 +951,10 @@ export const getBlockSelectors = ( blockTypes ) => {
|
|
|
840
951
|
hasLayoutSupport,
|
|
841
952
|
name,
|
|
842
953
|
selector,
|
|
954
|
+
styleVariationSelectors: Object.keys( styleVariationSelectors )
|
|
955
|
+
.length
|
|
956
|
+
? styleVariationSelectors
|
|
957
|
+
: undefined,
|
|
843
958
|
};
|
|
844
959
|
} );
|
|
845
960
|
|
|
@@ -892,12 +1007,19 @@ export function useGlobalStylesOutput() {
|
|
|
892
1007
|
return !! getSettings().disableLayoutStyles;
|
|
893
1008
|
} );
|
|
894
1009
|
|
|
1010
|
+
const getBlockStyles = useSelect( ( select ) => {
|
|
1011
|
+
return select( blocksStore ).getBlockStyles;
|
|
1012
|
+
}, [] );
|
|
1013
|
+
|
|
895
1014
|
return useMemo( () => {
|
|
896
1015
|
if ( ! mergedConfig?.styles || ! mergedConfig?.settings ) {
|
|
897
1016
|
return [];
|
|
898
1017
|
}
|
|
899
1018
|
mergedConfig = updateConfigWithSeparator( mergedConfig );
|
|
900
|
-
const blockSelectors = getBlockSelectors(
|
|
1019
|
+
const blockSelectors = getBlockSelectors(
|
|
1020
|
+
getBlockTypes(),
|
|
1021
|
+
getBlockStyles
|
|
1022
|
+
);
|
|
901
1023
|
const customProperties = toCustomProperties(
|
|
902
1024
|
mergedConfig,
|
|
903
1025
|
blockSelectors
|
|
@@ -909,6 +1031,7 @@ export function useGlobalStylesOutput() {
|
|
|
909
1031
|
hasFallbackGapSupport,
|
|
910
1032
|
disableLayoutStyles
|
|
911
1033
|
);
|
|
1034
|
+
|
|
912
1035
|
const filters = toSvgFilters( mergedConfig, blockSelectors );
|
|
913
1036
|
const stylesheets = [
|
|
914
1037
|
{
|
|
@@ -86,20 +86,60 @@ export const PRESET_METADATA = [
|
|
|
86
86
|
},
|
|
87
87
|
];
|
|
88
88
|
|
|
89
|
-
const STYLE_PATH_TO_CSS_VAR_INFIX = {
|
|
89
|
+
export const STYLE_PATH_TO_CSS_VAR_INFIX = {
|
|
90
90
|
'color.background': 'color',
|
|
91
91
|
'color.text': 'color',
|
|
92
92
|
'elements.link.color.text': 'color',
|
|
93
|
+
'elements.link.:hover.color.text': 'color',
|
|
94
|
+
'elements.link.typography.fontFamily': 'font-family',
|
|
95
|
+
'elements.link.typography.fontSize': 'font-size',
|
|
93
96
|
'elements.button.color.text': 'color',
|
|
94
|
-
'elements.button.
|
|
97
|
+
'elements.button.color.background': 'color',
|
|
98
|
+
'elements.button.typography.fontFamily': 'font-family',
|
|
99
|
+
'elements.button.typography.fontSize': 'font-size',
|
|
95
100
|
'elements.heading.color': 'color',
|
|
96
|
-
'elements.heading.
|
|
101
|
+
'elements.heading.color.background': 'color',
|
|
102
|
+
'elements.heading.typography.fontFamily': 'font-family',
|
|
97
103
|
'elements.heading.gradient': 'gradient',
|
|
104
|
+
'elements.heading.color.gradient': 'gradient',
|
|
105
|
+
'elements.h1.color': 'color',
|
|
106
|
+
'elements.h1.color.background': 'color',
|
|
107
|
+
'elements.h1.typography.fontFamily': 'font-family',
|
|
108
|
+
'elements.h1.color.gradient': 'gradient',
|
|
109
|
+
'elements.h2.color': 'color',
|
|
110
|
+
'elements.h2.color.background': 'color',
|
|
111
|
+
'elements.h2.typography.fontFamily': 'font-family',
|
|
112
|
+
'elements.h2.color.gradient': 'gradient',
|
|
113
|
+
'elements.h3.color': 'color',
|
|
114
|
+
'elements.h3.color.background': 'color',
|
|
115
|
+
'elements.h3.typography.fontFamily': 'font-family',
|
|
116
|
+
'elements.h3.color.gradient': 'gradient',
|
|
117
|
+
'elements.h4.color': 'color',
|
|
118
|
+
'elements.h4.color.background': 'color',
|
|
119
|
+
'elements.h4.typography.fontFamily': 'font-family',
|
|
120
|
+
'elements.h4.color.gradient': 'gradient',
|
|
121
|
+
'elements.h5.color': 'color',
|
|
122
|
+
'elements.h5.color.background': 'color',
|
|
123
|
+
'elements.h5.typography.fontFamily': 'font-family',
|
|
124
|
+
'elements.h5.color.gradient': 'gradient',
|
|
125
|
+
'elements.h6.color': 'color',
|
|
126
|
+
'elements.h6.color.background': 'color',
|
|
127
|
+
'elements.h6.typography.fontFamily': 'font-family',
|
|
128
|
+
'elements.h6.color.gradient': 'gradient',
|
|
98
129
|
'color.gradient': 'gradient',
|
|
99
130
|
'typography.fontSize': 'font-size',
|
|
100
131
|
'typography.fontFamily': 'font-family',
|
|
101
132
|
};
|
|
102
133
|
|
|
134
|
+
// A static list of block attributes that store global style preset slugs.
|
|
135
|
+
export const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
|
|
136
|
+
'color.background': 'backgroundColor',
|
|
137
|
+
'color.text': 'textColor',
|
|
138
|
+
'color.gradient': 'gradient',
|
|
139
|
+
'typography.fontSize': 'fontSize',
|
|
140
|
+
'typography.fontFamily': 'fontFamily',
|
|
141
|
+
};
|
|
142
|
+
|
|
103
143
|
function findInPresetsBy(
|
|
104
144
|
features,
|
|
105
145
|
blockName,
|
|
@@ -324,3 +364,16 @@ export function scopeSelector( scope, selector ) {
|
|
|
324
364
|
|
|
325
365
|
return selectorsScoped.join( ', ' );
|
|
326
366
|
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
*
|
|
370
|
+
* @param {string} path The variation path in the Global Styles tree.
|
|
371
|
+
*
|
|
372
|
+
* @return {string} The variation class name.
|
|
373
|
+
*/
|
|
374
|
+
export function getVariationClassNameFromPath( path ) {
|
|
375
|
+
if ( ! path ) {
|
|
376
|
+
return '';
|
|
377
|
+
}
|
|
378
|
+
return `is-style-${ path.split( '.' )[ 1 ] }`;
|
|
379
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { store as blocksStore } from '@wordpress/blocks';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { __experimentalItemGroup as ItemGroup } from '@wordpress/components';
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { NavigationButtonAsItem } from './navigation-button';
|
|
12
|
+
import ContextMenu from './context-menu';
|
|
13
|
+
|
|
14
|
+
function getCoreBlockStyles( blockStyles ) {
|
|
15
|
+
return blockStyles?.filter( ( style ) => style.source === 'block' );
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function useHasVariationsPanel( name, parentMenu = '' ) {
|
|
19
|
+
const isInsideVariationsPanel = parentMenu.includes( 'variations' );
|
|
20
|
+
const blockStyles = useSelect(
|
|
21
|
+
( select ) => {
|
|
22
|
+
const { getBlockStyles } = select( blocksStore );
|
|
23
|
+
return getBlockStyles( name );
|
|
24
|
+
},
|
|
25
|
+
[ name ]
|
|
26
|
+
);
|
|
27
|
+
const coreBlockStyles = getCoreBlockStyles( blockStyles );
|
|
28
|
+
return !! coreBlockStyles?.length && ! isInsideVariationsPanel;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function VariationsPanel( { name } ) {
|
|
32
|
+
const blockStyles = useSelect(
|
|
33
|
+
( select ) => {
|
|
34
|
+
const { getBlockStyles } = select( blocksStore );
|
|
35
|
+
return getBlockStyles( name );
|
|
36
|
+
},
|
|
37
|
+
[ name ]
|
|
38
|
+
);
|
|
39
|
+
const coreBlockStyles = getCoreBlockStyles( blockStyles );
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<ItemGroup isBordered isSeparated>
|
|
43
|
+
{ coreBlockStyles.map( ( style, index ) => {
|
|
44
|
+
if ( style?.isDefault ) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return (
|
|
48
|
+
<NavigationButtonAsItem
|
|
49
|
+
key={ index }
|
|
50
|
+
path={
|
|
51
|
+
'/blocks/' +
|
|
52
|
+
encodeURIComponent( name ) +
|
|
53
|
+
'/variations/' +
|
|
54
|
+
encodeURIComponent( style.name )
|
|
55
|
+
}
|
|
56
|
+
aria-label={ style.label }
|
|
57
|
+
>
|
|
58
|
+
{ style.label }
|
|
59
|
+
</NavigationButtonAsItem>
|
|
60
|
+
);
|
|
61
|
+
} ) }
|
|
62
|
+
</ItemGroup>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function VariationPanel( { blockName, styleName } ) {
|
|
67
|
+
return (
|
|
68
|
+
<ContextMenu
|
|
69
|
+
parentMenu={
|
|
70
|
+
'/blocks/' +
|
|
71
|
+
encodeURIComponent( blockName ) +
|
|
72
|
+
'/variations/' +
|
|
73
|
+
encodeURIComponent( styleName )
|
|
74
|
+
}
|
|
75
|
+
name={ blockName }
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
@@ -25,16 +25,13 @@ import {
|
|
|
25
25
|
useBlockDisplayInformation,
|
|
26
26
|
BlockIcon,
|
|
27
27
|
} from '@wordpress/block-editor';
|
|
28
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
29
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
30
28
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
31
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
32
29
|
|
|
33
30
|
/**
|
|
34
31
|
* Internal dependencies
|
|
35
32
|
*/
|
|
36
33
|
import TemplateDetails from '../../template-details';
|
|
37
|
-
import
|
|
34
|
+
import useEditedEntityRecord from '../../use-edited-entity-record';
|
|
38
35
|
|
|
39
36
|
function getBlockDisplayText( block ) {
|
|
40
37
|
if ( block ) {
|
|
@@ -70,36 +67,15 @@ function useSecondaryText() {
|
|
|
70
67
|
}
|
|
71
68
|
|
|
72
69
|
export default function DocumentActions() {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const record = getEditedEntityRecord(
|
|
83
|
-
'postType',
|
|
84
|
-
postType,
|
|
85
|
-
postId
|
|
86
|
-
);
|
|
87
|
-
const _isLoaded = !! postId;
|
|
88
|
-
|
|
89
|
-
return {
|
|
90
|
-
showIconLabels: select( preferencesStore ).get(
|
|
91
|
-
'core/edit-site',
|
|
92
|
-
'showIconLabels'
|
|
93
|
-
),
|
|
94
|
-
entityTitle: getTemplateInfo( record ).title,
|
|
95
|
-
isLoaded: _isLoaded,
|
|
96
|
-
template: record,
|
|
97
|
-
templateType: postType,
|
|
98
|
-
};
|
|
99
|
-
}, [] );
|
|
100
|
-
|
|
101
|
-
const entityLabel =
|
|
102
|
-
templateType === 'wp_template_part' ? 'template part' : 'template';
|
|
70
|
+
const showIconLabels = useSelect(
|
|
71
|
+
( select ) =>
|
|
72
|
+
select( preferencesStore ).get(
|
|
73
|
+
'core/edit-site',
|
|
74
|
+
'showIconLabels'
|
|
75
|
+
),
|
|
76
|
+
[]
|
|
77
|
+
);
|
|
78
|
+
const { isLoaded, record, getTitle } = useEditedEntityRecord();
|
|
103
79
|
const { label, icon } = useSecondaryText();
|
|
104
80
|
|
|
105
81
|
// Use internal state instead of a ref to make sure that the component
|
|
@@ -126,7 +102,7 @@ export default function DocumentActions() {
|
|
|
126
102
|
}
|
|
127
103
|
|
|
128
104
|
// Return feedback that the template does not seem to exist.
|
|
129
|
-
if ( !
|
|
105
|
+
if ( ! record ) {
|
|
130
106
|
return (
|
|
131
107
|
<div className="edit-site-document-actions">
|
|
132
108
|
{ __( 'Template not found' ) }
|
|
@@ -134,6 +110,11 @@ export default function DocumentActions() {
|
|
|
134
110
|
);
|
|
135
111
|
}
|
|
136
112
|
|
|
113
|
+
const entityLabel =
|
|
114
|
+
record.type === 'wp_template_part'
|
|
115
|
+
? __( 'template part' )
|
|
116
|
+
: __( 'template' );
|
|
117
|
+
|
|
137
118
|
return (
|
|
138
119
|
<div
|
|
139
120
|
className={ classnames( 'edit-site-document-actions', {
|
|
@@ -156,7 +137,7 @@ export default function DocumentActions() {
|
|
|
156
137
|
entityLabel
|
|
157
138
|
) }
|
|
158
139
|
</VisuallyHidden>
|
|
159
|
-
{
|
|
140
|
+
{ getTitle() }
|
|
160
141
|
</Text>
|
|
161
142
|
<div className="edit-site-document-actions__secondary-item">
|
|
162
143
|
<BlockIcon icon={ icon } showColors />
|
|
@@ -186,7 +167,7 @@ export default function DocumentActions() {
|
|
|
186
167
|
contentClassName="edit-site-document-actions__info-dropdown"
|
|
187
168
|
renderContent={ ( { onClose } ) => (
|
|
188
169
|
<TemplateDetails
|
|
189
|
-
template={
|
|
170
|
+
template={ record }
|
|
190
171
|
onClose={ onClose }
|
|
191
172
|
/>
|
|
192
173
|
) }
|