@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
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
export function range( start, length ) {
|
|
2
|
+
return Array.from( { length }, ( _, i ) => start + i );
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export class GridRect {
|
|
6
|
+
constructor( {
|
|
7
|
+
columnStart,
|
|
8
|
+
rowStart,
|
|
9
|
+
columnEnd,
|
|
10
|
+
rowEnd,
|
|
11
|
+
columnSpan,
|
|
12
|
+
rowSpan,
|
|
13
|
+
} = {} ) {
|
|
14
|
+
this.columnStart = columnStart ?? 1;
|
|
15
|
+
this.rowStart = rowStart ?? 1;
|
|
16
|
+
if ( columnSpan !== undefined ) {
|
|
17
|
+
this.columnEnd = this.columnStart + columnSpan - 1;
|
|
18
|
+
} else {
|
|
19
|
+
this.columnEnd = columnEnd ?? this.columnStart;
|
|
20
|
+
}
|
|
21
|
+
if ( rowSpan !== undefined ) {
|
|
22
|
+
this.rowEnd = this.rowStart + rowSpan - 1;
|
|
23
|
+
} else {
|
|
24
|
+
this.rowEnd = rowEnd ?? this.rowStart;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
get columnSpan() {
|
|
29
|
+
return this.columnEnd - this.columnStart + 1;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
get rowSpan() {
|
|
33
|
+
return this.rowEnd - this.rowStart + 1;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
contains( column, row ) {
|
|
37
|
+
return (
|
|
38
|
+
column >= this.columnStart &&
|
|
39
|
+
column <= this.columnEnd &&
|
|
40
|
+
row >= this.rowStart &&
|
|
41
|
+
row <= this.rowEnd
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
containsRect( rect ) {
|
|
46
|
+
return (
|
|
47
|
+
this.contains( rect.columnStart, rect.rowStart ) &&
|
|
48
|
+
this.contains( rect.columnEnd, rect.rowEnd )
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
intersectsRect( rect ) {
|
|
53
|
+
return (
|
|
54
|
+
this.columnStart <= rect.columnEnd &&
|
|
55
|
+
this.columnEnd >= rect.columnStart &&
|
|
56
|
+
this.rowStart <= rect.rowEnd &&
|
|
57
|
+
this.rowEnd >= rect.rowStart
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function getComputedCSS( element, property ) {
|
|
63
|
+
return element.ownerDocument.defaultView
|
|
64
|
+
.getComputedStyle( element )
|
|
65
|
+
.getPropertyValue( property );
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Given a grid-template-columns or grid-template-rows CSS property value, gets the start and end
|
|
70
|
+
* position in pixels of each grid track.
|
|
71
|
+
*
|
|
72
|
+
* https://css-tricks.com/snippets/css/complete-guide-grid/#aa-grid-track
|
|
73
|
+
*
|
|
74
|
+
* @param {string} template The grid-template-columns or grid-template-rows CSS property value.
|
|
75
|
+
* Only supports fixed sizes in pixels.
|
|
76
|
+
* @param {number} gap The gap between grid tracks in pixels.
|
|
77
|
+
*
|
|
78
|
+
* @return {Array<{start: number, end: number}>} An array of objects with the start and end
|
|
79
|
+
* position in pixels of each grid track.
|
|
80
|
+
*/
|
|
81
|
+
export function getGridTracks( template, gap ) {
|
|
82
|
+
const tracks = [];
|
|
83
|
+
for ( const size of template.split( ' ' ) ) {
|
|
84
|
+
const previousTrack = tracks[ tracks.length - 1 ];
|
|
85
|
+
const start = previousTrack ? previousTrack.end + gap : 0;
|
|
86
|
+
const end = start + parseFloat( size );
|
|
87
|
+
tracks.push( { start, end } );
|
|
88
|
+
}
|
|
89
|
+
return tracks;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Given an array of grid tracks and a position in pixels, gets the index of the closest track to
|
|
94
|
+
* that position.
|
|
95
|
+
*
|
|
96
|
+
* https://css-tricks.com/snippets/css/complete-guide-grid/#aa-grid-track
|
|
97
|
+
*
|
|
98
|
+
* @param {Array<{start: number, end: number}>} tracks An array of objects with the start and end
|
|
99
|
+
* position in pixels of each grid track.
|
|
100
|
+
* @param {number} position The position in pixels.
|
|
101
|
+
* @param {string} edge The edge of the track to compare the
|
|
102
|
+
* position to. Either 'start' or 'end'.
|
|
103
|
+
*
|
|
104
|
+
* @return {number} The index of the closest track to the position. 0-based, unlike CSS grid which
|
|
105
|
+
* is 1-based.
|
|
106
|
+
*/
|
|
107
|
+
export function getClosestTrack( tracks, position, edge = 'start' ) {
|
|
108
|
+
return tracks.reduce(
|
|
109
|
+
( closest, track, index ) =>
|
|
110
|
+
Math.abs( track[ edge ] - position ) <
|
|
111
|
+
Math.abs( tracks[ closest ][ edge ] - position )
|
|
112
|
+
? index
|
|
113
|
+
: closest,
|
|
114
|
+
0
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function getGridRect( gridElement, rect ) {
|
|
119
|
+
const columnGap = parseFloat( getComputedCSS( gridElement, 'column-gap' ) );
|
|
120
|
+
const rowGap = parseFloat( getComputedCSS( gridElement, 'row-gap' ) );
|
|
121
|
+
const gridColumnTracks = getGridTracks(
|
|
122
|
+
getComputedCSS( gridElement, 'grid-template-columns' ),
|
|
123
|
+
columnGap
|
|
124
|
+
);
|
|
125
|
+
const gridRowTracks = getGridTracks(
|
|
126
|
+
getComputedCSS( gridElement, 'grid-template-rows' ),
|
|
127
|
+
rowGap
|
|
128
|
+
);
|
|
129
|
+
const columnStart = getClosestTrack( gridColumnTracks, rect.left ) + 1;
|
|
130
|
+
const rowStart = getClosestTrack( gridRowTracks, rect.top ) + 1;
|
|
131
|
+
const columnEnd =
|
|
132
|
+
getClosestTrack( gridColumnTracks, rect.right, 'end' ) + 1;
|
|
133
|
+
const rowEnd = getClosestTrack( gridRowTracks, rect.bottom, 'end' ) + 1;
|
|
134
|
+
return new GridRect( {
|
|
135
|
+
columnStart,
|
|
136
|
+
columnEnd,
|
|
137
|
+
rowStart,
|
|
138
|
+
rowEnd,
|
|
139
|
+
} );
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function getGridItemRect( gridItemElement ) {
|
|
143
|
+
return getGridRect(
|
|
144
|
+
gridItemElement.parentElement,
|
|
145
|
+
new window.DOMRect(
|
|
146
|
+
gridItemElement.offsetLeft,
|
|
147
|
+
gridItemElement.offsetTop,
|
|
148
|
+
gridItemElement.offsetWidth,
|
|
149
|
+
gridItemElement.offsetHeight
|
|
150
|
+
)
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function getGridInfo( gridElement ) {
|
|
155
|
+
const gridTemplateColumns = getComputedCSS(
|
|
156
|
+
gridElement,
|
|
157
|
+
'grid-template-columns'
|
|
158
|
+
);
|
|
159
|
+
const gridTemplateRows = getComputedCSS(
|
|
160
|
+
gridElement,
|
|
161
|
+
'grid-template-rows'
|
|
162
|
+
);
|
|
163
|
+
const numColumns = gridTemplateColumns.split( ' ' ).length;
|
|
164
|
+
const numRows = gridTemplateRows.split( ' ' ).length;
|
|
165
|
+
const numItems = numColumns * numRows;
|
|
166
|
+
return {
|
|
167
|
+
numColumns,
|
|
168
|
+
numRows,
|
|
169
|
+
numItems,
|
|
170
|
+
currentColor: getComputedCSS( gridElement, 'color' ),
|
|
171
|
+
style: {
|
|
172
|
+
gridTemplateColumns,
|
|
173
|
+
gridTemplateRows,
|
|
174
|
+
gap: getComputedCSS( gridElement, 'gap' ),
|
|
175
|
+
padding: getComputedCSS( gridElement, 'padding' ),
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
@@ -267,7 +267,10 @@ export function useInnerBlocksProps( props = {}, options = {} ) {
|
|
|
267
267
|
|
|
268
268
|
const ref = useMergeRefs( [
|
|
269
269
|
props.ref,
|
|
270
|
-
__unstableDisableDropZone ||
|
|
270
|
+
__unstableDisableDropZone ||
|
|
271
|
+
isDropZoneDisabled ||
|
|
272
|
+
( layout?.isManualPlacement &&
|
|
273
|
+
window.__experimentalEnableGridInteractivity )
|
|
271
274
|
? null
|
|
272
275
|
: blockDropZoneRef,
|
|
273
276
|
] );
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { PatternCategoryPreviews } from './pattern-category-previews';
|
|
5
|
-
import { useZoomOut } from '../../../hooks/use-zoom-out';
|
|
6
5
|
|
|
7
|
-
function
|
|
6
|
+
export function PatternCategoryPreviewPanel( {
|
|
8
7
|
rootClientId,
|
|
9
8
|
onInsert,
|
|
10
9
|
onHover,
|
|
@@ -24,17 +23,3 @@ function PatternCategoryPreviewPanelInner( {
|
|
|
24
23
|
/>
|
|
25
24
|
);
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
function PatternCategoryPreviewPanelWithZoomOut( props ) {
|
|
29
|
-
useZoomOut();
|
|
30
|
-
return <PatternCategoryPreviewPanelInner { ...props } />;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function PatternCategoryPreviewPanel( props ) {
|
|
34
|
-
// When the pattern panel is showing, we want to use zoom out mode
|
|
35
|
-
if ( window.__experimentalEnableZoomedOutPatternsTab ) {
|
|
36
|
-
return <PatternCategoryPreviewPanelWithZoomOut { ...props } />;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return <PatternCategoryPreviewPanelInner { ...props } />;
|
|
40
|
-
}
|
|
@@ -30,8 +30,9 @@ import { PatternCategoryPreviewPanel } from './block-patterns-tab/pattern-catego
|
|
|
30
30
|
import { MediaTab, MediaCategoryPanel } from './media-tab';
|
|
31
31
|
import InserterSearchResults from './search-results';
|
|
32
32
|
import useInsertionPoint from './hooks/use-insertion-point';
|
|
33
|
-
import InserterTabs from './tabs';
|
|
34
33
|
import { store as blockEditorStore } from '../../store';
|
|
34
|
+
import TabbedSidebar from '../tabbed-sidebar';
|
|
35
|
+
import { useZoomOut } from '../../hooks/use-zoom-out';
|
|
35
36
|
|
|
36
37
|
const NOOP = () => {};
|
|
37
38
|
function InserterMenu(
|
|
@@ -88,7 +89,7 @@ function InserterMenu(
|
|
|
88
89
|
shouldForceFocusBlock,
|
|
89
90
|
_rootClientId
|
|
90
91
|
);
|
|
91
|
-
onSelect();
|
|
92
|
+
onSelect( blocks );
|
|
92
93
|
|
|
93
94
|
// Check for focus loss due to filtering blocks by selected block type
|
|
94
95
|
window.requestAnimationFrame( () => {
|
|
@@ -145,6 +146,11 @@ function InserterMenu(
|
|
|
145
146
|
|
|
146
147
|
const showMediaPanel = selectedTab === 'media' && !! selectedMediaCategory;
|
|
147
148
|
|
|
149
|
+
const showZoomOut =
|
|
150
|
+
showPatternPanel && window.__experimentalEnableZoomedOutPatternsTab;
|
|
151
|
+
|
|
152
|
+
useZoomOut( showZoomOut );
|
|
153
|
+
|
|
148
154
|
const inserterSearch = useMemo( () => {
|
|
149
155
|
if ( selectedTab === 'media' ) {
|
|
150
156
|
return null;
|
|
@@ -315,21 +321,49 @@ function InserterMenu(
|
|
|
315
321
|
ref={ ref }
|
|
316
322
|
>
|
|
317
323
|
<div className="block-editor-inserter__main-area">
|
|
318
|
-
<
|
|
324
|
+
<TabbedSidebar
|
|
319
325
|
ref={ tabsRef }
|
|
320
326
|
onSelect={ handleSetSelectedTab }
|
|
321
327
|
onClose={ onClose }
|
|
322
328
|
selectedTab={ selectedTab }
|
|
323
|
-
|
|
324
|
-
{
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
329
|
+
closeButtonLabel={ __( 'Close block inserter' ) }
|
|
330
|
+
tabs={ [
|
|
331
|
+
{
|
|
332
|
+
name: 'blocks',
|
|
333
|
+
title: __( 'Blocks' ),
|
|
334
|
+
panel: (
|
|
335
|
+
<>
|
|
336
|
+
{ inserterSearch }
|
|
337
|
+
{ selectedTab === 'blocks' &&
|
|
338
|
+
! delayedFilterValue &&
|
|
339
|
+
blocksTab }
|
|
340
|
+
</>
|
|
341
|
+
),
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
name: 'patterns',
|
|
345
|
+
title: __( 'Patterns' ),
|
|
346
|
+
panel: (
|
|
347
|
+
<>
|
|
348
|
+
{ inserterSearch }
|
|
349
|
+
{ selectedTab === 'patterns' &&
|
|
350
|
+
! delayedFilterValue &&
|
|
351
|
+
patternsTab }
|
|
352
|
+
</>
|
|
353
|
+
),
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
name: 'media',
|
|
357
|
+
title: __( 'Media' ),
|
|
358
|
+
panel: (
|
|
359
|
+
<>
|
|
360
|
+
{ inserterSearch }
|
|
361
|
+
{ mediaTab }
|
|
362
|
+
</>
|
|
363
|
+
),
|
|
364
|
+
},
|
|
365
|
+
] }
|
|
366
|
+
/>
|
|
333
367
|
</div>
|
|
334
368
|
{ showInserterHelpPanel && hoveredItem && (
|
|
335
369
|
<Popover
|
|
@@ -85,7 +85,12 @@ export default function QuickInserter( {
|
|
|
85
85
|
// When clicking Browse All select the appropriate block so as
|
|
86
86
|
// the insertion point can work as expected.
|
|
87
87
|
const onBrowseAll = () => {
|
|
88
|
-
setInserterIsOpened( {
|
|
88
|
+
setInserterIsOpened( {
|
|
89
|
+
rootClientId,
|
|
90
|
+
insertionIndex,
|
|
91
|
+
filterValue,
|
|
92
|
+
onSelect,
|
|
93
|
+
} );
|
|
89
94
|
};
|
|
90
95
|
|
|
91
96
|
let maxBlockPatterns = 0;
|
|
@@ -17,19 +17,13 @@ $block-inserter-tabs-height: 44px;
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
.block-editor-inserter__main-area {
|
|
20
|
-
position: relative;
|
|
21
|
-
display: flex;
|
|
22
|
-
flex-direction: column;
|
|
23
20
|
height: 100%;
|
|
24
21
|
gap: $grid-unit-20;
|
|
22
|
+
position: relative;
|
|
25
23
|
|
|
26
24
|
&.show-as-tabs {
|
|
27
25
|
gap: 0;
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
@include break-medium {
|
|
31
|
-
width: $block-inserter-width;
|
|
32
|
-
}
|
|
33
27
|
}
|
|
34
28
|
|
|
35
29
|
.block-editor-inserter__popover.is-quick {
|
|
@@ -109,48 +103,6 @@ $block-inserter-tabs-height: 44px;
|
|
|
109
103
|
padding: $grid-unit-20 $grid-unit-20 0 $grid-unit-20;
|
|
110
104
|
}
|
|
111
105
|
|
|
112
|
-
.block-editor-inserter__tabs {
|
|
113
|
-
flex-grow: 1;
|
|
114
|
-
display: flex;
|
|
115
|
-
flex-direction: column;
|
|
116
|
-
overflow: hidden;
|
|
117
|
-
|
|
118
|
-
.block-editor-inserter__tablist-and-close-button {
|
|
119
|
-
border-bottom: $border-width solid $gray-300;
|
|
120
|
-
padding-right: $grid-unit-15;
|
|
121
|
-
display: flex;
|
|
122
|
-
justify-content: space-between;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.block-editor-inserter__close-button {
|
|
126
|
-
/* stylelint-disable-next-line property-disallowed-list -- This should be refactored to avoid order if possible */
|
|
127
|
-
order: 1;
|
|
128
|
-
align-self: center;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.block-editor-inserter__tablist {
|
|
132
|
-
width: 100%;
|
|
133
|
-
margin-bottom: -$border-width;
|
|
134
|
-
|
|
135
|
-
button[role="tab"] {
|
|
136
|
-
flex-grow: 1;
|
|
137
|
-
&[id$="reusable"] {
|
|
138
|
-
flex-grow: inherit;
|
|
139
|
-
// These are to align the `reusable` icon with the search icon.
|
|
140
|
-
padding-left: $grid-unit-20;
|
|
141
|
-
padding-right: $grid-unit-20;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
.block-editor-inserter__tabpanel {
|
|
147
|
-
display: flex;
|
|
148
|
-
flex-grow: 1;
|
|
149
|
-
flex-direction: column;
|
|
150
|
-
overflow-y: auto;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
106
|
.block-editor-inserter__no-tab-container {
|
|
155
107
|
overflow-y: auto;
|
|
156
108
|
flex-grow: 1;
|
|
@@ -10,7 +10,7 @@ import { useCallback } from '@wordpress/element';
|
|
|
10
10
|
*/
|
|
11
11
|
import { store as blockEditorStore } from '../../store';
|
|
12
12
|
import { cleanEmptyObject } from '../../hooks/utils';
|
|
13
|
-
import {
|
|
13
|
+
import { useToolsPanelDropdownMenuProps } from '../global-styles/utils';
|
|
14
14
|
|
|
15
15
|
export default function BlockSupportToolsPanel( { children, group, label } ) {
|
|
16
16
|
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
@@ -20,7 +20,7 @@ export default function BlockSupportToolsPanel( { children, group, label } ) {
|
|
|
20
20
|
getSelectedBlockClientId,
|
|
21
21
|
hasMultiSelection,
|
|
22
22
|
} = useSelect( blockEditorStore );
|
|
23
|
-
|
|
23
|
+
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
24
24
|
const panelId = getSelectedBlockClientId();
|
|
25
25
|
const resetAll = useCallback(
|
|
26
26
|
( resetFilters = [] ) => {
|
|
@@ -72,7 +72,7 @@ export default function BlockSupportToolsPanel( { children, group, label } ) {
|
|
|
72
72
|
shouldRenderPlaceholderItems // Required to maintain fills ordering.
|
|
73
73
|
__experimentalFirstVisibleItemClass="first"
|
|
74
74
|
__experimentalLastVisibleItemClass="last"
|
|
75
|
-
dropdownMenuProps={
|
|
75
|
+
dropdownMenuProps={ dropdownMenuProps }
|
|
76
76
|
>
|
|
77
77
|
{ children }
|
|
78
78
|
</ToolsPanel>
|
|
@@ -60,28 +60,37 @@ const InsertFromURLPopover = ( {
|
|
|
60
60
|
</URLPopover>
|
|
61
61
|
);
|
|
62
62
|
|
|
63
|
-
const URLSelectionUI = ( {
|
|
64
|
-
isURLInputVisible,
|
|
65
|
-
src,
|
|
66
|
-
onChangeSrc,
|
|
67
|
-
onSubmitSrc,
|
|
68
|
-
openURLInput,
|
|
69
|
-
closeURLInput,
|
|
70
|
-
} ) => {
|
|
63
|
+
const URLSelectionUI = ( { src, onChangeSrc, onSelectURL } ) => {
|
|
71
64
|
// Use internal state instead of a ref to make sure that the component
|
|
72
65
|
// re-renders when the popover's anchor updates.
|
|
73
66
|
const [ popoverAnchor, setPopoverAnchor ] = useState( null );
|
|
67
|
+
const [ isURLInputVisible, setIsURLInputVisible ] = useState( false );
|
|
68
|
+
|
|
69
|
+
const openURLInput = () => {
|
|
70
|
+
setIsURLInputVisible( true );
|
|
71
|
+
};
|
|
72
|
+
const closeURLInput = () => {
|
|
73
|
+
setIsURLInputVisible( false );
|
|
74
|
+
popoverAnchor?.focus();
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const onSubmitSrc = ( event ) => {
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
if ( src && onSelectURL ) {
|
|
80
|
+
onSelectURL( src );
|
|
81
|
+
closeURLInput();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
74
84
|
|
|
75
85
|
return (
|
|
76
|
-
<div
|
|
77
|
-
className="block-editor-media-placeholder__url-input-container"
|
|
78
|
-
ref={ setPopoverAnchor }
|
|
79
|
-
>
|
|
86
|
+
<div className="block-editor-media-placeholder__url-input-container">
|
|
80
87
|
<Button
|
|
81
88
|
className="block-editor-media-placeholder__button"
|
|
82
89
|
onClick={ openURLInput }
|
|
83
90
|
isPressed={ isURLInputVisible }
|
|
84
91
|
variant="secondary"
|
|
92
|
+
aria-haspopup="dialog"
|
|
93
|
+
ref={ setPopoverAnchor }
|
|
85
94
|
>
|
|
86
95
|
{ __( 'Insert from URL' ) }
|
|
87
96
|
</Button>
|
|
@@ -138,7 +147,6 @@ export function MediaPlaceholder( {
|
|
|
138
147
|
return getSettings().mediaUpload;
|
|
139
148
|
}, [] );
|
|
140
149
|
const [ src, setSrc ] = useState( '' );
|
|
141
|
-
const [ isURLInputVisible, setIsURLInputVisible ] = useState( false );
|
|
142
150
|
|
|
143
151
|
useEffect( () => {
|
|
144
152
|
setSrc( value?.src ?? '' );
|
|
@@ -159,21 +167,6 @@ export function MediaPlaceholder( {
|
|
|
159
167
|
setSrc( event.target.value );
|
|
160
168
|
};
|
|
161
169
|
|
|
162
|
-
const openURLInput = () => {
|
|
163
|
-
setIsURLInputVisible( true );
|
|
164
|
-
};
|
|
165
|
-
const closeURLInput = () => {
|
|
166
|
-
setIsURLInputVisible( false );
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
const onSubmitSrc = ( event ) => {
|
|
170
|
-
event.preventDefault();
|
|
171
|
-
if ( src && onSelectURL ) {
|
|
172
|
-
onSelectURL( src );
|
|
173
|
-
closeURLInput();
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
|
|
177
170
|
const onFilesUpload = ( files ) => {
|
|
178
171
|
if ( ! handleUpload ) {
|
|
179
172
|
return onSelect( files );
|
|
@@ -404,12 +397,9 @@ export function MediaPlaceholder( {
|
|
|
404
397
|
return (
|
|
405
398
|
onSelectURL && (
|
|
406
399
|
<URLSelectionUI
|
|
407
|
-
isURLInputVisible={ isURLInputVisible }
|
|
408
400
|
src={ src }
|
|
409
401
|
onChangeSrc={ onChangeSrc }
|
|
410
|
-
|
|
411
|
-
openURLInput={ openURLInput }
|
|
412
|
-
closeURLInput={ closeURLInput }
|
|
402
|
+
onSelectURL={ onSelectURL }
|
|
413
403
|
/>
|
|
414
404
|
)
|
|
415
405
|
);
|
|
@@ -210,6 +210,7 @@ export default function NavigableToolbar( {
|
|
|
210
210
|
shouldUseKeyboardFocusShortcut = true,
|
|
211
211
|
__experimentalInitialIndex: initialIndex,
|
|
212
212
|
__experimentalOnIndexChange: onIndexChange,
|
|
213
|
+
orientation = 'horizontal',
|
|
213
214
|
...props
|
|
214
215
|
} ) {
|
|
215
216
|
const toolbarRef = useRef();
|
|
@@ -230,6 +231,7 @@ export default function NavigableToolbar( {
|
|
|
230
231
|
<Toolbar
|
|
231
232
|
label={ props[ 'aria-label' ] }
|
|
232
233
|
ref={ toolbarRef }
|
|
234
|
+
orientation={ orientation }
|
|
233
235
|
{ ...props }
|
|
234
236
|
>
|
|
235
237
|
{ children }
|
|
@@ -239,7 +241,7 @@ export default function NavigableToolbar( {
|
|
|
239
241
|
|
|
240
242
|
return (
|
|
241
243
|
<NavigableMenu
|
|
242
|
-
orientation=
|
|
244
|
+
orientation={ orientation }
|
|
243
245
|
role="toolbar"
|
|
244
246
|
ref={ toolbarRef }
|
|
245
247
|
{ ...props }
|
|
@@ -24,7 +24,6 @@ import {
|
|
|
24
24
|
create,
|
|
25
25
|
split,
|
|
26
26
|
toHTMLString,
|
|
27
|
-
slice,
|
|
28
27
|
} from '@wordpress/rich-text';
|
|
29
28
|
import { isURL } from '@wordpress/url';
|
|
30
29
|
|
|
@@ -46,6 +45,8 @@ import EmbedHandlerPicker from './embed-handler-picker';
|
|
|
46
45
|
import { Content } from './content';
|
|
47
46
|
import RichText from './native';
|
|
48
47
|
import { withDeprecations } from './with-deprecations';
|
|
48
|
+
import { findSelection } from './event-listeners/input-rules';
|
|
49
|
+
import { START_OF_SELECTED_AREA } from '../../utils/selection';
|
|
49
50
|
|
|
50
51
|
const classes = 'block-editor-rich-text__editable';
|
|
51
52
|
|
|
@@ -502,7 +503,7 @@ export function RichTextWrapper(
|
|
|
502
503
|
);
|
|
503
504
|
|
|
504
505
|
const inputRule = useCallback(
|
|
505
|
-
( value
|
|
506
|
+
( value ) => {
|
|
506
507
|
if ( ! onReplace ) {
|
|
507
508
|
return;
|
|
508
509
|
}
|
|
@@ -518,7 +519,7 @@ export function RichTextWrapper(
|
|
|
518
519
|
return;
|
|
519
520
|
}
|
|
520
521
|
|
|
521
|
-
const trimmedTextBefore = text.slice( 0,
|
|
522
|
+
const trimmedTextBefore = text.slice( 0, start ).trim();
|
|
522
523
|
const prefixTransforms = getBlockTransforms( 'from' ).filter(
|
|
523
524
|
( { type } ) => type === 'prefix'
|
|
524
525
|
);
|
|
@@ -533,15 +534,16 @@ export function RichTextWrapper(
|
|
|
533
534
|
return;
|
|
534
535
|
}
|
|
535
536
|
|
|
536
|
-
const content =
|
|
537
|
-
|
|
538
|
-
);
|
|
537
|
+
const content = toHTMLString( {
|
|
538
|
+
value: insert( value, START_OF_SELECTED_AREA, 0, start ),
|
|
539
|
+
} );
|
|
539
540
|
const block = transformation.transform( content );
|
|
540
|
-
|
|
541
|
+
const currentSelection = findSelection( [ block ] );
|
|
541
542
|
onReplace( [ block ] );
|
|
543
|
+
selectionChange( ...currentSelection );
|
|
542
544
|
__unstableMarkAutomaticChange();
|
|
543
545
|
},
|
|
544
|
-
[ onReplace, __unstableMarkAutomaticChange ]
|
|
546
|
+
[ onReplace, start, selectionChange, __unstableMarkAutomaticChange ]
|
|
545
547
|
);
|
|
546
548
|
|
|
547
549
|
const mergedRef = useMergeRefs( [ providedRef, fallbackRef ] );
|
|
@@ -316,6 +316,23 @@ export class RichText extends Component {
|
|
|
316
316
|
const contentWithoutRootTag = this.removeRootTagsProducedByAztec(
|
|
317
317
|
event.nativeEvent.text
|
|
318
318
|
);
|
|
319
|
+
|
|
320
|
+
const { __unstableInputRule } = this.props;
|
|
321
|
+
const currentValuePosition = {
|
|
322
|
+
end: this.isIOS ? this.selectionEnd : this.selectionEnd + 1,
|
|
323
|
+
start: this.isIOS ? this.selectionStart : this.selectionStart + 1,
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
if (
|
|
327
|
+
__unstableInputRule &&
|
|
328
|
+
__unstableInputRule( {
|
|
329
|
+
...currentValuePosition,
|
|
330
|
+
...this.formatToValue( contentWithoutRootTag ),
|
|
331
|
+
} )
|
|
332
|
+
) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
|
|
319
336
|
// On iOS, onChange can be triggered after selection changes, even though there are no content changes.
|
|
320
337
|
if ( contentWithoutRootTag === this.value?.toString() ) {
|
|
321
338
|
return;
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
5
|
Button,
|
|
6
|
-
CustomSelectControl,
|
|
7
6
|
Icon,
|
|
8
7
|
RangeControl,
|
|
9
8
|
__experimentalHStack as HStack,
|
|
10
9
|
__experimentalUnitControl as UnitControl,
|
|
11
10
|
__experimentalUseCustomUnits as useCustomUnits,
|
|
12
11
|
__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,
|
|
12
|
+
privateApis as componentsPrivateApis,
|
|
13
13
|
} from '@wordpress/components';
|
|
14
14
|
import { useSelect } from '@wordpress/data';
|
|
15
15
|
import { useState, useMemo } from '@wordpress/element';
|
|
@@ -31,6 +31,11 @@ import {
|
|
|
31
31
|
getPresetValueFromCustomValue,
|
|
32
32
|
isValueSpacingPreset,
|
|
33
33
|
} from '../utils';
|
|
34
|
+
import { unlock } from '../../../lock-unlock';
|
|
35
|
+
|
|
36
|
+
const { CustomSelectControlV2Legacy: CustomSelectControl } = unlock(
|
|
37
|
+
componentsPrivateApis
|
|
38
|
+
);
|
|
34
39
|
|
|
35
40
|
const CUSTOM_VALUE_SETTINGS = {
|
|
36
41
|
px: { max: 300, steps: 1 },
|