@wordpress/block-editor 13.3.0 → 13.4.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 +2 -0
- package/README.md +0 -4
- package/build/components/alignment-control/ui.js +2 -2
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/ui.js +1 -1
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/ui.native.js +1 -1
- package/build/components/block-alignment-control/ui.native.js.map +1 -1
- package/build/components/block-inspector/index.js +6 -3
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +3 -1
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-refs.js +9 -2
- package/build/components/block-list/use-block-props/use-block-refs.js.map +1 -1
- package/build/components/block-list/use-block-props/use-is-hovered.js +25 -9
- package/build/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +3 -2
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-lock/modal.js +2 -0
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +2 -0
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-switcher/index.js +1 -1
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/pattern-transformations-menu.js +11 -12
- package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build/components/block-switcher/preview-block-popover.js +20 -17
- package/build/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build/components/block-toolbar/shuffle.js +5 -2
- package/build/components/block-toolbar/shuffle.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +7 -8
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/block-tools/zoom-out-mode-inserter-button.js +45 -0
- package/build/components/block-tools/zoom-out-mode-inserter-button.js.map +1 -0
- package/build/components/block-tools/zoom-out-mode-inserters.js +27 -27
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build/components/block-tools/zoom-out-popover.js +2 -1
- package/build/components/block-tools/zoom-out-popover.js.map +1 -1
- package/build/components/block-tools/zoom-out-toolbar.js +1 -1
- package/build/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build/components/date-format-picker/index.js +2 -11
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/default-block-appender/index.js +7 -4
- package/build/components/default-block-appender/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +2 -7
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/global-styles/background-panel.js +8 -1
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +5 -1
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +26 -43
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +78 -7
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +24 -5
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/grid/grid-item-movers.js +89 -44
- package/build/components/grid/grid-item-movers.js.map +1 -1
- package/build/components/grid/grid-visualizer.js +1 -1
- package/build/components/grid/grid-visualizer.js.map +1 -1
- package/build/components/grid/use-grid-layout-sync.js +40 -28
- package/build/components/grid/use-grid-layout-sync.js.map +1 -1
- package/build/components/index.js +1 -9
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +1 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/patterns-filter.js +20 -23
- package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
- package/build/components/inserter/media-tab/media-panel.js +1 -0
- package/build/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build/components/inserter/menu.js +1 -1
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/preview-panel.js +20 -3
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inserter-draggable-blocks/index.js +10 -3
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/inspector-controls-tabs/settings-tab.js +1 -2
- package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -1
- package/build/components/list-view/block-select-button.js +2 -6
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +2 -2
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/utils.js +3 -1
- package/build/components/list-view/utils.js.map +1 -1
- package/build/components/rich-text/format-toolbar/index.js +1 -1
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/index.js +1 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +4 -2
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +3 -3
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/hooks/grid-visualizer.js +5 -8
- package/build/hooks/grid-visualizer.js.map +1 -1
- package/build/hooks/layout-child.js +9 -2
- package/build/hooks/layout-child.js.map +1 -1
- package/build/hooks/position.js +3 -7
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +81 -50
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/layouts/constrained.js +6 -2
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/grid.js +2 -0
- package/build/layouts/grid.js.map +1 -1
- package/build/private-apis.js +0 -3
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +18 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +19 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +13 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +2 -2
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.js +1 -1
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.native.js +1 -1
- package/build-module/components/block-alignment-control/ui.native.js.map +1 -1
- package/build-module/components/block-inspector/index.js +6 -3
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +3 -1
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-refs.js +11 -4
- package/build-module/components/block-list/use-block-props/use-block-refs.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-is-hovered.js +26 -9
- package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +3 -2
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-lock/modal.js +2 -0
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +2 -0
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +1 -1
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/pattern-transformations-menu.js +12 -13
- package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build-module/components/block-switcher/preview-block-popover.js +20 -17
- package/build-module/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build-module/components/block-toolbar/shuffle.js +5 -2
- package/build-module/components/block-toolbar/shuffle.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +7 -8
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-mode-inserter-button.js +37 -0
- package/build-module/components/block-tools/zoom-out-mode-inserter-button.js.map +1 -0
- package/build-module/components/block-tools/zoom-out-mode-inserters.js +28 -28
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-popover.js +2 -1
- package/build-module/components/block-tools/zoom-out-popover.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-toolbar.js +1 -1
- package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +4 -12
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/default-block-appender/index.js +7 -4
- package/build-module/components/default-block-appender/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +3 -6
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +8 -1
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +5 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +27 -44
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +76 -7
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +24 -5
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/grid/grid-item-movers.js +92 -46
- package/build-module/components/grid/grid-item-movers.js.map +1 -1
- package/build-module/components/grid/grid-visualizer.js +1 -1
- package/build-module/components/grid/grid-visualizer.js.map +1 -1
- package/build-module/components/grid/use-grid-layout-sync.js +41 -29
- package/build-module/components/grid/use-grid-layout-sync.js.map +1 -1
- package/build-module/components/index.js +0 -5
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +1 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js +20 -23
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-panel.js +1 -0
- package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build-module/components/inserter/menu.js +1 -1
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +20 -3
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.js +10 -3
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/settings-tab.js +1 -2
- package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +3 -7
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +2 -2
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/utils.js +3 -1
- package/build-module/components/list-view/utils.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +1 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +4 -2
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +3 -3
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/hooks/grid-visualizer.js +5 -8
- package/build-module/hooks/grid-visualizer.js.map +1 -1
- package/build-module/hooks/layout-child.js +9 -2
- package/build-module/hooks/layout-child.js.map +1 -1
- package/build-module/hooks/position.js +3 -7
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +81 -51
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/layouts/constrained.js +6 -2
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/grid.js +2 -0
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/private-apis.js +0 -3
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +15 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +18 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +10 -0
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/content-rtl.css +6 -6
- package/build-style/content.css +6 -6
- package/build-style/style-rtl.css +167 -103
- package/build-style/style.css +167 -103
- package/build-types/components/block-context/index.d.ts +2 -2
- package/build-types/components/block-context/index.d.ts.map +1 -1
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +31 -31
- package/src/components/alignment-control/ui.js +2 -2
- package/src/components/block-alignment-control/ui.js +1 -1
- package/src/components/block-alignment-control/ui.native.js +1 -1
- package/src/components/block-context/README.md +4 -4
- package/src/components/block-inspector/index.js +8 -4
- package/src/components/block-list/content.scss +2 -16
- package/src/components/block-list/use-block-props/index.js +1 -1
- package/src/components/block-list/use-block-props/use-block-refs.js +19 -3
- package/src/components/block-list/use-block-props/use-is-hovered.js +26 -11
- package/src/components/block-list/use-in-between-inserter.js +5 -1
- package/src/components/block-lock/modal.js +10 -2
- package/src/components/block-lock/style.scss +4 -8
- package/src/components/block-patterns-paging/style.scss +0 -23
- package/src/components/block-removal-warning-modal/index.js +10 -2
- package/src/components/block-switcher/index.js +1 -1
- package/src/components/block-switcher/pattern-transformations-menu.js +17 -15
- package/src/components/block-switcher/preview-block-popover.js +20 -14
- package/src/components/block-switcher/style.scss +8 -17
- package/src/components/block-toolbar/shuffle.js +8 -1
- package/src/components/block-tools/style.scss +8 -0
- package/src/components/block-tools/use-show-block-tools.js +12 -9
- package/src/components/block-tools/zoom-out-mode-inserter-button.js +47 -0
- package/src/components/block-tools/zoom-out-mode-inserters.js +43 -33
- package/src/components/block-tools/zoom-out-popover.js +1 -0
- package/src/components/block-tools/zoom-out-toolbar.js +1 -1
- package/src/components/date-format-picker/index.js +2 -11
- package/src/components/default-block-appender/index.js +11 -4
- package/src/components/font-appearance-control/index.js +1 -5
- package/src/components/global-styles/background-panel.js +21 -1
- package/src/components/global-styles/hooks.js +5 -1
- package/src/components/global-styles/style.scss +12 -0
- package/src/components/global-styles/test/typography-utils.js +325 -0
- package/src/components/global-styles/test/use-global-styles-output.js +3 -1
- package/src/components/global-styles/typography-panel.js +36 -44
- package/src/components/global-styles/typography-utils.js +103 -7
- package/src/components/global-styles/use-global-styles-output.js +22 -2
- package/src/components/grid/grid-item-movers.js +139 -69
- package/src/components/grid/grid-visualizer.js +1 -1
- package/src/components/grid/style.scss +114 -0
- package/src/components/grid/use-grid-layout-sync.js +66 -27
- package/src/components/iframe/content.scss +1 -1
- package/src/components/index.js +0 -5
- package/src/components/inner-blocks/index.js +4 -1
- package/src/components/inserter/block-patterns-tab/patterns-filter.js +40 -44
- package/src/components/inserter/media-tab/media-panel.js +1 -0
- package/src/components/inserter/menu.js +1 -1
- package/src/components/inserter/preview-panel.js +27 -4
- package/src/components/inserter/style.scss +57 -43
- package/src/components/inserter-draggable-blocks/index.js +11 -3
- package/src/components/inspector-controls-tabs/settings-tab.js +0 -2
- package/src/components/inspector-controls-tabs/style.scss +0 -21
- package/src/components/list-view/block-select-button.js +3 -13
- package/src/components/list-view/block.js +10 -3
- package/src/components/list-view/style.scss +2 -1
- package/src/components/list-view/utils.js +13 -2
- package/src/components/rich-text/format-toolbar/index.js +1 -1
- package/src/components/rich-text/index.js +1 -1
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +3 -1
- package/src/components/url-popover/image-url-input-ui.js +3 -3
- package/src/components/url-popover/style.scss +1 -0
- package/src/hooks/grid-visualizer.js +5 -7
- package/src/hooks/layout-child.js +12 -3
- package/src/hooks/position.js +3 -13
- package/src/hooks/use-bindings-attributes.js +89 -59
- package/src/layouts/constrained.js +10 -2
- package/src/layouts/grid.js +2 -0
- package/src/private-apis.js +0 -6
- package/src/store/actions.js +15 -0
- package/src/store/reducer.js +18 -0
- package/src/store/selectors.js +10 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/inserter/reusable-block-rename-hint.js +0 -71
- package/build/components/inserter/reusable-block-rename-hint.js.map +0 -1
- package/build/components/inspector-controls-tabs/settings-tab-hint.js +0 -53
- package/build/components/inspector-controls-tabs/settings-tab-hint.js.map +0 -1
- package/build-module/components/inserter/reusable-block-rename-hint.js +0 -64
- package/build-module/components/inserter/reusable-block-rename-hint.js.map +0 -1
- package/build-module/components/inspector-controls-tabs/settings-tab-hint.js +0 -47
- package/build-module/components/inspector-controls-tabs/settings-tab-hint.js.map +0 -1
- package/src/components/inserter/reusable-block-rename-hint.js +0 -69
- package/src/components/inspector-controls-tabs/settings-tab-hint.js +0 -52
|
@@ -10,18 +10,9 @@ import {
|
|
|
10
10
|
VisuallyHidden,
|
|
11
11
|
ToggleControl,
|
|
12
12
|
__experimentalVStack as VStack,
|
|
13
|
-
|
|
13
|
+
CustomSelectControl,
|
|
14
14
|
} from '@wordpress/components';
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* Internal dependencies
|
|
18
|
-
*/
|
|
19
|
-
import { unlock } from '../../lock-unlock';
|
|
20
|
-
|
|
21
|
-
const { CustomSelectControlV2Legacy: CustomSelectControl } = unlock(
|
|
22
|
-
componentsPrivateApis
|
|
23
|
-
);
|
|
24
|
-
|
|
25
16
|
// So that we illustrate the different formats in the dropdown properly, show a date that is
|
|
26
17
|
// somwhat recent, has a day greater than 12, and a month with more than three letters.
|
|
27
18
|
const exampleDate = new Date();
|
|
@@ -126,7 +117,7 @@ function NonDefaultControls( { format, onChange } ) {
|
|
|
126
117
|
name: __( 'Custom' ),
|
|
127
118
|
className:
|
|
128
119
|
'block-editor-date-format-picker__custom-format-select-control__custom-option',
|
|
129
|
-
|
|
120
|
+
hint: __( 'Enter your own date format' ),
|
|
130
121
|
};
|
|
131
122
|
|
|
132
123
|
const [ isCustom, setIsCustom ] = useState(
|
|
@@ -24,10 +24,14 @@ import { store as blockEditorStore } from '../../store';
|
|
|
24
24
|
export const ZWNBSP = '\ufeff';
|
|
25
25
|
|
|
26
26
|
export default function DefaultBlockAppender( { rootClientId } ) {
|
|
27
|
-
const { showPrompt, isLocked, placeholder } = useSelect(
|
|
27
|
+
const { showPrompt, isLocked, placeholder, isManualGrid } = useSelect(
|
|
28
28
|
( select ) => {
|
|
29
|
-
const {
|
|
30
|
-
|
|
29
|
+
const {
|
|
30
|
+
getBlockCount,
|
|
31
|
+
getSettings,
|
|
32
|
+
getTemplateLock,
|
|
33
|
+
getBlockAttributes,
|
|
34
|
+
} = select( blockEditorStore );
|
|
31
35
|
|
|
32
36
|
const isEmpty = ! getBlockCount( rootClientId );
|
|
33
37
|
const { bodyPlaceholder } = getSettings();
|
|
@@ -36,6 +40,9 @@ export default function DefaultBlockAppender( { rootClientId } ) {
|
|
|
36
40
|
showPrompt: isEmpty,
|
|
37
41
|
isLocked: !! getTemplateLock( rootClientId ),
|
|
38
42
|
placeholder: bodyPlaceholder,
|
|
43
|
+
isManualGrid:
|
|
44
|
+
getBlockAttributes( rootClientId )?.layout
|
|
45
|
+
?.isManualPlacement,
|
|
39
46
|
};
|
|
40
47
|
},
|
|
41
48
|
[ rootClientId ]
|
|
@@ -43,7 +50,7 @@ export default function DefaultBlockAppender( { rootClientId } ) {
|
|
|
43
50
|
|
|
44
51
|
const { insertDefaultBlock, startTyping } = useDispatch( blockEditorStore );
|
|
45
52
|
|
|
46
|
-
if ( isLocked ) {
|
|
53
|
+
if ( isLocked || isManualGrid ) {
|
|
47
54
|
return null;
|
|
48
55
|
}
|
|
49
56
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { CustomSelectControl } from '@wordpress/components';
|
|
5
5
|
import { useMemo } from '@wordpress/element';
|
|
6
6
|
import { __, sprintf } from '@wordpress/i18n';
|
|
7
7
|
|
|
@@ -9,11 +9,7 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
11
|
import { getFontStylesAndWeights } from '../../utils/get-font-styles-and-weights';
|
|
12
|
-
import { unlock } from '../../lock-unlock';
|
|
13
12
|
|
|
14
|
-
const { CustomSelectControlV2Legacy: CustomSelectControl } = unlock(
|
|
15
|
-
componentsPrivateApis
|
|
16
|
-
);
|
|
17
13
|
/**
|
|
18
14
|
* Adjusts font appearance field label in case either font styles or weights
|
|
19
15
|
* are disabled.
|
|
@@ -451,6 +451,9 @@ function BackgroundSizeControls( {
|
|
|
451
451
|
const positionValue =
|
|
452
452
|
style?.background?.backgroundPosition ||
|
|
453
453
|
inheritedValue?.background?.backgroundPosition;
|
|
454
|
+
const attachmentValue =
|
|
455
|
+
style?.background?.backgroundAttachment ||
|
|
456
|
+
inheritedValue?.background?.backgroundAttachment;
|
|
454
457
|
|
|
455
458
|
/*
|
|
456
459
|
* An `undefined` value is replaced with any supplied
|
|
@@ -546,8 +549,17 @@ function BackgroundSizeControls( {
|
|
|
546
549
|
)
|
|
547
550
|
);
|
|
548
551
|
|
|
552
|
+
const toggleScrollWithPage = () =>
|
|
553
|
+
onChange(
|
|
554
|
+
setImmutably(
|
|
555
|
+
style,
|
|
556
|
+
[ 'background', 'backgroundAttachment' ],
|
|
557
|
+
attachmentValue === 'fixed' ? 'scroll' : 'fixed'
|
|
558
|
+
)
|
|
559
|
+
);
|
|
560
|
+
|
|
549
561
|
return (
|
|
550
|
-
<VStack spacing={
|
|
562
|
+
<VStack spacing={ 4 } className="single-column">
|
|
551
563
|
<FocalPointPicker
|
|
552
564
|
__next40pxDefaultSize
|
|
553
565
|
__nextHasNoMarginBottom
|
|
@@ -556,6 +568,14 @@ function BackgroundSizeControls( {
|
|
|
556
568
|
value={ backgroundPositionToCoords( positionValue ) }
|
|
557
569
|
onChange={ updateBackgroundPosition }
|
|
558
570
|
/>
|
|
571
|
+
<ToggleControl
|
|
572
|
+
label={ __( 'Fixed background' ) }
|
|
573
|
+
checked={ attachmentValue === 'fixed' }
|
|
574
|
+
onChange={ toggleScrollWithPage }
|
|
575
|
+
help={ __(
|
|
576
|
+
'Whether your image should scroll with the page or stay fixed in place.'
|
|
577
|
+
) }
|
|
578
|
+
/>
|
|
559
579
|
<ToggleGroupControl
|
|
560
580
|
size="__unstable-large"
|
|
561
581
|
label={ __( 'Size' ) }
|
|
@@ -85,7 +85,11 @@ const VALID_SETTINGS = [
|
|
|
85
85
|
];
|
|
86
86
|
|
|
87
87
|
export const useGlobalStylesReset = () => {
|
|
88
|
-
const { user
|
|
88
|
+
const { user, setUserConfig } = useContext( GlobalStylesContext );
|
|
89
|
+
const config = {
|
|
90
|
+
settings: user.settings,
|
|
91
|
+
styles: user.styles,
|
|
92
|
+
};
|
|
89
93
|
const canReset = !! config && ! fastDeepEqual( config, EMPTY_CONFIG );
|
|
90
94
|
return [
|
|
91
95
|
canReset,
|
|
@@ -103,8 +103,13 @@
|
|
|
103
103
|
.block-editor-global-styles-background-panel__image-tools-panel-item {
|
|
104
104
|
border: 1px solid $gray-300;
|
|
105
105
|
border-radius: 2px;
|
|
106
|
+
|
|
106
107
|
// Full width. ToolsPanel lays out children in a grid.
|
|
107
108
|
grid-column: 1 / -1;
|
|
109
|
+
|
|
110
|
+
// Ensure the dropzone is positioned to the size of the item.
|
|
111
|
+
position: relative;
|
|
112
|
+
|
|
108
113
|
// Since there is no option to skip rendering the drag'n'drop icon in drop
|
|
109
114
|
// zone, we hide it for now.
|
|
110
115
|
.components-drop-zone__content-icon {
|
|
@@ -192,15 +197,22 @@
|
|
|
192
197
|
.components-toggle-control {
|
|
193
198
|
margin-bottom: 0;
|
|
194
199
|
}
|
|
200
|
+
|
|
195
201
|
.components-focal-point-picker-wrapper {
|
|
196
202
|
background-color: $gray-100;
|
|
197
203
|
width: 100%;
|
|
198
204
|
border-radius: $radius-block-ui;
|
|
199
205
|
border: $border-width solid $gray-300;
|
|
200
206
|
}
|
|
207
|
+
|
|
201
208
|
.components-focal-point-picker__media--image {
|
|
202
209
|
max-height: 180px;
|
|
203
210
|
}
|
|
211
|
+
|
|
212
|
+
// Override focal picker to avoid a double border.
|
|
213
|
+
.components-focal-point-picker::after {
|
|
214
|
+
content: none;
|
|
215
|
+
}
|
|
204
216
|
}
|
|
205
217
|
|
|
206
218
|
.block-editor-global-styles-background-panel__hidden-tools-panel-item {
|
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
getFluidTypographyOptionsFromSettings,
|
|
7
7
|
getMergedFontFamiliesAndFontFamilyFaces,
|
|
8
8
|
findNearestFontWeight,
|
|
9
|
+
findNearestFontStyle,
|
|
10
|
+
findNearestStyleAndWeight,
|
|
9
11
|
} from '../typography-utils';
|
|
10
12
|
|
|
11
13
|
describe( 'typography utils', () => {
|
|
@@ -951,6 +953,329 @@ describe( 'typography utils', () => {
|
|
|
951
953
|
);
|
|
952
954
|
} );
|
|
953
955
|
|
|
956
|
+
describe( 'findNearestFontStyle', () => {
|
|
957
|
+
[
|
|
958
|
+
{
|
|
959
|
+
message:
|
|
960
|
+
'should return empty string when newFontStyleValue is `undefined`',
|
|
961
|
+
availableFontStyles: undefined,
|
|
962
|
+
newFontStyleValue: undefined,
|
|
963
|
+
expected: '',
|
|
964
|
+
},
|
|
965
|
+
{
|
|
966
|
+
message:
|
|
967
|
+
'should return newFontStyleValue value when availableFontStyles is empty',
|
|
968
|
+
availableFontStyles: [],
|
|
969
|
+
newFontStyleValue: 'italic',
|
|
970
|
+
expected: 'italic',
|
|
971
|
+
},
|
|
972
|
+
{
|
|
973
|
+
message:
|
|
974
|
+
'should return empty string if there is no new font style available',
|
|
975
|
+
availableFontStyles: [ { name: 'Normal', value: 'normal' } ],
|
|
976
|
+
newFontStyleValue: 'italic',
|
|
977
|
+
expected: '',
|
|
978
|
+
},
|
|
979
|
+
{
|
|
980
|
+
message:
|
|
981
|
+
'should return empty string if the new font style is invalid',
|
|
982
|
+
availableFontStyles: [
|
|
983
|
+
{ name: 'Regular', value: 'normal' },
|
|
984
|
+
{ name: 'Italic', value: 'italic' },
|
|
985
|
+
],
|
|
986
|
+
newFontStyleValue: 'not-valid',
|
|
987
|
+
expected: '',
|
|
988
|
+
},
|
|
989
|
+
{
|
|
990
|
+
message: 'should return italic if oblique is not available',
|
|
991
|
+
availableFontStyles: [
|
|
992
|
+
{ name: 'Regular', value: 'normal' },
|
|
993
|
+
{ name: 'Italic', value: 'italic' },
|
|
994
|
+
],
|
|
995
|
+
newFontStyleValue: 'oblique',
|
|
996
|
+
expected: 'italic',
|
|
997
|
+
},
|
|
998
|
+
{
|
|
999
|
+
message: 'should return normal if normal is available',
|
|
1000
|
+
availableFontStyles: [
|
|
1001
|
+
{ name: 'Regular', value: 'normal' },
|
|
1002
|
+
{ name: 'Italic', value: 'italic' },
|
|
1003
|
+
],
|
|
1004
|
+
newFontStyleValue: 'normal',
|
|
1005
|
+
expected: 'normal',
|
|
1006
|
+
},
|
|
1007
|
+
].forEach(
|
|
1008
|
+
( {
|
|
1009
|
+
message,
|
|
1010
|
+
availableFontStyles,
|
|
1011
|
+
newFontStyleValue,
|
|
1012
|
+
expected,
|
|
1013
|
+
} ) => {
|
|
1014
|
+
it( `${ message }`, () => {
|
|
1015
|
+
expect(
|
|
1016
|
+
findNearestFontStyle(
|
|
1017
|
+
availableFontStyles,
|
|
1018
|
+
newFontStyleValue
|
|
1019
|
+
)
|
|
1020
|
+
).toEqual( expected );
|
|
1021
|
+
} );
|
|
1022
|
+
}
|
|
1023
|
+
);
|
|
1024
|
+
} );
|
|
1025
|
+
|
|
1026
|
+
describe( 'findNearestStyleAndWeight', () => {
|
|
1027
|
+
[
|
|
1028
|
+
{
|
|
1029
|
+
message: 'should return empty object when all values are empty',
|
|
1030
|
+
fontFamilyFaces: [],
|
|
1031
|
+
fontStyle: undefined,
|
|
1032
|
+
fontWeight: undefined,
|
|
1033
|
+
expected: {},
|
|
1034
|
+
},
|
|
1035
|
+
{
|
|
1036
|
+
message:
|
|
1037
|
+
'should return original fontStyle and fontWeight when fontFamilyFaces is empty',
|
|
1038
|
+
fontFamilyFaces: [],
|
|
1039
|
+
fontStyle: 'italic',
|
|
1040
|
+
fontWeight: '700',
|
|
1041
|
+
expected: {
|
|
1042
|
+
nearestFontStyle: 'italic',
|
|
1043
|
+
nearestFontWeight: '700',
|
|
1044
|
+
},
|
|
1045
|
+
},
|
|
1046
|
+
{
|
|
1047
|
+
message:
|
|
1048
|
+
'should return undefined values if both fontStyle and fontWeight are not available',
|
|
1049
|
+
fontFamilyFaces: [
|
|
1050
|
+
{
|
|
1051
|
+
fontFamily: 'ABeeZee',
|
|
1052
|
+
fontStyle: 'italic',
|
|
1053
|
+
fontWeight: '400',
|
|
1054
|
+
src: [
|
|
1055
|
+
'file:./assets/fonts/esDT31xSG-6AGleN2tCkkJUCGpG-GQ.woff2',
|
|
1056
|
+
],
|
|
1057
|
+
},
|
|
1058
|
+
],
|
|
1059
|
+
fontStyle: undefined,
|
|
1060
|
+
fontWeight: undefined,
|
|
1061
|
+
expected: {
|
|
1062
|
+
nearestFontStyle: undefined,
|
|
1063
|
+
nearestFontWeight: undefined,
|
|
1064
|
+
},
|
|
1065
|
+
},
|
|
1066
|
+
{
|
|
1067
|
+
message:
|
|
1068
|
+
'should return nearest fontStyle and fontWeight for normal/400',
|
|
1069
|
+
fontFamilyFaces: [
|
|
1070
|
+
{
|
|
1071
|
+
fontFamily: 'IBM Plex Mono',
|
|
1072
|
+
fontStyle: 'normal',
|
|
1073
|
+
fontWeight: '400',
|
|
1074
|
+
src: [
|
|
1075
|
+
'file:./assets/fonts/ibm-plex-mono/IBMPlexMono-Regular.woff2',
|
|
1076
|
+
],
|
|
1077
|
+
},
|
|
1078
|
+
{
|
|
1079
|
+
fontFamily: 'IBM Plex Mono',
|
|
1080
|
+
fontStyle: 'italic',
|
|
1081
|
+
fontWeight: '400',
|
|
1082
|
+
src: [
|
|
1083
|
+
'file:./assets/fonts/ibm-plex-mono/IBMPlexMono-Italic.woff2',
|
|
1084
|
+
],
|
|
1085
|
+
},
|
|
1086
|
+
{
|
|
1087
|
+
fontFamily: 'IBM Plex Mono',
|
|
1088
|
+
fontStyle: 'normal',
|
|
1089
|
+
fontWeight: '700',
|
|
1090
|
+
src: [
|
|
1091
|
+
'file:./assets/fonts/ibm-plex-mono/IBMPlexMono-Bold.woff2',
|
|
1092
|
+
],
|
|
1093
|
+
},
|
|
1094
|
+
],
|
|
1095
|
+
fontStyle: 'normal',
|
|
1096
|
+
fontWeight: '400',
|
|
1097
|
+
expected: {
|
|
1098
|
+
nearestFontStyle: 'normal',
|
|
1099
|
+
nearestFontWeight: '400',
|
|
1100
|
+
},
|
|
1101
|
+
},
|
|
1102
|
+
{
|
|
1103
|
+
message:
|
|
1104
|
+
'should return nearest fontStyle and fontWeight for normal/100',
|
|
1105
|
+
fontFamilyFaces: [
|
|
1106
|
+
{
|
|
1107
|
+
fontFamily: 'IBM Plex Mono',
|
|
1108
|
+
fontStyle: 'normal',
|
|
1109
|
+
fontWeight: '400',
|
|
1110
|
+
src: [
|
|
1111
|
+
'file:./assets/fonts/ibm-plex-mono/IBMPlexMono-Regular.woff2',
|
|
1112
|
+
],
|
|
1113
|
+
},
|
|
1114
|
+
{
|
|
1115
|
+
fontFamily: 'IBM Plex Mono',
|
|
1116
|
+
fontStyle: 'italic',
|
|
1117
|
+
fontWeight: '400',
|
|
1118
|
+
src: [
|
|
1119
|
+
'file:./assets/fonts/ibm-plex-mono/IBMPlexMono-Italic.woff2',
|
|
1120
|
+
],
|
|
1121
|
+
},
|
|
1122
|
+
{
|
|
1123
|
+
fontFamily: 'IBM Plex Mono',
|
|
1124
|
+
fontStyle: 'normal',
|
|
1125
|
+
fontWeight: '700',
|
|
1126
|
+
src: [
|
|
1127
|
+
'file:./assets/fonts/ibm-plex-mono/IBMPlexMono-Bold.woff2',
|
|
1128
|
+
],
|
|
1129
|
+
},
|
|
1130
|
+
],
|
|
1131
|
+
fontStyle: 'normal',
|
|
1132
|
+
fontWeight: '100',
|
|
1133
|
+
expected: {
|
|
1134
|
+
nearestFontStyle: 'normal',
|
|
1135
|
+
nearestFontWeight: '400',
|
|
1136
|
+
},
|
|
1137
|
+
},
|
|
1138
|
+
{
|
|
1139
|
+
message:
|
|
1140
|
+
'should return nearest fontStyle and fontWeight for italic/900',
|
|
1141
|
+
fontFamilyFaces: [
|
|
1142
|
+
{
|
|
1143
|
+
fontFamily: 'IBM Plex Mono',
|
|
1144
|
+
fontStyle: 'normal',
|
|
1145
|
+
fontWeight: '400',
|
|
1146
|
+
src: [
|
|
1147
|
+
'file:./assets/fonts/ibm-plex-mono/IBMPlexMono-Regular.woff2',
|
|
1148
|
+
],
|
|
1149
|
+
},
|
|
1150
|
+
{
|
|
1151
|
+
fontFamily: 'IBM Plex Mono',
|
|
1152
|
+
fontStyle: 'italic',
|
|
1153
|
+
fontWeight: '400',
|
|
1154
|
+
src: [
|
|
1155
|
+
'file:./assets/fonts/ibm-plex-mono/IBMPlexMono-Italic.woff2',
|
|
1156
|
+
],
|
|
1157
|
+
},
|
|
1158
|
+
{
|
|
1159
|
+
fontFamily: 'IBM Plex Mono',
|
|
1160
|
+
fontStyle: 'normal',
|
|
1161
|
+
fontWeight: '700',
|
|
1162
|
+
src: [
|
|
1163
|
+
'file:./assets/fonts/ibm-plex-mono/IBMPlexMono-Bold.woff2',
|
|
1164
|
+
],
|
|
1165
|
+
},
|
|
1166
|
+
],
|
|
1167
|
+
fontStyle: 'italic',
|
|
1168
|
+
fontWeight: '900',
|
|
1169
|
+
expected: {
|
|
1170
|
+
nearestFontStyle: 'italic',
|
|
1171
|
+
nearestFontWeight: '700',
|
|
1172
|
+
},
|
|
1173
|
+
},
|
|
1174
|
+
{
|
|
1175
|
+
message:
|
|
1176
|
+
'should return nearest fontStyle and fontWeight for oblique/600',
|
|
1177
|
+
fontFamilyFaces: [
|
|
1178
|
+
{
|
|
1179
|
+
fontFamily: 'IBM Plex Mono',
|
|
1180
|
+
fontStyle: 'normal',
|
|
1181
|
+
fontWeight: '400',
|
|
1182
|
+
src: [
|
|
1183
|
+
'file:./assets/fonts/ibm-plex-mono/IBMPlexMono-Regular.woff2',
|
|
1184
|
+
],
|
|
1185
|
+
},
|
|
1186
|
+
{
|
|
1187
|
+
fontFamily: 'IBM Plex Mono',
|
|
1188
|
+
fontStyle: 'italic',
|
|
1189
|
+
fontWeight: '700',
|
|
1190
|
+
src: [
|
|
1191
|
+
'file:./assets/fonts/ibm-plex-mono/IBMPlexMono-Bold.woff2',
|
|
1192
|
+
],
|
|
1193
|
+
},
|
|
1194
|
+
],
|
|
1195
|
+
fontStyle: 'oblique',
|
|
1196
|
+
fontWeight: '600',
|
|
1197
|
+
expected: {
|
|
1198
|
+
nearestFontStyle: 'italic',
|
|
1199
|
+
nearestFontWeight: '700',
|
|
1200
|
+
},
|
|
1201
|
+
},
|
|
1202
|
+
{
|
|
1203
|
+
message:
|
|
1204
|
+
'should return nearest fontStyle and fontWeight for 300 font weight and empty font style',
|
|
1205
|
+
fontFamilyFaces: [
|
|
1206
|
+
{
|
|
1207
|
+
fontFamily: 'IBM Plex Mono',
|
|
1208
|
+
fontStyle: 'normal',
|
|
1209
|
+
fontWeight: '400',
|
|
1210
|
+
src: [
|
|
1211
|
+
'file:./assets/fonts/ibm-plex-mono/IBMPlexMono-Regular.woff2',
|
|
1212
|
+
],
|
|
1213
|
+
},
|
|
1214
|
+
{
|
|
1215
|
+
fontFamily: 'IBM Plex Mono',
|
|
1216
|
+
fontStyle: 'italic',
|
|
1217
|
+
fontWeight: '700',
|
|
1218
|
+
src: [
|
|
1219
|
+
'file:./assets/fonts/ibm-plex-mono/IBMPlexMono-Bold.woff2',
|
|
1220
|
+
],
|
|
1221
|
+
},
|
|
1222
|
+
],
|
|
1223
|
+
fontStyle: undefined,
|
|
1224
|
+
fontWeight: '300',
|
|
1225
|
+
expected: {
|
|
1226
|
+
nearestFontStyle: 'normal',
|
|
1227
|
+
nearestFontWeight: '400',
|
|
1228
|
+
},
|
|
1229
|
+
},
|
|
1230
|
+
{
|
|
1231
|
+
message:
|
|
1232
|
+
'should return nearest fontStyle and fontWeight for oblique font style and empty font weight',
|
|
1233
|
+
fontFamilyFaces: [
|
|
1234
|
+
{
|
|
1235
|
+
fontFamily: 'IBM Plex Mono',
|
|
1236
|
+
fontStyle: 'normal',
|
|
1237
|
+
fontWeight: '400',
|
|
1238
|
+
src: [
|
|
1239
|
+
'file:./assets/fonts/ibm-plex-mono/IBMPlexMono-Regular.woff2',
|
|
1240
|
+
],
|
|
1241
|
+
},
|
|
1242
|
+
{
|
|
1243
|
+
fontFamily: 'IBM Plex Mono',
|
|
1244
|
+
fontStyle: 'italic',
|
|
1245
|
+
fontWeight: '700',
|
|
1246
|
+
src: [
|
|
1247
|
+
'file:./assets/fonts/ibm-plex-mono/IBMPlexMono-Bold.woff2',
|
|
1248
|
+
],
|
|
1249
|
+
},
|
|
1250
|
+
],
|
|
1251
|
+
fontStyle: 'oblique',
|
|
1252
|
+
fontWeight: undefined,
|
|
1253
|
+
expected: {
|
|
1254
|
+
nearestFontStyle: 'italic',
|
|
1255
|
+
nearestFontWeight: '400',
|
|
1256
|
+
},
|
|
1257
|
+
},
|
|
1258
|
+
].forEach(
|
|
1259
|
+
( {
|
|
1260
|
+
message,
|
|
1261
|
+
fontFamilyFaces,
|
|
1262
|
+
fontStyle,
|
|
1263
|
+
fontWeight,
|
|
1264
|
+
expected,
|
|
1265
|
+
} ) => {
|
|
1266
|
+
it( `${ message }`, () => {
|
|
1267
|
+
expect(
|
|
1268
|
+
findNearestStyleAndWeight(
|
|
1269
|
+
fontFamilyFaces,
|
|
1270
|
+
fontStyle,
|
|
1271
|
+
fontWeight
|
|
1272
|
+
)
|
|
1273
|
+
).toEqual( expected );
|
|
1274
|
+
} );
|
|
1275
|
+
}
|
|
1276
|
+
);
|
|
1277
|
+
} );
|
|
1278
|
+
|
|
954
1279
|
describe( 'typography utils', () => {
|
|
955
1280
|
[
|
|
956
1281
|
{
|
|
@@ -107,6 +107,7 @@ describe( 'global styles renderer', () => {
|
|
|
107
107
|
},
|
|
108
108
|
},
|
|
109
109
|
selector: ROOT_BLOCK_SELECTOR,
|
|
110
|
+
skipSelectorWrapper: true,
|
|
110
111
|
},
|
|
111
112
|
{
|
|
112
113
|
styles: {
|
|
@@ -128,6 +129,7 @@ describe( 'global styles renderer', () => {
|
|
|
128
129
|
},
|
|
129
130
|
},
|
|
130
131
|
selector: ELEMENTS.link,
|
|
132
|
+
skipSelectorWrapper: true,
|
|
131
133
|
},
|
|
132
134
|
{
|
|
133
135
|
styles: {
|
|
@@ -480,7 +482,7 @@ describe( 'global styles renderer', () => {
|
|
|
480
482
|
};
|
|
481
483
|
|
|
482
484
|
expect( toStyles( tree, blockSelectors ) ).toEqual(
|
|
483
|
-
':where(body) {margin: 0;}.is-layout-flow > .alignleft { float: left; margin-inline-start: 0; margin-inline-end: 2em; }.is-layout-flow > .alignright { float: right; margin-inline-start: 2em; margin-inline-end: 0; }.is-layout-flow > .aligncenter { margin-left: auto !important; margin-right: auto !important; }.is-layout-constrained > .alignleft { float: left; margin-inline-start: 0; margin-inline-end: 2em; }.is-layout-constrained > .alignright { float: right; margin-inline-start: 2em; margin-inline-end: 0; }.is-layout-constrained > .aligncenter { margin-left: auto !important; margin-right: auto !important; }.is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)) { max-width: var(--wp--style--global--content-size); margin-left: auto !important; margin-right: auto !important; }.is-layout-constrained > .alignwide { max-width: var(--wp--style--global--wide-size); }body .is-layout-flex { display:flex; }.is-layout-flex { flex-wrap: wrap; align-items: center; }.is-layout-flex > :is(*, div) { margin: 0; }body .is-layout-grid { display:grid; }.is-layout-grid > :is(*, div) { margin: 0; }
|
|
485
|
+
':where(body) {margin: 0;}.is-layout-flow > .alignleft { float: left; margin-inline-start: 0; margin-inline-end: 2em; }.is-layout-flow > .alignright { float: right; margin-inline-start: 2em; margin-inline-end: 0; }.is-layout-flow > .aligncenter { margin-left: auto !important; margin-right: auto !important; }.is-layout-constrained > .alignleft { float: left; margin-inline-start: 0; margin-inline-end: 2em; }.is-layout-constrained > .alignright { float: right; margin-inline-start: 2em; margin-inline-end: 0; }.is-layout-constrained > .aligncenter { margin-left: auto !important; margin-right: auto !important; }.is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)) { max-width: var(--wp--style--global--content-size); margin-left: auto !important; margin-right: auto !important; }.is-layout-constrained > .alignwide { max-width: var(--wp--style--global--wide-size); }body .is-layout-flex { display:flex; }.is-layout-flex { flex-wrap: wrap; align-items: center; }.is-layout-flex > :is(*, div) { margin: 0; }body .is-layout-grid { display:grid; }.is-layout-grid > :is(*, div) { margin: 0; }body{background-color: red;margin: 10px;padding: 10px;}a:where(:not(.wp-element-button)){color: blue;}:root :where(a:where(:not(.wp-element-button)):hover){color: orange;}:root :where(a:where(:not(.wp-element-button)):focus){color: orange;}h1{font-size: 42px;}:root :where(.wp-block-group){margin-top: 10px;margin-right: 20px;margin-bottom: 30px;margin-left: 40px;padding-top: 11px;padding-right: 22px;padding-bottom: 33px;padding-left: 44px;}:root :where(h1,h2,h3,h4,h5,h6){color: orange;}:root :where(h1 a:where(:not(.wp-element-button)),h2 a:where(:not(.wp-element-button)),h3 a:where(:not(.wp-element-button)),h4 a:where(:not(.wp-element-button)),h5 a:where(:not(.wp-element-button)),h6 a:where(:not(.wp-element-button))){color: hotpink;}:root :where(h1 a:where(:not(.wp-element-button)):hover,h2 a:where(:not(.wp-element-button)):hover,h3 a:where(:not(.wp-element-button)):hover,h4 a:where(:not(.wp-element-button)):hover,h5 a:where(:not(.wp-element-button)):hover,h6 a:where(:not(.wp-element-button)):hover){color: red;}:root :where(h1 a:where(:not(.wp-element-button)):focus,h2 a:where(:not(.wp-element-button)):focus,h3 a:where(:not(.wp-element-button)):focus,h4 a:where(:not(.wp-element-button)):focus,h5 a:where(:not(.wp-element-button)):focus,h6 a:where(:not(.wp-element-button)):focus){color: red;}:root :where(.wp-block-image img, .wp-block-image .wp-crop-area){border-radius: 9999px;}:root :where(.wp-block-image){color: red;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.has-white-color{color: var(--wp--preset--color--white) !important;}.has-white-background-color{background-color: var(--wp--preset--color--white) !important;}.has-white-border-color{border-color: var(--wp--preset--color--white) !important;}.has-black-color{color: var(--wp--preset--color--black) !important;}.has-black-background-color{background-color: var(--wp--preset--color--black) !important;}.has-black-border-color{border-color: var(--wp--preset--color--black) !important;}h1.has-blue-color,h2.has-blue-color,h3.has-blue-color,h4.has-blue-color,h5.has-blue-color,h6.has-blue-color{color: var(--wp--preset--color--blue) !important;}h1.has-blue-background-color,h2.has-blue-background-color,h3.has-blue-background-color,h4.has-blue-background-color,h5.has-blue-background-color,h6.has-blue-background-color{background-color: var(--wp--preset--color--blue) !important;}h1.has-blue-border-color,h2.has-blue-border-color,h3.has-blue-border-color,h4.has-blue-border-color,h5.has-blue-border-color,h6.has-blue-border-color{border-color: var(--wp--preset--color--blue) !important;}'
|
|
484
486
|
);
|
|
485
487
|
} );
|
|
486
488
|
|
|
@@ -25,9 +25,8 @@ import { getValueFromVariable, useToolsPanelDropdownMenuProps } from './utils';
|
|
|
25
25
|
import { setImmutably } from '../../utils/object';
|
|
26
26
|
import {
|
|
27
27
|
getMergedFontFamiliesAndFontFamilyFaces,
|
|
28
|
-
|
|
28
|
+
findNearestStyleAndWeight,
|
|
29
29
|
} from './typography-utils';
|
|
30
|
-
import { getFontStylesAndWeights } from '../../utils/get-font-styles-and-weights';
|
|
31
30
|
|
|
32
31
|
const MIN_TEXT_COLUMNS = 1;
|
|
33
32
|
const MAX_TEXT_COLUMNS = 6;
|
|
@@ -236,57 +235,50 @@ export default function TypographyPanel( {
|
|
|
236
235
|
const hasFontWeights = settings?.typography?.fontWeight;
|
|
237
236
|
const fontStyle = decodeValue( inheritedValue?.typography?.fontStyle );
|
|
238
237
|
const fontWeight = decodeValue( inheritedValue?.typography?.fontWeight );
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
238
|
+
const { nearestFontStyle, nearestFontWeight } = findNearestStyleAndWeight(
|
|
239
|
+
fontFamilyFaces,
|
|
240
|
+
fontStyle,
|
|
241
|
+
fontWeight
|
|
242
|
+
);
|
|
243
|
+
const setFontAppearance = useCallback(
|
|
244
|
+
( { fontStyle: newFontStyle, fontWeight: newFontWeight } ) => {
|
|
245
|
+
// Only update the font style and weight if they have changed.
|
|
246
|
+
if ( newFontStyle !== fontStyle || newFontWeight !== fontWeight ) {
|
|
247
|
+
onChange( {
|
|
248
|
+
...value,
|
|
249
|
+
typography: {
|
|
250
|
+
...value?.typography,
|
|
251
|
+
fontStyle: newFontStyle || undefined,
|
|
252
|
+
fontWeight: newFontWeight || undefined,
|
|
253
|
+
},
|
|
254
|
+
} );
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
[ fontStyle, fontWeight, onChange, value ]
|
|
258
|
+
);
|
|
252
259
|
const hasFontAppearance = () =>
|
|
253
260
|
!! value?.typography?.fontStyle || !! value?.typography?.fontWeight;
|
|
254
|
-
const resetFontAppearance = () => {
|
|
261
|
+
const resetFontAppearance = useCallback( () => {
|
|
255
262
|
setFontAppearance( {} );
|
|
256
|
-
};
|
|
263
|
+
}, [ setFontAppearance ] );
|
|
257
264
|
|
|
258
|
-
// Check if previous font style and weight values are available in the new font family
|
|
265
|
+
// Check if previous font style and weight values are available in the new font family.
|
|
259
266
|
useEffect( () => {
|
|
260
|
-
|
|
261
|
-
getFontStylesAndWeights( fontFamilyFaces );
|
|
262
|
-
const hasFontStyle = fontStyles?.some(
|
|
263
|
-
( { value: fs } ) => fs === fontStyle
|
|
264
|
-
);
|
|
265
|
-
const hasFontWeight = fontWeights?.some(
|
|
266
|
-
( { value: fw } ) => fw === fontWeight
|
|
267
|
-
);
|
|
268
|
-
|
|
269
|
-
// Try to set nearest available font weight
|
|
270
|
-
if ( ! hasFontWeight && fontWeight ) {
|
|
267
|
+
if ( nearestFontStyle && nearestFontWeight ) {
|
|
271
268
|
setFontAppearance( {
|
|
272
|
-
fontStyle,
|
|
273
|
-
fontWeight:
|
|
269
|
+
fontStyle: nearestFontStyle,
|
|
270
|
+
fontWeight: nearestFontWeight,
|
|
274
271
|
} );
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// Set the same weight and style values if the font family is a system font or if both are the same
|
|
278
|
-
if ( isSystemFont || ( hasFontStyle && hasFontWeight ) ) {
|
|
279
|
-
setFontAppearance( {
|
|
280
|
-
fontStyle,
|
|
281
|
-
fontWeight,
|
|
282
|
-
} );
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
// Reset font appearance if the font family does not have the selected font style
|
|
286
|
-
if ( ! hasFontStyle ) {
|
|
272
|
+
} else {
|
|
273
|
+
// Reset font appearance if there are no available styles or weights.
|
|
287
274
|
resetFontAppearance();
|
|
288
275
|
}
|
|
289
|
-
}, [
|
|
276
|
+
}, [
|
|
277
|
+
nearestFontStyle,
|
|
278
|
+
nearestFontWeight,
|
|
279
|
+
resetFontAppearance,
|
|
280
|
+
setFontAppearance,
|
|
281
|
+
] );
|
|
290
282
|
|
|
291
283
|
// Line Height
|
|
292
284
|
const hasLineHeightEnabled = useHasLineHeightControl( settings );
|