@wordpress/block-editor 11.5.0 → 11.7.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 +6 -0
- package/README.md +4 -0
- package/build/components/block-list/block-html.js +1 -3
- package/build/components/block-list/block-html.js.map +1 -1
- package/build/components/block-list/block-invalid-warning.js +63 -80
- package/build/components/block-list/block-invalid-warning.js.map +1 -1
- package/build/components/block-preview/auto.js +6 -23
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +1 -1
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build/components/editor-styles/index.js +20 -2
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +306 -0
- package/build/components/global-styles/border-panel.js.map +1 -0
- package/build/components/global-styles/color-panel.js +583 -0
- package/build/components/global-styles/color-panel.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +8 -30
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/get-block-css-selector.js +129 -0
- package/build/components/global-styles/get-block-css-selector.js.map +1 -0
- package/build/components/global-styles/hooks.js +109 -3
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +36 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +66 -45
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +180 -99
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/image-size-control/index.js +8 -5
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/inserter/index.js +29 -17
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/menu.js +1 -1
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +4 -2
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-results.js +10 -3
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +1 -1
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js +43 -7
- package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build/components/line-height-control/index.js +15 -1
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/index.js +1 -1
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-item.js +5 -2
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/list-view/appender.js +105 -0
- package/build/components/list-view/appender.js.map +1 -0
- package/build/components/list-view/block.js +5 -5
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +25 -5
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +37 -13
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +1 -2
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/media-replace-flow/index.js +13 -4
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +28 -3
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +5 -3
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +9 -7
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/link-ui.js +0 -1
- package/build/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build/components/provider/use-block-sync.js +17 -3
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/rich-text/format-edit.js +2 -30
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +0 -3
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/writing-flow/use-input.js +4 -8
- package/build/components/writing-flow/use-input.js.map +1 -1
- package/build/hooks/border.js +90 -240
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +92 -229
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +4 -2
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/{color-panel.js → contrast-checker.js} +11 -49
- package/build/hooks/contrast-checker.js.map +1 -0
- package/build/hooks/custom-class-name.js +4 -4
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/custom-class-name.native.js +3 -4
- package/build/hooks/custom-class-name.native.js.map +1 -1
- package/build/hooks/dimensions.js +0 -1
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +3 -1
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/layout.js +19 -22
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/position.js +2 -2
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +23 -26
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/supports.js +7 -1
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.js +2 -2
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +50 -75
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +6 -2
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/grid.js +165 -0
- package/build/layouts/grid.js.map +1 -0
- package/build/layouts/index.js +3 -1
- package/build/layouts/index.js.map +1 -1
- package/build/private-apis.js +7 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +10 -8
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +19 -3
- package/build/store/selectors.js.map +1 -1
- package/build/utils/object.js +76 -0
- package/build/utils/object.js.map +1 -0
- package/build/utils/parse-css-unit-to-px.js +15 -9
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/components/block-list/block-html.js +1 -3
- package/build-module/components/block-list/block-html.js.map +1 -1
- package/build-module/components/block-list/block-invalid-warning.js +66 -78
- package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
- package/build-module/components/block-preview/auto.js +6 -22
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +1 -1
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build-module/components/editor-styles/index.js +19 -2
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +291 -0
- package/build-module/components/global-styles/border-panel.js.map +1 -0
- package/build-module/components/global-styles/color-panel.js +554 -0
- package/build-module/components/global-styles/color-panel.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +7 -30
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/get-block-css-selector.js +120 -0
- package/build-module/components/global-styles/get-block-css-selector.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +104 -3
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +3 -0
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +65 -46
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +181 -100
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/image-size-control/index.js +8 -5
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/inserter/index.js +28 -16
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/menu.js +1 -1
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +4 -2
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-results.js +10 -3
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +1 -1
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js +42 -7
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build-module/components/line-height-control/index.js +15 -1
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +1 -1
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-item.js +4 -2
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/list-view/appender.js +88 -0
- package/build-module/components/list-view/appender.js.map +1 -0
- package/build-module/components/list-view/block.js +5 -4
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +22 -5
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +32 -12
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +1 -2
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +12 -4
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +28 -4
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +5 -3
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +9 -7
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/link-ui.js +0 -1
- package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +17 -3
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +3 -31
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +0 -3
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/writing-flow/use-input.js +4 -8
- package/build-module/components/writing-flow/use-input.js.map +1 -1
- package/build-module/hooks/border.js +92 -240
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +90 -232
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +4 -2
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/{color-panel.js → contrast-checker.js} +10 -44
- package/build-module/hooks/contrast-checker.js.map +1 -0
- package/build-module/hooks/custom-class-name.js +4 -4
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/custom-class-name.native.js +3 -4
- package/build-module/hooks/custom-class-name.native.js.map +1 -1
- package/build-module/hooks/dimensions.js +0 -1
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +4 -2
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/layout.js +19 -22
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/position.js +3 -3
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +23 -26
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/supports.js +7 -1
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.js +2 -2
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +48 -72
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +6 -2
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/grid.js +151 -0
- package/build-module/layouts/grid.js.map +1 -0
- package/build-module/layouts/index.js +2 -1
- package/build-module/layouts/index.js.map +1 -1
- package/build-module/private-apis.js +5 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +10 -8
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +17 -3
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/object.js +69 -0
- package/build-module/utils/object.js.map +1 -0
- package/build-module/utils/parse-css-unit-to-px.js +15 -9
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-style/style-rtl.css +32 -12
- package/build-style/style.css +32 -12
- package/package.json +31 -31
- package/src/components/block-draggable/content.scss +1 -1
- package/src/components/block-inspector/style.scss +3 -0
- package/src/components/block-list/block-html.js +1 -1
- package/src/components/block-list/block-invalid-warning.js +72 -64
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +20 -2
- package/src/components/block-preview/auto.js +2 -17
- package/src/components/block-preview/test/index.js +0 -2
- package/src/components/block-settings-menu-controls/index.js +2 -1
- package/src/components/block-styles/style.scss +2 -2
- package/src/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +16 -14
- package/src/components/colors-gradients/style.scss +8 -8
- package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +48 -38
- package/src/components/editor-styles/index.js +29 -1
- package/src/components/global-styles/border-panel.js +285 -0
- package/src/components/global-styles/color-panel.js +706 -0
- package/src/components/global-styles/dimensions-panel.js +13 -42
- package/src/components/global-styles/get-block-css-selector.js +129 -0
- package/src/components/global-styles/hooks.js +154 -1
- package/src/components/global-styles/index.js +3 -0
- package/src/components/global-styles/test/use-global-styles-output.js +31 -2
- package/src/components/global-styles/typography-panel.js +67 -45
- package/src/components/global-styles/use-global-styles-output.js +176 -93
- package/src/components/global-styles/utils.js +3 -0
- package/src/components/image-size-control/index.js +4 -3
- package/src/components/image-size-control/test/index.js +2 -2
- package/src/components/inner-blocks/README.md +1 -1
- package/src/components/inserter/index.js +30 -11
- package/src/components/inserter/menu.js +0 -1
- package/src/components/inserter/quick-inserter.js +2 -0
- package/src/components/inserter/search-results.js +7 -1
- package/src/components/inserter/style.scss +3 -0
- package/src/components/inserter/tabs.js +1 -9
- package/src/components/inspector-controls-tabs/position-controls-panel.js +40 -9
- package/src/components/line-height-control/index.js +10 -1
- package/src/components/link-control/index.js +1 -1
- package/src/components/link-control/search-item.js +3 -1
- package/src/components/link-control/style.scss +0 -4
- package/src/components/link-control/test/index.js +0 -2
- package/src/components/list-view/appender.js +101 -0
- package/src/components/list-view/block.js +5 -4
- package/src/components/list-view/branch.js +30 -1
- package/src/components/list-view/index.js +43 -10
- package/src/components/list-view/style.scss +19 -0
- package/src/components/list-view/use-block-selection.js +0 -2
- package/src/components/media-replace-flow/index.js +36 -24
- package/src/components/media-replace-flow/style.scss +5 -2
- package/src/components/off-canvas-editor/appender.js +31 -5
- package/src/components/off-canvas-editor/branch.js +3 -1
- package/src/components/off-canvas-editor/index.js +7 -7
- package/src/components/off-canvas-editor/link-ui.js +0 -1
- package/src/components/provider/use-block-sync.js +21 -4
- package/src/components/rich-text/format-edit.js +2 -32
- package/src/components/rich-text/format-toolbar-container.js +1 -7
- package/src/components/url-popover/test/index.js +0 -2
- package/src/components/writing-flow/use-input.js +4 -5
- package/src/hooks/border.js +93 -225
- package/src/hooks/color.js +120 -296
- package/src/hooks/content-lock-ui.js +6 -2
- package/src/hooks/{color-panel.js → contrast-checker.js} +10 -46
- package/src/hooks/custom-class-name.js +4 -4
- package/src/hooks/custom-class-name.native.js +3 -4
- package/src/hooks/dimensions.js +0 -1
- package/src/hooks/duotone.js +8 -5
- package/src/hooks/layout.js +19 -16
- package/src/hooks/position.js +3 -3
- package/src/hooks/style.js +29 -28
- package/src/hooks/supports.js +6 -0
- package/src/hooks/test/style.js +2 -1
- package/src/hooks/test/use-typography-props.js +2 -0
- package/src/hooks/test/utils.js +0 -104
- package/src/hooks/typography.js +2 -1
- package/src/hooks/utils.js +63 -70
- package/src/layouts/constrained.js +23 -17
- package/src/layouts/grid.js +172 -0
- package/src/layouts/index.js +2 -1
- package/src/layouts/test/grid.js +21 -0
- package/src/private-apis.js +4 -0
- package/src/store/actions.js +10 -8
- package/src/store/selectors.js +20 -3
- package/src/utils/object.js +69 -0
- package/src/utils/parse-css-unit-to-px.js +14 -9
- package/src/utils/test/object.js +107 -0
- package/src/utils/test/parse-css-unit-to-px.js +1 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/hooks/border-radius.js +0 -100
- package/build/hooks/border-radius.js.map +0 -1
- package/build/hooks/color-panel.js.map +0 -1
- package/build-module/hooks/border-radius.js +0 -84
- package/build-module/hooks/border-radius.js.map +0 -1
- package/build-module/hooks/color-panel.js.map +0 -1
- package/src/hooks/border-radius.js +0 -70
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
import { __, _x } from '@wordpress/i18n';
|
|
5
5
|
import { Button, Modal } from '@wordpress/components';
|
|
6
6
|
import { useState, useCallback, useMemo } from '@wordpress/element';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { withDispatch, withSelect } from '@wordpress/data';
|
|
7
|
+
import { createBlock, rawHandler } from '@wordpress/blocks';
|
|
8
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Internal dependencies
|
|
@@ -15,38 +14,86 @@ import Warning from '../warning';
|
|
|
15
14
|
import BlockCompare from '../block-compare';
|
|
16
15
|
import { store as blockEditorStore } from '../../store';
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
const blockToBlocks = ( block ) =>
|
|
18
|
+
rawHandler( {
|
|
19
|
+
HTML: block.originalContent,
|
|
20
|
+
} );
|
|
21
|
+
|
|
22
|
+
export default function BlockInvalidWarning( { clientId } ) {
|
|
23
|
+
const { block, canInsertHTMLBlock, canInsertClassicBlock } = useSelect(
|
|
24
|
+
( select ) => {
|
|
25
|
+
const { canInsertBlockType, getBlock, getBlockRootClientId } =
|
|
26
|
+
select( blockEditorStore );
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
const rootClientId = getBlockRootClientId( clientId );
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
block: getBlock( clientId ),
|
|
32
|
+
canInsertHTMLBlock: canInsertBlockType(
|
|
33
|
+
'core/html',
|
|
34
|
+
rootClientId
|
|
35
|
+
),
|
|
36
|
+
canInsertClassicBlock: canInsertBlockType(
|
|
37
|
+
'core/freeform',
|
|
38
|
+
rootClientId
|
|
39
|
+
),
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
[ clientId ]
|
|
43
|
+
);
|
|
44
|
+
const { replaceBlock } = useDispatch( blockEditorStore );
|
|
45
|
+
|
|
46
|
+
const [ compare, setCompare ] = useState( false );
|
|
29
47
|
const onCompareClose = useCallback( () => setCompare( false ), [] );
|
|
30
48
|
|
|
31
|
-
|
|
32
|
-
|
|
49
|
+
const convert = useMemo(
|
|
50
|
+
() => ( {
|
|
51
|
+
toClassic() {
|
|
52
|
+
const classicBlock = createBlock( 'core/freeform', {
|
|
53
|
+
content: block.originalContent,
|
|
54
|
+
} );
|
|
55
|
+
return replaceBlock( block.clientId, classicBlock );
|
|
56
|
+
},
|
|
57
|
+
toHTML() {
|
|
58
|
+
const htmlBlock = createBlock( 'core/html', {
|
|
59
|
+
content: block.originalContent,
|
|
60
|
+
} );
|
|
61
|
+
return replaceBlock( block.clientId, htmlBlock );
|
|
62
|
+
},
|
|
63
|
+
toBlocks() {
|
|
64
|
+
const newBlocks = blockToBlocks( block );
|
|
65
|
+
return replaceBlock( block.clientId, newBlocks );
|
|
66
|
+
},
|
|
67
|
+
toRecoveredBlock() {
|
|
68
|
+
const recoveredBlock = createBlock(
|
|
69
|
+
block.name,
|
|
70
|
+
block.attributes,
|
|
71
|
+
block.innerBlocks
|
|
72
|
+
);
|
|
73
|
+
return replaceBlock( block.clientId, recoveredBlock );
|
|
74
|
+
},
|
|
75
|
+
} ),
|
|
76
|
+
[ block, replaceBlock ]
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const secondaryActions = useMemo(
|
|
33
80
|
() =>
|
|
34
81
|
[
|
|
35
82
|
{
|
|
36
83
|
// translators: Button to fix block content
|
|
37
84
|
title: _x( 'Resolve', 'imperative verb' ),
|
|
38
|
-
onClick:
|
|
85
|
+
onClick: () => setCompare( true ),
|
|
39
86
|
},
|
|
40
|
-
|
|
87
|
+
canInsertHTMLBlock && {
|
|
41
88
|
title: __( 'Convert to HTML' ),
|
|
42
|
-
onClick:
|
|
89
|
+
onClick: convert.toHTML,
|
|
43
90
|
},
|
|
44
|
-
{
|
|
91
|
+
canInsertClassicBlock && {
|
|
45
92
|
title: __( 'Convert to Classic Block' ),
|
|
46
|
-
onClick:
|
|
93
|
+
onClick: convert.toClassic,
|
|
47
94
|
},
|
|
48
95
|
].filter( Boolean ),
|
|
49
|
-
[
|
|
96
|
+
[ canInsertHTMLBlock, canInsertClassicBlock, convert ]
|
|
50
97
|
);
|
|
51
98
|
|
|
52
99
|
return (
|
|
@@ -55,13 +102,13 @@ export function BlockInvalidWarning( {
|
|
|
55
102
|
actions={ [
|
|
56
103
|
<Button
|
|
57
104
|
key="recover"
|
|
58
|
-
onClick={
|
|
105
|
+
onClick={ convert.toRecoveredBlock }
|
|
59
106
|
variant="primary"
|
|
60
107
|
>
|
|
61
108
|
{ __( 'Attempt Block Recovery' ) }
|
|
62
109
|
</Button>,
|
|
63
110
|
] }
|
|
64
|
-
secondaryActions={
|
|
111
|
+
secondaryActions={ secondaryActions }
|
|
65
112
|
>
|
|
66
113
|
{ __( 'This block contains unexpected or invalid content.' ) }
|
|
67
114
|
</Warning>
|
|
@@ -76,8 +123,8 @@ export function BlockInvalidWarning( {
|
|
|
76
123
|
>
|
|
77
124
|
<BlockCompare
|
|
78
125
|
block={ block }
|
|
79
|
-
onKeep={
|
|
80
|
-
onConvert={
|
|
126
|
+
onKeep={ convert.toHTML }
|
|
127
|
+
onConvert={ convert.toBlocks }
|
|
81
128
|
convertor={ blockToBlocks }
|
|
82
129
|
convertButtonText={ __( 'Convert to Blocks' ) }
|
|
83
130
|
/>
|
|
@@ -86,42 +133,3 @@ export function BlockInvalidWarning( {
|
|
|
86
133
|
</>
|
|
87
134
|
);
|
|
88
135
|
}
|
|
89
|
-
|
|
90
|
-
const blockToClassic = ( block ) =>
|
|
91
|
-
createBlock( 'core/freeform', {
|
|
92
|
-
content: block.originalContent,
|
|
93
|
-
} );
|
|
94
|
-
const blockToHTML = ( block ) =>
|
|
95
|
-
createBlock( 'core/html', {
|
|
96
|
-
content: block.originalContent,
|
|
97
|
-
} );
|
|
98
|
-
const blockToBlocks = ( block ) =>
|
|
99
|
-
rawHandler( {
|
|
100
|
-
HTML: block.originalContent,
|
|
101
|
-
} );
|
|
102
|
-
const recoverBlock = ( { name, attributes, innerBlocks } ) =>
|
|
103
|
-
createBlock( name, attributes, innerBlocks );
|
|
104
|
-
|
|
105
|
-
export default compose( [
|
|
106
|
-
withSelect( ( select, { clientId } ) => ( {
|
|
107
|
-
block: select( blockEditorStore ).getBlock( clientId ),
|
|
108
|
-
} ) ),
|
|
109
|
-
withDispatch( ( dispatch, { block } ) => {
|
|
110
|
-
const { replaceBlock } = dispatch( blockEditorStore );
|
|
111
|
-
|
|
112
|
-
return {
|
|
113
|
-
convertToClassic() {
|
|
114
|
-
replaceBlock( block.clientId, blockToClassic( block ) );
|
|
115
|
-
},
|
|
116
|
-
convertToHTML() {
|
|
117
|
-
replaceBlock( block.clientId, blockToHTML( block ) );
|
|
118
|
-
},
|
|
119
|
-
convertToBlocks() {
|
|
120
|
-
replaceBlock( block.clientId, blockToBlocks( block ) );
|
|
121
|
-
},
|
|
122
|
-
attemptBlockRecovery() {
|
|
123
|
-
replaceBlock( block.clientId, recoverBlock( block ) );
|
|
124
|
-
},
|
|
125
|
-
};
|
|
126
|
-
} ),
|
|
127
|
-
] )( BlockInvalidWarning );
|
|
@@ -98,7 +98,16 @@ exports[`Block Mover Picker should match snapshot 1`] = `
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
>
|
|
101
|
-
Svg
|
|
101
|
+
<Svg
|
|
102
|
+
colorScheme="light"
|
|
103
|
+
height={24}
|
|
104
|
+
style={{}}
|
|
105
|
+
viewBox="0 0 24 24"
|
|
106
|
+
width={24}
|
|
107
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
108
|
+
>
|
|
109
|
+
Path
|
|
110
|
+
</Svg>
|
|
102
111
|
</View>
|
|
103
112
|
</View>
|
|
104
113
|
</View>
|
|
@@ -157,7 +166,16 @@ exports[`Block Mover Picker should match snapshot 1`] = `
|
|
|
157
166
|
}
|
|
158
167
|
}
|
|
159
168
|
>
|
|
160
|
-
Svg
|
|
169
|
+
<Svg
|
|
170
|
+
colorScheme="light"
|
|
171
|
+
height={24}
|
|
172
|
+
style={{}}
|
|
173
|
+
viewBox="0 0 24 24"
|
|
174
|
+
width={24}
|
|
175
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
176
|
+
>
|
|
177
|
+
Path
|
|
178
|
+
</Svg>
|
|
161
179
|
</View>
|
|
162
180
|
</View>
|
|
163
181
|
</View>
|
|
@@ -12,7 +12,6 @@ import { Disabled } from '@wordpress/components';
|
|
|
12
12
|
import BlockList from '../block-list';
|
|
13
13
|
import Iframe from '../iframe';
|
|
14
14
|
import EditorStyles from '../editor-styles';
|
|
15
|
-
import { __unstablePresetDuotoneFilter as PresetDuotoneFilter } from '../../components/duotone';
|
|
16
15
|
import { store } from '../../store';
|
|
17
16
|
|
|
18
17
|
// This is used to avoid rendering the block list if the sizes change.
|
|
@@ -32,11 +31,10 @@ function ScaledBlockPreview( {
|
|
|
32
31
|
|
|
33
32
|
const [ contentResizeListener, { height: contentHeight } ] =
|
|
34
33
|
useResizeObserver();
|
|
35
|
-
const { styles
|
|
34
|
+
const { styles } = useSelect( ( select ) => {
|
|
36
35
|
const settings = select( store ).getSettings();
|
|
37
36
|
return {
|
|
38
37
|
styles: settings.styles,
|
|
39
|
-
duotone: settings.__experimentalFeatures?.color?.duotone,
|
|
40
38
|
};
|
|
41
39
|
}, [] );
|
|
42
40
|
|
|
@@ -56,10 +54,6 @@ function ScaledBlockPreview( {
|
|
|
56
54
|
return styles;
|
|
57
55
|
}, [ styles, additionalStyles ] );
|
|
58
56
|
|
|
59
|
-
const svgFilters = useMemo( () => {
|
|
60
|
-
return [ ...( duotone?.default ?? [] ), ...( duotone?.theme ?? [] ) ];
|
|
61
|
-
}, [ duotone ] );
|
|
62
|
-
|
|
63
57
|
// Initialize on render instead of module top level, to avoid circular dependency issues.
|
|
64
58
|
MemoizedBlockList = MemoizedBlockList || pure( BlockList );
|
|
65
59
|
|
|
@@ -76,7 +70,6 @@ function ScaledBlockPreview( {
|
|
|
76
70
|
} }
|
|
77
71
|
>
|
|
78
72
|
<Iframe
|
|
79
|
-
head={ <EditorStyles styles={ editorStyles } /> }
|
|
80
73
|
contentRef={ useRefEffect( ( bodyElement ) => {
|
|
81
74
|
const {
|
|
82
75
|
ownerDocument: { documentElement },
|
|
@@ -108,16 +101,8 @@ function ScaledBlockPreview( {
|
|
|
108
101
|
: minHeight,
|
|
109
102
|
} }
|
|
110
103
|
>
|
|
104
|
+
<EditorStyles styles={ editorStyles } />
|
|
111
105
|
{ contentResizeListener }
|
|
112
|
-
{
|
|
113
|
-
/* Filters need to be rendered before children to avoid Safari rendering issues. */
|
|
114
|
-
svgFilters.map( ( preset ) => (
|
|
115
|
-
<PresetDuotoneFilter
|
|
116
|
-
preset={ preset }
|
|
117
|
-
key={ preset.slug }
|
|
118
|
-
/>
|
|
119
|
-
) )
|
|
120
|
-
}
|
|
121
106
|
<MemoizedBlockList renderAppender={ false } />
|
|
122
107
|
</Iframe>
|
|
123
108
|
</Disabled>
|
|
@@ -48,7 +48,8 @@ const BlockSettingsMenuControlsSlot = ( {
|
|
|
48
48
|
|
|
49
49
|
// Check if current selection of blocks is Groupable or Ungroupable
|
|
50
50
|
// and pass this props down to ConvertToGroupButton.
|
|
51
|
-
const convertToGroupButtonProps =
|
|
51
|
+
const convertToGroupButtonProps =
|
|
52
|
+
useConvertToGroupButtonProps( selectedClientIds );
|
|
52
53
|
const { isGroupable, isUngroupable } = convertToGroupButtonProps;
|
|
53
54
|
const showConvertToGroupButton =
|
|
54
55
|
( isGroupable || isUngroupable ) && canRemove;
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
gap: $grid-unit-10;
|
|
39
39
|
|
|
40
40
|
.block-editor-block-styles__item {
|
|
41
|
-
color: $gray-
|
|
41
|
+
color: $gray-900;
|
|
42
42
|
box-shadow: inset 0 0 0 1px $gray-400;
|
|
43
43
|
display: inline-block;
|
|
44
44
|
width: calc(50% - #{$grid-unit-05});
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
|
|
52
52
|
&.is-active,
|
|
53
53
|
&.is-active:hover {
|
|
54
|
-
background-color: $gray-
|
|
54
|
+
background-color: $gray-900;
|
|
55
55
|
box-shadow: none;
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -22,17 +22,18 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
|
|
|
22
22
|
display: -webkit-flex;
|
|
23
23
|
display: -ms-flexbox;
|
|
24
24
|
display: flex;
|
|
25
|
-
-webkit-align-items:
|
|
26
|
-
-webkit-box-align:
|
|
27
|
-
-ms-flex-align:
|
|
28
|
-
align-items:
|
|
25
|
+
-webkit-align-items: stretch;
|
|
26
|
+
-webkit-box-align: stretch;
|
|
27
|
+
-ms-flex-align: stretch;
|
|
28
|
+
align-items: stretch;
|
|
29
29
|
-webkit-flex-direction: column;
|
|
30
30
|
-ms-flex-direction: column;
|
|
31
31
|
flex-direction: column;
|
|
32
32
|
gap: calc(4px * 1);
|
|
33
|
-
-webkit-box-pack:
|
|
34
|
-
-
|
|
35
|
-
justify-content:
|
|
33
|
+
-webkit-box-pack: center;
|
|
34
|
+
-ms-flex-pack: center;
|
|
35
|
+
-webkit-justify-content: center;
|
|
36
|
+
justify-content: center;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
.emotion-4>* {
|
|
@@ -54,17 +55,18 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
|
|
|
54
55
|
display: -webkit-flex;
|
|
55
56
|
display: -ms-flexbox;
|
|
56
57
|
display: flex;
|
|
57
|
-
-webkit-align-items:
|
|
58
|
-
-webkit-box-align:
|
|
59
|
-
-ms-flex-align:
|
|
60
|
-
align-items:
|
|
58
|
+
-webkit-align-items: stretch;
|
|
59
|
+
-webkit-box-align: stretch;
|
|
60
|
+
-ms-flex-align: stretch;
|
|
61
|
+
align-items: stretch;
|
|
61
62
|
-webkit-flex-direction: column;
|
|
62
63
|
-ms-flex-direction: column;
|
|
63
64
|
flex-direction: column;
|
|
64
65
|
gap: calc(4px * 3);
|
|
65
|
-
-webkit-box-pack:
|
|
66
|
-
-
|
|
67
|
-
justify-content:
|
|
66
|
+
-webkit-box-pack: center;
|
|
67
|
+
-ms-flex-pack: center;
|
|
68
|
+
-webkit-justify-content: center;
|
|
69
|
+
justify-content: center;
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
.emotion-8>* {
|
|
@@ -73,20 +73,20 @@ $swatch-gap: 12px;
|
|
|
73
73
|
max-width: 100%;
|
|
74
74
|
|
|
75
75
|
// Border styles.
|
|
76
|
-
border-left: 1px solid
|
|
77
|
-
border-right: 1px solid
|
|
78
|
-
border-bottom: 1px solid
|
|
76
|
+
border-left: 1px solid $gray-300;
|
|
77
|
+
border-right: 1px solid $gray-300;
|
|
78
|
+
border-bottom: 1px solid $gray-300;
|
|
79
79
|
|
|
80
80
|
&.first {
|
|
81
81
|
margin-top: $grid-unit-30;
|
|
82
|
-
border-top-left-radius:
|
|
83
|
-
border-top-right-radius:
|
|
84
|
-
border-top: 1px solid
|
|
82
|
+
border-top-left-radius: $radius-block-ui;
|
|
83
|
+
border-top-right-radius: $radius-block-ui;
|
|
84
|
+
border-top: 1px solid $gray-300;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
&.last {
|
|
88
|
-
border-bottom-left-radius:
|
|
89
|
-
border-bottom-right-radius:
|
|
88
|
+
border-bottom-left-radius: $radius-block-ui;
|
|
89
|
+
border-bottom-right-radius: $radius-block-ui;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
> div,
|
|
@@ -25,59 +25,69 @@ import { store as blockEditorStore } from '../../store';
|
|
|
25
25
|
* It is used in `BlockSettingsMenuControls` to know if `ConvertToGroupButton`
|
|
26
26
|
* should be rendered, to avoid ending up with an empty MenuGroup.
|
|
27
27
|
*
|
|
28
|
+
* @param {?string[]} selectedClientIds An optional array of clientIds to group. The selected blocks
|
|
29
|
+
* from the block editor store are used if this is not provided.
|
|
30
|
+
*
|
|
28
31
|
* @return {ConvertToGroupButtonProps} Returns the properties needed by `ConvertToGroupButton`.
|
|
29
32
|
*/
|
|
30
|
-
export default function useConvertToGroupButtonProps() {
|
|
33
|
+
export default function useConvertToGroupButtonProps( selectedClientIds ) {
|
|
31
34
|
const {
|
|
32
35
|
clientIds,
|
|
33
36
|
isGroupable,
|
|
34
37
|
isUngroupable,
|
|
35
38
|
blocksSelection,
|
|
36
39
|
groupingBlockName,
|
|
37
|
-
} = useSelect(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
} = useSelect(
|
|
41
|
+
( select ) => {
|
|
42
|
+
const {
|
|
43
|
+
getBlockRootClientId,
|
|
44
|
+
getBlocksByClientId,
|
|
45
|
+
canInsertBlockType,
|
|
46
|
+
getSelectedBlockClientIds,
|
|
47
|
+
} = select( blockEditorStore );
|
|
48
|
+
const { getGroupingBlockName } = select( blocksStore );
|
|
49
|
+
|
|
50
|
+
const _clientIds = selectedClientIds?.length
|
|
51
|
+
? selectedClientIds
|
|
52
|
+
: getSelectedBlockClientIds();
|
|
53
|
+
const _groupingBlockName = getGroupingBlockName();
|
|
45
54
|
|
|
46
|
-
|
|
47
|
-
|
|
55
|
+
const rootClientId = !! _clientIds?.length
|
|
56
|
+
? getBlockRootClientId( _clientIds[ 0 ] )
|
|
57
|
+
: undefined;
|
|
48
58
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
const groupingBlockAvailable = canInsertBlockType(
|
|
60
|
+
_groupingBlockName,
|
|
61
|
+
rootClientId
|
|
62
|
+
);
|
|
52
63
|
|
|
53
|
-
|
|
54
|
-
_groupingBlockName,
|
|
55
|
-
rootClientId
|
|
56
|
-
);
|
|
64
|
+
const _blocksSelection = getBlocksByClientId( _clientIds );
|
|
57
65
|
|
|
58
|
-
|
|
66
|
+
const isSingleGroupingBlock =
|
|
67
|
+
_blocksSelection.length === 1 &&
|
|
68
|
+
_blocksSelection[ 0 ]?.name === _groupingBlockName;
|
|
59
69
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
70
|
+
// Do we have
|
|
71
|
+
// 1. Grouping block available to be inserted?
|
|
72
|
+
// 2. One or more blocks selected
|
|
73
|
+
const _isGroupable =
|
|
74
|
+
groupingBlockAvailable && _blocksSelection.length;
|
|
63
75
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
76
|
+
// Do we have a single Group Block selected and does that group have inner blocks?
|
|
77
|
+
const _isUngroupable =
|
|
78
|
+
isSingleGroupingBlock &&
|
|
79
|
+
!! _blocksSelection[ 0 ].innerBlocks.length;
|
|
80
|
+
return {
|
|
81
|
+
clientIds: _clientIds,
|
|
82
|
+
isGroupable: _isGroupable,
|
|
83
|
+
isUngroupable: _isUngroupable,
|
|
84
|
+
blocksSelection: _blocksSelection,
|
|
85
|
+
groupingBlockName: _groupingBlockName,
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
[ selectedClientIds ]
|
|
89
|
+
);
|
|
68
90
|
|
|
69
|
-
// Do we have a single Group Block selected and does that group have inner blocks?
|
|
70
|
-
const _isUngroupable =
|
|
71
|
-
isSingleGroupingBlock &&
|
|
72
|
-
!! _blocksSelection[ 0 ].innerBlocks.length;
|
|
73
|
-
return {
|
|
74
|
-
clientIds: _clientIds,
|
|
75
|
-
isGroupable: _isGroupable,
|
|
76
|
-
isUngroupable: _isUngroupable,
|
|
77
|
-
blocksSelection: _blocksSelection,
|
|
78
|
-
groupingBlockName: _groupingBlockName,
|
|
79
|
-
};
|
|
80
|
-
}, [] );
|
|
81
91
|
return {
|
|
82
92
|
clientIds,
|
|
83
93
|
isGroupable,
|
|
@@ -8,6 +8,7 @@ import a11yPlugin from 'colord/plugins/a11y';
|
|
|
8
8
|
/**
|
|
9
9
|
* WordPress dependencies
|
|
10
10
|
*/
|
|
11
|
+
import { SVG } from '@wordpress/components';
|
|
11
12
|
import { useCallback, useMemo } from '@wordpress/element';
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -68,7 +69,20 @@ function useDarkThemeBodyClassName( styles ) {
|
|
|
68
69
|
|
|
69
70
|
export default function EditorStyles( { styles } ) {
|
|
70
71
|
const transformedStyles = useMemo(
|
|
71
|
-
() =>
|
|
72
|
+
() =>
|
|
73
|
+
transformStyles(
|
|
74
|
+
styles.filter( ( style ) => style?.css ),
|
|
75
|
+
EDITOR_STYLES_SELECTOR
|
|
76
|
+
),
|
|
77
|
+
[ styles ]
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const transformedSvgs = useMemo(
|
|
81
|
+
() =>
|
|
82
|
+
styles
|
|
83
|
+
.filter( ( style ) => style.__unstableType === 'svgs' )
|
|
84
|
+
.map( ( style ) => style.assets )
|
|
85
|
+
.join( '' ),
|
|
72
86
|
[ styles ]
|
|
73
87
|
);
|
|
74
88
|
|
|
@@ -80,6 +94,20 @@ export default function EditorStyles( { styles } ) {
|
|
|
80
94
|
{ transformedStyles.map( ( css, index ) => (
|
|
81
95
|
<style key={ index }>{ css }</style>
|
|
82
96
|
) ) }
|
|
97
|
+
<SVG
|
|
98
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
99
|
+
viewBox="0 0 0 0"
|
|
100
|
+
width="0"
|
|
101
|
+
height="0"
|
|
102
|
+
role="none"
|
|
103
|
+
style={ {
|
|
104
|
+
visibility: 'hidden',
|
|
105
|
+
position: 'absolute',
|
|
106
|
+
left: '-9999px',
|
|
107
|
+
overflow: 'hidden',
|
|
108
|
+
} }
|
|
109
|
+
dangerouslySetInnerHTML={ { __html: transformedSvgs } }
|
|
110
|
+
/>
|
|
83
111
|
</>
|
|
84
112
|
);
|
|
85
113
|
}
|