@wordpress/block-editor 11.0.0 → 11.2.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 +16 -1
- package/LICENSE.md +1 -1
- package/README.md +2 -1
- package/build/components/alignment-control/ui.js +1 -7
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-actions/index.js +9 -0
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-alignment-control/use-available-alignments.js +4 -3
- package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build/components/block-icon/index.js +4 -2
- package/build/components/block-icon/index.js.map +1 -1
- package/build/components/block-inspector/index.js +58 -5
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list-appender/index.js +46 -34
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-list-appender/index.native.js +39 -34
- package/build/components/block-list-appender/index.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +18 -18
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/index.native.js +1 -1
- package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +14 -7
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-preview/auto.js +1 -4
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/index.js +3 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-styles/index.native.js +1 -3
- package/build/components/block-styles/index.native.js.map +1 -1
- package/build/components/block-styles/utils.js +7 -10
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-toolbar/index.native.js +6 -8
- package/build/components/block-toolbar/index.native.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +1 -3
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +43 -10
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build/components/block-variation-picker/index.js +1 -1
- package/build/components/block-variation-picker/index.js.map +1 -1
- package/build/components/colors/utils.js +2 -6
- package/build/components/colors/utils.js.map +1 -1
- package/build/components/colors-gradients/control.js +0 -3
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +0 -2
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +2 -19
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -3
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build/components/copy-handler/index.js +37 -9
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/default-style-picker/index.js +1 -0
- package/build/components/default-style-picker/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +5 -2
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/utils.js +10 -4
- package/build/components/font-sizes/utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +14 -12
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/gradients/use-gradient.js +2 -8
- package/build/components/gradients/use-gradient.js.map +1 -1
- package/build/components/iframe/index.js +48 -101
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/iframe/use-compatibility-styles.js +98 -0
- package/build/components/iframe/use-compatibility-styles.js.map +1 -0
- package/build/components/image-size-control/index.js +1 -0
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +6 -2
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +4 -4
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js +4 -3
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/index.js +16 -6
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +8 -5
- package/build/components/inserter/media-tab/hooks.js.map +1 -1
- package/build/components/inserter/menu.js +11 -5
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +6 -3
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-items.js +15 -14
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inserter/search-results.js +4 -2
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inspector-controls/groups.js +3 -1
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js +46 -0
- package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -0
- package/build/components/inspector-controls-tabs/settings-tab.js +3 -1
- package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -11
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -0
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/list-view/block-select-button.js +1 -1
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +3 -44
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +38 -5
- package/build/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build/components/off-canvas-editor/block-select-button.js +3 -2
- package/build/components/off-canvas-editor/block-select-button.js.map +1 -1
- package/build/components/off-canvas-editor/block.js +51 -57
- package/build/components/off-canvas-editor/block.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +12 -5
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/use-inserted-block.js +58 -0
- package/build/components/off-canvas-editor/use-inserted-block.js.map +1 -0
- package/build/components/provider/index.js +3 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/responsive-block-control/label.js.map +1 -1
- package/build/components/rich-text/format-edit.js +12 -10
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-enter.js +4 -5
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +21 -12
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/spacing-sizes-control/index.js +0 -1
- package/build/components/spacing-sizes-control/index.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +1 -1
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/typewriter/index.js +1 -1
- package/build/components/typewriter/index.js.map +1 -1
- package/build/components/url-input/button.js +1 -0
- package/build/components/url-input/button.js.map +1 -1
- package/build/components/url-input/index.js +15 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +2 -2
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/url-popover/link-editor.js +1 -0
- package/build/components/url-popover/link-editor.js.map +1 -1
- package/build/components/use-paste-styles/index.js +188 -0
- package/build/components/use-paste-styles/index.js.map +1 -0
- package/build/components/writing-flow/index.js +1 -1
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +22 -29
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/hooks/border.js +0 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +0 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +1 -2
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/font-family.js +4 -4
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +5 -3
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/metadata.js +1 -1
- package/build/hooks/metadata.js.map +1 -1
- package/build/hooks/position.js +376 -0
- package/build/hooks/position.js.map +1 -0
- package/build/hooks/supports.js +328 -0
- package/build/hooks/supports.js.map +1 -0
- package/build/hooks/use-typography-props.js +11 -8
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/store/reducer.js +27 -9
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +9 -7
- package/build/store/selectors.js.map +1 -1
- package/build/utils/pasting.js +6 -11
- package/build/utils/pasting.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +1 -6
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-actions/index.js +6 -0
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +4 -3
- package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build-module/components/block-icon/index.js +4 -2
- package/build-module/components/block-icon/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +58 -6
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +46 -34
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.native.js +39 -32
- package/build-module/components/block-list-appender/index.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +18 -18
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +14 -7
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +1 -4
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/index.js +2 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-styles/index.native.js +1 -2
- package/build-module/components/block-styles/index.native.js.map +1 -1
- package/build-module/components/block-styles/utils.js +7 -9
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-toolbar/index.native.js +6 -8
- package/build-module/components/block-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +1 -2
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +42 -11
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build-module/components/block-variation-picker/index.js +1 -1
- package/build-module/components/block-variation-picker/index.js.map +1 -1
- package/build-module/components/colors/utils.js +3 -7
- package/build-module/components/colors/utils.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +0 -3
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +0 -2
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +4 -19
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -2
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build-module/components/copy-handler/index.js +38 -10
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/default-style-picker/index.js +1 -0
- package/build-module/components/default-style-picker/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +5 -2
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/utils.js +11 -5
- package/build-module/components/font-sizes/utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +14 -11
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/gradients/use-gradient.js +2 -7
- package/build-module/components/gradients/use-gradient.js.map +1 -1
- package/build-module/components/iframe/index.js +46 -102
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/iframe/use-compatibility-styles.js +90 -0
- package/build-module/components/iframe/use-compatibility-styles.js.map +1 -0
- package/build-module/components/image-size-control/index.js +1 -0
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +6 -2
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +4 -4
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js +4 -3
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/index.js +16 -6
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +8 -5
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
- package/build-module/components/inserter/menu.js +11 -5
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +6 -3
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-items.js +15 -13
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter/search-results.js +4 -2
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +3 -1
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js +33 -0
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/settings-tab.js +2 -1
- package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -11
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -0
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +1 -1
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +5 -44
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +37 -7
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-select-button.js +3 -2
- package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -1
- package/build-module/components/off-canvas-editor/block.js +54 -60
- package/build-module/components/off-canvas-editor/block.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +12 -5
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/use-inserted-block.js +47 -0
- package/build-module/components/off-canvas-editor/use-inserted-block.js.map +1 -0
- package/build-module/components/provider/index.js +3 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/responsive-block-control/label.js +1 -2
- package/build-module/components/responsive-block-control/label.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +12 -9
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-enter.js +4 -5
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +22 -12
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/spacing-sizes-control/index.js +0 -1
- package/build-module/components/spacing-sizes-control/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +1 -1
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/typewriter/index.js +1 -1
- package/build-module/components/typewriter/index.js.map +1 -1
- package/build-module/components/url-input/button.js +1 -0
- package/build-module/components/url-input/button.js.map +1 -1
- package/build-module/components/url-input/index.js +14 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +3 -3
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/url-popover/link-editor.js +1 -0
- package/build-module/components/url-popover/link-editor.js.map +1 -1
- package/build-module/components/use-paste-styles/index.js +174 -0
- package/build-module/components/use-paste-styles/index.js.map +1 -0
- package/build-module/components/writing-flow/index.js +1 -1
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +22 -29
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/hooks/border.js +0 -1
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +0 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +1 -2
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/font-family.js +5 -5
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +5 -3
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/metadata.js +1 -1
- package/build-module/hooks/metadata.js.map +1 -1
- package/build-module/hooks/position.js +337 -0
- package/build-module/hooks/position.js.map +1 -0
- package/build-module/hooks/supports.js +257 -0
- package/build-module/hooks/supports.js.map +1 -0
- package/build-module/hooks/use-typography-props.js +11 -8
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/store/reducer.js +27 -8
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +9 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/pasting.js +6 -10
- package/build-module/utils/pasting.js.map +1 -1
- package/build-style/content-rtl.css +60 -3
- package/build-style/content.css +60 -3
- package/build-style/default-editor-styles-rtl.css +3 -3
- package/build-style/default-editor-styles.css +3 -3
- package/build-style/style-rtl.css +62 -69
- package/build-style/style.css +62 -69
- package/package.json +29 -29
- package/src/components/alignment-control/test/index.js +2 -0
- package/src/components/alignment-control/ui.js +1 -7
- package/src/components/block-actions/index.js +5 -0
- package/src/components/block-alignment-control/test/index.js +2 -0
- package/src/components/block-alignment-control/use-available-alignments.js +4 -3
- package/src/components/block-icon/index.js +4 -2
- package/src/components/block-icon/test/index.js +9 -5
- package/src/components/block-inspector/index.js +79 -4
- package/src/components/block-inspector/style.scss +7 -0
- package/src/components/block-list-appender/index.js +65 -54
- package/src/components/block-list-appender/index.native.js +45 -34
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +18 -22
- package/src/components/block-mobile-toolbar/index.native.js +1 -1
- package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +125 -0
- package/src/components/block-mobile-toolbar/test/block-actions-menu.native.js +439 -0
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +42 -0
- package/src/components/block-mover/test/index.native.js +157 -1
- package/src/components/block-pattern-setup/index.js +15 -6
- package/src/components/block-pattern-setup/style.scss +29 -1
- package/src/components/block-preview/auto.js +2 -4
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -0
- package/src/components/block-styles/index.js +4 -1
- package/src/components/block-styles/index.native.js +1 -2
- package/src/components/block-styles/utils.js +5 -7
- package/src/components/block-switcher/test/index.js +3 -2
- package/src/components/block-toolbar/index.native.js +8 -11
- package/src/components/block-tools/selected-block-popover.js +1 -3
- package/src/components/block-tools/use-block-toolbar-popover-props.js +68 -12
- package/src/components/block-variation-picker/index.js +5 -1
- package/src/components/block-vertical-alignment-control/test/index.js +2 -0
- package/src/components/button-block-appender/{style.scss → content.scss} +0 -0
- package/src/components/colors/test/with-colors.js +2 -0
- package/src/components/colors/utils.js +5 -3
- package/src/components/colors-gradients/control.js +0 -7
- package/src/components/colors-gradients/dropdown.js +0 -2
- package/src/components/colors-gradients/panel-color-gradient-settings.js +4 -22
- package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -2
- package/src/components/copy-handler/index.js +53 -7
- package/src/components/default-block-appender/test/index.js +2 -0
- package/src/components/default-style-picker/index.js +1 -0
- package/src/components/font-sizes/fluid-utils.js +7 -1
- package/src/components/font-sizes/utils.js +5 -3
- package/src/components/font-sizes/with-font-sizes.js +36 -36
- package/src/components/gradients/use-gradient.js +2 -7
- package/src/components/iframe/index.js +60 -122
- package/src/components/iframe/use-compatibility-styles.js +101 -0
- package/src/components/image-size-control/index.js +1 -0
- package/src/components/image-size-control/test/index.js +147 -79
- package/src/components/inner-blocks/index.js +4 -2
- package/src/components/inserter/block-patterns-tab.js +7 -4
- package/src/components/inserter/hooks/use-insertion-point.js +3 -2
- package/src/components/inserter/index.js +61 -43
- package/src/components/inserter/media-tab/hooks.js +5 -4
- package/src/components/inserter/menu.js +8 -4
- package/src/components/inserter/quick-inserter.js +3 -0
- package/src/components/inserter/search-items.js +1 -2
- package/src/components/inserter/search-results.js +2 -0
- package/src/components/inserter/test/__snapshots__/index.native.js.snap +117 -0
- package/src/components/inserter/test/index.native.js +255 -1
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/position-controls-panel.js +37 -0
- package/src/components/inspector-controls-tabs/settings-tab.js +2 -0
- package/src/components/inspector-controls-tabs/style.scss +15 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -8
- package/src/components/link-control/search-input.js +1 -0
- package/src/components/link-control/style.scss +1 -0
- package/src/components/link-control/test/index.js +18 -4
- package/src/components/list-view/block-select-button.js +1 -1
- package/src/components/list-view/style.scss +14 -10
- package/src/components/media-replace-flow/test/index.js +2 -0
- package/src/components/off-canvas-editor/appender.js +4 -49
- package/src/components/off-canvas-editor/block-contents.js +84 -23
- package/src/components/off-canvas-editor/block-select-button.js +6 -2
- package/src/components/off-canvas-editor/block.js +90 -105
- package/src/components/off-canvas-editor/index.js +21 -2
- package/src/components/off-canvas-editor/style.scss +5 -1
- package/src/components/off-canvas-editor/test/use-inserted-block.js +108 -0
- package/src/components/off-canvas-editor/use-inserted-block.js +47 -0
- package/src/components/provider/index.js +4 -1
- package/src/components/responsive-block-control/label.js +2 -3
- package/src/components/responsive-block-control/test/index.js +4 -2
- package/src/components/rich-text/format-edit.js +6 -10
- package/src/components/rich-text/index.js +1 -0
- package/src/components/rich-text/use-enter.js +4 -4
- package/src/components/rich-text/use-paste-handler.js +33 -14
- package/src/components/spacing-sizes-control/index.js +0 -1
- package/src/components/spacing-sizes-control/utils.js +1 -1
- package/src/components/typewriter/index.js +3 -1
- package/src/components/url-input/README.md +5 -0
- package/src/components/url-input/button.js +1 -0
- package/src/components/url-input/index.js +15 -1
- package/src/components/url-input/test/button.js +2 -0
- package/src/components/url-popover/image-url-input-ui.js +5 -4
- package/src/components/url-popover/link-editor.js +1 -0
- package/src/components/url-popover/test/index.js +21 -5
- package/src/components/use-paste-styles/index.js +230 -0
- package/src/components/warning/test/index.js +2 -0
- package/src/components/writing-flow/index.js +1 -1
- package/src/components/writing-flow/use-arrow-nav.js +20 -28
- package/src/content.scss +1 -0
- package/src/hooks/border.js +0 -1
- package/src/hooks/color-panel.js +0 -1
- package/src/hooks/color.js +0 -2
- package/src/hooks/font-family.js +3 -5
- package/src/hooks/font-size.js +13 -4
- package/src/hooks/index.js +1 -0
- package/src/hooks/metadata.js +1 -2
- package/src/hooks/position.js +375 -0
- package/src/hooks/position.scss +18 -0
- package/src/hooks/supports.js +302 -0
- package/src/hooks/test/__snapshots__/align.native.js.snap +73 -0
- package/src/hooks/test/align.native.js +133 -0
- package/src/hooks/test/use-typography-props.js +26 -0
- package/src/hooks/use-typography-props.js +15 -7
- package/src/store/reducer.js +20 -8
- package/src/store/selectors.js +7 -8
- package/src/store/test/reducer.js +45 -3
- package/src/store/test/selectors.js +12 -9
- package/src/style.scss +2 -1
- package/src/utils/pasting.js +3 -9
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/colors-gradients/use-common-single-multiple-selects.js +0 -21
- package/build/components/colors-gradients/use-common-single-multiple-selects.js.map +0 -1
- package/build/components/rich-text/file-paste-handler.js +0 -21
- package/build/components/rich-text/file-paste-handler.js.map +0 -1
- package/build-module/components/colors-gradients/use-common-single-multiple-selects.js +0 -11
- package/build-module/components/colors-gradients/use-common-single-multiple-selects.js.map +0 -1
- package/build-module/components/rich-text/file-paste-handler.js +0 -13
- package/build-module/components/rich-text/file-paste-handler.js.map +0 -1
- package/src/components/colors-gradients/use-common-single-multiple-selects.js +0 -11
- package/src/components/rich-text/file-paste-handler.js +0 -13
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';
|
|
5
|
+
import { Platform } from '@wordpress/element';
|
|
6
|
+
|
|
7
|
+
const ALIGN_SUPPORT_KEY = 'align';
|
|
8
|
+
const ALIGN_WIDE_SUPPORT_KEY = 'alignWide';
|
|
9
|
+
const BORDER_SUPPORT_KEY = '__experimentalBorder';
|
|
10
|
+
const COLOR_SUPPORT_KEY = 'color';
|
|
11
|
+
const CUSTOM_CLASS_NAME_SUPPORT_KEY = 'customClassName';
|
|
12
|
+
const FONT_FAMILY_SUPPORT_KEY = 'typography.__experimentalFontFamily';
|
|
13
|
+
const FONT_SIZE_SUPPORT_KEY = 'typography.fontSize';
|
|
14
|
+
const LINE_HEIGHT_SUPPORT_KEY = 'typography.lineHeight';
|
|
15
|
+
/**
|
|
16
|
+
* Key within block settings' support array indicating support for font style.
|
|
17
|
+
*/
|
|
18
|
+
const FONT_STYLE_SUPPORT_KEY = 'typography.__experimentalFontStyle';
|
|
19
|
+
/**
|
|
20
|
+
* Key within block settings' support array indicating support for font weight.
|
|
21
|
+
*/
|
|
22
|
+
const FONT_WEIGHT_SUPPORT_KEY = 'typography.__experimentalFontWeight';
|
|
23
|
+
/**
|
|
24
|
+
* Key within block settings' supports array indicating support for text
|
|
25
|
+
* decorations e.g. settings found in `block.json`.
|
|
26
|
+
*/
|
|
27
|
+
const TEXT_DECORATION_SUPPORT_KEY = 'typography.__experimentalTextDecoration';
|
|
28
|
+
/**
|
|
29
|
+
* Key within block settings' supports array indicating support for text
|
|
30
|
+
* transforms e.g. settings found in `block.json`.
|
|
31
|
+
*/
|
|
32
|
+
const TEXT_TRANSFORM_SUPPORT_KEY = 'typography.__experimentalTextTransform';
|
|
33
|
+
/**
|
|
34
|
+
* Key within block settings' supports array indicating support for letter-spacing
|
|
35
|
+
* e.g. settings found in `block.json`.
|
|
36
|
+
*/
|
|
37
|
+
const LETTER_SPACING_SUPPORT_KEY = 'typography.__experimentalLetterSpacing';
|
|
38
|
+
const LAYOUT_SUPPORT_KEY = '__experimentalLayout';
|
|
39
|
+
const TYPOGRAPHY_SUPPORT_KEYS = [
|
|
40
|
+
LINE_HEIGHT_SUPPORT_KEY,
|
|
41
|
+
FONT_SIZE_SUPPORT_KEY,
|
|
42
|
+
FONT_STYLE_SUPPORT_KEY,
|
|
43
|
+
FONT_WEIGHT_SUPPORT_KEY,
|
|
44
|
+
FONT_FAMILY_SUPPORT_KEY,
|
|
45
|
+
TEXT_DECORATION_SUPPORT_KEY,
|
|
46
|
+
TEXT_TRANSFORM_SUPPORT_KEY,
|
|
47
|
+
LETTER_SPACING_SUPPORT_KEY,
|
|
48
|
+
];
|
|
49
|
+
const SPACING_SUPPORT_KEY = 'spacing';
|
|
50
|
+
const styleSupportKeys = [
|
|
51
|
+
...TYPOGRAPHY_SUPPORT_KEYS,
|
|
52
|
+
BORDER_SUPPORT_KEY,
|
|
53
|
+
COLOR_SUPPORT_KEY,
|
|
54
|
+
SPACING_SUPPORT_KEY,
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Returns true if the block defines support for align.
|
|
59
|
+
*
|
|
60
|
+
* @param {string|Object} nameOrType Block name or type object.
|
|
61
|
+
* @return {boolean} Whether the block supports the feature.
|
|
62
|
+
*/
|
|
63
|
+
export const hasAlignSupport = ( nameOrType ) =>
|
|
64
|
+
hasBlockSupport( nameOrType, ALIGN_SUPPORT_KEY );
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Returns the block support value for align, if defined.
|
|
68
|
+
*
|
|
69
|
+
* @param {string|Object} nameOrType Block name or type object.
|
|
70
|
+
* @return {unknown} The block support value.
|
|
71
|
+
*/
|
|
72
|
+
export const getAlignSupport = ( nameOrType ) =>
|
|
73
|
+
getBlockSupport( nameOrType, ALIGN_SUPPORT_KEY );
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Returns true if the block defines support for align wide.
|
|
77
|
+
*
|
|
78
|
+
* @param {string|Object} nameOrType Block name or type object.
|
|
79
|
+
* @return {boolean} Whether the block supports the feature.
|
|
80
|
+
*/
|
|
81
|
+
export const hasAlignWideSupport = ( nameOrType ) =>
|
|
82
|
+
hasBlockSupport( nameOrType, ALIGN_WIDE_SUPPORT_KEY );
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Returns the block support value for align wide, if defined.
|
|
86
|
+
*
|
|
87
|
+
* @param {string|Object} nameOrType Block name or type object.
|
|
88
|
+
* @return {unknown} The block support value.
|
|
89
|
+
*/
|
|
90
|
+
export const getAlignWideSupport = ( nameOrType ) =>
|
|
91
|
+
getBlockSupport( nameOrType, ALIGN_WIDE_SUPPORT_KEY );
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Determine whether there is block support for border properties.
|
|
95
|
+
*
|
|
96
|
+
* @param {string|Object} nameOrType Block name or type object.
|
|
97
|
+
* @param {string} feature Border feature to check support for.
|
|
98
|
+
*
|
|
99
|
+
* @return {boolean} Whether there is support.
|
|
100
|
+
*/
|
|
101
|
+
export function hasBorderSupport( nameOrType, feature = 'any' ) {
|
|
102
|
+
if ( Platform.OS !== 'web' ) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const support = getBlockSupport( nameOrType, BORDER_SUPPORT_KEY );
|
|
107
|
+
|
|
108
|
+
if ( support === true ) {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if ( feature === 'any' ) {
|
|
113
|
+
return !! (
|
|
114
|
+
support?.color ||
|
|
115
|
+
support?.radius ||
|
|
116
|
+
support?.width ||
|
|
117
|
+
support?.style
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return !! support?.[ feature ];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Get block support for border properties.
|
|
126
|
+
*
|
|
127
|
+
* @param {string|Object} nameOrType Block name or type object.
|
|
128
|
+
* @param {string} feature Border feature to get.
|
|
129
|
+
*
|
|
130
|
+
* @return {unknown} The block support.
|
|
131
|
+
*/
|
|
132
|
+
export const getBorderSupport = ( nameOrType, feature ) =>
|
|
133
|
+
getBlockSupport( nameOrType, [ BORDER_SUPPORT_KEY, feature ] );
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Returns true if the block defines support for color.
|
|
137
|
+
*
|
|
138
|
+
* @param {string|Object} nameOrType Block name or type object.
|
|
139
|
+
* @return {boolean} Whether the block supports the feature.
|
|
140
|
+
*/
|
|
141
|
+
export const hasColorSupport = ( nameOrType ) => {
|
|
142
|
+
const colorSupport = getBlockSupport( nameOrType, COLOR_SUPPORT_KEY );
|
|
143
|
+
return (
|
|
144
|
+
colorSupport &&
|
|
145
|
+
( colorSupport.link === true ||
|
|
146
|
+
colorSupport.gradient === true ||
|
|
147
|
+
colorSupport.background !== false ||
|
|
148
|
+
colorSupport.text !== false )
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Returns true if the block defines support for link color.
|
|
154
|
+
*
|
|
155
|
+
* @param {string|Object} nameOrType Block name or type object.
|
|
156
|
+
* @return {boolean} Whether the block supports the feature.
|
|
157
|
+
*/
|
|
158
|
+
export const hasLinkColorSupport = ( nameOrType ) => {
|
|
159
|
+
if ( Platform.OS !== 'web' ) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const colorSupport = getBlockSupport( nameOrType, COLOR_SUPPORT_KEY );
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
colorSupport !== null &&
|
|
167
|
+
typeof colorSupport === 'object' &&
|
|
168
|
+
!! colorSupport.link
|
|
169
|
+
);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Returns true if the block defines support for gradient color.
|
|
174
|
+
*
|
|
175
|
+
* @param {string|Object} nameOrType Block name or type object.
|
|
176
|
+
* @return {boolean} Whether the block supports the feature.
|
|
177
|
+
*/
|
|
178
|
+
export const hasGradientSupport = ( nameOrType ) => {
|
|
179
|
+
const colorSupport = getBlockSupport( nameOrType, COLOR_SUPPORT_KEY );
|
|
180
|
+
|
|
181
|
+
return (
|
|
182
|
+
colorSupport !== null &&
|
|
183
|
+
typeof colorSupport === 'object' &&
|
|
184
|
+
!! colorSupport.gradients
|
|
185
|
+
);
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Returns true if the block defines support for background color.
|
|
190
|
+
*
|
|
191
|
+
* @param {string|Object} nameOrType Block name or type object.
|
|
192
|
+
* @return {boolean} Whether the block supports the feature.
|
|
193
|
+
*/
|
|
194
|
+
export const hasBackgroundColorSupport = ( nameOrType ) => {
|
|
195
|
+
const colorSupport = getBlockSupport( nameOrType, COLOR_SUPPORT_KEY );
|
|
196
|
+
|
|
197
|
+
return colorSupport && colorSupport.background !== false;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Returns true if the block defines support for background color.
|
|
202
|
+
*
|
|
203
|
+
* @param {string|Object} nameOrType Block name or type object.
|
|
204
|
+
* @return {boolean} Whether the block supports the feature.
|
|
205
|
+
*/
|
|
206
|
+
export const hasTextColorSupport = ( nameOrType ) => {
|
|
207
|
+
const colorSupport = getBlockSupport( nameOrType, COLOR_SUPPORT_KEY );
|
|
208
|
+
|
|
209
|
+
return colorSupport && colorSupport.text !== false;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Get block support for color properties.
|
|
214
|
+
*
|
|
215
|
+
* @param {string|Object} nameOrType Block name or type object.
|
|
216
|
+
* @param {string} feature Color feature to get.
|
|
217
|
+
*
|
|
218
|
+
* @return {unknown} The block support.
|
|
219
|
+
*/
|
|
220
|
+
export const getColorSupport = ( nameOrType, feature ) =>
|
|
221
|
+
getBlockSupport( nameOrType, [ COLOR_SUPPORT_KEY, feature ] );
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Returns true if the block defines support for custom class name.
|
|
225
|
+
*
|
|
226
|
+
* @param {string|Object} nameOrType Block name or type object.
|
|
227
|
+
* @return {boolean} Whether the block supports the feature.
|
|
228
|
+
*/
|
|
229
|
+
export const hasCustomClassNameSupport = ( nameOrType ) =>
|
|
230
|
+
hasBlockSupport( nameOrType, CUSTOM_CLASS_NAME_SUPPORT_KEY, true );
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Returns the block support value for custom class name, if defined.
|
|
234
|
+
*
|
|
235
|
+
* @param {string|Object} nameOrType Block name or type object.
|
|
236
|
+
* @return {unknown} The block support value.
|
|
237
|
+
*/
|
|
238
|
+
export const getCustomClassNameSupport = ( nameOrType ) =>
|
|
239
|
+
getBlockSupport( nameOrType, CUSTOM_CLASS_NAME_SUPPORT_KEY, true );
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Returns true if the block defines support for font family.
|
|
243
|
+
*
|
|
244
|
+
* @param {string|Object} nameOrType Block name or type object.
|
|
245
|
+
* @return {boolean} Whether the block supports the feature.
|
|
246
|
+
*/
|
|
247
|
+
export const hasFontFamilySupport = ( nameOrType ) =>
|
|
248
|
+
hasBlockSupport( nameOrType, FONT_FAMILY_SUPPORT_KEY );
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Returns the block support value for font family, if defined.
|
|
252
|
+
*
|
|
253
|
+
* @param {string|Object} nameOrType Block name or type object.
|
|
254
|
+
* @return {unknown} The block support value.
|
|
255
|
+
*/
|
|
256
|
+
export const getFontFamilySupport = ( nameOrType ) =>
|
|
257
|
+
getBlockSupport( nameOrType, FONT_FAMILY_SUPPORT_KEY );
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Returns true if the block defines support for font size.
|
|
261
|
+
*
|
|
262
|
+
* @param {string|Object} nameOrType Block name or type object.
|
|
263
|
+
* @return {boolean} Whether the block supports the feature.
|
|
264
|
+
*/
|
|
265
|
+
export const hasFontSizeSupport = ( nameOrType ) =>
|
|
266
|
+
hasBlockSupport( nameOrType, FONT_SIZE_SUPPORT_KEY );
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Returns the block support value for font size, if defined.
|
|
270
|
+
*
|
|
271
|
+
* @param {string|Object} nameOrType Block name or type object.
|
|
272
|
+
* @return {unknown} The block support value.
|
|
273
|
+
*/
|
|
274
|
+
export const getFontSizeSupport = ( nameOrType ) =>
|
|
275
|
+
getBlockSupport( nameOrType, FONT_SIZE_SUPPORT_KEY );
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Returns true if the block defines support for layout.
|
|
279
|
+
*
|
|
280
|
+
* @param {string|Object} nameOrType Block name or type object.
|
|
281
|
+
* @return {boolean} Whether the block supports the feature.
|
|
282
|
+
*/
|
|
283
|
+
export const hasLayoutSupport = ( nameOrType ) =>
|
|
284
|
+
hasBlockSupport( nameOrType, LAYOUT_SUPPORT_KEY );
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Returns the block support value for layout, if defined.
|
|
288
|
+
*
|
|
289
|
+
* @param {string|Object} nameOrType Block name or type object.
|
|
290
|
+
* @return {unknown} The block support value.
|
|
291
|
+
*/
|
|
292
|
+
export const getLayoutSupport = ( nameOrType ) =>
|
|
293
|
+
getBlockSupport( nameOrType, LAYOUT_SUPPORT_KEY );
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Returns true if the block defines support for style.
|
|
297
|
+
*
|
|
298
|
+
* @param {string|Object} nameOrType Block name or type object.
|
|
299
|
+
* @return {boolean} Whether the block supports the feature.
|
|
300
|
+
*/
|
|
301
|
+
export const hasStyleSupport = ( nameOrType ) =>
|
|
302
|
+
styleSupportKeys.some( ( key ) => hasBlockSupport( nameOrType, key ) );
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Align options for group block sets Full width option 1`] = `
|
|
4
|
+
"<!-- wp:group {\\"align\\":\\"full\\",\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
|
|
5
|
+
<div class=\\"wp-block-group alignfull\\"></div>
|
|
6
|
+
<!-- /wp:group -->"
|
|
7
|
+
`;
|
|
8
|
+
|
|
9
|
+
exports[`Align options for group block sets None option 1`] = `
|
|
10
|
+
"<!-- wp:group {\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
|
|
11
|
+
<div class=\\"wp-block-group\\"></div>
|
|
12
|
+
<!-- /wp:group -->"
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
exports[`Align options for group block sets Wide width option 1`] = `
|
|
16
|
+
"<!-- wp:group {\\"align\\":\\"wide\\",\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
|
|
17
|
+
<div class=\\"wp-block-group alignwide\\"></div>
|
|
18
|
+
<!-- /wp:group -->"
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
exports[`Align options for media block sets Align center option 1`] = `
|
|
22
|
+
"<!-- wp:image {\\"align\\":\\"center\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
|
|
23
|
+
<figure class=\\"wp-block-image aligncenter size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
|
|
24
|
+
<!-- /wp:image -->"
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
exports[`Align options for media block sets Align left option 1`] = `
|
|
28
|
+
"<!-- wp:image {\\"align\\":\\"left\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
|
|
29
|
+
<figure class=\\"wp-block-image alignleft size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
|
|
30
|
+
<!-- /wp:image -->"
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
exports[`Align options for media block sets Align right option 1`] = `
|
|
34
|
+
"<!-- wp:image {\\"align\\":\\"right\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
|
|
35
|
+
<figure class=\\"wp-block-image alignright size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
|
|
36
|
+
<!-- /wp:image -->"
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
exports[`Align options for media block sets Full width option 1`] = `
|
|
40
|
+
"<!-- wp:image {\\"align\\":\\"full\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
|
|
41
|
+
<figure class=\\"wp-block-image alignfull size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
|
|
42
|
+
<!-- /wp:image -->"
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
exports[`Align options for media block sets None option 1`] = `
|
|
46
|
+
"<!-- wp:image {\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
|
|
47
|
+
<figure class=\\"wp-block-image size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
|
|
48
|
+
<!-- /wp:image -->"
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
exports[`Align options for media block sets Wide width option 1`] = `
|
|
52
|
+
"<!-- wp:image {\\"align\\":\\"wide\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
|
|
53
|
+
<figure class=\\"wp-block-image alignwide size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
|
|
54
|
+
<!-- /wp:image -->"
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
exports[`Align options for text block sets Align text center option 1`] = `
|
|
58
|
+
"<!-- wp:paragraph {\\"align\\":\\"center\\"} -->
|
|
59
|
+
<p class=\\"has-text-align-center\\"></p>
|
|
60
|
+
<!-- /wp:paragraph -->"
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
exports[`Align options for text block sets Align text left option 1`] = `
|
|
64
|
+
"<!-- wp:paragraph {\\"align\\":\\"left\\"} -->
|
|
65
|
+
<p class=\\"has-text-align-left\\"></p>
|
|
66
|
+
<!-- /wp:paragraph -->"
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
exports[`Align options for text block sets Align text right option 1`] = `
|
|
70
|
+
"<!-- wp:paragraph {\\"align\\":\\"right\\"} -->
|
|
71
|
+
<p class=\\"has-text-align-right\\"></p>
|
|
72
|
+
<!-- /wp:paragraph -->"
|
|
73
|
+
`;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
addBlock,
|
|
6
|
+
getEditorHtml,
|
|
7
|
+
initializeEditor,
|
|
8
|
+
getBlock,
|
|
9
|
+
fireEvent,
|
|
10
|
+
within,
|
|
11
|
+
} from 'test/helpers';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* WordPress dependencies
|
|
15
|
+
*/
|
|
16
|
+
import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
|
|
17
|
+
import { registerCoreBlocks } from '@wordpress/block-library';
|
|
18
|
+
|
|
19
|
+
const imageHTML = `<!-- wp:image {"id":1,"sizeSlug":"large","linkDestination":"none"} -->
|
|
20
|
+
<figure class="wp-block-image size-large"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt="" class="wp-image-1"/></figure>
|
|
21
|
+
<!-- /wp:image -->`;
|
|
22
|
+
|
|
23
|
+
beforeAll( () => {
|
|
24
|
+
// Register all core blocks
|
|
25
|
+
registerCoreBlocks();
|
|
26
|
+
} );
|
|
27
|
+
|
|
28
|
+
afterAll( () => {
|
|
29
|
+
// Clean up registered blocks
|
|
30
|
+
getBlockTypes().forEach( ( block ) => {
|
|
31
|
+
unregisterBlockType( block.name );
|
|
32
|
+
} );
|
|
33
|
+
} );
|
|
34
|
+
|
|
35
|
+
describe( 'Align options', () => {
|
|
36
|
+
describe( 'for media block', () => {
|
|
37
|
+
[
|
|
38
|
+
'None',
|
|
39
|
+
'Align left',
|
|
40
|
+
'Align center',
|
|
41
|
+
'Align right',
|
|
42
|
+
'Wide width',
|
|
43
|
+
'Full width',
|
|
44
|
+
].forEach( ( alignmentOption ) =>
|
|
45
|
+
it( `sets ${ alignmentOption } option`, async () => {
|
|
46
|
+
const screen = await initializeEditor( {
|
|
47
|
+
initialHtml: imageHTML,
|
|
48
|
+
} );
|
|
49
|
+
const { getByLabelText } = screen;
|
|
50
|
+
|
|
51
|
+
// Get Image block
|
|
52
|
+
const imageBlock = await getBlock( screen, 'Image' );
|
|
53
|
+
expect( imageBlock ).toBeVisible();
|
|
54
|
+
fireEvent.press( imageBlock );
|
|
55
|
+
|
|
56
|
+
// Open alignments menu
|
|
57
|
+
const alignmentButtons = getByLabelText( 'Align' );
|
|
58
|
+
fireEvent.press( alignmentButtons );
|
|
59
|
+
|
|
60
|
+
// Select alignment option.
|
|
61
|
+
fireEvent.press( await getByLabelText( alignmentOption ) );
|
|
62
|
+
|
|
63
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
64
|
+
} )
|
|
65
|
+
);
|
|
66
|
+
} );
|
|
67
|
+
|
|
68
|
+
describe( 'for text block', () => {
|
|
69
|
+
[ 'Align text left', 'Align text center', 'Align text right' ].forEach(
|
|
70
|
+
( alignmentOption ) =>
|
|
71
|
+
it( `sets ${ alignmentOption } option`, async () => {
|
|
72
|
+
const screen = await initializeEditor();
|
|
73
|
+
const { getByLabelText } = screen;
|
|
74
|
+
|
|
75
|
+
// Add Paragraph block
|
|
76
|
+
await addBlock( screen, 'Paragraph' );
|
|
77
|
+
|
|
78
|
+
// Get Paragraph block
|
|
79
|
+
const paragraphBlock = await getBlock(
|
|
80
|
+
screen,
|
|
81
|
+
'Paragraph'
|
|
82
|
+
);
|
|
83
|
+
expect( paragraphBlock ).toBeVisible();
|
|
84
|
+
|
|
85
|
+
// Open alignments menu
|
|
86
|
+
const alignmentButtons = getByLabelText( 'Align' );
|
|
87
|
+
fireEvent.press( alignmentButtons );
|
|
88
|
+
|
|
89
|
+
// Select alignment option.
|
|
90
|
+
fireEvent.press( await getByLabelText( alignmentOption ) );
|
|
91
|
+
|
|
92
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
93
|
+
} )
|
|
94
|
+
);
|
|
95
|
+
} );
|
|
96
|
+
|
|
97
|
+
describe( 'for group block', () => {
|
|
98
|
+
[ 'None', 'Wide width', 'Full width' ].forEach( ( alignmentOption ) =>
|
|
99
|
+
it( `sets ${ alignmentOption } option`, async () => {
|
|
100
|
+
const screen = await initializeEditor();
|
|
101
|
+
const { getByLabelText } = screen;
|
|
102
|
+
|
|
103
|
+
// Add Group block
|
|
104
|
+
await addBlock( screen, 'Group' );
|
|
105
|
+
|
|
106
|
+
// Get Paragraph block
|
|
107
|
+
const groupBlock = await getBlock( screen, 'Group' );
|
|
108
|
+
expect( groupBlock ).toBeVisible();
|
|
109
|
+
|
|
110
|
+
// Trigger inner blocks layout
|
|
111
|
+
const innerBlockListWrapper = await within(
|
|
112
|
+
groupBlock
|
|
113
|
+
).findByTestId( 'block-list-wrapper' );
|
|
114
|
+
fireEvent( innerBlockListWrapper, 'layout', {
|
|
115
|
+
nativeEvent: {
|
|
116
|
+
layout: {
|
|
117
|
+
width: 300,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
} );
|
|
121
|
+
|
|
122
|
+
// Open alignments menu
|
|
123
|
+
const alignmentButtons = getByLabelText( 'Align' );
|
|
124
|
+
fireEvent.press( alignmentButtons );
|
|
125
|
+
|
|
126
|
+
// Select alignment option.
|
|
127
|
+
fireEvent.press( await getByLabelText( alignmentOption ) );
|
|
128
|
+
|
|
129
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
130
|
+
} )
|
|
131
|
+
);
|
|
132
|
+
} );
|
|
133
|
+
} );
|
|
@@ -47,4 +47,30 @@ describe( 'getTypographyClassesAndStyles', () => {
|
|
|
47
47
|
},
|
|
48
48
|
} );
|
|
49
49
|
} );
|
|
50
|
+
|
|
51
|
+
it( 'should return configured fluid font size styles', () => {
|
|
52
|
+
const attributes = {
|
|
53
|
+
fontFamily: 'tofu',
|
|
54
|
+
style: {
|
|
55
|
+
typography: {
|
|
56
|
+
textDecoration: 'underline',
|
|
57
|
+
fontSize: '2rem',
|
|
58
|
+
textTransform: 'uppercase',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
expect(
|
|
63
|
+
getTypographyClassesAndStyles( attributes, {
|
|
64
|
+
minFontSize: '1rem',
|
|
65
|
+
} )
|
|
66
|
+
).toEqual( {
|
|
67
|
+
className: 'has-tofu-font-family',
|
|
68
|
+
style: {
|
|
69
|
+
textDecoration: 'underline',
|
|
70
|
+
fontSize:
|
|
71
|
+
'clamp(1.5rem, 1.5rem + ((1vw - 0.48rem) * 0.962), 2rem)',
|
|
72
|
+
textTransform: 'uppercase',
|
|
73
|
+
},
|
|
74
|
+
} );
|
|
75
|
+
} );
|
|
50
76
|
} );
|
|
@@ -19,23 +19,31 @@ import { getComputedFluidTypographyValue } from '../components/font-sizes/fluid-
|
|
|
19
19
|
* Provides the CSS class names and inline styles for a block's typography support
|
|
20
20
|
* attributes.
|
|
21
21
|
*
|
|
22
|
-
* @param {Object}
|
|
23
|
-
* @param {boolean}
|
|
22
|
+
* @param {Object} attributes Block attributes.
|
|
23
|
+
* @param {Object|boolean} fluidTypographySettings If boolean, whether the function should try to convert font sizes to fluid values,
|
|
24
|
+
* otherwise an object containing theme fluid typography settings.
|
|
24
25
|
*
|
|
25
26
|
* @return {Object} Typography block support derived CSS classes & styles.
|
|
26
27
|
*/
|
|
27
28
|
export function getTypographyClassesAndStyles(
|
|
28
29
|
attributes,
|
|
29
|
-
|
|
30
|
+
fluidTypographySettings
|
|
30
31
|
) {
|
|
31
32
|
let typographyStyles = attributes?.style?.typography || {};
|
|
32
33
|
|
|
33
|
-
if (
|
|
34
|
+
if (
|
|
35
|
+
!! fluidTypographySettings &&
|
|
36
|
+
( true === fluidTypographySettings ||
|
|
37
|
+
Object.keys( fluidTypographySettings ).length !== 0 )
|
|
38
|
+
) {
|
|
39
|
+
const newFontSize =
|
|
40
|
+
getComputedFluidTypographyValue( {
|
|
41
|
+
fontSize: attributes?.style?.typography?.fontSize,
|
|
42
|
+
minimumFontSizeLimit: fluidTypographySettings?.minFontSize,
|
|
43
|
+
} ) || attributes?.style?.typography?.fontSize;
|
|
34
44
|
typographyStyles = {
|
|
35
45
|
...typographyStyles,
|
|
36
|
-
fontSize:
|
|
37
|
-
fontSize: attributes?.style?.typography?.fontSize,
|
|
38
|
-
} ),
|
|
46
|
+
fontSize: newFontSize,
|
|
39
47
|
};
|
|
40
48
|
}
|
|
41
49
|
|
package/src/store/reducer.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import fastDeepEqual from 'fast-deep-equal/es6';
|
|
5
|
-
import { omit, isEmpty } from 'lodash';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* WordPress dependencies
|
|
@@ -113,7 +112,10 @@ function getFlattenedClientIds( blocks ) {
|
|
|
113
112
|
* @return {Array} Flattened block attributes object.
|
|
114
113
|
*/
|
|
115
114
|
function getFlattenedBlocksWithoutAttributes( blocks ) {
|
|
116
|
-
return flattenBlocks( blocks, ( block ) =>
|
|
115
|
+
return flattenBlocks( blocks, ( block ) => {
|
|
116
|
+
const { attributes, ...restBlock } = block;
|
|
117
|
+
return restBlock;
|
|
118
|
+
} );
|
|
117
119
|
}
|
|
118
120
|
|
|
119
121
|
/**
|
|
@@ -782,8 +784,8 @@ export const blocks = pipe(
|
|
|
782
784
|
}
|
|
783
785
|
|
|
784
786
|
// Do nothing if only attributes change.
|
|
785
|
-
const changes =
|
|
786
|
-
if (
|
|
787
|
+
const { attributes, ...changes } = action.updates;
|
|
788
|
+
if ( Object.values( changes ).length === 0 ) {
|
|
787
789
|
return state;
|
|
788
790
|
}
|
|
789
791
|
|
|
@@ -1641,13 +1643,18 @@ export const blockListSettings = ( state = {}, action ) => {
|
|
|
1641
1643
|
// should correct the state.
|
|
1642
1644
|
case 'REPLACE_BLOCKS':
|
|
1643
1645
|
case 'REMOVE_BLOCKS': {
|
|
1644
|
-
return
|
|
1646
|
+
return Object.fromEntries(
|
|
1647
|
+
Object.entries( state ).filter(
|
|
1648
|
+
( [ id ] ) => ! action.clientIds.includes( id )
|
|
1649
|
+
)
|
|
1650
|
+
);
|
|
1645
1651
|
}
|
|
1646
1652
|
case 'UPDATE_BLOCK_LIST_SETTINGS': {
|
|
1647
1653
|
const { clientId } = action;
|
|
1648
1654
|
if ( ! action.settings ) {
|
|
1649
1655
|
if ( state.hasOwnProperty( clientId ) ) {
|
|
1650
|
-
|
|
1656
|
+
const { [ clientId ]: removedBlock, ...restBlocks } = state;
|
|
1657
|
+
return restBlocks;
|
|
1651
1658
|
}
|
|
1652
1659
|
|
|
1653
1660
|
return state;
|
|
@@ -1822,14 +1829,19 @@ export function highlightedBlock( state, action ) {
|
|
|
1822
1829
|
export function lastBlockInserted( state = {}, action ) {
|
|
1823
1830
|
switch ( action.type ) {
|
|
1824
1831
|
case 'INSERT_BLOCKS':
|
|
1832
|
+
case 'REPLACE_BLOCKS':
|
|
1833
|
+
case 'REPLACE_INNER_BLOCKS':
|
|
1825
1834
|
if ( ! action.blocks.length ) {
|
|
1826
1835
|
return state;
|
|
1827
1836
|
}
|
|
1828
1837
|
|
|
1829
|
-
const
|
|
1838
|
+
const clientIds = action.blocks.map( ( block ) => {
|
|
1839
|
+
return block.clientId;
|
|
1840
|
+
} );
|
|
1841
|
+
|
|
1830
1842
|
const source = action.meta?.source;
|
|
1831
1843
|
|
|
1832
|
-
return {
|
|
1844
|
+
return { clientIds, source };
|
|
1833
1845
|
case 'RESET_BLOCKS':
|
|
1834
1846
|
return {};
|
|
1835
1847
|
}
|
package/src/store/selectors.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { map
|
|
4
|
+
import { map } from 'lodash';
|
|
5
5
|
import createSelector from 'rememo';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -2469,8 +2469,7 @@ export const __experimentalGetBlockListSettingsForBlocks = createSelector(
|
|
|
2469
2469
|
*/
|
|
2470
2470
|
export const __experimentalGetReusableBlockTitle = createSelector(
|
|
2471
2471
|
( state, ref ) => {
|
|
2472
|
-
const reusableBlock = find(
|
|
2473
|
-
getReusableBlocks( state ),
|
|
2472
|
+
const reusableBlock = getReusableBlocks( state ).find(
|
|
2474
2473
|
( block ) => block.id === ref
|
|
2475
2474
|
);
|
|
2476
2475
|
if ( ! reusableBlock ) {
|
|
@@ -2648,19 +2647,19 @@ export const __experimentalGetActiveBlockIdByBlockNames = createSelector(
|
|
|
2648
2647
|
export function wasBlockJustInserted( state, clientId, source ) {
|
|
2649
2648
|
const { lastBlockInserted } = state;
|
|
2650
2649
|
return (
|
|
2651
|
-
lastBlockInserted.clientId
|
|
2650
|
+
lastBlockInserted.clientIds?.includes( clientId ) &&
|
|
2652
2651
|
lastBlockInserted.source === source
|
|
2653
2652
|
);
|
|
2654
2653
|
}
|
|
2655
2654
|
|
|
2656
2655
|
/**
|
|
2657
|
-
* Gets the client
|
|
2656
|
+
* Gets the client ids of the last inserted blocks.
|
|
2658
2657
|
*
|
|
2659
2658
|
* @param {Object} state Global application state.
|
|
2660
|
-
* @return {
|
|
2659
|
+
* @return {Array|undefined} Client Ids of the last inserted block(s).
|
|
2661
2660
|
*/
|
|
2662
|
-
export function
|
|
2663
|
-
return state?.lastBlockInserted?.
|
|
2661
|
+
export function getLastInsertedBlocksClientIds( state ) {
|
|
2662
|
+
return state?.lastBlockInserted?.clientIds;
|
|
2664
2663
|
}
|
|
2665
2664
|
|
|
2666
2665
|
/**
|