@wordpress/block-editor 13.1.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 +21 -17
- package/README.md +1 -2
- package/build/components/block-breadcrumb/index.js +12 -1
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-lock/modal.js +67 -67
- package/build/components/block-lock/modal.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 +12 -6
- 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 +4 -1
- 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 +193 -127
- 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 +25 -9
- 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 +94 -0
- package/build/components/grid/grid-item-movers.js.map +1 -0
- package/build/components/{grid-visualizer → grid}/grid-item-resizer.js +18 -56
- package/build/components/grid/grid-item-resizer.js.map +1 -0
- package/build/components/grid/grid-visualizer.js +305 -0
- package/build/components/grid/grid-visualizer.js.map +1 -0
- package/build/components/{grid-visualizer → grid}/index.js +14 -0
- package/build/components/grid/index.js.map +1 -0
- package/build/components/grid/use-get-number-of-blocks-before-cell.js +40 -0
- package/build/components/grid/use-get-number-of-blocks-before-cell.js.map +1 -0
- package/build/components/grid/use-grid-layout-sync.js +169 -0
- package/build/components/grid/use-grid-layout-sync.js.map +1 -0
- package/build/components/grid/utils.js +145 -0
- package/build/components/grid/utils.js.map +1 -0
- package/build/components/image-editor/aspect-ratio-dropdown.js +0 -1
- package/build/components/image-editor/aspect-ratio-dropdown.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/rich-text/event-listeners/input-rules.js +1 -0
- package/build/components/rich-text/event-listeners/input-rules.js.map +1 -1
- package/build/components/rich-text/index.native.js +10 -4
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +14 -0
- package/build/components/rich-text/native/index.native.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 +195 -11
- 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 +65 -40
- 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 +5 -2
- 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 +92 -76
- package/build/layouts/grid.js.map +1 -1
- package/build/lock-unlock.js +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/private-apis.js +6 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +17 -1
- package/build/store/actions.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/modal.js +67 -67
- package/build-module/components/block-lock/modal.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 +12 -6
- 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 +4 -1
- 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 +194 -128
- 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 +25 -9
- 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 +87 -0
- package/build-module/components/grid/grid-item-movers.js.map +1 -0
- package/build-module/components/{grid-visualizer → grid}/grid-item-resizer.js +13 -51
- package/build-module/components/grid/grid-item-resizer.js.map +1 -0
- package/build-module/components/grid/grid-visualizer.js +297 -0
- package/build-module/components/grid/grid-visualizer.js.map +1 -0
- package/build-module/components/grid/index.js +5 -0
- package/build-module/components/grid/index.js.map +1 -0
- package/build-module/components/grid/use-get-number-of-blocks-before-cell.js +33 -0
- package/build-module/components/grid/use-get-number-of-blocks-before-cell.js.map +1 -0
- package/build-module/components/grid/use-grid-layout-sync.js +162 -0
- package/build-module/components/grid/use-grid-layout-sync.js.map +1 -0
- package/build-module/components/grid/utils.js +131 -0
- package/build-module/components/grid/utils.js.map +1 -0
- package/build-module/components/image-editor/aspect-ratio-dropdown.js +0 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.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/rich-text/event-listeners/input-rules.js +1 -1
- package/build-module/components/rich-text/event-listeners/input-rules.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +11 -5
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +14 -0
- package/build-module/components/rich-text/native/index.native.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 +193 -11
- 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 +63 -38
- 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 +5 -2
- 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 +92 -76
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/lock-unlock.js +1 -1
- package/build-module/lock-unlock.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/actions.js +17 -1
- package/build-module/store/actions.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 +238 -106
- package/build-style/style.css +238 -106
- package/package.json +32 -32
- package/src/components/block-breadcrumb/index.js +16 -1
- package/src/components/block-lock/modal.js +95 -82
- package/src/components/block-lock/style.scss +11 -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 +37 -24
- 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 +4 -1
- 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 +243 -160
- 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/test/use-global-styles-output.js +38 -3
- 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 +25 -9
- package/src/components/global-styles/utils.js +17 -6
- package/src/components/grid/grid-item-movers.js +112 -0
- package/src/components/{grid-visualizer → grid}/grid-item-resizer.js +15 -52
- package/src/components/grid/grid-visualizer.js +384 -0
- package/src/components/grid/index.js +4 -0
- package/src/components/grid/style.scss +98 -0
- package/src/components/grid/use-get-number-of-blocks-before-cell.js +30 -0
- package/src/components/grid/use-grid-layout-sync.js +170 -0
- package/src/components/grid/utils.js +178 -0
- package/src/components/iframe/content.scss +1 -0
- package/src/components/image-editor/aspect-ratio-dropdown.js +0 -1
- package/src/components/inner-blocks/index.js +4 -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/rich-text/event-listeners/input-rules.js +1 -1
- package/src/components/rich-text/index.native.js +10 -8
- package/src/components/rich-text/native/index.native.js +17 -0
- 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 +226 -9
- 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 +75 -39
- 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 +5 -1
- package/src/layouts/constrained.js +43 -2
- package/src/layouts/grid.js +175 -88
- package/src/lock-unlock.js +1 -1
- package/src/private-apis.js +12 -1
- package/src/store/actions.js +21 -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 +2 -2
- 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/build/components/grid-visualizer/grid-item-resizer.js.map +0 -1
- package/build/components/grid-visualizer/grid-visualizer.js +0 -92
- package/build/components/grid-visualizer/grid-visualizer.js.map +0 -1
- package/build/components/grid-visualizer/index.js.map +0 -1
- package/build/components/grid-visualizer/utils.js +0 -10
- package/build/components/grid-visualizer/utils.js.map +0 -1
- package/build-module/components/grid-visualizer/grid-item-resizer.js.map +0 -1
- package/build-module/components/grid-visualizer/grid-visualizer.js +0 -84
- package/build-module/components/grid-visualizer/grid-visualizer.js.map +0 -1
- package/build-module/components/grid-visualizer/index.js +0 -3
- package/build-module/components/grid-visualizer/index.js.map +0 -1
- package/build-module/components/grid-visualizer/utils.js +0 -4
- package/build-module/components/grid-visualizer/utils.js.map +0 -1
- package/src/components/grid-visualizer/grid-visualizer.js +0 -101
- package/src/components/grid-visualizer/index.js +0 -2
- package/src/components/grid-visualizer/style.scss +0 -34
- package/src/components/grid-visualizer/utils.js +0 -5
- package/src/hooks/position.scss +0 -18
- /package/src/components/font-sizes/{README.MD → README.md} +0 -0
|
@@ -12,8 +12,15 @@ import {
|
|
|
12
12
|
Flex,
|
|
13
13
|
FlexItem,
|
|
14
14
|
} from '@wordpress/components';
|
|
15
|
-
import { __ } from '@wordpress/i18n';
|
|
15
|
+
import { __, _x } from '@wordpress/i18n';
|
|
16
16
|
import { useEffect } from '@wordpress/element';
|
|
17
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Internal dependencies
|
|
21
|
+
*/
|
|
22
|
+
import { useGetNumberOfBlocksBeforeCell } from '../grid/use-get-number-of-blocks-before-cell';
|
|
23
|
+
import { store as blockEditorStore } from '../../store';
|
|
17
24
|
|
|
18
25
|
function helpText( selfStretch, parentLayout ) {
|
|
19
26
|
const { orientation = 'horizontal' } = parentLayout;
|
|
@@ -48,21 +55,46 @@ export default function ChildLayoutControl( {
|
|
|
48
55
|
isShownByDefault,
|
|
49
56
|
panelId,
|
|
50
57
|
} ) {
|
|
51
|
-
const {
|
|
52
|
-
selfStretch,
|
|
53
|
-
flexSize,
|
|
54
|
-
columnStart,
|
|
55
|
-
rowStart,
|
|
56
|
-
columnSpan,
|
|
57
|
-
rowSpan,
|
|
58
|
-
} = childLayout;
|
|
59
58
|
const {
|
|
60
59
|
type: parentType,
|
|
61
60
|
default: { type: defaultParentType = 'default' } = {},
|
|
62
|
-
orientation = 'horizontal',
|
|
63
61
|
} = parentLayout ?? {};
|
|
64
62
|
const parentLayoutType = parentType || defaultParentType;
|
|
65
63
|
|
|
64
|
+
if ( parentLayoutType === 'flex' ) {
|
|
65
|
+
return (
|
|
66
|
+
<FlexControls
|
|
67
|
+
childLayout={ childLayout }
|
|
68
|
+
onChange={ onChange }
|
|
69
|
+
parentLayout={ parentLayout }
|
|
70
|
+
isShownByDefault={ isShownByDefault }
|
|
71
|
+
panelId={ panelId }
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
} else if ( parentLayoutType === 'grid' ) {
|
|
75
|
+
return (
|
|
76
|
+
<GridControls
|
|
77
|
+
childLayout={ childLayout }
|
|
78
|
+
onChange={ onChange }
|
|
79
|
+
parentLayout={ parentLayout }
|
|
80
|
+
isShownByDefault={ isShownByDefault }
|
|
81
|
+
panelId={ panelId }
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function FlexControls( {
|
|
90
|
+
childLayout,
|
|
91
|
+
onChange,
|
|
92
|
+
parentLayout,
|
|
93
|
+
isShownByDefault,
|
|
94
|
+
panelId,
|
|
95
|
+
} ) {
|
|
96
|
+
const { selfStretch, flexSize } = childLayout;
|
|
97
|
+
const { orientation = 'horizontal' } = parentLayout ?? {};
|
|
66
98
|
const hasFlexValue = () => !! selfStretch;
|
|
67
99
|
const flexResetLabel =
|
|
68
100
|
orientation === 'horizontal' ? __( 'Width' ) : __( 'Height' );
|
|
@@ -73,6 +105,104 @@ export default function ChildLayoutControl( {
|
|
|
73
105
|
} );
|
|
74
106
|
};
|
|
75
107
|
|
|
108
|
+
useEffect( () => {
|
|
109
|
+
if ( selfStretch === 'fixed' && ! flexSize ) {
|
|
110
|
+
onChange( {
|
|
111
|
+
...childLayout,
|
|
112
|
+
selfStretch: 'fit',
|
|
113
|
+
} );
|
|
114
|
+
}
|
|
115
|
+
}, [] );
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<VStack
|
|
119
|
+
as={ ToolsPanelItem }
|
|
120
|
+
spacing={ 2 }
|
|
121
|
+
hasValue={ hasFlexValue }
|
|
122
|
+
label={ flexResetLabel }
|
|
123
|
+
onDeselect={ resetFlex }
|
|
124
|
+
isShownByDefault={ isShownByDefault }
|
|
125
|
+
panelId={ panelId }
|
|
126
|
+
>
|
|
127
|
+
<ToggleGroupControl
|
|
128
|
+
__nextHasNoMarginBottom
|
|
129
|
+
size="__unstable-large"
|
|
130
|
+
label={ childLayoutOrientation( parentLayout ) }
|
|
131
|
+
value={ selfStretch || 'fit' }
|
|
132
|
+
help={ helpText( selfStretch, parentLayout ) }
|
|
133
|
+
onChange={ ( value ) => {
|
|
134
|
+
const newFlexSize = value !== 'fixed' ? null : flexSize;
|
|
135
|
+
onChange( {
|
|
136
|
+
selfStretch: value,
|
|
137
|
+
flexSize: newFlexSize,
|
|
138
|
+
} );
|
|
139
|
+
} }
|
|
140
|
+
isBlock
|
|
141
|
+
>
|
|
142
|
+
<ToggleGroupControlOption
|
|
143
|
+
key="fit"
|
|
144
|
+
value="fit"
|
|
145
|
+
label={ _x(
|
|
146
|
+
'Fit',
|
|
147
|
+
'Intrinsic block width in flex layout'
|
|
148
|
+
) }
|
|
149
|
+
/>
|
|
150
|
+
<ToggleGroupControlOption
|
|
151
|
+
key="fill"
|
|
152
|
+
value="fill"
|
|
153
|
+
label={ _x(
|
|
154
|
+
'Grow',
|
|
155
|
+
'Block with expanding width in flex layout'
|
|
156
|
+
) }
|
|
157
|
+
/>
|
|
158
|
+
<ToggleGroupControlOption
|
|
159
|
+
key="fixed"
|
|
160
|
+
value="fixed"
|
|
161
|
+
label={ _x(
|
|
162
|
+
'Fixed',
|
|
163
|
+
'Block with fixed width in flex layout'
|
|
164
|
+
) }
|
|
165
|
+
/>
|
|
166
|
+
</ToggleGroupControl>
|
|
167
|
+
{ selfStretch === 'fixed' && (
|
|
168
|
+
<UnitControl
|
|
169
|
+
size="__unstable-large"
|
|
170
|
+
onChange={ ( value ) => {
|
|
171
|
+
onChange( {
|
|
172
|
+
selfStretch,
|
|
173
|
+
flexSize: value,
|
|
174
|
+
} );
|
|
175
|
+
} }
|
|
176
|
+
value={ flexSize }
|
|
177
|
+
/>
|
|
178
|
+
) }
|
|
179
|
+
</VStack>
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function childLayoutOrientation( parentLayout ) {
|
|
184
|
+
const { orientation = 'horizontal' } = parentLayout;
|
|
185
|
+
return orientation === 'horizontal' ? __( 'Width' ) : __( 'Height' );
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function GridControls( {
|
|
189
|
+
childLayout,
|
|
190
|
+
onChange,
|
|
191
|
+
parentLayout,
|
|
192
|
+
isShownByDefault,
|
|
193
|
+
panelId,
|
|
194
|
+
} ) {
|
|
195
|
+
const { columnStart, rowStart, columnSpan, rowSpan } = childLayout;
|
|
196
|
+
const { columnCount = 3, rowCount } = parentLayout ?? {};
|
|
197
|
+
const rootClientId = useSelect( ( select ) =>
|
|
198
|
+
select( blockEditorStore ).getBlockRootClientId( panelId )
|
|
199
|
+
);
|
|
200
|
+
const { moveBlocksToPosition, __unstableMarkNextChangeAsNotPersistent } =
|
|
201
|
+
useDispatch( blockEditorStore );
|
|
202
|
+
const getNumberOfBlocksBeforeCell = useGetNumberOfBlocksBeforeCell(
|
|
203
|
+
rootClientId,
|
|
204
|
+
columnCount
|
|
205
|
+
);
|
|
76
206
|
const hasStartValue = () => !! columnStart || !! rowStart;
|
|
77
207
|
const hasSpanValue = () => !! columnSpan || !! rowSpan;
|
|
78
208
|
const resetGridStarts = () => {
|
|
@@ -88,184 +218,137 @@ export default function ChildLayoutControl( {
|
|
|
88
218
|
} );
|
|
89
219
|
};
|
|
90
220
|
|
|
91
|
-
useEffect( () => {
|
|
92
|
-
if ( selfStretch === 'fixed' && ! flexSize ) {
|
|
93
|
-
onChange( {
|
|
94
|
-
...childLayout,
|
|
95
|
-
selfStretch: 'fit',
|
|
96
|
-
} );
|
|
97
|
-
}
|
|
98
|
-
}, [] );
|
|
99
|
-
|
|
100
221
|
return (
|
|
101
222
|
<>
|
|
102
|
-
|
|
103
|
-
|
|
223
|
+
<HStack
|
|
224
|
+
as={ ToolsPanelItem }
|
|
225
|
+
hasValue={ hasSpanValue }
|
|
226
|
+
label={ __( 'Grid span' ) }
|
|
227
|
+
onDeselect={ resetGridSpans }
|
|
228
|
+
isShownByDefault={ isShownByDefault }
|
|
229
|
+
panelId={ panelId }
|
|
230
|
+
>
|
|
231
|
+
<InputControl
|
|
232
|
+
size="__unstable-large"
|
|
233
|
+
label={ __( 'Column span' ) }
|
|
234
|
+
type="number"
|
|
235
|
+
onChange={ ( value ) => {
|
|
236
|
+
// Don't allow unsetting.
|
|
237
|
+
const newColumnSpan =
|
|
238
|
+
value === '' ? 1 : parseInt( value, 10 );
|
|
239
|
+
onChange( {
|
|
240
|
+
columnStart,
|
|
241
|
+
rowStart,
|
|
242
|
+
rowSpan,
|
|
243
|
+
columnSpan: newColumnSpan,
|
|
244
|
+
} );
|
|
245
|
+
} }
|
|
246
|
+
value={ columnSpan ?? 1 }
|
|
247
|
+
min={ 1 }
|
|
248
|
+
/>
|
|
249
|
+
<InputControl
|
|
250
|
+
size="__unstable-large"
|
|
251
|
+
label={ __( 'Row span' ) }
|
|
252
|
+
type="number"
|
|
253
|
+
onChange={ ( value ) => {
|
|
254
|
+
// Don't allow unsetting.
|
|
255
|
+
const newRowSpan =
|
|
256
|
+
value === '' ? 1 : parseInt( value, 10 );
|
|
257
|
+
onChange( {
|
|
258
|
+
columnStart,
|
|
259
|
+
rowStart,
|
|
260
|
+
columnSpan,
|
|
261
|
+
rowSpan: newRowSpan,
|
|
262
|
+
} );
|
|
263
|
+
} }
|
|
264
|
+
value={ rowSpan ?? 1 }
|
|
265
|
+
min={ 1 }
|
|
266
|
+
/>
|
|
267
|
+
</HStack>
|
|
268
|
+
{ window.__experimentalEnableGridInteractivity && columnCount && (
|
|
269
|
+
// Use Flex with an explicit width on the FlexItem instead of HStack to
|
|
270
|
+
// work around an issue in webkit where inputs with a max attribute are
|
|
271
|
+
// sized incorrectly.
|
|
272
|
+
<Flex
|
|
104
273
|
as={ ToolsPanelItem }
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
isShownByDefault={ isShownByDefault }
|
|
274
|
+
hasValue={ hasStartValue }
|
|
275
|
+
label={ __( 'Grid placement' ) }
|
|
276
|
+
onDeselect={ resetGridStarts }
|
|
277
|
+
isShownByDefault={ false }
|
|
110
278
|
panelId={ panelId }
|
|
111
279
|
>
|
|
112
|
-
<
|
|
113
|
-
__nextHasNoMarginBottom
|
|
114
|
-
size="__unstable-large"
|
|
115
|
-
label={ childLayoutOrientation( parentLayout ) }
|
|
116
|
-
value={ selfStretch || 'fit' }
|
|
117
|
-
help={ helpText( selfStretch, parentLayout ) }
|
|
118
|
-
onChange={ ( value ) => {
|
|
119
|
-
const newFlexSize =
|
|
120
|
-
value !== 'fixed' ? null : flexSize;
|
|
121
|
-
onChange( {
|
|
122
|
-
selfStretch: value,
|
|
123
|
-
flexSize: newFlexSize,
|
|
124
|
-
} );
|
|
125
|
-
} }
|
|
126
|
-
isBlock
|
|
127
|
-
>
|
|
128
|
-
<ToggleGroupControlOption
|
|
129
|
-
key="fit"
|
|
130
|
-
value="fit"
|
|
131
|
-
label={ __( 'Fit' ) }
|
|
132
|
-
/>
|
|
133
|
-
<ToggleGroupControlOption
|
|
134
|
-
key="fill"
|
|
135
|
-
value="fill"
|
|
136
|
-
label={ __( 'Fill' ) }
|
|
137
|
-
/>
|
|
138
|
-
<ToggleGroupControlOption
|
|
139
|
-
key="fixed"
|
|
140
|
-
value="fixed"
|
|
141
|
-
label={ __( 'Fixed' ) }
|
|
142
|
-
/>
|
|
143
|
-
</ToggleGroupControl>
|
|
144
|
-
{ selfStretch === 'fixed' && (
|
|
145
|
-
<UnitControl
|
|
146
|
-
size="__unstable-large"
|
|
147
|
-
onChange={ ( value ) => {
|
|
148
|
-
onChange( {
|
|
149
|
-
selfStretch,
|
|
150
|
-
flexSize: value,
|
|
151
|
-
} );
|
|
152
|
-
} }
|
|
153
|
-
value={ flexSize }
|
|
154
|
-
/>
|
|
155
|
-
) }
|
|
156
|
-
</VStack>
|
|
157
|
-
) }
|
|
158
|
-
{ parentLayoutType === 'grid' && (
|
|
159
|
-
<>
|
|
160
|
-
<HStack
|
|
161
|
-
as={ ToolsPanelItem }
|
|
162
|
-
hasValue={ hasSpanValue }
|
|
163
|
-
label={ __( 'Grid span' ) }
|
|
164
|
-
onDeselect={ resetGridSpans }
|
|
165
|
-
isShownByDefault={ isShownByDefault }
|
|
166
|
-
panelId={ panelId }
|
|
167
|
-
>
|
|
280
|
+
<FlexItem style={ { width: '50%' } }>
|
|
168
281
|
<InputControl
|
|
169
282
|
size="__unstable-large"
|
|
170
|
-
label={ __( 'Column
|
|
283
|
+
label={ __( 'Column' ) }
|
|
171
284
|
type="number"
|
|
172
285
|
onChange={ ( value ) => {
|
|
286
|
+
// Don't allow unsetting.
|
|
287
|
+
const newColumnStart =
|
|
288
|
+
value === '' ? 1 : parseInt( value, 10 );
|
|
173
289
|
onChange( {
|
|
174
|
-
columnStart,
|
|
290
|
+
columnStart: newColumnStart,
|
|
175
291
|
rowStart,
|
|
292
|
+
columnSpan,
|
|
176
293
|
rowSpan,
|
|
177
|
-
columnSpan: value,
|
|
178
294
|
} );
|
|
295
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
296
|
+
moveBlocksToPosition(
|
|
297
|
+
[ panelId ],
|
|
298
|
+
rootClientId,
|
|
299
|
+
rootClientId,
|
|
300
|
+
getNumberOfBlocksBeforeCell(
|
|
301
|
+
newColumnStart,
|
|
302
|
+
rowStart
|
|
303
|
+
)
|
|
304
|
+
);
|
|
179
305
|
} }
|
|
180
|
-
value={
|
|
306
|
+
value={ columnStart ?? 1 }
|
|
181
307
|
min={ 1 }
|
|
308
|
+
max={
|
|
309
|
+
columnCount
|
|
310
|
+
? columnCount - ( columnSpan ?? 1 ) + 1
|
|
311
|
+
: undefined
|
|
312
|
+
}
|
|
182
313
|
/>
|
|
314
|
+
</FlexItem>
|
|
315
|
+
<FlexItem style={ { width: '50%' } }>
|
|
183
316
|
<InputControl
|
|
184
317
|
size="__unstable-large"
|
|
185
|
-
label={ __( 'Row
|
|
318
|
+
label={ __( 'Row' ) }
|
|
186
319
|
type="number"
|
|
187
320
|
onChange={ ( value ) => {
|
|
321
|
+
// Don't allow unsetting.
|
|
322
|
+
const newRowStart =
|
|
323
|
+
value === '' ? 1 : parseInt( value, 10 );
|
|
188
324
|
onChange( {
|
|
189
325
|
columnStart,
|
|
190
|
-
rowStart,
|
|
326
|
+
rowStart: newRowStart,
|
|
191
327
|
columnSpan,
|
|
192
|
-
rowSpan
|
|
328
|
+
rowSpan,
|
|
193
329
|
} );
|
|
330
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
331
|
+
moveBlocksToPosition(
|
|
332
|
+
[ panelId ],
|
|
333
|
+
rootClientId,
|
|
334
|
+
rootClientId,
|
|
335
|
+
getNumberOfBlocksBeforeCell(
|
|
336
|
+
columnStart,
|
|
337
|
+
newRowStart
|
|
338
|
+
)
|
|
339
|
+
);
|
|
194
340
|
} }
|
|
195
|
-
value={
|
|
341
|
+
value={ rowStart ?? 1 }
|
|
196
342
|
min={ 1 }
|
|
343
|
+
max={
|
|
344
|
+
rowCount
|
|
345
|
+
? rowCount - ( rowSpan ?? 1 ) + 1
|
|
346
|
+
: undefined
|
|
347
|
+
}
|
|
197
348
|
/>
|
|
198
|
-
</
|
|
199
|
-
|
|
200
|
-
// Use Flex with an explicit width on the FlexItem instead of HStack to
|
|
201
|
-
// work around an issue in webkit where inputs with a max attribute are
|
|
202
|
-
// sized incorrectly.
|
|
203
|
-
<Flex
|
|
204
|
-
as={ ToolsPanelItem }
|
|
205
|
-
hasValue={ hasStartValue }
|
|
206
|
-
label={ __( 'Grid placement' ) }
|
|
207
|
-
onDeselect={ resetGridStarts }
|
|
208
|
-
isShownByDefault={ false }
|
|
209
|
-
panelId={ panelId }
|
|
210
|
-
>
|
|
211
|
-
<FlexItem style={ { width: '50%' } }>
|
|
212
|
-
<InputControl
|
|
213
|
-
size="__unstable-large"
|
|
214
|
-
label={ __( 'Column' ) }
|
|
215
|
-
type="number"
|
|
216
|
-
onChange={ ( value ) => {
|
|
217
|
-
onChange( {
|
|
218
|
-
columnStart: value,
|
|
219
|
-
rowStart,
|
|
220
|
-
columnSpan,
|
|
221
|
-
rowSpan,
|
|
222
|
-
} );
|
|
223
|
-
} }
|
|
224
|
-
value={ columnStart }
|
|
225
|
-
min={ 1 }
|
|
226
|
-
max={
|
|
227
|
-
parentLayout?.columnCount
|
|
228
|
-
? parentLayout.columnCount -
|
|
229
|
-
( columnSpan ?? 1 ) +
|
|
230
|
-
1
|
|
231
|
-
: undefined
|
|
232
|
-
}
|
|
233
|
-
/>
|
|
234
|
-
</FlexItem>
|
|
235
|
-
<FlexItem style={ { width: '50%' } }>
|
|
236
|
-
<InputControl
|
|
237
|
-
size="__unstable-large"
|
|
238
|
-
label={ __( 'Row' ) }
|
|
239
|
-
type="number"
|
|
240
|
-
onChange={ ( value ) => {
|
|
241
|
-
onChange( {
|
|
242
|
-
columnStart,
|
|
243
|
-
rowStart: value,
|
|
244
|
-
columnSpan,
|
|
245
|
-
rowSpan,
|
|
246
|
-
} );
|
|
247
|
-
} }
|
|
248
|
-
value={ rowStart }
|
|
249
|
-
min={ 1 }
|
|
250
|
-
max={
|
|
251
|
-
parentLayout?.rowCount
|
|
252
|
-
? parentLayout.rowCount -
|
|
253
|
-
( rowSpan ?? 1 ) +
|
|
254
|
-
1
|
|
255
|
-
: undefined
|
|
256
|
-
}
|
|
257
|
-
/>
|
|
258
|
-
</FlexItem>
|
|
259
|
-
</Flex>
|
|
260
|
-
) }
|
|
261
|
-
</>
|
|
349
|
+
</FlexItem>
|
|
350
|
+
</Flex>
|
|
262
351
|
) }
|
|
263
352
|
</>
|
|
264
353
|
);
|
|
265
354
|
}
|
|
266
|
-
|
|
267
|
-
export function childLayoutOrientation( parentLayout ) {
|
|
268
|
-
const { orientation = 'horizontal' } = parentLayout;
|
|
269
|
-
|
|
270
|
-
return orientation === 'horizontal' ? __( 'Width' ) : __( 'Height' );
|
|
271
|
-
}
|
|
@@ -8,11 +8,20 @@ import {
|
|
|
8
8
|
TextControl,
|
|
9
9
|
ExternalLink,
|
|
10
10
|
VisuallyHidden,
|
|
11
|
-
CustomSelectControl,
|
|
12
11
|
ToggleControl,
|
|
13
12
|
__experimentalVStack as VStack,
|
|
13
|
+
privateApis as componentsPrivateApis,
|
|
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
|
+
|
|
16
25
|
// So that we illustrate the different formats in the dropdown properly, show a date that is
|
|
17
26
|
// somwhat recent, has a day greater than 12, and a month with more than three letters.
|
|
18
27
|
const exampleDate = new Date();
|
|
@@ -4,13 +4,4 @@
|
|
|
4
4
|
|
|
5
5
|
.block-editor-date-format-picker__custom-format-select-control__custom-option {
|
|
6
6
|
border-top: 1px solid $gray-300;
|
|
7
|
-
|
|
8
|
-
&.has-hint {
|
|
9
|
-
grid-template-columns: auto 30px;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.components-custom-select-control__item-hint {
|
|
13
|
-
grid-row: 2;
|
|
14
|
-
text-align: left;
|
|
15
|
-
}
|
|
16
7
|
}
|
|
@@ -58,6 +58,7 @@ function DimensionsTool( {
|
|
|
58
58
|
scaleOptions, // Default options handled by ScaleTool.
|
|
59
59
|
defaultScale = 'fill', // Match CSS default value for object-fit.
|
|
60
60
|
unitsOptions, // Default options handled by UnitControl.
|
|
61
|
+
tools = [ 'aspectRatio', 'widthHeight', 'scale' ],
|
|
61
62
|
} ) {
|
|
62
63
|
// Coerce undefined and CSS default values to be null.
|
|
63
64
|
const width =
|
|
@@ -92,95 +93,102 @@ function DimensionsTool( {
|
|
|
92
93
|
|
|
93
94
|
return (
|
|
94
95
|
<>
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
nextAspectRatio
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
96
|
+
{ tools.includes( 'aspectRatio' ) && (
|
|
97
|
+
<AspectRatioTool
|
|
98
|
+
panelId={ panelId }
|
|
99
|
+
options={ aspectRatioOptions }
|
|
100
|
+
defaultValue={ defaultAspectRatio }
|
|
101
|
+
value={ aspectRatioValue }
|
|
102
|
+
onChange={ ( nextAspectRatio ) => {
|
|
103
|
+
const nextValue = { ...value };
|
|
104
|
+
|
|
105
|
+
// 'auto' is CSS default, so it gets treated as null.
|
|
106
|
+
nextAspectRatio =
|
|
107
|
+
nextAspectRatio === 'auto' ? null : nextAspectRatio;
|
|
108
|
+
|
|
109
|
+
setLastAspectRatio( nextAspectRatio );
|
|
110
|
+
|
|
111
|
+
// Update aspectRatio.
|
|
112
|
+
if ( ! nextAspectRatio ) {
|
|
113
|
+
delete nextValue.aspectRatio;
|
|
114
|
+
} else {
|
|
115
|
+
nextValue.aspectRatio = nextAspectRatio;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Auto-update scale.
|
|
119
|
+
if ( ! nextAspectRatio ) {
|
|
120
|
+
delete nextValue.scale;
|
|
121
|
+
} else if ( lastScale ) {
|
|
122
|
+
nextValue.scale = lastScale;
|
|
123
|
+
} else {
|
|
124
|
+
nextValue.scale = defaultScale;
|
|
125
|
+
setLastScale( defaultScale );
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Auto-update width and height.
|
|
129
|
+
if ( 'custom' !== nextAspectRatio && width && height ) {
|
|
130
|
+
delete nextValue.height;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
onChange( nextValue );
|
|
134
|
+
} }
|
|
135
|
+
/>
|
|
136
|
+
) }
|
|
137
|
+
{ tools.includes( 'widthHeight' ) && (
|
|
138
|
+
<WidthHeightTool
|
|
139
|
+
panelId={ panelId }
|
|
140
|
+
units={ unitsOptions }
|
|
141
|
+
value={ { width, height } }
|
|
142
|
+
onChange={ ( { width: nextWidth, height: nextHeight } ) => {
|
|
143
|
+
const nextValue = { ...value };
|
|
144
|
+
|
|
145
|
+
// 'auto' is CSS default, so it gets treated as null.
|
|
146
|
+
nextWidth = nextWidth === 'auto' ? null : nextWidth;
|
|
147
|
+
nextHeight = nextHeight === 'auto' ? null : nextHeight;
|
|
148
|
+
|
|
149
|
+
// Update width.
|
|
150
|
+
if ( ! nextWidth ) {
|
|
151
|
+
delete nextValue.width;
|
|
152
|
+
} else {
|
|
153
|
+
nextValue.width = nextWidth;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Update height.
|
|
157
|
+
if ( ! nextHeight ) {
|
|
158
|
+
delete nextValue.height;
|
|
159
|
+
} else {
|
|
160
|
+
nextValue.height = nextHeight;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Auto-update aspectRatio.
|
|
164
|
+
if ( nextWidth && nextHeight ) {
|
|
165
|
+
delete nextValue.aspectRatio;
|
|
166
|
+
} else if ( lastAspectRatio ) {
|
|
167
|
+
nextValue.aspectRatio = lastAspectRatio;
|
|
168
|
+
} else {
|
|
169
|
+
// No setting defaultAspectRatio here, because
|
|
170
|
+
// aspectRatio is optional in this scenario,
|
|
171
|
+
// unlike scale.
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Auto-update scale.
|
|
175
|
+
if (
|
|
176
|
+
! lastAspectRatio &&
|
|
177
|
+
!! nextWidth !== !! nextHeight
|
|
178
|
+
) {
|
|
179
|
+
delete nextValue.scale;
|
|
180
|
+
} else if ( lastScale ) {
|
|
181
|
+
nextValue.scale = lastScale;
|
|
182
|
+
} else {
|
|
183
|
+
nextValue.scale = defaultScale;
|
|
184
|
+
setLastScale( defaultScale );
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
onChange( nextValue );
|
|
188
|
+
} }
|
|
189
|
+
/>
|
|
190
|
+
) }
|
|
191
|
+
{ tools.includes( 'scale' ) && showScaleControl && (
|
|
184
192
|
<ScaleTool
|
|
185
193
|
panelId={ panelId }
|
|
186
194
|
options={ scaleOptions }
|