@wordpress/block-editor 7.0.4 → 8.0.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 +11 -0
- package/README.md +31 -0
- package/build/components/alignment-control/ui.js +1 -2
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-icon/index.js +5 -1
- package/build/components/block-icon/index.js.map +1 -1
- package/build/components/block-inspector/index.js +4 -0
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/index.native.js +1 -1
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-block-props/use-multi-selection.js +21 -8
- package/build/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build/components/block-navigation/dropdown.js +0 -1
- package/build/components/block-navigation/dropdown.js.map +1 -1
- package/build/components/block-patterns-list/index.js +1 -8
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-settings/container.native.js +5 -2
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +22 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/preview.native.js +2 -2
- package/build/components/block-styles/preview.native.js.map +1 -1
- package/build/components/colors-gradients/control.js +8 -47
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +81 -6
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/duotone-control/index.js +5 -2
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +27 -15
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/iframe/index.js +1 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.js +20 -2
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +2 -2
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/index.js +5 -4
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +4 -3
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/explorer.js +62 -0
- package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/patterns-list.js +111 -0
- package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js +78 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
- package/build/components/inserter/block-patterns-tab.js +74 -45
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
- package/build/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build/components/inserter/pattern-panel.js +19 -10
- package/build/components/inserter/pattern-panel.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/letter-spacing-control/index.js +9 -6
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/link-control/index.js +88 -35
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/link-preview.js +19 -6
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-input.js +12 -3
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/list-view/block.js +49 -23
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +92 -73
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +39 -16
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +1 -1
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +8 -58
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/rich-text/embed-handler-picker.native.js +1 -0
- package/build/components/rich-text/embed-handler-picker.native.js.map +1 -1
- package/build/components/rich-text/format-edit.js +28 -2
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/rich-text/format-toolbar/index.js +2 -1
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/url-input/index.js +11 -4
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-setting/index.js +48 -9
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/border.js +5 -5
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +2 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/duotone.js +16 -5
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/font-appearance.js +49 -6
- package/build/hooks/font-appearance.js.map +1 -1
- package/build/hooks/font-family.js +37 -16
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +51 -9
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/index.js +8 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +8 -0
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/letter-spacing.js +44 -7
- package/build/hooks/letter-spacing.js.map +1 -1
- package/build/hooks/line-height.js +45 -8
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/margin.js +1 -1
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +1 -1
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/text-decoration.js +42 -6
- package/build/hooks/text-decoration.js.map +1 -1
- package/build/hooks/text-transform.js +42 -6
- package/build/hooks/text-transform.js.map +1 -1
- package/build/hooks/typography.js +108 -8
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/use-cached-truthy.js +29 -0
- package/build/hooks/use-cached-truthy.js.map +1 -0
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/layouts/flex.js +120 -28
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +303 -265
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +1 -3
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +23 -22
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +44 -35
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +1 -2
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-icon/index.js +5 -1
- package/build-module/components/block-icon/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +4 -0
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/index.native.js +1 -1
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-multi-selection.js +21 -8
- package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build-module/components/block-navigation/dropdown.js +0 -1
- package/build-module/components/block-navigation/dropdown.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +1 -6
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +6 -3
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +24 -4
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/preview.native.js +2 -2
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +12 -53
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +82 -6
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/duotone-control/index.js +5 -2
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +23 -15
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/iframe/index.js +1 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/index.js +3 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +6 -5
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +5 -4
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/explorer.js +50 -0
- package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +92 -0
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js +69 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab.js +75 -46
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build-module/components/inserter/pattern-panel.js +21 -13
- package/build-module/components/inserter/pattern-panel.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/letter-spacing-control/index.js +9 -6
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +88 -36
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +19 -7
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-input.js +11 -3
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/list-view/block.js +49 -24
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +92 -73
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +41 -18
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +1 -1
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +8 -58
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/rich-text/embed-handler-picker.native.js +1 -0
- package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +28 -3
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js +2 -1
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/url-input/index.js +11 -4
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +48 -9
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/border.js +5 -5
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +2 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/duotone.js +16 -5
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/font-appearance.js +45 -6
- package/build-module/hooks/font-appearance.js.map +1 -1
- package/build-module/hooks/font-family.js +33 -16
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +47 -9
- 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/index.native.js +1 -0
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/letter-spacing.js +40 -7
- package/build-module/hooks/letter-spacing.js.map +1 -1
- package/build-module/hooks/line-height.js +41 -8
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/margin.js +1 -1
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +1 -1
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/text-decoration.js +38 -6
- package/build-module/hooks/text-decoration.js.map +1 -1
- package/build-module/hooks/text-transform.js +38 -6
- package/build-module/hooks/text-transform.js.map +1 -1
- package/build-module/hooks/typography.js +117 -17
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/use-cached-truthy.js +21 -0
- package/build-module/hooks/use-cached-truthy.js.map +1 -0
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/flex.js +124 -32
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +266 -241
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +1 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +23 -22
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +42 -30
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +160 -57
- package/build-style/style.css +160 -57
- package/package.json +13 -14
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +0 -2
- package/src/components/alignment-control/ui.js +1 -4
- package/src/components/block-draggable/style.scss +19 -4
- package/src/components/block-icon/index.js +4 -1
- package/src/components/block-inspector/index.js +5 -0
- package/src/components/block-list/index.native.js +1 -1
- package/src/components/block-list/use-block-props/use-multi-selection.js +27 -7
- package/src/components/block-navigation/dropdown.js +0 -1
- package/src/components/block-patterns-list/index.js +1 -8
- package/src/components/block-patterns-list/style.scss +22 -12
- package/src/components/block-settings/container.native.js +7 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +19 -7
- package/src/components/block-styles/preview.native.js +2 -2
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +1 -1
- package/src/components/color-palette/test/__snapshots__/control.js.snap +88 -63
- package/src/components/colors-gradients/control.js +19 -62
- package/src/components/colors-gradients/panel-color-gradient-settings.js +76 -6
- package/src/components/colors-gradients/style.scss +3 -14
- package/src/components/colors-gradients/test/control.js +0 -16
- package/src/components/duotone-control/index.js +6 -0
- package/src/components/duotone-control/style.scss +27 -12
- package/src/components/font-appearance-control/index.js +22 -14
- package/src/components/iframe/index.js +1 -1
- package/src/components/index.js +3 -4
- package/src/components/index.native.js +1 -4
- package/src/components/inner-blocks/index.js +4 -4
- package/src/components/inner-blocks/index.native.js +7 -4
- package/src/components/inserter/block-patterns-explorer/explorer.js +50 -0
- package/src/components/inserter/block-patterns-explorer/patterns-list.js +122 -0
- package/src/components/inserter/block-patterns-explorer/sidebar.js +73 -0
- package/src/components/inserter/block-patterns-tab.js +107 -80
- package/src/components/inserter/hooks/use-block-type-impressions.native.js +14 -21
- package/src/components/inserter/pattern-panel.js +33 -16
- package/src/components/inserter/style.scss +64 -1
- package/src/components/inserter/test/block-types-tab.native.js +1 -1
- package/src/components/inserter/test/fixtures/index.native.js +12 -0
- package/src/components/inspector-controls/groups.js +4 -0
- package/src/components/letter-spacing-control/index.js +12 -6
- package/src/components/link-control/README.md +7 -0
- package/src/components/link-control/index.js +99 -34
- package/src/components/link-control/link-preview.js +21 -9
- package/src/components/link-control/search-input.js +9 -3
- package/src/components/link-control/style.scss +32 -16
- package/src/components/link-control/test/index.js +179 -4
- package/src/components/list-view/block.js +67 -23
- package/src/components/list-view/branch.js +113 -91
- package/src/components/list-view/index.js +58 -19
- package/src/components/list-view/leaf.js +1 -1
- package/src/components/list-view/style.scss +14 -3
- package/src/components/list-view/use-list-view-client-ids.js +7 -66
- package/src/components/rich-text/embed-handler-picker.native.js +1 -0
- package/src/components/rich-text/format-edit.js +36 -2
- package/src/components/rich-text/format-toolbar/index.js +3 -0
- package/src/components/url-input/index.js +14 -4
- package/src/components/use-setting/index.js +49 -11
- package/src/hooks/border.js +8 -11
- package/src/hooks/color-panel.js +1 -0
- package/src/hooks/duotone.js +21 -7
- package/src/hooks/font-appearance.js +38 -7
- package/src/hooks/font-family.js +29 -13
- package/src/hooks/font-size.js +42 -6
- package/src/hooks/index.js +1 -0
- package/src/hooks/index.native.js +1 -0
- package/src/hooks/layout.scss +3 -1
- package/src/hooks/letter-spacing.js +35 -7
- package/src/hooks/line-height.js +37 -9
- package/src/hooks/margin.js +1 -1
- package/src/hooks/padding.js +1 -1
- package/src/hooks/text-decoration.js +34 -6
- package/src/hooks/text-transform.js +34 -6
- package/src/hooks/typography.js +165 -15
- package/src/hooks/typography.scss +16 -0
- package/src/hooks/use-cached-truthy.js +20 -0
- package/src/index.js +1 -0
- package/src/layouts/flex.js +137 -41
- package/src/store/actions.js +223 -391
- package/src/store/index.js +1 -2
- package/src/store/reducer.js +36 -18
- package/src/store/selectors.js +52 -47
- package/src/store/test/actions.js +395 -694
- package/src/store/test/selectors.js +79 -21
- package/src/style.scss +1 -1
- package/src/utils/test/parse-css-unit-to-px.js +127 -167
- package/build/components/text-decoration-and-transform/index.js +0 -39
- package/build/components/text-decoration-and-transform/index.js.map +0 -1
- package/build/store/controls.js +0 -44
- package/build/store/controls.js.map +0 -1
- package/build-module/components/text-decoration-and-transform/index.js +0 -30
- package/build-module/components/text-decoration-and-transform/index.js.map +0 -1
- package/build-module/store/controls.js +0 -32
- package/build-module/store/controls.js.map +0 -1
- package/src/components/text-decoration-and-transform/index.js +0 -36
- package/src/components/text-decoration-and-transform/style.scss +0 -3
- package/src/store/controls.js +0 -39
|
@@ -1,154 +1,174 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { compact } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
+
import { memo } from '@wordpress/element';
|
|
9
10
|
import { AsyncModeProvider } from '@wordpress/data';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Internal dependencies
|
|
13
14
|
*/
|
|
14
15
|
import ListViewBlock from './block';
|
|
15
|
-
import ListViewAppender from './appender';
|
|
16
|
-
import { isClientIdSelected } from './utils';
|
|
17
16
|
import { useListViewContext } from './context';
|
|
17
|
+
import { isClientIdSelected } from './utils';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Given a block, returns the total number of blocks in that subtree. This is used to help determine
|
|
21
|
+
* the list position of a block.
|
|
22
|
+
*
|
|
23
|
+
* When a block is collapsed, we do not count their children as part of that total. In the current drag
|
|
24
|
+
* implementation dragged blocks and their children are not counted.
|
|
25
|
+
*
|
|
26
|
+
* @param {Object} block block tree
|
|
27
|
+
* @param {Object} expandedState state that notes which branches are collapsed
|
|
28
|
+
* @param {Array} draggedClientIds a list of dragged client ids
|
|
29
|
+
* @return {number} block count
|
|
30
|
+
*/
|
|
31
|
+
function countBlocks( block, expandedState, draggedClientIds ) {
|
|
32
|
+
const isDragged = draggedClientIds?.includes( block.clientId );
|
|
33
|
+
if ( isDragged ) {
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
36
|
+
const isExpanded = expandedState[ block.clientId ] ?? true;
|
|
37
|
+
if ( isExpanded ) {
|
|
38
|
+
return (
|
|
39
|
+
1 +
|
|
40
|
+
block.innerBlocks.reduce(
|
|
41
|
+
countReducer( expandedState, draggedClientIds ),
|
|
42
|
+
0
|
|
43
|
+
)
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
return 1;
|
|
47
|
+
}
|
|
48
|
+
const countReducer = ( expandedState, draggedClientIds ) => (
|
|
49
|
+
count,
|
|
50
|
+
block
|
|
51
|
+
) => {
|
|
52
|
+
const isDragged = draggedClientIds?.includes( block.clientId );
|
|
53
|
+
if ( isDragged ) {
|
|
54
|
+
return count;
|
|
55
|
+
}
|
|
56
|
+
const isExpanded = expandedState[ block.clientId ] ?? true;
|
|
57
|
+
if ( isExpanded && block.innerBlocks.length > 0 ) {
|
|
58
|
+
return count + countBlocks( block, expandedState, draggedClientIds );
|
|
59
|
+
}
|
|
60
|
+
return count + 1;
|
|
61
|
+
};
|
|
18
62
|
|
|
19
|
-
|
|
63
|
+
function ListViewBranch( props ) {
|
|
20
64
|
const {
|
|
21
65
|
blocks,
|
|
22
66
|
selectBlock,
|
|
23
|
-
showAppender,
|
|
24
67
|
showBlockMovers,
|
|
25
68
|
showNestedBlocks,
|
|
26
|
-
|
|
69
|
+
selectedClientIds,
|
|
27
70
|
level = 1,
|
|
28
|
-
|
|
29
|
-
path = [],
|
|
71
|
+
path = '',
|
|
30
72
|
isBranchSelected = false,
|
|
31
|
-
|
|
73
|
+
listPosition = 0,
|
|
74
|
+
fixedListWindow,
|
|
32
75
|
} = props;
|
|
33
76
|
|
|
34
77
|
const {
|
|
35
78
|
expandedState,
|
|
36
|
-
expand,
|
|
37
|
-
collapse,
|
|
38
79
|
draggedClientIds,
|
|
39
|
-
|
|
80
|
+
__experimentalPersistentListViewFeatures,
|
|
40
81
|
} = useListViewContext();
|
|
41
82
|
|
|
42
|
-
const isTreeRoot = ! parentBlockClientId;
|
|
43
83
|
const filteredBlocks = compact( blocks );
|
|
44
|
-
const itemHasAppender = ( parentClientId ) =>
|
|
45
|
-
showAppender &&
|
|
46
|
-
! isTreeRoot &&
|
|
47
|
-
isClientIdSelected( parentClientId, selectedClientIds );
|
|
48
|
-
const hasAppender = itemHasAppender( parentBlockClientId );
|
|
49
|
-
// Add +1 to the rowCount to take the block appender into account.
|
|
50
84
|
const blockCount = filteredBlocks.length;
|
|
51
|
-
|
|
52
|
-
const appenderPosition = rowCount;
|
|
85
|
+
let nextPosition = listPosition;
|
|
53
86
|
|
|
54
87
|
return (
|
|
55
88
|
<>
|
|
56
|
-
{ map(
|
|
89
|
+
{ filteredBlocks.map( ( block, index ) => {
|
|
57
90
|
const { clientId, innerBlocks } = block;
|
|
91
|
+
|
|
92
|
+
if ( index > 0 ) {
|
|
93
|
+
nextPosition += countBlocks(
|
|
94
|
+
filteredBlocks[ index - 1 ],
|
|
95
|
+
expandedState,
|
|
96
|
+
draggedClientIds
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const usesWindowing = __experimentalPersistentListViewFeatures;
|
|
101
|
+
|
|
102
|
+
const { itemInView } = fixedListWindow;
|
|
103
|
+
|
|
104
|
+
const blockInView =
|
|
105
|
+
! usesWindowing || itemInView( nextPosition );
|
|
106
|
+
|
|
58
107
|
const position = index + 1;
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const updatedPath = [ ...path, position ];
|
|
108
|
+
const updatedPath =
|
|
109
|
+
path.length > 0
|
|
110
|
+
? `${ path }_${ position }`
|
|
111
|
+
: `${ position }`;
|
|
64
112
|
const hasNestedBlocks =
|
|
65
113
|
showNestedBlocks && !! innerBlocks && !! innerBlocks.length;
|
|
66
|
-
const hasNestedAppender = itemHasAppender( clientId );
|
|
67
|
-
const hasNestedBranch = hasNestedBlocks || hasNestedAppender;
|
|
68
|
-
|
|
69
|
-
const isSelected = isClientIdSelected(
|
|
70
|
-
clientId,
|
|
71
|
-
selectedClientIds
|
|
72
|
-
);
|
|
73
|
-
const isSelectedBranch =
|
|
74
|
-
isBranchSelected || ( isSelected && hasNestedBranch );
|
|
75
114
|
|
|
76
|
-
|
|
77
|
-
// This is currently only needed for styling purposes. See: `.is-last-of-selected-branch`.
|
|
78
|
-
const isLastBlock = index === blockCount - 1;
|
|
79
|
-
const isLast = isSelected || ( isLastOfBranch && isLastBlock );
|
|
80
|
-
const isLastOfSelectedBranch =
|
|
81
|
-
isLastOfBranch && ! hasNestedBranch && isLastBlock;
|
|
82
|
-
|
|
83
|
-
const isExpanded = hasNestedBranch
|
|
115
|
+
const isExpanded = hasNestedBlocks
|
|
84
116
|
? expandedState[ clientId ] ?? true
|
|
85
117
|
: undefined;
|
|
86
118
|
|
|
87
|
-
const
|
|
88
|
-
event.stopPropagation();
|
|
89
|
-
selectBlock( clientId );
|
|
90
|
-
};
|
|
119
|
+
const isDragged = !! draggedClientIds?.includes( clientId );
|
|
91
120
|
|
|
92
|
-
const
|
|
93
|
-
event.stopPropagation();
|
|
94
|
-
if ( isExpanded === true ) {
|
|
95
|
-
collapse( clientId );
|
|
96
|
-
} else if ( isExpanded === false ) {
|
|
97
|
-
expand( clientId );
|
|
98
|
-
}
|
|
99
|
-
};
|
|
121
|
+
const showBlock = isDragged || blockInView;
|
|
100
122
|
|
|
101
123
|
// Make updates to the selected or dragged blocks synchronous,
|
|
102
124
|
// but asynchronous for any other block.
|
|
103
|
-
const
|
|
104
|
-
|
|
125
|
+
const isSelected = isClientIdSelected(
|
|
126
|
+
clientId,
|
|
127
|
+
selectedClientIds
|
|
128
|
+
);
|
|
129
|
+
const isSelectedBranch =
|
|
130
|
+
isBranchSelected || ( isSelected && hasNestedBlocks );
|
|
105
131
|
return (
|
|
106
132
|
<AsyncModeProvider key={ clientId } value={ ! isSelected }>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
{
|
|
133
|
+
{ showBlock && (
|
|
134
|
+
<ListViewBlock
|
|
135
|
+
block={ block }
|
|
136
|
+
selectBlock={ selectBlock }
|
|
137
|
+
isSelected={ isSelected }
|
|
138
|
+
isBranchSelected={ isSelectedBranch }
|
|
139
|
+
isDragged={ isDragged }
|
|
140
|
+
level={ level }
|
|
141
|
+
position={ position }
|
|
142
|
+
rowCount={ blockCount }
|
|
143
|
+
siblingBlockCount={ blockCount }
|
|
144
|
+
showBlockMovers={ showBlockMovers }
|
|
145
|
+
path={ updatedPath }
|
|
146
|
+
isExpanded={ isExpanded }
|
|
147
|
+
listPosition={ nextPosition }
|
|
148
|
+
/>
|
|
149
|
+
) }
|
|
150
|
+
{ ! showBlock && (
|
|
151
|
+
<tr>
|
|
152
|
+
<td className="block-editor-list-view-placeholder" />
|
|
153
|
+
</tr>
|
|
154
|
+
) }
|
|
155
|
+
{ hasNestedBlocks && isExpanded && ! isDragged && (
|
|
125
156
|
<ListViewBranch
|
|
126
157
|
blocks={ innerBlocks }
|
|
127
158
|
selectBlock={ selectBlock }
|
|
128
|
-
isBranchSelected={ isSelectedBranch }
|
|
129
|
-
isLastOfBranch={ isLast }
|
|
130
|
-
showAppender={ showAppender }
|
|
131
159
|
showBlockMovers={ showBlockMovers }
|
|
132
160
|
showNestedBlocks={ showNestedBlocks }
|
|
133
|
-
parentBlockClientId={ clientId }
|
|
134
161
|
level={ level + 1 }
|
|
135
|
-
terminatedLevels={ updatedTerminatedLevels }
|
|
136
162
|
path={ updatedPath }
|
|
163
|
+
listPosition={ nextPosition + 1 }
|
|
164
|
+
fixedListWindow={ fixedListWindow }
|
|
165
|
+
isBranchSelected={ isSelectedBranch }
|
|
166
|
+
selectedClientIds={ selectedClientIds }
|
|
137
167
|
/>
|
|
138
168
|
) }
|
|
139
169
|
</AsyncModeProvider>
|
|
140
170
|
);
|
|
141
171
|
} ) }
|
|
142
|
-
{ hasAppender && (
|
|
143
|
-
<ListViewAppender
|
|
144
|
-
parentBlockClientId={ parentBlockClientId }
|
|
145
|
-
position={ rowCount }
|
|
146
|
-
rowCount={ appenderPosition }
|
|
147
|
-
level={ level }
|
|
148
|
-
terminatedLevels={ terminatedLevels }
|
|
149
|
-
path={ [ ...path, appenderPosition ] }
|
|
150
|
-
/>
|
|
151
|
-
) }
|
|
152
172
|
</>
|
|
153
173
|
);
|
|
154
174
|
}
|
|
@@ -156,3 +176,5 @@ export default function ListViewBranch( props ) {
|
|
|
156
176
|
ListViewBranch.defaultProps = {
|
|
157
177
|
selectBlock: () => {},
|
|
158
178
|
};
|
|
179
|
+
|
|
180
|
+
export default memo( ListViewBranch );
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
useMergeRefs,
|
|
6
|
+
__experimentalUseFixedWindowList as useFixedWindowList,
|
|
7
|
+
} from '@wordpress/compose';
|
|
6
8
|
import { __experimentalTreeGrid as TreeGrid } from '@wordpress/components';
|
|
7
|
-
import { AsyncModeProvider, useDispatch } from '@wordpress/data';
|
|
9
|
+
import { AsyncModeProvider, useDispatch, useSelect } from '@wordpress/data';
|
|
8
10
|
import {
|
|
9
11
|
useCallback,
|
|
10
12
|
useEffect,
|
|
@@ -46,32 +48,46 @@ const expanded = ( state, action ) => {
|
|
|
46
48
|
* @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.
|
|
47
49
|
* @param {Function} props.onSelect Block selection callback.
|
|
48
50
|
* @param {boolean} props.showNestedBlocks Flag to enable displaying nested blocks.
|
|
49
|
-
* @param {boolean} props.
|
|
51
|
+
* @param {boolean} props.showBlockMovers Flag to enable block movers
|
|
50
52
|
* @param {boolean} props.__experimentalFeatures Flag to enable experimental features.
|
|
51
53
|
* @param {boolean} props.__experimentalPersistentListViewFeatures Flag to enable features for the Persistent List View experiment.
|
|
54
|
+
* @param {boolean} props.__experimentalHideContainerBlockActions Flag to hide actions of top level blocks (like core/widget-area)
|
|
52
55
|
* @param {Object} ref Forwarded ref
|
|
53
56
|
*/
|
|
54
57
|
function ListView(
|
|
55
58
|
{
|
|
56
59
|
blocks,
|
|
57
|
-
showOnlyCurrentHierarchy,
|
|
58
60
|
onSelect = noop,
|
|
59
61
|
__experimentalFeatures,
|
|
60
62
|
__experimentalPersistentListViewFeatures,
|
|
63
|
+
__experimentalHideContainerBlockActions,
|
|
64
|
+
showNestedBlocks,
|
|
65
|
+
showBlockMovers,
|
|
61
66
|
...props
|
|
62
67
|
},
|
|
63
68
|
ref
|
|
64
69
|
) {
|
|
65
70
|
const {
|
|
66
71
|
clientIdsTree,
|
|
67
|
-
selectedClientIds,
|
|
68
72
|
draggedClientIds,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
showOnlyCurrentHierarchy,
|
|
72
|
-
__experimentalPersistentListViewFeatures
|
|
73
|
-
);
|
|
73
|
+
selectedClientIds,
|
|
74
|
+
} = useListViewClientIds( blocks );
|
|
74
75
|
const { selectBlock } = useDispatch( blockEditorStore );
|
|
76
|
+
const { visibleBlockCount } = useSelect(
|
|
77
|
+
( select ) => {
|
|
78
|
+
const { getGlobalBlockCount, getClientIdsOfDescendants } = select(
|
|
79
|
+
blockEditorStore
|
|
80
|
+
);
|
|
81
|
+
const draggedBlockCount =
|
|
82
|
+
draggedClientIds?.length > 0
|
|
83
|
+
? getClientIdsOfDescendants( draggedClientIds ).length + 1
|
|
84
|
+
: 0;
|
|
85
|
+
return {
|
|
86
|
+
visibleBlockCount: getGlobalBlockCount() - draggedBlockCount,
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
[ draggedClientIds ]
|
|
90
|
+
);
|
|
75
91
|
const selectEditorBlock = useCallback(
|
|
76
92
|
( clientId ) => {
|
|
77
93
|
selectBlock( clientId );
|
|
@@ -90,6 +106,19 @@ function ListView(
|
|
|
90
106
|
isMounted.current = true;
|
|
91
107
|
}, [] );
|
|
92
108
|
|
|
109
|
+
// List View renders a fixed number of items and relies on each having a fixed item height of 36px.
|
|
110
|
+
// If this value changes, we should also change the itemHeight value set in useFixedWindowList.
|
|
111
|
+
// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.
|
|
112
|
+
const [ fixedListWindow ] = useFixedWindowList(
|
|
113
|
+
elementRef,
|
|
114
|
+
36,
|
|
115
|
+
visibleBlockCount,
|
|
116
|
+
{
|
|
117
|
+
useWindowing: __experimentalPersistentListViewFeatures,
|
|
118
|
+
windowOverscan: 40,
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
|
|
93
122
|
const expand = useCallback(
|
|
94
123
|
( clientId ) => {
|
|
95
124
|
if ( ! clientId ) {
|
|
@@ -108,20 +137,26 @@ function ListView(
|
|
|
108
137
|
},
|
|
109
138
|
[ setExpandedState ]
|
|
110
139
|
);
|
|
111
|
-
const expandRow = (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
140
|
+
const expandRow = useCallback(
|
|
141
|
+
( row ) => {
|
|
142
|
+
expand( row?.dataset?.block );
|
|
143
|
+
},
|
|
144
|
+
[ expand ]
|
|
145
|
+
);
|
|
146
|
+
const collapseRow = useCallback(
|
|
147
|
+
( row ) => {
|
|
148
|
+
collapse( row?.dataset?.block );
|
|
149
|
+
},
|
|
150
|
+
[ collapse ]
|
|
151
|
+
);
|
|
117
152
|
|
|
118
153
|
const contextValue = useMemo(
|
|
119
154
|
() => ( {
|
|
120
155
|
__experimentalFeatures,
|
|
121
156
|
__experimentalPersistentListViewFeatures,
|
|
157
|
+
__experimentalHideContainerBlockActions,
|
|
122
158
|
isTreeGridMounted: isMounted.current,
|
|
123
159
|
draggedClientIds,
|
|
124
|
-
selectedClientIds,
|
|
125
160
|
expandedState,
|
|
126
161
|
expand,
|
|
127
162
|
collapse,
|
|
@@ -129,9 +164,9 @@ function ListView(
|
|
|
129
164
|
[
|
|
130
165
|
__experimentalFeatures,
|
|
131
166
|
__experimentalPersistentListViewFeatures,
|
|
167
|
+
__experimentalHideContainerBlockActions,
|
|
132
168
|
isMounted.current,
|
|
133
169
|
draggedClientIds,
|
|
134
|
-
selectedClientIds,
|
|
135
170
|
expandedState,
|
|
136
171
|
expand,
|
|
137
172
|
collapse,
|
|
@@ -155,6 +190,10 @@ function ListView(
|
|
|
155
190
|
<ListViewBranch
|
|
156
191
|
blocks={ clientIdsTree }
|
|
157
192
|
selectBlock={ selectEditorBlock }
|
|
193
|
+
showNestedBlocks={ showNestedBlocks }
|
|
194
|
+
showBlockMovers={ showBlockMovers }
|
|
195
|
+
fixedListWindow={ fixedListWindow }
|
|
196
|
+
selectedClientIds={ selectedClientIds }
|
|
158
197
|
{ ...props }
|
|
159
198
|
/>
|
|
160
199
|
</ListViewContext.Provider>
|
|
@@ -57,14 +57,14 @@
|
|
|
57
57
|
&.is-branch-selected:not(.is-selected) .block-editor-list-view-block-contents {
|
|
58
58
|
border-radius: 0;
|
|
59
59
|
}
|
|
60
|
-
&.is-branch-selected.is-last-of-selected-branch .block-editor-list-view-block-contents {
|
|
61
|
-
border-radius: 0 0 2px 2px;
|
|
62
|
-
}
|
|
63
60
|
|
|
64
61
|
&.is-dragging {
|
|
65
62
|
display: none;
|
|
66
63
|
}
|
|
67
64
|
|
|
65
|
+
// List View renders a fixed number of items and relies on each item having a fixed height of 36px.
|
|
66
|
+
// If this value changes, we should also change the itemHeight value set in useFixedWindowList.
|
|
67
|
+
// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.
|
|
68
68
|
.block-editor-list-view-block-contents {
|
|
69
69
|
display: flex;
|
|
70
70
|
align-items: center;
|
|
@@ -115,6 +115,11 @@
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
+
// Fix focus styling width when one row has fewer cells.
|
|
119
|
+
&.has-single-cell .block-editor-list-view-block-contents:focus::after {
|
|
120
|
+
right: 0;
|
|
121
|
+
}
|
|
122
|
+
|
|
118
123
|
.block-editor-list-view-block__menu:focus {
|
|
119
124
|
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
120
125
|
z-index: 1;
|
|
@@ -355,3 +360,9 @@ $block-navigation-max-indent: 8;
|
|
|
355
360
|
box-shadow: none;
|
|
356
361
|
}
|
|
357
362
|
|
|
363
|
+
.block-editor-list-view-placeholder {
|
|
364
|
+
padding: 0;
|
|
365
|
+
margin: 0;
|
|
366
|
+
height: 36px;
|
|
367
|
+
}
|
|
368
|
+
|
|
@@ -7,82 +7,23 @@ import { useSelect } from '@wordpress/data';
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
|
-
import { isClientIdSelected } from './utils';
|
|
11
10
|
import { store as blockEditorStore } from '../../store';
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
selectedClientIds,
|
|
16
|
-
showOnlyCurrentHierarchy
|
|
17
|
-
) =>
|
|
18
|
-
useSelect(
|
|
12
|
+
export default function useListViewClientIds( blocks ) {
|
|
13
|
+
return useSelect(
|
|
19
14
|
( select ) => {
|
|
20
15
|
const {
|
|
21
|
-
getBlockHierarchyRootClientId,
|
|
22
|
-
__unstableGetClientIdsTree,
|
|
23
|
-
__unstableGetClientIdWithClientIdsTree,
|
|
24
|
-
} = select( blockEditorStore );
|
|
25
|
-
|
|
26
|
-
if ( blocks ) {
|
|
27
|
-
return blocks;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const isSingleBlockSelected =
|
|
31
|
-
selectedClientIds && ! Array.isArray( selectedClientIds );
|
|
32
|
-
if ( ! showOnlyCurrentHierarchy || ! isSingleBlockSelected ) {
|
|
33
|
-
return __unstableGetClientIdsTree();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const rootBlock = __unstableGetClientIdWithClientIdsTree(
|
|
37
|
-
getBlockHierarchyRootClientId( selectedClientIds )
|
|
38
|
-
);
|
|
39
|
-
if ( ! rootBlock ) {
|
|
40
|
-
return __unstableGetClientIdsTree();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const hasHierarchy =
|
|
44
|
-
! isClientIdSelected( rootBlock.clientId, selectedClientIds ) ||
|
|
45
|
-
( rootBlock.innerBlocks && rootBlock.innerBlocks.length !== 0 );
|
|
46
|
-
if ( hasHierarchy ) {
|
|
47
|
-
return [ rootBlock ];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return __unstableGetClientIdsTree();
|
|
51
|
-
},
|
|
52
|
-
[ blocks, selectedClientIds, showOnlyCurrentHierarchy ]
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
export default function useListViewClientIds(
|
|
56
|
-
blocks,
|
|
57
|
-
showOnlyCurrentHierarchy,
|
|
58
|
-
__experimentalPersistentListViewFeatures
|
|
59
|
-
) {
|
|
60
|
-
const { selectedClientIds, draggedClientIds } = useSelect(
|
|
61
|
-
( select ) => {
|
|
62
|
-
const {
|
|
63
|
-
getSelectedBlockClientId,
|
|
64
|
-
getSelectedBlockClientIds,
|
|
65
16
|
getDraggedBlockClientIds,
|
|
17
|
+
getSelectedBlockClientIds,
|
|
18
|
+
__unstableGetClientIdsTree,
|
|
66
19
|
} = select( blockEditorStore );
|
|
67
20
|
|
|
68
|
-
if ( __experimentalPersistentListViewFeatures ) {
|
|
69
|
-
return {
|
|
70
|
-
selectedClientIds: getSelectedBlockClientIds(),
|
|
71
|
-
draggedClientIds: getDraggedBlockClientIds(),
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
21
|
return {
|
|
76
|
-
selectedClientIds:
|
|
22
|
+
selectedClientIds: getSelectedBlockClientIds(),
|
|
77
23
|
draggedClientIds: getDraggedBlockClientIds(),
|
|
24
|
+
clientIdsTree: blocks ? blocks : __unstableGetClientIdsTree(),
|
|
78
25
|
};
|
|
79
26
|
},
|
|
80
|
-
[
|
|
81
|
-
);
|
|
82
|
-
const clientIdsTree = useListViewClientIdsTree(
|
|
83
|
-
blocks,
|
|
84
|
-
selectedClientIds,
|
|
85
|
-
showOnlyCurrentHierarchy
|
|
27
|
+
[ blocks ]
|
|
86
28
|
);
|
|
87
|
-
return { clientIdsTree, selectedClientIds, draggedClientIds };
|
|
88
29
|
}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
getActiveFormat,
|
|
6
|
+
getActiveObject,
|
|
7
|
+
isCollapsed,
|
|
8
|
+
} from '@wordpress/rich-text';
|
|
9
|
+
/**
|
|
10
|
+
* External dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { find } from 'lodash';
|
|
5
13
|
|
|
6
14
|
export default function FormatEdit( {
|
|
7
15
|
formatTypes,
|
|
@@ -18,11 +26,37 @@ export default function FormatEdit( {
|
|
|
18
26
|
}
|
|
19
27
|
|
|
20
28
|
const activeFormat = getActiveFormat( value, name );
|
|
21
|
-
|
|
29
|
+
let isActive = activeFormat !== undefined;
|
|
22
30
|
const activeObject = getActiveObject( value );
|
|
23
31
|
const isObjectActive =
|
|
24
32
|
activeObject !== undefined && activeObject.type === name;
|
|
25
33
|
|
|
34
|
+
// Edge case: un-collapsed link formats.
|
|
35
|
+
// If there is a missing link format at either end of the selection
|
|
36
|
+
// then we shouldn't show the Edit UI because the selection has exceeded
|
|
37
|
+
// the bounds of the link format.
|
|
38
|
+
// Also if the format objects don't match then we're dealing with two separate
|
|
39
|
+
// links so we should not allow the link to be modified over the top.
|
|
40
|
+
if ( name === 'core/link' && ! isCollapsed( value ) ) {
|
|
41
|
+
const formats = value.formats;
|
|
42
|
+
|
|
43
|
+
const linkFormatAtStart = find( formats[ value.start ], {
|
|
44
|
+
type: 'core/link',
|
|
45
|
+
} );
|
|
46
|
+
|
|
47
|
+
const linkFormatAtEnd = find( formats[ value.end - 1 ], {
|
|
48
|
+
type: 'core/link',
|
|
49
|
+
} );
|
|
50
|
+
|
|
51
|
+
if (
|
|
52
|
+
! linkFormatAtStart ||
|
|
53
|
+
! linkFormatAtEnd ||
|
|
54
|
+
linkFormatAtStart !== linkFormatAtEnd
|
|
55
|
+
) {
|
|
56
|
+
isActive = false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
26
60
|
return (
|
|
27
61
|
<Edit
|
|
28
62
|
key={ name }
|
|
@@ -60,7 +60,10 @@ class URLInput extends Component {
|
|
|
60
60
|
|
|
61
61
|
componentDidUpdate( prevProps ) {
|
|
62
62
|
const { showSuggestions, selectedSuggestion } = this.state;
|
|
63
|
-
const {
|
|
63
|
+
const {
|
|
64
|
+
value,
|
|
65
|
+
__experimentalShowInitialSuggestions = false,
|
|
66
|
+
} = this.props;
|
|
64
67
|
|
|
65
68
|
// only have to worry about scrolling selected suggestion into view
|
|
66
69
|
// when already expanded
|
|
@@ -84,12 +87,19 @@ class URLInput extends Component {
|
|
|
84
87
|
}, 100 );
|
|
85
88
|
}
|
|
86
89
|
|
|
87
|
-
//
|
|
90
|
+
// Update suggestions when the value changes
|
|
88
91
|
if (
|
|
89
92
|
prevProps.value !== value &&
|
|
90
|
-
this.
|
|
93
|
+
! this.props.disableSuggestions &&
|
|
94
|
+
! this.isUpdatingSuggestions
|
|
91
95
|
) {
|
|
92
|
-
|
|
96
|
+
if ( value?.length ) {
|
|
97
|
+
// If the new value is not empty we need to update with suggestions for it
|
|
98
|
+
this.updateSuggestions( value );
|
|
99
|
+
} else if ( __experimentalShowInitialSuggestions ) {
|
|
100
|
+
// If the new value is empty and we can show initial suggestions, then show initial suggestions
|
|
101
|
+
this.updateSuggestions();
|
|
102
|
+
}
|
|
93
103
|
}
|
|
94
104
|
}
|
|
95
105
|
|