@wordpress/block-editor 13.2.0 → 13.3.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 -1
- package/build/components/block-breadcrumb/index.js +12 -1
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-lock/toolbar.js +0 -1
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-mover/button.js +1 -1
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +1 -1
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +2 -2
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-patterns-paging/index.js +5 -7
- package/build/components/block-patterns-paging/index.js.map +1 -1
- package/build/components/block-quick-navigation/index.js +20 -17
- package/build/components/block-quick-navigation/index.js.map +1 -1
- package/build/components/block-rename/modal.js +4 -12
- package/build/components/block-rename/modal.js.map +1 -1
- package/build/components/block-toolbar/shuffle.js +1 -0
- package/build/components/block-toolbar/shuffle.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +7 -58
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/block-toolbar-breadcrumb.js +9 -2
- package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
- package/build/components/block-tools/index.js +14 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +4 -2
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/block-tools/zoom-out-mode-inserters.js +5 -4
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build/components/block-tools/zoom-out-popover.js +57 -0
- package/build/components/block-tools/zoom-out-popover.js.map +1 -0
- package/build/components/block-tools/zoom-out-toolbar.js +138 -0
- package/build/components/block-tools/zoom-out-toolbar.js.map +1 -0
- package/build/components/button-block-appender/index.js +3 -1
- package/build/components/button-block-appender/index.js.map +1 -1
- package/build/components/child-layout-control/index.js +26 -18
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +10 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/dimensions-tool/index.js +6 -4
- package/build/components/dimensions-tool/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +26 -61
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/global-styles/background-panel.js +178 -116
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/border-panel.js +2 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +2 -1
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +2 -1
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +2 -1
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +8 -0
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js +2 -1
- package/build/components/global-styles/image-settings-panel.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +50 -12
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +50 -0
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +23 -8
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +17 -7
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/grid/grid-item-movers.js +11 -14
- package/build/components/grid/grid-item-movers.js.map +1 -1
- package/build/components/grid/grid-item-resizer.js +2 -2
- package/build/components/grid/grid-item-resizer.js.map +1 -1
- package/build/components/grid/grid-visualizer.js +116 -36
- package/build/components/grid/grid-visualizer.js.map +1 -1
- package/build/components/grid/use-grid-layout-sync.js +29 -22
- package/build/components/grid/use-grid-layout-sync.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/pattern-category-preview-panel.js +1 -19
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
- package/build/components/inserter/menu.js +26 -4
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +2 -1
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +2 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/link-control/link-preview.js +1 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/media-placeholder/index.js +19 -23
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +3 -1
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +5 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/tabbed-sidebar/index.js +66 -0
- package/build/components/tabbed-sidebar/index.js.map +1 -0
- package/build/components/url-popover/index.js +3 -0
- package/build/components/url-popover/index.js.map +1 -1
- package/build/hooks/background.js +26 -4
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-hooks.js +11 -17
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-style-variation.js +169 -4
- package/build/hooks/block-style-variation.js.map +1 -1
- package/build/hooks/duotone.js +16 -11
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/grid-visualizer.js +65 -0
- package/build/hooks/grid-visualizer.js.map +1 -0
- package/build/hooks/index.js +15 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout-child.js +39 -22
- package/build/hooks/layout-child.js.map +1 -1
- package/build/hooks/position.js +2 -9
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +16 -6
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/utils.js +2 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +44 -2
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/grid.js +90 -51
- package/build/layouts/grid.js.map +1 -1
- package/build/private-apis.js +6 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/defaults.js +0 -2
- package/build/store/defaults.js.map +1 -1
- package/build/store/defaults.native.js +0 -3
- package/build/store/defaults.native.js.map +1 -1
- package/build/store/private-keys.js +2 -1
- package/build/store/private-keys.js.map +1 -1
- package/build/utils/format-font-style.js +45 -0
- package/build/utils/format-font-style.js.map +1 -0
- package/build/utils/format-font-weight.js +68 -0
- package/build/utils/format-font-weight.js.map +1 -0
- package/build/utils/get-editor-region.js +34 -0
- package/build/utils/get-editor-region.js.map +1 -0
- package/build/utils/get-font-styles-and-weights.js +167 -0
- package/build/utils/get-font-styles-and-weights.js.map +1 -0
- package/build/utils/pasting.js +5 -13
- package/build/utils/pasting.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js +12 -1
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +0 -1
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-mover/button.js +1 -1
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +1 -1
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +2 -2
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-patterns-paging/index.js +5 -7
- package/build-module/components/block-patterns-paging/index.js.map +1 -1
- package/build-module/components/block-quick-navigation/index.js +20 -17
- package/build-module/components/block-quick-navigation/index.js.map +1 -1
- package/build-module/components/block-rename/modal.js +5 -13
- package/build-module/components/block-rename/modal.js.map +1 -1
- package/build-module/components/block-toolbar/shuffle.js +1 -0
- package/build-module/components/block-toolbar/shuffle.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +10 -61
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js +9 -2
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
- package/build-module/components/block-tools/index.js +14 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +4 -2
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-mode-inserters.js +5 -4
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-popover.js +48 -0
- package/build-module/components/block-tools/zoom-out-popover.js.map +1 -0
- package/build-module/components/block-tools/zoom-out-toolbar.js +131 -0
- package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -0
- package/build-module/components/button-block-appender/index.js +3 -1
- package/build-module/components/button-block-appender/index.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +27 -19
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +11 -3
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/dimensions-tool/index.js +6 -4
- package/build-module/components/dimensions-tool/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +28 -63
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +181 -119
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +3 -2
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +3 -2
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +3 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +3 -2
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +8 -0
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js +3 -2
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +52 -14
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +48 -0
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +23 -8
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +15 -6
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/grid/grid-item-movers.js +11 -14
- package/build-module/components/grid/grid-item-movers.js.map +1 -1
- package/build-module/components/grid/grid-item-resizer.js +2 -2
- package/build-module/components/grid/grid-item-resizer.js.map +1 -1
- package/build-module/components/grid/grid-visualizer.js +117 -37
- package/build-module/components/grid/grid-visualizer.js.map +1 -1
- package/build-module/components/grid/use-grid-layout-sync.js +29 -22
- package/build-module/components/grid/use-grid-layout-sync.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/pattern-category-preview-panel.js +1 -19
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
- package/build-module/components/inserter/menu.js +26 -4
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +2 -1
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +3 -2
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +1 -1
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +19 -23
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +3 -1
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +5 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/tabbed-sidebar/index.js +60 -0
- package/build-module/components/tabbed-sidebar/index.js.map +1 -0
- package/build-module/components/url-popover/index.js +3 -0
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/hooks/background.js +26 -4
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-hooks.js +11 -17
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-style-variation.js +168 -4
- package/build-module/hooks/block-style-variation.js.map +1 -1
- package/build-module/hooks/duotone.js +16 -11
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/grid-visualizer.js +64 -0
- package/build-module/hooks/grid-visualizer.js.map +1 -0
- package/build-module/hooks/index.js +3 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout-child.js +39 -22
- package/build-module/hooks/layout-child.js.map +1 -1
- package/build-module/hooks/position.js +2 -9
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +16 -6
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/utils.js +2 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +44 -2
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/grid.js +90 -51
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/private-apis.js +8 -3
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/defaults.js +0 -2
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/defaults.native.js +0 -3
- package/build-module/store/defaults.native.js.map +1 -1
- package/build-module/store/private-keys.js +1 -0
- package/build-module/store/private-keys.js.map +1 -1
- package/build-module/utils/format-font-style.js +39 -0
- package/build-module/utils/format-font-style.js.map +1 -0
- package/build-module/utils/format-font-weight.js +62 -0
- package/build-module/utils/format-font-weight.js.map +1 -0
- package/build-module/utils/get-editor-region.js +28 -0
- package/build-module/utils/get-editor-region.js.map +1 -0
- package/build-module/utils/get-font-styles-and-weights.js +160 -0
- package/build-module/utils/get-font-styles-and-weights.js.map +1 -0
- package/build-module/utils/pasting.js +5 -13
- package/build-module/utils/pasting.js.map +1 -1
- package/build-style/content-rtl.css +1 -0
- package/build-style/content.css +1 -0
- package/build-style/style-rtl.css +207 -96
- package/build-style/style.css +207 -96
- package/package.json +32 -32
- package/src/components/block-breadcrumb/index.js +16 -1
- package/src/components/block-lock/toolbar.js +0 -1
- package/src/components/block-mover/button.js +1 -1
- package/src/components/block-mover/index.js +1 -1
- package/src/components/block-pattern-setup/setup-toolbar.js +2 -2
- package/src/components/block-patterns-paging/index.js +8 -11
- package/src/components/block-patterns-paging/style.scss +18 -0
- package/src/components/block-quick-navigation/index.js +21 -28
- package/src/components/block-rename/modal.js +2 -8
- package/src/components/block-switcher/test/index.js +6 -6
- package/src/components/block-toolbar/shuffle.js +1 -0
- package/src/components/block-toolbar/style.scss +1 -11
- package/src/components/block-tools/block-selection-button.js +11 -83
- package/src/components/block-tools/block-toolbar-breadcrumb.js +9 -4
- package/src/components/block-tools/index.js +21 -1
- package/src/components/block-tools/style.scss +15 -0
- package/src/components/block-tools/use-show-block-tools.js +14 -6
- package/src/components/block-tools/zoom-out-mode-inserters.js +5 -4
- package/src/components/block-tools/zoom-out-popover.js +49 -0
- package/src/components/block-tools/zoom-out-toolbar.js +140 -0
- package/src/components/button-block-appender/index.js +2 -1
- package/src/components/child-layout-control/index.js +41 -23
- package/src/components/date-format-picker/index.js +10 -1
- package/src/components/date-format-picker/style.scss +0 -9
- package/src/components/dimensions-tool/index.js +97 -89
- package/src/components/font-appearance-control/index.js +29 -83
- package/src/components/font-appearance-control/style.scss +3 -5
- package/src/components/global-styles/background-panel.js +249 -170
- package/src/components/global-styles/border-panel.js +3 -2
- package/src/components/global-styles/color-panel.js +3 -2
- package/src/components/global-styles/dimensions-panel.js +3 -2
- package/src/components/global-styles/filters-panel.js +3 -2
- package/src/components/global-styles/hooks.js +9 -0
- package/src/components/global-styles/image-settings-panel.js +3 -2
- package/src/components/global-styles/style.scss +105 -20
- package/src/components/global-styles/test/typography-utils.js +269 -0
- package/src/components/global-styles/typography-panel.js +49 -12
- package/src/components/global-styles/typography-utils.js +63 -0
- package/src/components/global-styles/use-global-styles-output.js +23 -8
- package/src/components/global-styles/utils.js +17 -6
- package/src/components/grid/grid-item-movers.js +11 -27
- package/src/components/grid/grid-item-resizer.js +3 -2
- package/src/components/grid/grid-visualizer.js +171 -54
- package/src/components/grid/style.scss +43 -8
- package/src/components/grid/use-grid-layout-sync.js +31 -28
- package/src/components/iframe/content.scss +1 -0
- package/src/components/inner-blocks/index.js +2 -1
- package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -16
- package/src/components/inserter/menu.js +47 -13
- package/src/components/inserter/quick-inserter.js +6 -1
- package/src/components/inserter/style.scss +1 -49
- package/src/components/inspector-controls/block-support-tools-panel.js +3 -3
- package/src/components/link-control/link-preview.js +1 -1
- package/src/components/media-placeholder/index.js +22 -32
- package/src/components/navigable-toolbar/index.js +3 -1
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +6 -1
- package/src/components/tabbed-sidebar/README.md +76 -0
- package/src/components/tabbed-sidebar/index.js +70 -0
- package/src/components/tabbed-sidebar/style.scss +53 -0
- package/src/components/url-popover/index.js +3 -0
- package/src/hooks/background.js +25 -10
- package/src/hooks/block-hooks.js +9 -16
- package/src/hooks/block-style-variation.js +202 -3
- package/src/hooks/duotone.js +16 -12
- package/src/hooks/grid-visualizer.js +64 -0
- package/src/hooks/index.js +3 -0
- package/src/hooks/layout-child.js +53 -37
- package/src/hooks/position.js +3 -10
- package/src/hooks/test/get-variation-styles-with-ref-values.js +91 -0
- package/src/hooks/use-bindings-attributes.js +18 -4
- package/src/hooks/utils.js +2 -0
- package/src/layouts/constrained.js +43 -2
- package/src/layouts/grid.js +146 -51
- package/src/private-apis.js +12 -1
- package/src/store/defaults.js +0 -2
- package/src/store/defaults.native.js +0 -3
- package/src/store/private-keys.js +1 -0
- package/src/style.scss +1 -1
- package/src/utils/format-font-style.js +40 -0
- package/src/utils/format-font-weight.js +63 -0
- package/src/utils/get-editor-region.js +31 -0
- package/src/utils/get-font-styles-and-weights.js +191 -0
- package/src/utils/pasting.js +5 -12
- package/src/utils/test/format-font-style.js +34 -0
- package/src/utils/test/format-font-weight.js +66 -0
- package/src/utils/test/get-font-styles-and-weights.js +513 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/hooks/position.scss +0 -18
|
@@ -11,7 +11,7 @@ import { __, _x } from '@wordpress/i18n';
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
|
-
import {
|
|
14
|
+
import { useToolsPanelDropdownMenuProps } from './utils';
|
|
15
15
|
|
|
16
16
|
export function useHasImageSettingsPanel( name, value, inheritedValue ) {
|
|
17
17
|
// Note: If lightbox `value` exists, that means it was
|
|
@@ -30,6 +30,7 @@ export default function ImageSettingsPanel( {
|
|
|
30
30
|
inheritedValue,
|
|
31
31
|
panelId,
|
|
32
32
|
} ) {
|
|
33
|
+
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
33
34
|
const resetLightbox = () => {
|
|
34
35
|
onChange( undefined );
|
|
35
36
|
};
|
|
@@ -52,7 +53,7 @@ export default function ImageSettingsPanel( {
|
|
|
52
53
|
label={ _x( 'Settings', 'Image settings' ) }
|
|
53
54
|
resetAll={ resetLightbox }
|
|
54
55
|
panelId={ panelId }
|
|
55
|
-
dropdownMenuProps={
|
|
56
|
+
dropdownMenuProps={ dropdownMenuProps }
|
|
56
57
|
>
|
|
57
58
|
<ToolsPanelItem
|
|
58
59
|
// We use the `userSettings` prop instead of `settings`, because `settings`
|
|
@@ -71,20 +71,55 @@
|
|
|
71
71
|
direction: ltr;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
|
|
74
75
|
.block-editor-global-styles-background-panel__inspector-media-replace-container {
|
|
75
|
-
|
|
76
|
+
border: 1px solid $gray-300;
|
|
77
|
+
border-radius: 2px;
|
|
78
|
+
// Full width. ToolsPanel lays out children in a grid.
|
|
79
|
+
grid-column: 1 / -1;
|
|
80
|
+
|
|
81
|
+
&.is-open {
|
|
82
|
+
background-color: $gray-100;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.block-editor-global-styles-background-panel__image-tools-panel-item {
|
|
86
|
+
flex-grow: 1;
|
|
87
|
+
border: 0;
|
|
88
|
+
.components-dropdown {
|
|
89
|
+
display: block;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.block-editor-global-styles-background-panel__inspector-preview-inner {
|
|
94
|
+
height: 100%;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.components-dropdown {
|
|
98
|
+
display: block;
|
|
99
|
+
height: 36px;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.block-editor-global-styles-background-panel__image-tools-panel-item {
|
|
104
|
+
border: 1px solid $gray-300;
|
|
105
|
+
border-radius: 2px;
|
|
106
|
+
// Full width. ToolsPanel lays out children in a grid.
|
|
107
|
+
grid-column: 1 / -1;
|
|
76
108
|
// Since there is no option to skip rendering the drag'n'drop icon in drop
|
|
77
109
|
// zone, we hide it for now.
|
|
78
110
|
.components-drop-zone__content-icon {
|
|
79
111
|
display: none;
|
|
80
112
|
}
|
|
81
113
|
|
|
114
|
+
.components-dropdown {
|
|
115
|
+
display: block;
|
|
116
|
+
height: 36px;
|
|
117
|
+
}
|
|
118
|
+
|
|
82
119
|
button.components-button {
|
|
83
120
|
color: $gray-900;
|
|
84
|
-
box-shadow: inset 0 0 0 $border-width $gray-400;
|
|
85
121
|
width: 100%;
|
|
86
122
|
display: block;
|
|
87
|
-
height: $grid-unit-50;
|
|
88
123
|
|
|
89
124
|
&:hover {
|
|
90
125
|
color: var(--wp-admin-theme-color);
|
|
@@ -94,28 +129,37 @@
|
|
|
94
129
|
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
95
130
|
}
|
|
96
131
|
}
|
|
132
|
+
}
|
|
97
133
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
134
|
+
.block-editor-global-styles-background-panel__image-preview-content,
|
|
135
|
+
.block-editor-global-styles-background-panel__dropdown-toggle {
|
|
136
|
+
height: 100%;
|
|
137
|
+
width: 100%;
|
|
138
|
+
padding-left: $grid-unit-15;
|
|
139
|
+
}
|
|
102
140
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
141
|
+
.block-editor-global-styles-background-panel__dropdown-toggle {
|
|
142
|
+
cursor: pointer;
|
|
143
|
+
background: transparent;
|
|
144
|
+
border: none;
|
|
145
|
+
}
|
|
107
146
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
147
|
+
.block-editor-global-styles-background-panel__inspector-media-replace-title {
|
|
148
|
+
word-break: break-all;
|
|
149
|
+
// The Button component is white-space: nowrap, and that won't work with line-clamp.
|
|
150
|
+
white-space: normal;
|
|
151
|
+
|
|
152
|
+
// Without this, the ellipsis can sometimes be partially hidden by the Button padding.
|
|
153
|
+
text-align: start;
|
|
154
|
+
text-align-last: center;
|
|
111
155
|
}
|
|
112
156
|
|
|
113
|
-
.block-editor-global-styles-background-panel__inspector-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
157
|
+
.block-editor-global-styles-background-panel__inspector-preview-inner {
|
|
158
|
+
.block-editor-global-styles-background-panel__inspector-image-indicator-wrapper {
|
|
159
|
+
width: 20px;
|
|
160
|
+
height: 20px;
|
|
161
|
+
min-width: auto;
|
|
162
|
+
}
|
|
119
163
|
}
|
|
120
164
|
|
|
121
165
|
.block-editor-global-styles-background-panel__inspector-image-indicator {
|
|
@@ -141,3 +185,44 @@
|
|
|
141
185
|
box-sizing: inherit;
|
|
142
186
|
}
|
|
143
187
|
|
|
188
|
+
.block-editor-global-styles-background-panel__dropdown-content-wrapper {
|
|
189
|
+
min-width: 260px;
|
|
190
|
+
overflow-x: hidden;
|
|
191
|
+
.components-base-control__help,
|
|
192
|
+
.components-toggle-control {
|
|
193
|
+
margin-bottom: 0;
|
|
194
|
+
}
|
|
195
|
+
.components-focal-point-picker-wrapper {
|
|
196
|
+
background-color: $gray-100;
|
|
197
|
+
width: 100%;
|
|
198
|
+
border-radius: $radius-block-ui;
|
|
199
|
+
border: $border-width solid $gray-300;
|
|
200
|
+
}
|
|
201
|
+
.components-focal-point-picker__media--image {
|
|
202
|
+
max-height: 180px;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.block-editor-global-styles-background-panel__hidden-tools-panel-item {
|
|
207
|
+
height: 0;
|
|
208
|
+
width: 0;
|
|
209
|
+
position: absolute;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Push control panel into the background when the media modal is open.
|
|
213
|
+
.modal-open .block-editor-global-styles-background-panel__popover {
|
|
214
|
+
z-index: z-index(".block-editor-global-styles-background-panel__popover");
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.block-editor-global-styles-background-panel__media-replace-popover {
|
|
218
|
+
.components-popover__content {
|
|
219
|
+
// width of block-editor-global-styles-background-panel__dropdown-content-wrapper minus padding.
|
|
220
|
+
width: 226px;
|
|
221
|
+
}
|
|
222
|
+
.components-button {
|
|
223
|
+
padding: 0 $grid-unit-10;
|
|
224
|
+
}
|
|
225
|
+
.components-button .components-menu-items__item-icon.has-icon-right {
|
|
226
|
+
margin-left: $grid-unit-30 - $grid-unit-10;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
import {
|
|
5
5
|
getTypographyFontSizeValue,
|
|
6
6
|
getFluidTypographyOptionsFromSettings,
|
|
7
|
+
getMergedFontFamiliesAndFontFamilyFaces,
|
|
8
|
+
findNearestFontWeight,
|
|
7
9
|
} from '../typography-utils';
|
|
8
10
|
|
|
9
11
|
describe( 'typography utils', () => {
|
|
@@ -682,6 +684,273 @@ describe( 'typography utils', () => {
|
|
|
682
684
|
} );
|
|
683
685
|
} );
|
|
684
686
|
|
|
687
|
+
describe( 'getMergedFontFamiliesAndFontFamilyFaces', () => {
|
|
688
|
+
[
|
|
689
|
+
{
|
|
690
|
+
message:
|
|
691
|
+
'should return empty arrays when settings and fontFamily are empty',
|
|
692
|
+
settings: {},
|
|
693
|
+
fontFamily: '',
|
|
694
|
+
expected: {
|
|
695
|
+
fontFamilies: [],
|
|
696
|
+
fontFamilyFaces: [],
|
|
697
|
+
},
|
|
698
|
+
},
|
|
699
|
+
|
|
700
|
+
{
|
|
701
|
+
message:
|
|
702
|
+
'should return empty arrays when only settings is `undefined`',
|
|
703
|
+
settings: undefined,
|
|
704
|
+
fontFamily: 'ABeeZee, sans-serif',
|
|
705
|
+
expected: {
|
|
706
|
+
fontFamilies: [],
|
|
707
|
+
fontFamilyFaces: [],
|
|
708
|
+
},
|
|
709
|
+
},
|
|
710
|
+
|
|
711
|
+
{
|
|
712
|
+
message:
|
|
713
|
+
'should return fontFamilies array and an empty fontFamilyFaces array when fontfamily is empty',
|
|
714
|
+
settings: {
|
|
715
|
+
typography: {
|
|
716
|
+
fontFamilies: {
|
|
717
|
+
custom: [
|
|
718
|
+
{
|
|
719
|
+
name: 'ABeeZee',
|
|
720
|
+
slug: 'abeezee',
|
|
721
|
+
fontFamily: 'ABeeZee, sans-serif',
|
|
722
|
+
fontFace: [
|
|
723
|
+
{
|
|
724
|
+
src: 'http://www.wordpress.org/wp-content/uploads/fonts/esDT31xSG-6AGleN2tCkkJUCGpG-GQ.woff2',
|
|
725
|
+
fontWeight: '400',
|
|
726
|
+
fontStyle: 'italic',
|
|
727
|
+
fontFamily: 'ABeeZee',
|
|
728
|
+
},
|
|
729
|
+
],
|
|
730
|
+
},
|
|
731
|
+
],
|
|
732
|
+
},
|
|
733
|
+
},
|
|
734
|
+
},
|
|
735
|
+
fontFamily: '',
|
|
736
|
+
expected: {
|
|
737
|
+
fontFamilies: [
|
|
738
|
+
{
|
|
739
|
+
fontFace: [
|
|
740
|
+
{
|
|
741
|
+
fontFamily: 'ABeeZee',
|
|
742
|
+
fontStyle: 'italic',
|
|
743
|
+
fontWeight: '400',
|
|
744
|
+
src: 'http://www.wordpress.org/wp-content/uploads/fonts/esDT31xSG-6AGleN2tCkkJUCGpG-GQ.woff2',
|
|
745
|
+
},
|
|
746
|
+
],
|
|
747
|
+
fontFamily: 'ABeeZee, sans-serif',
|
|
748
|
+
name: 'ABeeZee',
|
|
749
|
+
slug: 'abeezee',
|
|
750
|
+
},
|
|
751
|
+
],
|
|
752
|
+
fontFamilyFaces: [],
|
|
753
|
+
},
|
|
754
|
+
},
|
|
755
|
+
|
|
756
|
+
{
|
|
757
|
+
message:
|
|
758
|
+
'should return font families and font faces when both settings and fontFamily are defined',
|
|
759
|
+
settings: {
|
|
760
|
+
typography: {
|
|
761
|
+
fontFamilies: {
|
|
762
|
+
theme: [
|
|
763
|
+
{
|
|
764
|
+
fontFace: [
|
|
765
|
+
{
|
|
766
|
+
fontFamily: 'PT Sans',
|
|
767
|
+
fontStyle: 'normal',
|
|
768
|
+
fontWeight: '400',
|
|
769
|
+
src: [
|
|
770
|
+
'file:./assets/fonts/pt-sans_normal_400.ttf',
|
|
771
|
+
],
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
fontFamily: 'PT Sans',
|
|
775
|
+
fontStyle: 'normal',
|
|
776
|
+
fontWeight: '700',
|
|
777
|
+
src: [
|
|
778
|
+
'file:./assets/fonts/pt-sans_normal_700.ttf',
|
|
779
|
+
],
|
|
780
|
+
},
|
|
781
|
+
{
|
|
782
|
+
fontFamily: 'PT Sans',
|
|
783
|
+
fontStyle: 'italic',
|
|
784
|
+
fontWeight: '400',
|
|
785
|
+
src: [
|
|
786
|
+
'file:./assets/fonts/pt-sans_italic_400.ttf',
|
|
787
|
+
],
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
fontFamily: 'PT Sans',
|
|
791
|
+
fontStyle: 'italic',
|
|
792
|
+
fontWeight: '700',
|
|
793
|
+
src: [
|
|
794
|
+
'file:./assets/fonts/pt-sans_italic_700.ttf',
|
|
795
|
+
],
|
|
796
|
+
},
|
|
797
|
+
],
|
|
798
|
+
fontFamily: 'PT Sans',
|
|
799
|
+
name: 'PT Sans',
|
|
800
|
+
slug: 'pt-sans',
|
|
801
|
+
},
|
|
802
|
+
],
|
|
803
|
+
custom: [
|
|
804
|
+
{
|
|
805
|
+
name: 'ABeeZee',
|
|
806
|
+
slug: 'abeezee',
|
|
807
|
+
fontFamily: 'ABeeZee, sans-serif',
|
|
808
|
+
fontFace: [
|
|
809
|
+
{
|
|
810
|
+
src: 'http://www.wordpress.org/wp-content/uploads/fonts/esDT31xSG-6AGleN2tCkkJUCGpG-GQ.woff2',
|
|
811
|
+
fontWeight: '400',
|
|
812
|
+
fontStyle: 'italic',
|
|
813
|
+
fontFamily: 'ABeeZee',
|
|
814
|
+
},
|
|
815
|
+
],
|
|
816
|
+
},
|
|
817
|
+
],
|
|
818
|
+
},
|
|
819
|
+
},
|
|
820
|
+
},
|
|
821
|
+
fontFamily: 'ABeeZee, sans-serif',
|
|
822
|
+
expected: {
|
|
823
|
+
fontFamilyFaces: [
|
|
824
|
+
{
|
|
825
|
+
fontFamily: 'ABeeZee',
|
|
826
|
+
fontStyle: 'italic',
|
|
827
|
+
fontWeight: '400',
|
|
828
|
+
src: 'http://www.wordpress.org/wp-content/uploads/fonts/esDT31xSG-6AGleN2tCkkJUCGpG-GQ.woff2',
|
|
829
|
+
},
|
|
830
|
+
],
|
|
831
|
+
fontFamilies: [
|
|
832
|
+
{
|
|
833
|
+
fontFace: [
|
|
834
|
+
{
|
|
835
|
+
fontFamily: 'PT Sans',
|
|
836
|
+
fontStyle: 'normal',
|
|
837
|
+
fontWeight: '400',
|
|
838
|
+
src: [
|
|
839
|
+
'file:./assets/fonts/pt-sans_normal_400.ttf',
|
|
840
|
+
],
|
|
841
|
+
},
|
|
842
|
+
{
|
|
843
|
+
fontFamily: 'PT Sans',
|
|
844
|
+
fontStyle: 'normal',
|
|
845
|
+
fontWeight: '700',
|
|
846
|
+
src: [
|
|
847
|
+
'file:./assets/fonts/pt-sans_normal_700.ttf',
|
|
848
|
+
],
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
fontFamily: 'PT Sans',
|
|
852
|
+
fontStyle: 'italic',
|
|
853
|
+
fontWeight: '400',
|
|
854
|
+
src: [
|
|
855
|
+
'file:./assets/fonts/pt-sans_italic_400.ttf',
|
|
856
|
+
],
|
|
857
|
+
},
|
|
858
|
+
{
|
|
859
|
+
fontFamily: 'PT Sans',
|
|
860
|
+
fontStyle: 'italic',
|
|
861
|
+
fontWeight: '700',
|
|
862
|
+
src: [
|
|
863
|
+
'file:./assets/fonts/pt-sans_italic_700.ttf',
|
|
864
|
+
],
|
|
865
|
+
},
|
|
866
|
+
],
|
|
867
|
+
fontFamily: 'PT Sans',
|
|
868
|
+
name: 'PT Sans',
|
|
869
|
+
slug: 'pt-sans',
|
|
870
|
+
},
|
|
871
|
+
{
|
|
872
|
+
fontFace: [
|
|
873
|
+
{
|
|
874
|
+
fontFamily: 'ABeeZee',
|
|
875
|
+
fontStyle: 'italic',
|
|
876
|
+
fontWeight: '400',
|
|
877
|
+
src: 'http://www.wordpress.org/wp-content/uploads/fonts/esDT31xSG-6AGleN2tCkkJUCGpG-GQ.woff2',
|
|
878
|
+
},
|
|
879
|
+
],
|
|
880
|
+
fontFamily: 'ABeeZee, sans-serif',
|
|
881
|
+
name: 'ABeeZee',
|
|
882
|
+
slug: 'abeezee',
|
|
883
|
+
},
|
|
884
|
+
],
|
|
885
|
+
},
|
|
886
|
+
},
|
|
887
|
+
].forEach( ( { message, settings, fontFamily, expected } ) => {
|
|
888
|
+
it( `${ message }`, () => {
|
|
889
|
+
expect(
|
|
890
|
+
getMergedFontFamiliesAndFontFamilyFaces(
|
|
891
|
+
settings,
|
|
892
|
+
fontFamily
|
|
893
|
+
)
|
|
894
|
+
).toEqual( expected );
|
|
895
|
+
} );
|
|
896
|
+
} );
|
|
897
|
+
} );
|
|
898
|
+
|
|
899
|
+
describe( 'findNearestFontWeight', () => {
|
|
900
|
+
[
|
|
901
|
+
{
|
|
902
|
+
message:
|
|
903
|
+
'should return empty string when newFontWeightValue is `undefined`',
|
|
904
|
+
availableFontWeights: undefined,
|
|
905
|
+
newFontWeightValue: undefined,
|
|
906
|
+
expected: '',
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
message:
|
|
910
|
+
'should return newFontWeightValue value when availableFontWeights is empty',
|
|
911
|
+
availableFontWeights: [],
|
|
912
|
+
newFontWeightValue: '300',
|
|
913
|
+
expected: '300',
|
|
914
|
+
},
|
|
915
|
+
{
|
|
916
|
+
message: 'should return correct nearest higher font weight',
|
|
917
|
+
availableFontWeights: [
|
|
918
|
+
{ name: 'Regular', value: '400' },
|
|
919
|
+
{ name: 'Bold', value: '700' },
|
|
920
|
+
{ name: 'Black', value: '900' },
|
|
921
|
+
],
|
|
922
|
+
newFontWeightValue: '300',
|
|
923
|
+
expected: '400',
|
|
924
|
+
},
|
|
925
|
+
{
|
|
926
|
+
message: 'should return correct nearest lower font weight',
|
|
927
|
+
availableFontWeights: [
|
|
928
|
+
{ name: 'Thin', value: '100' },
|
|
929
|
+
{ name: 'Light', value: '300' },
|
|
930
|
+
{ name: 'Regular', value: '400' },
|
|
931
|
+
],
|
|
932
|
+
newFontWeightValue: '900',
|
|
933
|
+
expected: '400',
|
|
934
|
+
},
|
|
935
|
+
].forEach(
|
|
936
|
+
( {
|
|
937
|
+
message,
|
|
938
|
+
availableFontWeights,
|
|
939
|
+
newFontWeightValue,
|
|
940
|
+
expected,
|
|
941
|
+
} ) => {
|
|
942
|
+
it( `${ message }`, () => {
|
|
943
|
+
expect(
|
|
944
|
+
findNearestFontWeight(
|
|
945
|
+
availableFontWeights,
|
|
946
|
+
newFontWeightValue
|
|
947
|
+
)
|
|
948
|
+
).toEqual( expected );
|
|
949
|
+
} );
|
|
950
|
+
}
|
|
951
|
+
);
|
|
952
|
+
} );
|
|
953
|
+
|
|
685
954
|
describe( 'typography utils', () => {
|
|
686
955
|
[
|
|
687
956
|
{
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
9
9
|
} from '@wordpress/components';
|
|
10
10
|
import { __ } from '@wordpress/i18n';
|
|
11
|
-
import { useCallback, useMemo } from '@wordpress/element';
|
|
11
|
+
import { useCallback, useMemo, useEffect } from '@wordpress/element';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Internal dependencies
|
|
@@ -21,8 +21,13 @@ import TextAlignmentControl from '../text-alignment-control';
|
|
|
21
21
|
import TextTransformControl from '../text-transform-control';
|
|
22
22
|
import TextDecorationControl from '../text-decoration-control';
|
|
23
23
|
import WritingModeControl from '../writing-mode-control';
|
|
24
|
-
import { getValueFromVariable,
|
|
24
|
+
import { getValueFromVariable, useToolsPanelDropdownMenuProps } from './utils';
|
|
25
25
|
import { setImmutably } from '../../utils/object';
|
|
26
|
+
import {
|
|
27
|
+
getMergedFontFamiliesAndFontFamilyFaces,
|
|
28
|
+
findNearestFontWeight,
|
|
29
|
+
} from './typography-utils';
|
|
30
|
+
import { getFontStylesAndWeights } from '../../utils/get-font-styles-and-weights';
|
|
26
31
|
|
|
27
32
|
const MIN_TEXT_COLUMNS = 1;
|
|
28
33
|
const MAX_TEXT_COLUMNS = 6;
|
|
@@ -135,6 +140,7 @@ function TypographyToolsPanel( {
|
|
|
135
140
|
panelId,
|
|
136
141
|
children,
|
|
137
142
|
} ) {
|
|
143
|
+
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
138
144
|
const resetAll = () => {
|
|
139
145
|
const updatedValue = resetAllFilter( value );
|
|
140
146
|
onChange( updatedValue );
|
|
@@ -145,7 +151,7 @@ function TypographyToolsPanel( {
|
|
|
145
151
|
label={ __( 'Typography' ) }
|
|
146
152
|
resetAll={ resetAll }
|
|
147
153
|
panelId={ panelId }
|
|
148
|
-
dropdownMenuProps={
|
|
154
|
+
dropdownMenuProps={ dropdownMenuProps }
|
|
149
155
|
>
|
|
150
156
|
{ children }
|
|
151
157
|
</ToolsPanel>
|
|
@@ -179,15 +185,13 @@ export default function TypographyPanel( {
|
|
|
179
185
|
|
|
180
186
|
// Font Family
|
|
181
187
|
const hasFontFamilyEnabled = useHasFontFamilyControl( settings );
|
|
182
|
-
const fontFamilies = settings?.typography?.fontFamilies;
|
|
183
|
-
const mergedFontFamilies = useMemo( () => {
|
|
184
|
-
return [ 'default', 'theme', 'custom' ].flatMap(
|
|
185
|
-
( key ) => fontFamilies?.[ key ] ?? []
|
|
186
|
-
);
|
|
187
|
-
}, [ fontFamilies ] );
|
|
188
188
|
const fontFamily = decodeValue( inheritedValue?.typography?.fontFamily );
|
|
189
|
+
const { fontFamilies, fontFamilyFaces } = useMemo( () => {
|
|
190
|
+
return getMergedFontFamiliesAndFontFamilyFaces( settings, fontFamily );
|
|
191
|
+
}, [ settings, fontFamily ] );
|
|
192
|
+
|
|
189
193
|
const setFontFamily = ( newValue ) => {
|
|
190
|
-
const slug =
|
|
194
|
+
const slug = fontFamilies?.find(
|
|
191
195
|
( { fontFamily: f } ) => f === newValue
|
|
192
196
|
)?.slug;
|
|
193
197
|
onChange(
|
|
@@ -251,6 +255,39 @@ export default function TypographyPanel( {
|
|
|
251
255
|
setFontAppearance( {} );
|
|
252
256
|
};
|
|
253
257
|
|
|
258
|
+
// Check if previous font style and weight values are available in the new font family
|
|
259
|
+
useEffect( () => {
|
|
260
|
+
const { fontStyles, fontWeights, isSystemFont } =
|
|
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 ) {
|
|
271
|
+
setFontAppearance( {
|
|
272
|
+
fontStyle,
|
|
273
|
+
fontWeight: findNearestFontWeight( fontWeights, fontWeight ),
|
|
274
|
+
} );
|
|
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 ) {
|
|
287
|
+
resetFontAppearance();
|
|
288
|
+
}
|
|
289
|
+
}, [ fontFamily ] );
|
|
290
|
+
|
|
254
291
|
// Line Height
|
|
255
292
|
const hasLineHeightEnabled = useHasLineHeightControl( settings );
|
|
256
293
|
const lineHeight = decodeValue( inheritedValue?.typography?.lineHeight );
|
|
@@ -386,7 +423,7 @@ export default function TypographyPanel( {
|
|
|
386
423
|
panelId={ panelId }
|
|
387
424
|
>
|
|
388
425
|
<FontFamilyControl
|
|
389
|
-
fontFamilies={
|
|
426
|
+
fontFamilies={ fontFamilies }
|
|
390
427
|
value={ fontFamily }
|
|
391
428
|
onChange={ setFontFamily }
|
|
392
429
|
size="__unstable-large"
|
|
@@ -430,8 +467,8 @@ export default function TypographyPanel( {
|
|
|
430
467
|
onChange={ setFontAppearance }
|
|
431
468
|
hasFontStyles={ hasFontStyles }
|
|
432
469
|
hasFontWeights={ hasFontWeights }
|
|
470
|
+
fontFamilyFaces={ fontFamilyFaces }
|
|
433
471
|
size="__unstable-large"
|
|
434
|
-
__nextHasNoMarginBottom
|
|
435
472
|
/>
|
|
436
473
|
</ToolsPanelItem>
|
|
437
474
|
) }
|
|
@@ -122,3 +122,66 @@ export function getFluidTypographyOptionsFromSettings( settings ) {
|
|
|
122
122
|
fluid: typographySettings?.fluid,
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Returns an object of merged font families and the font faces from the selected font family
|
|
128
|
+
* based on the theme.json settings object and the currently selected font family.
|
|
129
|
+
*
|
|
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
|
|
133
|
+
*/
|
|
134
|
+
export function getMergedFontFamiliesAndFontFamilyFaces(
|
|
135
|
+
settings,
|
|
136
|
+
selectedFontFamily
|
|
137
|
+
) {
|
|
138
|
+
const fontFamiliesFromSettings = settings?.typography?.fontFamilies;
|
|
139
|
+
|
|
140
|
+
const fontFamilies = [ 'default', 'theme', 'custom' ].flatMap(
|
|
141
|
+
( key ) => fontFamiliesFromSettings?.[ key ] ?? []
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
const fontFamilyFaces =
|
|
145
|
+
fontFamilies.find(
|
|
146
|
+
( family ) => family.fontFamily === selectedFontFamily
|
|
147
|
+
)?.fontFace ?? [];
|
|
148
|
+
|
|
149
|
+
return { fontFamilies, fontFamilyFaces };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Returns the nearest font weight value from the available font weight list based on the new font weight.
|
|
154
|
+
* The nearest font weight is the one with the smallest difference from the new font weight.
|
|
155
|
+
*
|
|
156
|
+
* @param {Array} availableFontWeights Array of available font weights
|
|
157
|
+
* @param {string} newFontWeightValue New font weight value
|
|
158
|
+
* @return {string} Nearest font weight
|
|
159
|
+
*/
|
|
160
|
+
|
|
161
|
+
export function findNearestFontWeight(
|
|
162
|
+
availableFontWeights,
|
|
163
|
+
newFontWeightValue
|
|
164
|
+
) {
|
|
165
|
+
if ( ! newFontWeightValue || typeof newFontWeightValue !== 'string' ) {
|
|
166
|
+
return '';
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if ( ! availableFontWeights || availableFontWeights.length === 0 ) {
|
|
170
|
+
return newFontWeightValue;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const nearestFontWeight = availableFontWeights?.reduce(
|
|
174
|
+
( nearest, { value: fw } ) => {
|
|
175
|
+
const currentDiff = Math.abs(
|
|
176
|
+
parseInt( fw ) - parseInt( newFontWeightValue )
|
|
177
|
+
);
|
|
178
|
+
const nearestDiff = Math.abs(
|
|
179
|
+
parseInt( nearest ) - parseInt( newFontWeightValue )
|
|
180
|
+
);
|
|
181
|
+
return currentDiff < nearestDiff ? fw : nearest;
|
|
182
|
+
},
|
|
183
|
+
availableFontWeights[ 0 ]?.value
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
return nearestFontWeight;
|
|
187
|
+
}
|