@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
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
getComputedFluidTypographyValue,
|
|
12
12
|
getTypographyValueAndUnit,
|
|
13
13
|
} from '../font-sizes/fluid-utils';
|
|
14
|
+
import { getFontStylesAndWeights } from '../../utils/get-font-styles-and-weights';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* @typedef {Object} FluidPreset
|
|
@@ -127,9 +128,9 @@ export function getFluidTypographyOptionsFromSettings( settings ) {
|
|
|
127
128
|
* Returns an object of merged font families and the font faces from the selected font family
|
|
128
129
|
* based on the theme.json settings object and the currently selected font family.
|
|
129
130
|
*
|
|
130
|
-
* @param {Object} settings Theme.json settings
|
|
131
|
-
* @param {string} selectedFontFamily Decoded font family string
|
|
132
|
-
* @return {Object} Merged font families and font faces from the selected font family
|
|
131
|
+
* @param {Object} settings Theme.json settings.
|
|
132
|
+
* @param {string} selectedFontFamily Decoded font family string.
|
|
133
|
+
* @return {Object} Merged font families and font faces from the selected font family.
|
|
133
134
|
*/
|
|
134
135
|
export function getMergedFontFamiliesAndFontFamilyFaces(
|
|
135
136
|
settings,
|
|
@@ -153,11 +154,10 @@ export function getMergedFontFamiliesAndFontFamilyFaces(
|
|
|
153
154
|
* Returns the nearest font weight value from the available font weight list based on the new font weight.
|
|
154
155
|
* The nearest font weight is the one with the smallest difference from the new font weight.
|
|
155
156
|
*
|
|
156
|
-
* @param {Array} availableFontWeights Array of available font weights
|
|
157
|
-
* @param {string} newFontWeightValue New font weight value
|
|
158
|
-
* @return {string} Nearest font weight
|
|
157
|
+
* @param {Array} availableFontWeights Array of available font weights.
|
|
158
|
+
* @param {string} newFontWeightValue New font weight value.
|
|
159
|
+
* @return {string} Nearest font weight.
|
|
159
160
|
*/
|
|
160
|
-
|
|
161
161
|
export function findNearestFontWeight(
|
|
162
162
|
availableFontWeights,
|
|
163
163
|
newFontWeightValue
|
|
@@ -185,3 +185,99 @@ export function findNearestFontWeight(
|
|
|
185
185
|
|
|
186
186
|
return nearestFontWeight;
|
|
187
187
|
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Returns the nearest font style based on the new font style.
|
|
191
|
+
* Defaults to an empty string if the new font style is not valid or available.
|
|
192
|
+
*
|
|
193
|
+
* @param {Array} availableFontStyles Array of available font weights.
|
|
194
|
+
* @param {string} newFontStyleValue New font style value.
|
|
195
|
+
* @return {string} Nearest font style or an empty string.
|
|
196
|
+
*/
|
|
197
|
+
export function findNearestFontStyle( availableFontStyles, newFontStyleValue ) {
|
|
198
|
+
if ( typeof newFontStyleValue !== 'string' || ! newFontStyleValue ) {
|
|
199
|
+
return '';
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const validStyles = [ 'normal', 'italic', 'oblique' ];
|
|
203
|
+
if ( ! validStyles.includes( newFontStyleValue ) ) {
|
|
204
|
+
return '';
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (
|
|
208
|
+
! availableFontStyles ||
|
|
209
|
+
availableFontStyles.length === 0 ||
|
|
210
|
+
availableFontStyles.find(
|
|
211
|
+
( style ) => style.value === newFontStyleValue
|
|
212
|
+
)
|
|
213
|
+
) {
|
|
214
|
+
return newFontStyleValue;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (
|
|
218
|
+
newFontStyleValue === 'oblique' &&
|
|
219
|
+
! availableFontStyles.find( ( style ) => style.value === 'oblique' )
|
|
220
|
+
) {
|
|
221
|
+
return 'italic';
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return '';
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Returns the nearest font style and weight based on the available font family faces and the new font style and weight.
|
|
229
|
+
*
|
|
230
|
+
* @param {Array} fontFamilyFaces Array of available font family faces.
|
|
231
|
+
* @param {string} fontStyle New font style. Defaults to previous value.
|
|
232
|
+
* @param {string} fontWeight New font weight. Defaults to previous value.
|
|
233
|
+
* @return {Object} Nearest font style and font weight.
|
|
234
|
+
*/
|
|
235
|
+
export function findNearestStyleAndWeight(
|
|
236
|
+
fontFamilyFaces,
|
|
237
|
+
fontStyle,
|
|
238
|
+
fontWeight
|
|
239
|
+
) {
|
|
240
|
+
let nearestFontStyle = fontStyle;
|
|
241
|
+
let nearestFontWeight = fontWeight;
|
|
242
|
+
|
|
243
|
+
const { fontStyles, fontWeights, combinedStyleAndWeightOptions } =
|
|
244
|
+
getFontStylesAndWeights( fontFamilyFaces );
|
|
245
|
+
|
|
246
|
+
// Check if the new font style and weight are available in the font family faces.
|
|
247
|
+
const hasFontStyle = fontStyles?.some(
|
|
248
|
+
( { value: fs } ) => fs === fontStyle
|
|
249
|
+
);
|
|
250
|
+
const hasFontWeight = fontWeights?.some(
|
|
251
|
+
( { value: fw } ) => fw === fontWeight
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
if ( ! hasFontStyle ) {
|
|
255
|
+
/*
|
|
256
|
+
* Default to italic if oblique is not available.
|
|
257
|
+
* Or find the nearest font style based on the nearest font weight.
|
|
258
|
+
*/
|
|
259
|
+
nearestFontStyle = fontStyle
|
|
260
|
+
? findNearestFontStyle( fontStyles, fontStyle )
|
|
261
|
+
: combinedStyleAndWeightOptions?.find(
|
|
262
|
+
( option ) =>
|
|
263
|
+
option.style.fontWeight ===
|
|
264
|
+
findNearestFontWeight( fontWeights, fontWeight )
|
|
265
|
+
)?.style?.fontStyle;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if ( ! hasFontWeight ) {
|
|
269
|
+
/*
|
|
270
|
+
* Find the nearest font weight based on available weights.
|
|
271
|
+
* Or find the nearest font weight based on the nearest font style.
|
|
272
|
+
*/
|
|
273
|
+
nearestFontWeight = fontWeight
|
|
274
|
+
? findNearestFontWeight( fontWeights, fontWeight )
|
|
275
|
+
: combinedStyleAndWeightOptions?.find(
|
|
276
|
+
( option ) =>
|
|
277
|
+
option.style.fontStyle ===
|
|
278
|
+
( nearestFontStyle || fontStyle )
|
|
279
|
+
)?.style?.fontWeight;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return { nearestFontStyle, nearestFontWeight };
|
|
283
|
+
}
|
|
@@ -38,6 +38,12 @@ import { getValueFromObjectPath, setImmutably } from '../../utils/object';
|
|
|
38
38
|
import { unlock } from '../../lock-unlock';
|
|
39
39
|
import { setThemeFileUris } from './theme-file-uri-utils';
|
|
40
40
|
|
|
41
|
+
// Elements that rely on class names in their selectors.
|
|
42
|
+
const ELEMENT_CLASS_NAMES = {
|
|
43
|
+
button: 'wp-element-button',
|
|
44
|
+
caption: 'wp-element-caption',
|
|
45
|
+
};
|
|
46
|
+
|
|
41
47
|
// List of block support features that can have their related styles
|
|
42
48
|
// generated under their own feature level selector rather than the block's.
|
|
43
49
|
const BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {
|
|
@@ -643,6 +649,9 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
|
|
|
643
649
|
nodes.push( {
|
|
644
650
|
styles,
|
|
645
651
|
selector: ROOT_BLOCK_SELECTOR,
|
|
652
|
+
// Root selector (body) styles should not be wrapped in `:root where()` to keep
|
|
653
|
+
// specificity at (0,0,1) and maintain backwards compatibility.
|
|
654
|
+
skipSelectorWrapper: true,
|
|
646
655
|
} );
|
|
647
656
|
}
|
|
648
657
|
|
|
@@ -651,6 +660,9 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
|
|
|
651
660
|
nodes.push( {
|
|
652
661
|
styles: tree.styles?.elements?.[ name ],
|
|
653
662
|
selector,
|
|
663
|
+
// Top level elements that don't use a class name should not receive the
|
|
664
|
+
// `:root :where()` wrapper to maintain backwards compatibility.
|
|
665
|
+
skipSelectorWrapper: ! ELEMENT_CLASS_NAMES[ name ],
|
|
654
666
|
} );
|
|
655
667
|
}
|
|
656
668
|
} );
|
|
@@ -957,6 +969,7 @@ export const toStyles = (
|
|
|
957
969
|
hasLayoutSupport,
|
|
958
970
|
featureSelectors,
|
|
959
971
|
styleVariationSelectors,
|
|
972
|
+
skipSelectorWrapper,
|
|
960
973
|
} ) => {
|
|
961
974
|
// Process styles for block support features with custom feature level
|
|
962
975
|
// CSS selectors set.
|
|
@@ -1015,7 +1028,10 @@ export const toStyles = (
|
|
|
1015
1028
|
disableRootPadding
|
|
1016
1029
|
);
|
|
1017
1030
|
if ( styleDeclarations?.length ) {
|
|
1018
|
-
|
|
1031
|
+
const generalSelector = skipSelectorWrapper
|
|
1032
|
+
? selector
|
|
1033
|
+
: `:root :where(${ selector })`;
|
|
1034
|
+
ruleset += `${ generalSelector }{${ styleDeclarations.join(
|
|
1019
1035
|
';'
|
|
1020
1036
|
) };}`;
|
|
1021
1037
|
}
|
|
@@ -1109,7 +1125,11 @@ export const toStyles = (
|
|
|
1109
1125
|
.map( ( sel ) => sel + pseudoKey )
|
|
1110
1126
|
.join( ',' );
|
|
1111
1127
|
|
|
1112
|
-
|
|
1128
|
+
// As pseudo classes such as :hover, :focus etc. have class-level
|
|
1129
|
+
// specificity, they must use the `:root :where()` wrapper. This.
|
|
1130
|
+
// caps the specificity at `0-1-0` to allow proper nesting of variations
|
|
1131
|
+
// and block type element styles.
|
|
1132
|
+
const pseudoRule = `:root :where(${ _selector }){${ pseudoDeclarations.join(
|
|
1113
1133
|
';'
|
|
1114
1134
|
) };}`;
|
|
1115
1135
|
|
|
@@ -1,10 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
4
9
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
6
|
-
|
|
10
|
+
import {
|
|
11
|
+
VisuallyHidden,
|
|
12
|
+
ToolbarButton,
|
|
13
|
+
ToolbarGroup,
|
|
14
|
+
} from '@wordpress/components';
|
|
15
|
+
import {
|
|
16
|
+
chevronLeft,
|
|
17
|
+
chevronUp,
|
|
18
|
+
chevronDown,
|
|
19
|
+
chevronRight,
|
|
20
|
+
} from '@wordpress/icons';
|
|
7
21
|
import { useDispatch } from '@wordpress/data';
|
|
22
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
8
23
|
|
|
9
24
|
/**
|
|
10
25
|
* Internal dependencies
|
|
@@ -39,74 +54,129 @@ export function GridItemMovers( {
|
|
|
39
54
|
|
|
40
55
|
return (
|
|
41
56
|
<BlockControls group="parent">
|
|
57
|
+
<ToolbarGroup className="block-editor-grid-item-mover__move-button-container">
|
|
58
|
+
<GridItemMover
|
|
59
|
+
className="is-left-button"
|
|
60
|
+
icon={ chevronLeft }
|
|
61
|
+
label={ __( 'Move left' ) }
|
|
62
|
+
description={ __( 'Move left' ) }
|
|
63
|
+
isDisabled={ columnStart <= 1 }
|
|
64
|
+
onClick={ () => {
|
|
65
|
+
onChange( {
|
|
66
|
+
columnStart: columnStart - 1,
|
|
67
|
+
} );
|
|
68
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
69
|
+
moveBlocksToPosition(
|
|
70
|
+
[ blockClientId ],
|
|
71
|
+
gridClientId,
|
|
72
|
+
gridClientId,
|
|
73
|
+
getNumberOfBlocksBeforeCell(
|
|
74
|
+
columnStart - 1,
|
|
75
|
+
rowStart
|
|
76
|
+
)
|
|
77
|
+
);
|
|
78
|
+
} }
|
|
79
|
+
/>
|
|
80
|
+
<div className="block-editor-grid-item-mover__move-vertical-button-container">
|
|
81
|
+
<GridItemMover
|
|
82
|
+
className="is-up-button"
|
|
83
|
+
icon={ chevronUp }
|
|
84
|
+
label={ __( 'Move up' ) }
|
|
85
|
+
description={ __( 'Move up' ) }
|
|
86
|
+
isDisabled={ rowStart <= 1 }
|
|
87
|
+
onClick={ () => {
|
|
88
|
+
onChange( {
|
|
89
|
+
rowStart: rowStart - 1,
|
|
90
|
+
} );
|
|
91
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
92
|
+
moveBlocksToPosition(
|
|
93
|
+
[ blockClientId ],
|
|
94
|
+
gridClientId,
|
|
95
|
+
gridClientId,
|
|
96
|
+
getNumberOfBlocksBeforeCell(
|
|
97
|
+
columnStart,
|
|
98
|
+
rowStart - 1
|
|
99
|
+
)
|
|
100
|
+
);
|
|
101
|
+
} }
|
|
102
|
+
/>
|
|
103
|
+
<GridItemMover
|
|
104
|
+
className="is-down-button"
|
|
105
|
+
icon={ chevronDown }
|
|
106
|
+
label={ __( 'Move down' ) }
|
|
107
|
+
description={ __( 'Move down' ) }
|
|
108
|
+
isDisabled={ rowCount && rowEnd >= rowCount }
|
|
109
|
+
onClick={ () => {
|
|
110
|
+
onChange( {
|
|
111
|
+
rowStart: rowStart + 1,
|
|
112
|
+
} );
|
|
113
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
114
|
+
moveBlocksToPosition(
|
|
115
|
+
[ blockClientId ],
|
|
116
|
+
gridClientId,
|
|
117
|
+
gridClientId,
|
|
118
|
+
getNumberOfBlocksBeforeCell(
|
|
119
|
+
columnStart,
|
|
120
|
+
rowStart + 1
|
|
121
|
+
)
|
|
122
|
+
);
|
|
123
|
+
} }
|
|
124
|
+
/>
|
|
125
|
+
</div>
|
|
126
|
+
<GridItemMover
|
|
127
|
+
className="is-right-button"
|
|
128
|
+
icon={ chevronRight }
|
|
129
|
+
label={ __( 'Move right' ) }
|
|
130
|
+
description={ __( 'Move right' ) }
|
|
131
|
+
isDisabled={ columnCount && columnEnd >= columnCount }
|
|
132
|
+
onClick={ () => {
|
|
133
|
+
onChange( {
|
|
134
|
+
columnStart: columnStart + 1,
|
|
135
|
+
} );
|
|
136
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
137
|
+
moveBlocksToPosition(
|
|
138
|
+
[ blockClientId ],
|
|
139
|
+
gridClientId,
|
|
140
|
+
gridClientId,
|
|
141
|
+
getNumberOfBlocksBeforeCell(
|
|
142
|
+
columnStart + 1,
|
|
143
|
+
rowStart
|
|
144
|
+
)
|
|
145
|
+
);
|
|
146
|
+
} }
|
|
147
|
+
/>
|
|
148
|
+
</ToolbarGroup>
|
|
149
|
+
</BlockControls>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function GridItemMover( {
|
|
154
|
+
className,
|
|
155
|
+
icon,
|
|
156
|
+
label,
|
|
157
|
+
isDisabled,
|
|
158
|
+
onClick,
|
|
159
|
+
description,
|
|
160
|
+
} ) {
|
|
161
|
+
const instanceId = useInstanceId( GridItemMover );
|
|
162
|
+
const descriptionId = `block-editor-grid-item-mover-button__description-${ instanceId }`;
|
|
163
|
+
return (
|
|
164
|
+
<>
|
|
42
165
|
<ToolbarButton
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
gridClientId,
|
|
54
|
-
gridClientId,
|
|
55
|
-
getNumberOfBlocksBeforeCell( columnStart, rowStart - 1 )
|
|
56
|
-
);
|
|
57
|
-
} }
|
|
58
|
-
/>
|
|
59
|
-
<ToolbarButton
|
|
60
|
-
icon={ arrowDown }
|
|
61
|
-
label={ __( 'Move block down' ) }
|
|
62
|
-
disabled={ rowCount && rowEnd >= rowCount }
|
|
63
|
-
onClick={ () => {
|
|
64
|
-
onChange( {
|
|
65
|
-
rowStart: rowStart + 1,
|
|
66
|
-
} );
|
|
67
|
-
__unstableMarkNextChangeAsNotPersistent();
|
|
68
|
-
moveBlocksToPosition(
|
|
69
|
-
[ blockClientId ],
|
|
70
|
-
gridClientId,
|
|
71
|
-
gridClientId,
|
|
72
|
-
getNumberOfBlocksBeforeCell( columnStart, rowStart + 1 )
|
|
73
|
-
);
|
|
74
|
-
} }
|
|
75
|
-
/>
|
|
76
|
-
<ToolbarButton
|
|
77
|
-
icon={ arrowLeft }
|
|
78
|
-
label={ __( 'Move block left' ) }
|
|
79
|
-
disabled={ columnStart <= 1 }
|
|
80
|
-
onClick={ () => {
|
|
81
|
-
onChange( {
|
|
82
|
-
columnStart: columnStart - 1,
|
|
83
|
-
} );
|
|
84
|
-
__unstableMarkNextChangeAsNotPersistent();
|
|
85
|
-
moveBlocksToPosition(
|
|
86
|
-
[ blockClientId ],
|
|
87
|
-
gridClientId,
|
|
88
|
-
gridClientId,
|
|
89
|
-
getNumberOfBlocksBeforeCell( columnStart - 1, rowStart )
|
|
90
|
-
);
|
|
91
|
-
} }
|
|
92
|
-
/>
|
|
93
|
-
<ToolbarButton
|
|
94
|
-
icon={ arrowRight }
|
|
95
|
-
label={ __( 'Move block right' ) }
|
|
96
|
-
disabled={ columnCount && columnEnd >= columnCount }
|
|
97
|
-
onClick={ () => {
|
|
98
|
-
onChange( {
|
|
99
|
-
columnStart: columnStart + 1,
|
|
100
|
-
} );
|
|
101
|
-
__unstableMarkNextChangeAsNotPersistent();
|
|
102
|
-
moveBlocksToPosition(
|
|
103
|
-
[ blockClientId ],
|
|
104
|
-
gridClientId,
|
|
105
|
-
gridClientId,
|
|
106
|
-
getNumberOfBlocksBeforeCell( columnStart + 1, rowStart )
|
|
107
|
-
);
|
|
108
|
-
} }
|
|
166
|
+
className={ clsx(
|
|
167
|
+
'block-editor-grid-item-mover-button',
|
|
168
|
+
className
|
|
169
|
+
) }
|
|
170
|
+
icon={ icon }
|
|
171
|
+
label={ label }
|
|
172
|
+
aria-describedby={ descriptionId }
|
|
173
|
+
onClick={ isDisabled ? null : onClick }
|
|
174
|
+
disabled={ isDisabled }
|
|
175
|
+
accessibleWhenDisabled
|
|
109
176
|
/>
|
|
110
|
-
|
|
177
|
+
<VisuallyHidden id={ descriptionId }>
|
|
178
|
+
{ description }
|
|
179
|
+
</VisuallyHidden>
|
|
180
|
+
</>
|
|
111
181
|
);
|
|
112
182
|
}
|
|
@@ -96,3 +96,117 @@
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
.block-editor-grid-item-mover__move-button-container {
|
|
100
|
+
display: flex;
|
|
101
|
+
padding: 0;
|
|
102
|
+
border: none;
|
|
103
|
+
justify-content: center;
|
|
104
|
+
|
|
105
|
+
.block-editor-grid-item-mover-button {
|
|
106
|
+
width: $block-toolbar-height * 0.5;
|
|
107
|
+
min-width: 0 !important; // overrides default button width.
|
|
108
|
+
overflow: hidden;
|
|
109
|
+
padding-left: 0;
|
|
110
|
+
padding-right: 0;
|
|
111
|
+
|
|
112
|
+
svg {
|
|
113
|
+
min-width: $grid-unit-30;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Focus and toggle pseudo elements.
|
|
117
|
+
&::before {
|
|
118
|
+
content: "";
|
|
119
|
+
position: absolute;
|
|
120
|
+
display: block;
|
|
121
|
+
border-radius: $radius-block-ui;
|
|
122
|
+
height: $grid-unit-40;
|
|
123
|
+
|
|
124
|
+
// Position the focus rectangle.
|
|
125
|
+
left: $grid-unit-10;
|
|
126
|
+
right: $grid-unit-10;
|
|
127
|
+
z-index: -1;
|
|
128
|
+
|
|
129
|
+
// Animate in.
|
|
130
|
+
animation: components-button__appear-animation 0.1s ease;
|
|
131
|
+
animation-fill-mode: forwards;
|
|
132
|
+
@include reduce-motion("animation");
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Don't show the focus inherited by the Button component.
|
|
136
|
+
&:focus,
|
|
137
|
+
&:focus:enabled,
|
|
138
|
+
&:focus::before {
|
|
139
|
+
box-shadow: none;
|
|
140
|
+
outline: none;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
&:focus-visible::before {
|
|
144
|
+
@include block-toolbar-button-style__focus();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
.block-editor-grid-item-mover__move-vertical-button-container {
|
|
151
|
+
display: flex;
|
|
152
|
+
position: relative;
|
|
153
|
+
@include break-small() {
|
|
154
|
+
flex-direction: column;
|
|
155
|
+
justify-content: space-around;
|
|
156
|
+
|
|
157
|
+
> .block-editor-grid-item-mover-button.block-editor-grid-item-mover-button {
|
|
158
|
+
height: $block-toolbar-height * 0.5 - $grid-unit-05;
|
|
159
|
+
width: 100%;
|
|
160
|
+
min-width: 0 !important; // overrides default button width.
|
|
161
|
+
|
|
162
|
+
// Focus style.
|
|
163
|
+
&::before {
|
|
164
|
+
height: calc(100% - 4px);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.block-editor-grid-item-mover-button.is-up-button svg,
|
|
169
|
+
.block-editor-grid-item-mover-button.is-down-button svg {
|
|
170
|
+
flex-shrink: 0;
|
|
171
|
+
height: $block-toolbar-height * 0.5 - $grid-unit-05;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.show-icon-labels {
|
|
177
|
+
|
|
178
|
+
.block-editor-grid-item-mover-button.block-editor-grid-item-mover-button.is-left-button {
|
|
179
|
+
border-right: 1px solid $gray-700;
|
|
180
|
+
padding-right: 12px;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.block-editor-grid-item-mover-button.block-editor-grid-item-mover-button.is-right-button {
|
|
184
|
+
border-left: 1px solid $gray-700;
|
|
185
|
+
padding-left: 12px;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
.block-editor-grid-item-mover__move-vertical-button-container {
|
|
190
|
+
&::before {
|
|
191
|
+
@include break-small() {
|
|
192
|
+
content: "";
|
|
193
|
+
height: $border-width;
|
|
194
|
+
width: 100%;
|
|
195
|
+
background: $gray-200;
|
|
196
|
+
position: absolute;
|
|
197
|
+
top: 50%;
|
|
198
|
+
left: 50%;
|
|
199
|
+
// With Top toolbar enabled, this separator has a smaller width. Translating the
|
|
200
|
+
// X axis allows to make the separator always centered regardless of its width.
|
|
201
|
+
transform: translate(-50%, 0);
|
|
202
|
+
margin-top: -$border-width * 0.5;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
@include break-medium {
|
|
206
|
+
background: $gray-900;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
}
|
|
212
|
+
|