@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
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
@@ -58,6 +63,7 @@ const MediaReplaceFlow = ( {
|
|
|
58
63
|
const mediaUpload = useSelect( ( select ) => {
|
|
59
64
|
return select( blockEditorStore ).getSettings().mediaUpload;
|
|
60
65
|
}, [] );
|
|
66
|
+
const canUpload = !! mediaUpload;
|
|
61
67
|
const editMediaButtonRef = useRef();
|
|
62
68
|
const errorNoticeID = `block-editor/media-replace-flow/error-notice/${ ++uniqueId }`;
|
|
63
69
|
|
|
@@ -152,7 +158,7 @@ const MediaReplaceFlow = ( {
|
|
|
152
158
|
renderContent={ ( { onClose } ) => (
|
|
153
159
|
<>
|
|
154
160
|
<NavigableMenu className="block-editor-media-replace-flow__media-upload-menu">
|
|
155
|
-
|
|
161
|
+
<MediaUploadCheck>
|
|
156
162
|
<MediaUpload
|
|
157
163
|
gallery={ gallery }
|
|
158
164
|
addToGallery={ addToGallery }
|
|
@@ -171,28 +177,26 @@ const MediaReplaceFlow = ( {
|
|
|
171
177
|
</MenuItem>
|
|
172
178
|
) }
|
|
173
179
|
/>
|
|
174
|
-
<
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
</MediaUploadCheck>
|
|
195
|
-
</>
|
|
180
|
+
<FormFileUpload
|
|
181
|
+
onChange={ ( event ) => {
|
|
182
|
+
uploadFiles( event, onClose );
|
|
183
|
+
} }
|
|
184
|
+
accept={ accept }
|
|
185
|
+
multiple={ multiple }
|
|
186
|
+
render={ ( { openFileDialog } ) => {
|
|
187
|
+
return (
|
|
188
|
+
<MenuItem
|
|
189
|
+
icon={ upload }
|
|
190
|
+
onClick={ () => {
|
|
191
|
+
openFileDialog();
|
|
192
|
+
} }
|
|
193
|
+
>
|
|
194
|
+
{ __( 'Upload' ) }
|
|
195
|
+
</MenuItem>
|
|
196
|
+
);
|
|
197
|
+
} }
|
|
198
|
+
/>
|
|
199
|
+
</MediaUploadCheck>
|
|
196
200
|
{ onToggleFeaturedImage && (
|
|
197
201
|
<MenuItem
|
|
198
202
|
icon={ postFeaturedImage }
|
|
@@ -206,7 +210,15 @@ const MediaReplaceFlow = ( {
|
|
|
206
210
|
</NavigableMenu>
|
|
207
211
|
{ onSelectURL && (
|
|
208
212
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
209
|
-
<form
|
|
213
|
+
<form
|
|
214
|
+
className={ classnames(
|
|
215
|
+
'block-editor-media-flow__url-input',
|
|
216
|
+
{
|
|
217
|
+
'has-siblings':
|
|
218
|
+
canUpload || onToggleFeaturedImage,
|
|
219
|
+
}
|
|
220
|
+
) }
|
|
221
|
+
>
|
|
210
222
|
<span className="block-editor-media-replace-flow__image-url-label">
|
|
211
223
|
{ __( 'Current media URL:' ) }
|
|
212
224
|
</span>
|
|
@@ -10,12 +10,15 @@
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
.block-editor-media-flow__url-input {
|
|
13
|
-
border-top: $border-width solid $gray-900;
|
|
14
|
-
margin-top: $grid-unit-10;
|
|
15
13
|
margin-right: -$grid-unit-10;
|
|
16
14
|
margin-left: -$grid-unit-10;
|
|
17
15
|
padding: $grid-unit-20;
|
|
18
16
|
|
|
17
|
+
&.has-siblings {
|
|
18
|
+
border-top: $border-width solid $gray-900;
|
|
19
|
+
margin-top: $grid-unit-10;
|
|
20
|
+
}
|
|
21
|
+
|
|
19
22
|
.block-editor-media-replace-flow__image-url-label {
|
|
20
23
|
display: block;
|
|
21
24
|
top: $grid-unit-20;
|
|
@@ -4,7 +4,12 @@
|
|
|
4
4
|
import { useInstanceId } from '@wordpress/compose';
|
|
5
5
|
import { speak } from '@wordpress/a11y';
|
|
6
6
|
import { useSelect } from '@wordpress/data';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
forwardRef,
|
|
9
|
+
useState,
|
|
10
|
+
useEffect,
|
|
11
|
+
useCallback,
|
|
12
|
+
} from '@wordpress/element';
|
|
8
13
|
import { __, sprintf } from '@wordpress/i18n';
|
|
9
14
|
|
|
10
15
|
/**
|
|
@@ -12,7 +17,14 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
12
17
|
*/
|
|
13
18
|
import { store as blockEditorStore } from '../../store';
|
|
14
19
|
import useBlockDisplayTitle from '../block-title/use-block-display-title';
|
|
15
|
-
|
|
20
|
+
|
|
21
|
+
import { unlock } from '../../lock-unlock';
|
|
22
|
+
import { privateApis as blockEditorPrivateApis } from '../../private-apis';
|
|
23
|
+
|
|
24
|
+
const prioritizedInserterBlocks = [
|
|
25
|
+
'core/navigation-link/page',
|
|
26
|
+
'core/navigation-link',
|
|
27
|
+
];
|
|
16
28
|
|
|
17
29
|
export const Appender = forwardRef(
|
|
18
30
|
( { nestingLevel, blockCount, clientId, ...props }, ref ) => {
|
|
@@ -58,10 +70,23 @@ export const Appender = forwardRef(
|
|
|
58
70
|
);
|
|
59
71
|
}, [ insertedBlockTitle ] );
|
|
60
72
|
|
|
73
|
+
const orderInitialBlockItems = useCallback( ( items ) => {
|
|
74
|
+
items.sort( ( { id: aName }, { id: bName } ) => {
|
|
75
|
+
// Sort block items according to `prioritizedInserterBlocks`.
|
|
76
|
+
let aIndex = prioritizedInserterBlocks.indexOf( aName );
|
|
77
|
+
let bIndex = prioritizedInserterBlocks.indexOf( bName );
|
|
78
|
+
// All other block items should come after that.
|
|
79
|
+
if ( aIndex < 0 ) aIndex = prioritizedInserterBlocks.length;
|
|
80
|
+
if ( bIndex < 0 ) bIndex = prioritizedInserterBlocks.length;
|
|
81
|
+
return aIndex - bIndex;
|
|
82
|
+
} );
|
|
83
|
+
return items;
|
|
84
|
+
}, [] );
|
|
85
|
+
|
|
61
86
|
if ( hideInserter ) {
|
|
62
87
|
return null;
|
|
63
88
|
}
|
|
64
|
-
|
|
89
|
+
const { PrivateInserter } = unlock( blockEditorPrivateApis );
|
|
65
90
|
const descriptionId = `off-canvas-editor-appender__${ instanceId }`;
|
|
66
91
|
const description = sprintf(
|
|
67
92
|
/* translators: 1: The name of the block. 2: The numerical position of the block. 3: The level of nesting for the block. */
|
|
@@ -73,11 +98,11 @@ export const Appender = forwardRef(
|
|
|
73
98
|
|
|
74
99
|
return (
|
|
75
100
|
<div className="offcanvas-editor-appender">
|
|
76
|
-
<
|
|
101
|
+
<PrivateInserter
|
|
77
102
|
ref={ ref }
|
|
78
103
|
rootClientId={ clientId }
|
|
79
104
|
position="bottom right"
|
|
80
|
-
isAppender
|
|
105
|
+
isAppender
|
|
81
106
|
selectBlockOnInsert={ false }
|
|
82
107
|
shouldDirectInsert={ false }
|
|
83
108
|
__experimentalIsQuick
|
|
@@ -88,6 +113,7 @@ export const Appender = forwardRef(
|
|
|
88
113
|
setInsertedBlock( maybeInsertedBlock );
|
|
89
114
|
}
|
|
90
115
|
} }
|
|
116
|
+
orderInitialBlockItems={ orderInitialBlockItems }
|
|
91
117
|
/>
|
|
92
118
|
<div
|
|
93
119
|
className="offcanvas-editor-appender__description"
|
|
@@ -97,6 +97,7 @@ function ListViewBranch( props ) {
|
|
|
97
97
|
isExpanded,
|
|
98
98
|
parentId,
|
|
99
99
|
shouldShowInnerBlocks = true,
|
|
100
|
+
showAppender: showAppenderProp = true,
|
|
100
101
|
} = props;
|
|
101
102
|
|
|
102
103
|
const isContentLocked = useSelect(
|
|
@@ -117,7 +118,7 @@ function ListViewBranch( props ) {
|
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
// Only show the appender at the first level.
|
|
120
|
-
const showAppender = level === 1;
|
|
121
|
+
const showAppender = showAppenderProp && level === 1;
|
|
121
122
|
|
|
122
123
|
const filteredBlocks = blocks.filter( Boolean );
|
|
123
124
|
const blockCount = filteredBlocks.length;
|
|
@@ -205,6 +206,7 @@ function ListViewBranch( props ) {
|
|
|
205
206
|
isBranchSelected={ isSelectedBranch }
|
|
206
207
|
selectedClientIds={ selectedClientIds }
|
|
207
208
|
isExpanded={ isExpanded }
|
|
209
|
+
showAppender={ showAppenderProp }
|
|
208
210
|
/>
|
|
209
211
|
) }
|
|
210
212
|
</AsyncModeProvider>
|
|
@@ -56,20 +56,24 @@ export const BLOCK_LIST_ITEM_HEIGHT = 36;
|
|
|
56
56
|
*
|
|
57
57
|
* @param {Object} props Components props.
|
|
58
58
|
* @param {string} props.id An HTML element id for the root element of ListView.
|
|
59
|
+
* @param {string} props.parentClientId The client id of the parent block.
|
|
59
60
|
* @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.
|
|
60
61
|
* @param {boolean} props.showBlockMovers Flag to enable block movers
|
|
61
62
|
* @param {boolean} props.isExpanded Flag to determine whether nested levels are expanded by default.
|
|
62
63
|
* @param {Object} props.LeafMoreMenu Optional more menu substitution.
|
|
63
64
|
* @param {string} props.description Optional accessible description for the tree grid component.
|
|
64
65
|
* @param {string} props.onSelect Optional callback to be invoked when a block is selected.
|
|
66
|
+
* @param {string} props.showAppender Flag to show or hide the block appender.
|
|
65
67
|
* @param {Object} ref Forwarded ref
|
|
66
68
|
*/
|
|
67
69
|
function OffCanvasEditor(
|
|
68
70
|
{
|
|
69
71
|
id,
|
|
72
|
+
parentClientId,
|
|
70
73
|
blocks,
|
|
71
74
|
showBlockMovers = false,
|
|
72
75
|
isExpanded = false,
|
|
76
|
+
showAppender = true,
|
|
73
77
|
LeafMoreMenu,
|
|
74
78
|
description = __( 'Block navigation structure' ),
|
|
75
79
|
onSelect,
|
|
@@ -80,10 +84,9 @@ function OffCanvasEditor(
|
|
|
80
84
|
const { clientIdsTree, draggedClientIds, selectedClientIds } =
|
|
81
85
|
useListViewClientIds( blocks );
|
|
82
86
|
|
|
83
|
-
const { visibleBlockCount, shouldShowInnerBlocks
|
|
87
|
+
const { visibleBlockCount, shouldShowInnerBlocks } = useSelect(
|
|
84
88
|
( select ) => {
|
|
85
89
|
const {
|
|
86
|
-
getBlockRootClientId,
|
|
87
90
|
getGlobalBlockCount,
|
|
88
91
|
getClientIdsOfDescendants,
|
|
89
92
|
__unstableGetEditorMode,
|
|
@@ -95,10 +98,6 @@ function OffCanvasEditor(
|
|
|
95
98
|
return {
|
|
96
99
|
visibleBlockCount: getGlobalBlockCount() - draggedBlockCount,
|
|
97
100
|
shouldShowInnerBlocks: __unstableGetEditorMode() !== 'zoom-out',
|
|
98
|
-
parentId:
|
|
99
|
-
blocks.length > 0
|
|
100
|
-
? getBlockRootClientId( blocks[ 0 ].clientId )
|
|
101
|
-
: undefined,
|
|
102
101
|
};
|
|
103
102
|
},
|
|
104
103
|
[ draggedClientIds, blocks ]
|
|
@@ -232,7 +231,7 @@ function OffCanvasEditor(
|
|
|
232
231
|
>
|
|
233
232
|
<ListViewContext.Provider value={ contextValue }>
|
|
234
233
|
<ListViewBranch
|
|
235
|
-
parentId={
|
|
234
|
+
parentId={ parentClientId }
|
|
236
235
|
blocks={ clientIdsTree }
|
|
237
236
|
selectBlock={ selectEditorBlock }
|
|
238
237
|
showBlockMovers={ showBlockMovers }
|
|
@@ -240,6 +239,7 @@ function OffCanvasEditor(
|
|
|
240
239
|
selectedClientIds={ selectedClientIds }
|
|
241
240
|
isExpanded={ isExpanded }
|
|
242
241
|
shouldShowInnerBlocks={ shouldShowInnerBlocks }
|
|
242
|
+
showAppender={ showAppender }
|
|
243
243
|
/>
|
|
244
244
|
<TreeGridRow
|
|
245
245
|
level={ 1 }
|
|
@@ -76,10 +76,18 @@ export default function useBlockSync( {
|
|
|
76
76
|
resetBlocks,
|
|
77
77
|
resetSelection,
|
|
78
78
|
replaceInnerBlocks,
|
|
79
|
+
selectBlock,
|
|
79
80
|
setHasControlledInnerBlocks,
|
|
80
81
|
__unstableMarkNextChangeAsNotPersistent,
|
|
81
82
|
} = registry.dispatch( blockEditorStore );
|
|
82
|
-
const {
|
|
83
|
+
const {
|
|
84
|
+
hasSelectedBlock,
|
|
85
|
+
getBlockName,
|
|
86
|
+
getBlocks,
|
|
87
|
+
getSelectionStart,
|
|
88
|
+
getSelectionEnd,
|
|
89
|
+
getBlock,
|
|
90
|
+
} = registry.select( blockEditorStore );
|
|
83
91
|
const isControlled = useSelect(
|
|
84
92
|
( select ) => {
|
|
85
93
|
return (
|
|
@@ -159,6 +167,9 @@ export default function useBlockSync( {
|
|
|
159
167
|
// bound sync, unset the outbound value to avoid considering it in
|
|
160
168
|
// subsequent renders.
|
|
161
169
|
pendingChanges.current.outgoing = [];
|
|
170
|
+
const hadSelecton = hasSelectedBlock();
|
|
171
|
+
const selectionAnchor = getSelectionStart();
|
|
172
|
+
const selectionFocus = getSelectionEnd();
|
|
162
173
|
setControlledBlocks();
|
|
163
174
|
|
|
164
175
|
if ( controlledSelection ) {
|
|
@@ -167,6 +178,15 @@ export default function useBlockSync( {
|
|
|
167
178
|
controlledSelection.selectionEnd,
|
|
168
179
|
controlledSelection.initialPosition
|
|
169
180
|
);
|
|
181
|
+
} else {
|
|
182
|
+
const selectionStillExists = getBlock(
|
|
183
|
+
selectionAnchor.clientId
|
|
184
|
+
);
|
|
185
|
+
if ( hadSelecton && ! selectionStillExists ) {
|
|
186
|
+
selectBlock( clientId );
|
|
187
|
+
} else {
|
|
188
|
+
resetSelection( selectionAnchor, selectionFocus );
|
|
189
|
+
}
|
|
170
190
|
}
|
|
171
191
|
}
|
|
172
192
|
}, [ controlledBlocks, clientId ] );
|
|
@@ -182,8 +202,6 @@ export default function useBlockSync( {
|
|
|
182
202
|
|
|
183
203
|
useEffect( () => {
|
|
184
204
|
const {
|
|
185
|
-
getSelectionStart,
|
|
186
|
-
getSelectionEnd,
|
|
187
205
|
getSelectedBlocksInitialCaretPosition,
|
|
188
206
|
isLastBlockChangePersistent,
|
|
189
207
|
__unstableIsLastBlockChangeIgnored,
|
|
@@ -220,7 +238,6 @@ export default function useBlockSync( {
|
|
|
220
238
|
const newBlocks = getBlocks( clientId );
|
|
221
239
|
const areBlocksDifferent = newBlocks !== blocks;
|
|
222
240
|
blocks = newBlocks;
|
|
223
|
-
|
|
224
241
|
if (
|
|
225
242
|
areBlocksDifferent &&
|
|
226
243
|
( pendingChanges.current.incoming ||
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
getActiveFormat,
|
|
6
|
-
getActiveObject,
|
|
7
|
-
isCollapsed,
|
|
8
|
-
} from '@wordpress/rich-text';
|
|
4
|
+
import { getActiveFormat, getActiveObject } from '@wordpress/rich-text';
|
|
9
5
|
|
|
10
6
|
export default function FormatEdit( {
|
|
11
7
|
formatTypes,
|
|
@@ -22,37 +18,11 @@ export default function FormatEdit( {
|
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
const activeFormat = getActiveFormat( value, name );
|
|
25
|
-
|
|
21
|
+
const isActive = activeFormat !== undefined;
|
|
26
22
|
const activeObject = getActiveObject( value );
|
|
27
23
|
const isObjectActive =
|
|
28
24
|
activeObject !== undefined && activeObject.type === name;
|
|
29
25
|
|
|
30
|
-
// Edge case: un-collapsed link formats.
|
|
31
|
-
// If there is a missing link format at either end of the selection
|
|
32
|
-
// then we shouldn't show the Edit UI because the selection has exceeded
|
|
33
|
-
// the bounds of the link format.
|
|
34
|
-
// Also if the format objects don't match then we're dealing with two separate
|
|
35
|
-
// links so we should not allow the link to be modified over the top.
|
|
36
|
-
if ( name === 'core/link' && ! isCollapsed( value ) ) {
|
|
37
|
-
const formats = value.formats;
|
|
38
|
-
|
|
39
|
-
const linkFormatAtStart = formats[ value.start ]?.find(
|
|
40
|
-
( { type } ) => type === 'core/link'
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
const linkFormatAtEnd = formats[ value.end - 1 ]?.find(
|
|
44
|
-
( { type } ) => type === 'core/link'
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
! linkFormatAtStart ||
|
|
49
|
-
! linkFormatAtEnd ||
|
|
50
|
-
linkFormatAtStart !== linkFormatAtEnd
|
|
51
|
-
) {
|
|
52
|
-
isActive = false;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
26
|
return (
|
|
57
27
|
<Edit
|
|
58
28
|
key={ name }
|
|
@@ -19,11 +19,7 @@ import FormatToolbar from './format-toolbar';
|
|
|
19
19
|
import NavigableToolbar from '../navigable-toolbar';
|
|
20
20
|
import { store as blockEditorStore } from '../../store';
|
|
21
21
|
|
|
22
|
-
function InlineSelectionToolbar( {
|
|
23
|
-
value,
|
|
24
|
-
editableContentElement,
|
|
25
|
-
activeFormats,
|
|
26
|
-
} ) {
|
|
22
|
+
function InlineSelectionToolbar( { editableContentElement, activeFormats } ) {
|
|
27
23
|
const lastFormat = activeFormats[ activeFormats.length - 1 ];
|
|
28
24
|
const lastFormatType = lastFormat?.type;
|
|
29
25
|
const settings = useSelect(
|
|
@@ -32,7 +28,6 @@ function InlineSelectionToolbar( {
|
|
|
32
28
|
);
|
|
33
29
|
const popoverAnchor = useAnchor( {
|
|
34
30
|
editableContentElement,
|
|
35
|
-
value,
|
|
36
31
|
settings,
|
|
37
32
|
} );
|
|
38
33
|
|
|
@@ -85,7 +80,6 @@ const FormatToolbarContainer = ( {
|
|
|
85
80
|
return (
|
|
86
81
|
<InlineSelectionToolbar
|
|
87
82
|
editableContentElement={ editableContentElement }
|
|
88
|
-
value={ value }
|
|
89
83
|
activeFormats={ activeFormats }
|
|
90
84
|
/>
|
|
91
85
|
);
|
|
@@ -31,11 +31,10 @@ export default function useInput() {
|
|
|
31
31
|
|
|
32
32
|
return useRefEffect( ( node ) => {
|
|
33
33
|
function onBeforeInput( event ) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if ( event.inputType?.startsWith( 'format' ) ) {
|
|
34
|
+
// If writing flow is editable, NEVER allow the browser to alter the
|
|
35
|
+
// DOM. This will cause React errors (and the DOM should only be
|
|
36
|
+
// altered in a controlled fashion).
|
|
37
|
+
if ( node.contentEditable === 'true' ) {
|
|
39
38
|
event.preventDefault();
|
|
40
39
|
}
|
|
41
40
|
}
|