@wordpress/block-editor 12.17.0 → 12.18.1
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 +4 -0
- package/README.md +32 -0
- package/build/components/block-draggable/index.js +11 -3
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-edit/context.js +3 -1
- package/build/components/block-edit/context.js.map +1 -1
- package/build/components/block-edit/index.js +4 -2
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-editing-mode/index.js +6 -3
- package/build/components/block-editing-mode/index.js.map +1 -1
- package/build/components/block-inspector/index.js +5 -2
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block.js +4 -3
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +9 -5
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.js +30 -4
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list/private-block-context.js +1 -1
- package/build/components/block-list/private-block-context.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +1 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-lock/toolbar.js +8 -2
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-popover/inbetween.js +15 -3
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-preview/auto.js +1 -1
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +3 -2
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -4
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.js +12 -1
- package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build/components/block-switcher/index.js +119 -90
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +10 -3
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/dimensions-tool/aspect-ratio-tool.js +2 -1
- package/build/components/dimensions-tool/aspect-ratio-tool.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +7 -1
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/global-styles/border-panel.js +5 -14
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +30 -5
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +7 -1
- package/build/components/global-styles/effects-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +11 -8
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +31 -14
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +6 -0
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/iframe/get-compatibility-styles.js +99 -0
- package/build/components/iframe/get-compatibility-styles.js.map +1 -0
- package/build/components/iframe/index.js +2 -3
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.js +16 -2
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +16 -2
- package/build/components/index.native.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js +3 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build/components/link-control/link-preview.js +30 -26
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -9
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/list-view/block-contents.js +3 -1
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block.js +10 -1
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +29 -8
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +100 -32
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +52 -4
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +2 -2
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-list-view-block-indexes.js +30 -0
- package/build/components/list-view/use-list-view-block-indexes.js.map +1 -0
- package/build/components/list-view/use-list-view-drop-zone.js +56 -5
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/list-view/utils.js +92 -0
- package/build/components/list-view/utils.js.map +1 -1
- package/build/components/provider/index.js +1 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/recursion-provider/index.js +21 -0
- package/build/components/recursion-provider/index.js.map +1 -1
- package/build/components/rich-text/index.js +30 -6
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +9 -9
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +30 -7
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +50 -8
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/hooks/block-hooks.js +5 -14
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/content-lock-ui.js +17 -42
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/dimensions.js +71 -1
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/effects.js +66 -0
- package/build/hooks/effects.js.map +1 -0
- package/build/hooks/index.js +17 -4
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +13 -0
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/style.js +9 -2
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/supports.js +2 -1
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.native.js +2 -2
- package/build/hooks/typography.native.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +115 -0
- package/build/hooks/use-bindings-attributes.js.map +1 -0
- package/build/hooks/use-shadow-props.js +46 -0
- package/build/hooks/use-shadow-props.js.map +1 -0
- package/build/hooks/utils.js +12 -7
- package/build/hooks/utils.js.map +1 -1
- package/build/index.js +14 -0
- package/build/index.js.map +1 -1
- package/build/store/actions.js +10 -6
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +2 -0
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +37 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +60 -9
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +44 -3
- package/build/store/reducer.js.map +1 -1
- package/build/store/resolvers.js +27 -0
- package/build/store/resolvers.js.map +1 -0
- package/build/store/selectors.js +94 -56
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +5 -26
- package/build/store/utils.js.map +1 -1
- package/build/utils/index.js +0 -16
- package/build/utils/index.js.map +1 -1
- package/build/utils/math.js +13 -0
- package/build/utils/math.js.map +1 -1
- package/build/utils/object.js +17 -0
- package/build/utils/object.js.map +1 -1
- package/build/utils/transform-styles/index.js +37 -27
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build-module/components/block-draggable/index.js +11 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-edit/context.js +1 -0
- package/build-module/components/block-edit/context.js.map +1 -1
- package/build-module/components/block-edit/index.js +5 -3
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-editing-mode/index.js +7 -4
- package/build-module/components/block-editing-mode/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +5 -2
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block.js +6 -5
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +11 -7
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.js +31 -5
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list/private-block-context.js +1 -1
- package/build-module/components/block-list/private-block-context.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +8 -2
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +15 -3
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-preview/auto.js +3 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +3 -2
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -4
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.js +12 -1
- package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build-module/components/block-switcher/index.js +116 -86
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +10 -3
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/dimensions-tool/aspect-ratio-tool.js +2 -1
- package/build-module/components/dimensions-tool/aspect-ratio-tool.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +7 -1
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +5 -14
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +30 -5
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +7 -1
- package/build-module/components/global-styles/effects-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +11 -8
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +32 -15
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +6 -0
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/iframe/get-compatibility-styles.js +93 -0
- package/build-module/components/iframe/get-compatibility-styles.js.map +1 -0
- package/build-module/components/iframe/index.js +2 -3
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/index.js +1 -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/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +3 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +32 -28
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -8
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +3 -1
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block.js +10 -1
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +30 -9
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +99 -32
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +54 -6
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +2 -2
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-list-view-block-indexes.js +23 -0
- package/build-module/components/list-view/use-list-view-block-indexes.js.map +1 -0
- package/build-module/components/list-view/use-list-view-drop-zone.js +58 -7
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/list-view/utils.js +91 -0
- package/build-module/components/list-view/utils.js.map +1 -1
- package/build-module/components/provider/index.js +1 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/recursion-provider/index.js +17 -0
- package/build-module/components/recursion-provider/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +30 -6
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +9 -9
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +31 -8
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +51 -9
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/hooks/block-hooks.js +5 -14
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +19 -43
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/dimensions.js +70 -2
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/effects.js +51 -0
- package/build-module/hooks/effects.js.map +1 -0
- package/build-module/hooks/index.js +5 -3
- 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/style.js +9 -2
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/supports.js +2 -1
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.native.js +2 -2
- package/build-module/hooks/typography.native.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +112 -0
- package/build-module/hooks/use-bindings-attributes.js.map +1 -0
- package/build-module/hooks/use-shadow-props.js +39 -0
- package/build-module/hooks/use-shadow-props.js.map +1 -0
- package/build-module/hooks/utils.js +14 -9
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +10 -6
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +2 -0
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +35 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +53 -8
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +43 -3
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/resolvers.js +20 -0
- package/build-module/store/resolvers.js.map +1 -0
- package/build-module/store/selectors.js +89 -52
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +3 -23
- package/build-module/store/utils.js.map +1 -1
- package/build-module/utils/index.js +0 -1
- package/build-module/utils/index.js.map +1 -1
- package/build-module/utils/math.js +12 -0
- package/build-module/utils/math.js.map +1 -1
- package/build-module/utils/object.js +16 -0
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +36 -27
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-style/content-rtl.css +33 -16
- package/build-style/content.css +33 -16
- package/build-style/default-editor-styles-rtl.css +1 -1
- package/build-style/default-editor-styles.css +1 -1
- package/build-style/style-rtl.css +169 -114
- package/build-style/style.css +169 -114
- package/package.json +31 -31
- package/src/components/block-canvas/style.scss +8 -1
- package/src/components/block-draggable/index.js +16 -5
- package/src/components/block-edit/context.js +1 -0
- package/src/components/block-edit/index.js +4 -0
- package/src/components/block-editing-mode/index.js +12 -7
- package/src/components/block-inspector/index.js +5 -2
- package/src/components/block-list/block.js +5 -4
- package/src/components/block-list/block.native.js +13 -3
- package/src/components/block-list/content.scss +34 -5
- package/src/components/block-list/index.js +52 -16
- package/src/components/block-list/private-block-context.js +1 -1
- package/src/components/block-list/use-in-between-inserter.js +1 -2
- package/src/components/block-lock/toolbar.js +10 -2
- package/src/components/block-popover/inbetween.js +22 -2
- package/src/components/block-preview/auto.js +3 -3
- package/src/components/block-removal-warning-modal/index.js +3 -2
- package/src/components/block-settings-menu/block-settings-dropdown.js +2 -7
- package/src/components/block-switcher/block-transformations-menu.js +18 -1
- package/src/components/block-switcher/index.js +133 -111
- package/src/components/block-switcher/style.scss +6 -4
- package/src/components/block-switcher/test/index.js +113 -230
- package/src/components/block-toolbar/style.scss +22 -18
- package/src/components/block-tools/insertion-point.js +15 -2
- package/src/components/block-tools/style.scss +8 -7
- package/src/components/dimensions-tool/aspect-ratio-tool.js +4 -1
- package/src/components/font-sizes/fluid-utils.js +8 -2
- package/src/components/font-sizes/test/fluid-utils.js +9 -0
- package/src/components/global-styles/border-panel.js +7 -17
- package/src/components/global-styles/dimensions-panel.js +50 -1
- package/src/components/global-styles/effects-panel.js +16 -1
- package/src/components/global-styles/hooks.js +11 -6
- package/src/components/global-styles/typography-panel.js +45 -13
- package/src/components/global-styles/use-global-styles-output.js +6 -0
- package/src/components/iframe/get-compatibility-styles.js +120 -0
- package/src/components/iframe/index.js +2 -3
- package/src/components/index.js +4 -2
- package/src/components/index.native.js +4 -2
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +1 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +2 -0
- package/src/components/link-control/link-preview.js +31 -55
- package/src/components/link-control/search-input.js +1 -9
- package/src/components/link-control/style.scss +31 -85
- package/src/components/link-control/test/index.js +2 -1
- package/src/components/list-view/block-contents.js +5 -1
- package/src/components/list-view/block.js +9 -0
- package/src/components/list-view/branch.js +30 -10
- package/src/components/list-view/drop-indicator.js +139 -46
- package/src/components/list-view/index.js +74 -3
- package/src/components/list-view/leaf.js +2 -2
- package/src/components/list-view/style.scss +102 -13
- package/src/components/list-view/test/use-list-view-drop-zone.js +4 -0
- package/src/components/list-view/test/utils.js +218 -1
- package/src/components/list-view/use-list-view-block-indexes.js +29 -0
- package/src/components/list-view/use-list-view-drop-zone.js +78 -6
- package/src/components/list-view/utils.js +116 -0
- package/src/components/provider/index.js +3 -1
- package/src/components/recursion-provider/README.md +2 -2
- package/src/components/recursion-provider/index.js +17 -0
- package/src/components/rich-text/index.js +48 -10
- package/src/components/rich-text/native/index.native.js +10 -10
- package/src/components/use-block-drop-zone/index.js +60 -19
- package/src/components/use-block-drop-zone/test/index.js +32 -61
- package/src/components/use-on-block-drop/index.js +92 -11
- package/src/hooks/block-hooks.js +5 -17
- package/src/hooks/content-lock-ui.js +15 -55
- package/src/hooks/dimensions.js +74 -3
- package/src/hooks/effects.js +57 -0
- package/src/hooks/index.js +4 -2
- package/src/hooks/index.native.js +1 -0
- package/src/hooks/style.js +12 -0
- package/src/hooks/supports.js +2 -0
- package/src/hooks/test/effects.js +39 -0
- package/src/hooks/typography.native.js +2 -2
- package/src/hooks/use-bindings-attributes.js +148 -0
- package/src/hooks/use-shadow-props.js +37 -0
- package/src/hooks/utils.js +30 -10
- package/src/index.js +2 -0
- package/src/store/actions.js +9 -4
- package/src/store/index.js +2 -0
- package/src/store/private-actions.js +32 -0
- package/src/store/private-selectors.js +78 -21
- package/src/store/reducer.js +49 -2
- package/src/store/resolvers.js +17 -0
- package/src/store/selectors.js +169 -161
- package/src/store/test/registry-selectors.js +431 -0
- package/src/store/test/selectors.js +14 -400
- package/src/store/utils.js +10 -33
- package/src/style.scss +0 -1
- package/src/utils/index.js +0 -1
- package/src/utils/math.js +12 -0
- package/src/utils/object.js +16 -0
- package/src/utils/transform-styles/index.js +52 -37
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/iframe/use-compatibility-styles.js +0 -100
- package/build/components/iframe/use-compatibility-styles.js.map +0 -1
- package/build/hooks/custom-fields.js +0 -106
- package/build/hooks/custom-fields.js.map +0 -1
- package/build/utils/block-variation-transforms.js +0 -42
- package/build/utils/block-variation-transforms.js.map +0 -1
- package/build-module/components/iframe/use-compatibility-styles.js +0 -94
- package/build-module/components/iframe/use-compatibility-styles.js.map +0 -1
- package/build-module/hooks/custom-fields.js +0 -99
- package/build-module/hooks/custom-fields.js.map +0 -1
- package/build-module/utils/block-variation-transforms.js +0 -35
- package/build-module/utils/block-variation-transforms.js.map +0 -1
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +0 -116
- package/src/components/contrast-checker/style.scss +0 -3
- package/src/components/iframe/use-compatibility-styles.js +0 -122
- package/src/hooks/custom-fields.js +0 -115
- package/src/utils/block-variation-transforms.js +0 -38
- package/src/utils/test/block-variation-transforms.js +0 -94
|
@@ -8,10 +8,13 @@ import classnames from 'classnames';
|
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
10
|
import { __ } from '@wordpress/i18n';
|
|
11
|
-
import { Button, ExternalLink,
|
|
11
|
+
import { Button, ExternalLink, __experimentalTruncate as Truncate, Tooltip } from '@wordpress/components';
|
|
12
|
+
import { useCopyToClipboard } from '@wordpress/compose';
|
|
12
13
|
import { filterURLForDisplay, safeDecodeURI } from '@wordpress/url';
|
|
13
|
-
import { Icon, globe, info, linkOff, edit } from '@wordpress/icons';
|
|
14
|
+
import { Icon, globe, info, linkOff, edit, copy } from '@wordpress/icons';
|
|
14
15
|
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
|
|
16
|
+
import { useDispatch } from '@wordpress/data';
|
|
17
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
15
18
|
|
|
16
19
|
/**
|
|
17
20
|
* Internal dependencies
|
|
@@ -35,7 +38,7 @@ export default function LinkPreview({
|
|
|
35
38
|
|
|
36
39
|
// Rich data may be an empty object so test for that.
|
|
37
40
|
const hasRichData = richData && Object.keys(richData).length;
|
|
38
|
-
const displayURL = value && filterURLForDisplay(safeDecodeURI(value.url),
|
|
41
|
+
const displayURL = value && filterURLForDisplay(safeDecodeURI(value.url), 24) || '';
|
|
39
42
|
|
|
40
43
|
// url can be undefined if the href attribute is unset
|
|
41
44
|
const isEmptyURL = !value?.url?.length;
|
|
@@ -56,6 +59,15 @@ export default function LinkPreview({
|
|
|
56
59
|
icon: globe
|
|
57
60
|
});
|
|
58
61
|
}
|
|
62
|
+
const {
|
|
63
|
+
createNotice
|
|
64
|
+
} = useDispatch(noticesStore);
|
|
65
|
+
const ref = useCopyToClipboard(value.url, () => {
|
|
66
|
+
createNotice('info', __('Copied URL to clipboard.'), {
|
|
67
|
+
isDismissible: true,
|
|
68
|
+
type: 'snackbar'
|
|
69
|
+
});
|
|
70
|
+
});
|
|
59
71
|
return createElement("div", {
|
|
60
72
|
"aria-label": __('Currently selected'),
|
|
61
73
|
className: classnames('block-editor-link-control__search-item', {
|
|
@@ -77,47 +89,39 @@ export default function LinkPreview({
|
|
|
77
89
|
}, icon), createElement("span", {
|
|
78
90
|
className: "block-editor-link-control__search-item-details"
|
|
79
91
|
}, !isEmptyURL ? createElement(Fragment, null, createElement(Tooltip, {
|
|
80
|
-
text: value.url
|
|
81
|
-
placement: "bottom-start"
|
|
92
|
+
text: value.url
|
|
82
93
|
}, createElement(ExternalLink, {
|
|
83
94
|
className: "block-editor-link-control__search-item-title",
|
|
84
95
|
href: value.url
|
|
85
|
-
},
|
|
96
|
+
}, createElement(Truncate, {
|
|
97
|
+
numberOfLines: 1
|
|
98
|
+
}, displayTitle))), value?.url && displayTitle !== displayURL && createElement("span", {
|
|
86
99
|
className: "block-editor-link-control__search-item-info"
|
|
87
|
-
},
|
|
100
|
+
}, createElement(Truncate, {
|
|
101
|
+
numberOfLines: 1
|
|
102
|
+
}, displayURL))) : createElement("span", {
|
|
88
103
|
className: "block-editor-link-control__search-item-error-notice"
|
|
89
104
|
}, __('Link is empty')))), createElement(Button, {
|
|
90
105
|
icon: edit,
|
|
91
106
|
label: __('Edit'),
|
|
92
107
|
className: "block-editor-link-control__search-item-action",
|
|
93
108
|
onClick: onEditClick,
|
|
94
|
-
|
|
109
|
+
size: "compact"
|
|
95
110
|
}), hasUnlinkControl && createElement(Button, {
|
|
96
111
|
icon: linkOff,
|
|
97
112
|
label: __('Unlink'),
|
|
98
113
|
className: "block-editor-link-control__search-item-action block-editor-link-control__unlink",
|
|
99
114
|
onClick: onRemove,
|
|
100
|
-
|
|
115
|
+
size: "compact"
|
|
116
|
+
}), createElement(Button, {
|
|
117
|
+
icon: copy,
|
|
118
|
+
label: __('Copy URL'),
|
|
119
|
+
className: "block-editor-link-control__search-item-action block-editor-link-control__copy",
|
|
120
|
+
ref: ref,
|
|
121
|
+
disabled: isEmptyURL,
|
|
122
|
+
size: "compact"
|
|
101
123
|
}), createElement(ViewerSlot, {
|
|
102
124
|
fillProps: value
|
|
103
|
-
})),
|
|
104
|
-
className: "block-editor-link-control__search-item-bottom"
|
|
105
|
-
}, (richData?.image || isFetching) && createElement("div", {
|
|
106
|
-
"aria-hidden": !richData?.image,
|
|
107
|
-
className: classnames('block-editor-link-control__search-item-image', {
|
|
108
|
-
'is-placeholder': !richData?.image
|
|
109
|
-
})
|
|
110
|
-
}, richData?.image && createElement("img", {
|
|
111
|
-
src: richData?.image,
|
|
112
|
-
alt: ""
|
|
113
|
-
})), (richData?.description || isFetching) && createElement("div", {
|
|
114
|
-
"aria-hidden": !richData?.description,
|
|
115
|
-
className: classnames('block-editor-link-control__search-item-description', {
|
|
116
|
-
'is-placeholder': !richData?.description
|
|
117
|
-
})
|
|
118
|
-
}, richData?.description && createElement(Text, {
|
|
119
|
-
truncate: true,
|
|
120
|
-
numberOfLines: "2"
|
|
121
|
-
}, richData.description))), additionalControls && additionalControls());
|
|
125
|
+
})), additionalControls && additionalControls());
|
|
122
126
|
}
|
|
123
127
|
//# sourceMappingURL=link-preview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","__","Button","ExternalLink","
|
|
1
|
+
{"version":3,"names":["classnames","__","Button","ExternalLink","__experimentalTruncate","Truncate","Tooltip","useCopyToClipboard","filterURLForDisplay","safeDecodeURI","Icon","globe","info","linkOff","edit","copy","__unstableStripHTML","stripHTML","useDispatch","store","noticesStore","ViewerSlot","useRichUrlData","LinkPreview","value","onEditClick","hasRichPreviews","hasUnlinkControl","onRemove","additionalControls","showRichPreviews","url","richData","isFetching","hasRichData","Object","keys","length","displayURL","isEmptyURL","displayTitle","title","icon","createElement","src","alt","size","createNotice","ref","isDismissible","type","className","Fragment","text","href","numberOfLines","label","onClick","disabled","fillProps"],"sources":["@wordpress/block-editor/src/components/link-control/link-preview.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\tExternalLink,\n\t__experimentalTruncate as Truncate,\n\tTooltip,\n} from '@wordpress/components';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { filterURLForDisplay, safeDecodeURI } from '@wordpress/url';\nimport { Icon, globe, info, linkOff, edit, copy } from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { ViewerSlot } from './viewer-slot';\n\nimport useRichUrlData from './use-rich-url-data';\n\nexport default function LinkPreview( {\n\tvalue,\n\tonEditClick,\n\thasRichPreviews = false,\n\thasUnlinkControl = false,\n\tonRemove,\n\tadditionalControls,\n} ) {\n\t// Avoid fetching if rich previews are not desired.\n\tconst showRichPreviews = hasRichPreviews ? value?.url : null;\n\n\tconst { richData, isFetching } = useRichUrlData( showRichPreviews );\n\n\t// Rich data may be an empty object so test for that.\n\tconst hasRichData = richData && Object.keys( richData ).length;\n\n\tconst displayURL =\n\t\t( value && filterURLForDisplay( safeDecodeURI( value.url ), 24 ) ) ||\n\t\t'';\n\n\t// url can be undefined if the href attribute is unset\n\tconst isEmptyURL = ! value?.url?.length;\n\n\tconst displayTitle =\n\t\t! isEmptyURL &&\n\t\tstripHTML( richData?.title || value?.title || displayURL );\n\n\tlet icon;\n\n\tif ( richData?.icon ) {\n\t\ticon = <img src={ richData?.icon } alt=\"\" />;\n\t} else if ( isEmptyURL ) {\n\t\ticon = <Icon icon={ info } size={ 32 } />;\n\t} else {\n\t\ticon = <Icon icon={ globe } />;\n\t}\n\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst ref = useCopyToClipboard( value.url, () => {\n\t\tcreateNotice( 'info', __( 'Copied URL to clipboard.' ), {\n\t\t\tisDismissible: true,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t} );\n\n\treturn (\n\t\t<div\n\t\t\taria-label={ __( 'Currently selected' ) }\n\t\t\tclassName={ classnames( 'block-editor-link-control__search-item', {\n\t\t\t\t'is-current': true,\n\t\t\t\t'is-rich': hasRichData,\n\t\t\t\t'is-fetching': !! isFetching,\n\t\t\t\t'is-preview': true,\n\t\t\t\t'is-error': isEmptyURL,\n\t\t\t\t'is-url-title': displayTitle === displayURL,\n\t\t\t} ) }\n\t\t>\n\t\t\t<div className=\"block-editor-link-control__search-item-top\">\n\t\t\t\t<span className=\"block-editor-link-control__search-item-header\">\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-link-control__search-item-icon',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-image': richData?.icon,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ icon }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"block-editor-link-control__search-item-details\">\n\t\t\t\t\t\t{ ! isEmptyURL ? (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<Tooltip text={ value.url }>\n\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-item-title\"\n\t\t\t\t\t\t\t\t\t\thref={ value.url }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t\t\t\t\t\t\t\t{ displayTitle }\n\t\t\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t\t\t\t{ value?.url && displayTitle !== displayURL && (\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-info\">\n\t\t\t\t\t\t\t\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t\t\t\t\t\t\t\t{ displayURL }\n\t\t\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-error-notice\">\n\t\t\t\t\t\t\t\t{ __( 'Link is empty' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t</span>\n\n\t\t\t\t<Button\n\t\t\t\t\ticon={ edit }\n\t\t\t\t\tlabel={ __( 'Edit' ) }\n\t\t\t\t\tclassName=\"block-editor-link-control__search-item-action\"\n\t\t\t\t\tonClick={ onEditClick }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t/>\n\t\t\t\t{ hasUnlinkControl && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Unlink' ) }\n\t\t\t\t\t\tclassName=\"block-editor-link-control__search-item-action block-editor-link-control__unlink\"\n\t\t\t\t\t\tonClick={ onRemove }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<Button\n\t\t\t\t\ticon={ copy }\n\t\t\t\t\tlabel={ __( 'Copy URL' ) }\n\t\t\t\t\tclassName=\"block-editor-link-control__search-item-action block-editor-link-control__copy\"\n\t\t\t\t\tref={ ref }\n\t\t\t\t\tdisabled={ isEmptyURL }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t/>\n\t\t\t\t<ViewerSlot fillProps={ value } />\n\t\t\t</div>\n\t\t\t{ additionalControls && additionalControls() }\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,MAAM,EACNC,YAAY,EACZC,sBAAsB,IAAIC,QAAQ,EAClCC,OAAO,QACD,uBAAuB;AAC9B,SAASC,kBAAkB,QAAQ,oBAAoB;AACvD,SAASC,mBAAmB,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|
-
/**
|
|
3
|
-
* External dependencies
|
|
4
|
-
*/
|
|
5
|
-
import classnames from 'classnames';
|
|
6
2
|
/**
|
|
7
3
|
* WordPress dependencies
|
|
8
4
|
*/
|
|
@@ -100,9 +96,6 @@ const LinkControlSearchInput = forwardRef(({
|
|
|
100
96
|
}, suggestion);
|
|
101
97
|
}
|
|
102
98
|
};
|
|
103
|
-
const inputClasses = classnames(className, {
|
|
104
|
-
// 'has-no-label': ! hideLabelFromVision,
|
|
105
|
-
});
|
|
106
99
|
return createElement("div", {
|
|
107
100
|
className: "block-editor-link-control__search-input-container"
|
|
108
101
|
}, createElement(URLInput, {
|
|
@@ -110,7 +103,7 @@ const LinkControlSearchInput = forwardRef(({
|
|
|
110
103
|
__nextHasNoMarginBottom: true,
|
|
111
104
|
label: __('Link'),
|
|
112
105
|
hideLabelFromVision: hideLabelFromVision,
|
|
113
|
-
className:
|
|
106
|
+
className: className,
|
|
114
107
|
value: value,
|
|
115
108
|
onChange: onInputChange,
|
|
116
109
|
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : __('Search or type url'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["useInstanceId","forwardRef","useState","__","URLInput","LinkControlSearchResults","CREATE_TYPE","useSearchHandler","noopSearchHandler","Promise","resolve","noop","LinkControlSearchInput","value","children","currentLink","className","placeholder","withCreateSuggestion","onCreateSuggestion","onChange","onSelect","showSuggestions","renderSuggestions","props","createElement","fetchSuggestions","allowDirectEntry","showInitialSuggestions","suggestionsQuery","withURLSuggestion","createSuggestionButtonText","hideLabelFromVision","ref","genericSearchHandler","searchHandler","instanceId","focusedSuggestion","setFocusedSuggestion","onInputChange","selection","suggestion","handleRenderSuggestions","handleSuggestionClick","onSuggestionSelected","selectedSuggestion","type","title","url","e","Object","keys","length","id","restLinkProps","disableSuggestions","__nextHasNoMarginBottom","label","__experimentalRenderSuggestions","__experimentalFetchLinkSuggestions","__experimentalHandleURLSuggestions","__experimentalShowInitialSuggestions","onSubmit","event","hasSuggestion","trim","preventDefault"],"sources":["@wordpress/block-editor/src/components/link-control/search-input.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { forwardRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { URLInput } from '../';\nimport LinkControlSearchResults from './search-results';\nimport { CREATE_TYPE } from './constants';\nimport useSearchHandler from './use-search-handler';\n\n// Must be a function as otherwise URLInput will default\n// to the fetchLinkSuggestions passed in block editor settings\n// which will cause an unintended http request.\nconst noopSearchHandler = () => Promise.resolve( [] );\n\nconst noop = () => {};\n\nconst LinkControlSearchInput = forwardRef(\n\t(\n\t\t{\n\t\t\tvalue,\n\t\t\tchildren,\n\t\t\tcurrentLink = {},\n\t\t\tclassName = null,\n\t\t\tplaceholder = null,\n\t\t\twithCreateSuggestion = false,\n\t\t\tonCreateSuggestion = noop,\n\t\t\tonChange = noop,\n\t\t\tonSelect = noop,\n\t\t\tshowSuggestions = true,\n\t\t\trenderSuggestions = ( props ) => (\n\t\t\t\t<LinkControlSearchResults { ...props } />\n\t\t\t),\n\t\t\tfetchSuggestions = null,\n\t\t\tallowDirectEntry = true,\n\t\t\tshowInitialSuggestions = false,\n\t\t\tsuggestionsQuery = {},\n\t\t\twithURLSuggestion = true,\n\t\t\tcreateSuggestionButtonText,\n\t\t\thideLabelFromVision = false,\n\t\t},\n\t\tref\n\t) => {\n\t\tconst genericSearchHandler = useSearchHandler(\n\t\t\tsuggestionsQuery,\n\t\t\tallowDirectEntry,\n\t\t\twithCreateSuggestion,\n\t\t\twithURLSuggestion\n\t\t);\n\n\t\tconst searchHandler = showSuggestions\n\t\t\t? fetchSuggestions || genericSearchHandler\n\t\t\t: noopSearchHandler;\n\n\t\tconst instanceId = useInstanceId( LinkControlSearchInput );\n\t\tconst [ focusedSuggestion, setFocusedSuggestion ] = useState();\n\n\t\t/**\n\t\t * Handles the user moving between different suggestions. Does not handle\n\t\t * choosing an individual item.\n\t\t *\n\t\t * @param {string} selection the url of the selected suggestion.\n\t\t * @param {Object} suggestion the suggestion object.\n\t\t */\n\t\tconst onInputChange = ( selection, suggestion ) => {\n\t\t\tonChange( selection );\n\t\t\tsetFocusedSuggestion( suggestion );\n\t\t};\n\n\t\tconst handleRenderSuggestions = ( props ) =>\n\t\t\trenderSuggestions( {\n\t\t\t\t...props,\n\t\t\t\tinstanceId,\n\t\t\t\twithCreateSuggestion,\n\t\t\t\tcreateSuggestionButtonText,\n\t\t\t\tsuggestionsQuery,\n\t\t\t\thandleSuggestionClick: ( suggestion ) => {\n\t\t\t\t\tif ( props.handleSuggestionClick ) {\n\t\t\t\t\t\tprops.handleSuggestionClick( suggestion );\n\t\t\t\t\t}\n\t\t\t\t\tonSuggestionSelected( suggestion );\n\t\t\t\t},\n\t\t\t} );\n\n\t\tconst onSuggestionSelected = async ( selectedSuggestion ) => {\n\t\t\tlet suggestion = selectedSuggestion;\n\t\t\tif ( CREATE_TYPE === selectedSuggestion.type ) {\n\t\t\t\t// Create a new page and call onSelect with the output from the onCreateSuggestion callback.\n\t\t\t\ttry {\n\t\t\t\t\tsuggestion = await onCreateSuggestion(\n\t\t\t\t\t\tselectedSuggestion.title\n\t\t\t\t\t);\n\t\t\t\t\tif ( suggestion?.url ) {\n\t\t\t\t\t\tonSelect( suggestion );\n\t\t\t\t\t}\n\t\t\t\t} catch ( e ) {}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tallowDirectEntry ||\n\t\t\t\t( suggestion && Object.keys( suggestion ).length >= 1 )\n\t\t\t) {\n\t\t\t\tconst { id, url, ...restLinkProps } = currentLink ?? {};\n\t\t\t\tonSelect(\n\t\t\t\t\t// Some direct entries don't have types or IDs, and we still need to clear the previous ones.\n\t\t\t\t\t{ ...restLinkProps, ...suggestion },\n\t\t\t\t\tsuggestion\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\treturn (\n\t\t\t<div className=\"block-editor-link-control__search-input-container\">\n\t\t\t\t<URLInput\n\t\t\t\t\tdisableSuggestions={ currentLink?.url === value }\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t\t\tclassName={ className }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onInputChange }\n\t\t\t\t\tplaceholder={ placeholder ?? __( 'Search or type url' ) }\n\t\t\t\t\t__experimentalRenderSuggestions={\n\t\t\t\t\t\tshowSuggestions ? handleRenderSuggestions : null\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalFetchLinkSuggestions={ searchHandler }\n\t\t\t\t\t__experimentalHandleURLSuggestions={ true }\n\t\t\t\t\t__experimentalShowInitialSuggestions={\n\t\t\t\t\t\tshowInitialSuggestions\n\t\t\t\t\t}\n\t\t\t\t\tonSubmit={ ( suggestion, event ) => {\n\t\t\t\t\t\tconst hasSuggestion = suggestion || focusedSuggestion;\n\n\t\t\t\t\t\t// If there is no suggestion and the value (ie: any manually entered URL) is empty\n\t\t\t\t\t\t// then don't allow submission otherwise we get empty links.\n\t\t\t\t\t\tif ( ! hasSuggestion && ! value?.trim()?.length ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonSuggestionSelected(\n\t\t\t\t\t\t\t\thasSuggestion || { url: value }\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tref={ ref }\n\t\t\t\t/>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nexport default LinkControlSearchInput;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,oBAAoB;AAClD,SAASC,UAAU,EAAEC,QAAQ,QAAQ,oBAAoB;AACzD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AAC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QAAQ;IACRmD,kBAAkB,EAAGxC,WAAW,EAAEiC,GAAG,KAAKnC,KAAO;IACjD2C,uBAAuB;IACvBC,KAAK,EAAGtD,EAAE,CAAE,MAAO,CAAG;IACtB6B,mBAAmB,EAAGA,mBAAqB;IAC3ChB,SAAS,EAAGA,SAAW;IACvBH,KAAK,EAAGA,KAAO;IACfO,QAAQ,EAAGmB,aAAe;IAC1BtB,WAAW,EAAGA,WAAW,aAAXA,WAAW,cAAXA,WAAW,GAAId,EAAE,CAAE,oBAAqB,CAAG;IACzDuD,+BAA+B,EAC9BpC,eAAe,GAAGoB,uBAAuB,GAAG,IAC5C;IACDiB,kCAAkC,EAAGxB,aAAe;IACpDyB,kCAAkC,EAAG,IAAM;IAC3CC,oCAAoC,EACnCjC,sBACA;IACDkC,QAAQ,EAAGA,CAAErB,UAAU,EAAEsB,KAAK,KAAM;MACnC,MAAMC,aAAa,GAAGvB,UAAU,IAAIJ,iBAAiB;;MAErD;MACA;MACA,IAAK,CAAE2B,aAAa,IAAI,CAAEnD,KAAK,EAAEoD,IAAI,CAAC,CAAC,EAAEb,MAAM,EAAG;QACjDW,KAAK,CAACG,cAAc,CAAC,CAAC;MACvB,CAAC,MAAM;QACNtB,oBAAoB,CACnBoB,aAAa,IAAI;UAAEhB,GAAG,EAAEnC;QAAM,CAC/B,CAAC;MACF;IACD,CAAG;IACHoB,GAAG,EAAGA;EAAK,CACX,CAAC,EACAnB,QACE,CAAC;AAER,CACD,CAAC;AAED,eAAeF,sBAAsB"}
|
|
@@ -65,7 +65,9 @@ const ListViewBlockContents = forwardRef(({
|
|
|
65
65
|
insertedBlock: insertedBlock,
|
|
66
66
|
setInsertedBlock: setInsertedBlock
|
|
67
67
|
}), createElement(BlockDraggable, {
|
|
68
|
-
|
|
68
|
+
appendToOwnerDocument: true,
|
|
69
|
+
clientIds: draggableClientIds,
|
|
70
|
+
cloneClassname: 'block-editor-list-view-draggable-chip'
|
|
69
71
|
}, ({
|
|
70
72
|
draggable,
|
|
71
73
|
onDragStart,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","useSelect","forwardRef","ListViewBlockSelectButton","BlockDraggable","store","blockEditorStore","useListViewContext","ListViewBlockContents","onClick","onToggleExpanded","block","isSelected","position","siblingBlockCount","level","isExpanded","selectedClientIds","props","ref","clientId","blockMovingClientId","selectedBlockInBlockEditor","select","hasBlockMovingClientId","getSelectedBlockClientId","AdditionalBlockContent","insertedBlock","setInsertedBlock","isBlockMoveTarget","className","draggableClientIds","includes","createElement","Fragment","clientIds","draggable","onDragStart","onDragEnd"],"sources":["@wordpress/block-editor/src/components/list-view/block-contents.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ListViewBlockSelectButton from './block-select-button';\nimport BlockDraggable from '../block-draggable';\nimport { store as blockEditorStore } from '../../store';\nimport { useListViewContext } from './context';\n\nconst ListViewBlockContents = forwardRef(\n\t(\n\t\t{\n\t\t\tonClick,\n\t\t\tonToggleExpanded,\n\t\t\tblock,\n\t\t\tisSelected,\n\t\t\tposition,\n\t\t\tsiblingBlockCount,\n\t\t\tlevel,\n\t\t\tisExpanded,\n\t\t\tselectedClientIds,\n\t\t\t...props\n\t\t},\n\t\tref\n\t) => {\n\t\tconst { clientId } = block;\n\n\t\tconst { blockMovingClientId, selectedBlockInBlockEditor } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { hasBlockMovingClientId, getSelectedBlockClientId } =\n\t\t\t\t\tselect( blockEditorStore );\n\t\t\t\treturn {\n\t\t\t\t\tblockMovingClientId: hasBlockMovingClientId(),\n\t\t\t\t\tselectedBlockInBlockEditor: getSelectedBlockClientId(),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\n\t\tconst { AdditionalBlockContent, insertedBlock, setInsertedBlock } =\n\t\t\tuseListViewContext();\n\n\t\tconst isBlockMoveTarget =\n\t\t\tblockMovingClientId && selectedBlockInBlockEditor === clientId;\n\n\t\tconst className = classnames( 'block-editor-list-view-block-contents', {\n\t\t\t'is-dropping-before': isBlockMoveTarget,\n\t\t} );\n\n\t\t// Only include all selected blocks if the currently clicked on block\n\t\t// is one of the selected blocks. This ensures that if a user attempts\n\t\t// to drag a block that isn't part of the selection, they're still able\n\t\t// to drag it and rearrange its position.\n\t\tconst draggableClientIds = selectedClientIds.includes( clientId )\n\t\t\t? selectedClientIds\n\t\t\t: [ clientId ];\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ AdditionalBlockContent && (\n\t\t\t\t\t<AdditionalBlockContent\n\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\tinsertedBlock={ insertedBlock }\n\t\t\t\t\t\tsetInsertedBlock={ setInsertedBlock }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<BlockDraggable
|
|
1
|
+
{"version":3,"names":["classnames","useSelect","forwardRef","ListViewBlockSelectButton","BlockDraggable","store","blockEditorStore","useListViewContext","ListViewBlockContents","onClick","onToggleExpanded","block","isSelected","position","siblingBlockCount","level","isExpanded","selectedClientIds","props","ref","clientId","blockMovingClientId","selectedBlockInBlockEditor","select","hasBlockMovingClientId","getSelectedBlockClientId","AdditionalBlockContent","insertedBlock","setInsertedBlock","isBlockMoveTarget","className","draggableClientIds","includes","createElement","Fragment","appendToOwnerDocument","clientIds","cloneClassname","draggable","onDragStart","onDragEnd"],"sources":["@wordpress/block-editor/src/components/list-view/block-contents.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ListViewBlockSelectButton from './block-select-button';\nimport BlockDraggable from '../block-draggable';\nimport { store as blockEditorStore } from '../../store';\nimport { useListViewContext } from './context';\n\nconst ListViewBlockContents = forwardRef(\n\t(\n\t\t{\n\t\t\tonClick,\n\t\t\tonToggleExpanded,\n\t\t\tblock,\n\t\t\tisSelected,\n\t\t\tposition,\n\t\t\tsiblingBlockCount,\n\t\t\tlevel,\n\t\t\tisExpanded,\n\t\t\tselectedClientIds,\n\t\t\t...props\n\t\t},\n\t\tref\n\t) => {\n\t\tconst { clientId } = block;\n\n\t\tconst { blockMovingClientId, selectedBlockInBlockEditor } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { hasBlockMovingClientId, getSelectedBlockClientId } =\n\t\t\t\t\tselect( blockEditorStore );\n\t\t\t\treturn {\n\t\t\t\t\tblockMovingClientId: hasBlockMovingClientId(),\n\t\t\t\t\tselectedBlockInBlockEditor: getSelectedBlockClientId(),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\n\t\tconst { AdditionalBlockContent, insertedBlock, setInsertedBlock } =\n\t\t\tuseListViewContext();\n\n\t\tconst isBlockMoveTarget =\n\t\t\tblockMovingClientId && selectedBlockInBlockEditor === clientId;\n\n\t\tconst className = classnames( 'block-editor-list-view-block-contents', {\n\t\t\t'is-dropping-before': isBlockMoveTarget,\n\t\t} );\n\n\t\t// Only include all selected blocks if the currently clicked on block\n\t\t// is one of the selected blocks. This ensures that if a user attempts\n\t\t// to drag a block that isn't part of the selection, they're still able\n\t\t// to drag it and rearrange its position.\n\t\tconst draggableClientIds = selectedClientIds.includes( clientId )\n\t\t\t? selectedClientIds\n\t\t\t: [ clientId ];\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ AdditionalBlockContent && (\n\t\t\t\t\t<AdditionalBlockContent\n\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\tinsertedBlock={ insertedBlock }\n\t\t\t\t\t\tsetInsertedBlock={ setInsertedBlock }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<BlockDraggable\n\t\t\t\t\tappendToOwnerDocument\n\t\t\t\t\tclientIds={ draggableClientIds }\n\t\t\t\t\tcloneClassname={ 'block-editor-list-view-draggable-chip' }\n\t\t\t\t>\n\t\t\t\t\t{ ( { draggable, onDragStart, onDragEnd } ) => (\n\t\t\t\t\t\t<ListViewBlockSelectButton\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t\t\tonToggleExpanded={ onToggleExpanded }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\tsiblingBlockCount={ siblingBlockCount }\n\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\tdraggable={ draggable }\n\t\t\t\t\t\t\tonDragStart={ onDragStart }\n\t\t\t\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</BlockDraggable>\n\t\t\t</>\n\t\t);\n\t}\n);\n\nexport default ListViewBlockContents;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,UAAU,QAAQ,oBAAoB;;AAE/C;AACA;AACA;AACA,OAAOC,yBAAyB,MAAM,uBAAuB;AAC7D,OAAOC,cAAc,MAAM,oBAAoB;AAC/C,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,kBAAkB,QAAQ,WAAW;AAE9C,MAAMC,qBAAqB,GAAGN,UAAU,CACvC,CACC;EACCO,OAAO;EACPC,gBAAgB;EAChBC,KAAK;EACLC,UAAU;EACVC,QAAQ;EACRC,iBAAiB;EACjBC,KAAK;EACLC,UAAU;EACVC,iBAAiB;EACjB,GAAGC;AACJ,CAAC,EACDC,GAAG,KACC;EACJ,MAAM;IAAEC;EAAS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AAQ,EAAGA,QAAU;IACrBC,iBAAiB,EAAGA,iBAAmB;IACvCC,KAAK,EAAGA,KAAO;IACfuB,SAAS,EAAGA,SAAW;IACvBC,WAAW,EAAGA,WAAa;IAC3BC,SAAS,EAAGA,SAAW;IACvBxB,UAAU,EAAGA,UAAY;IAAA,GACpBE;EAAK,CACV,CAEa,CACf,CAAC;AAEL,CACD,CAAC;AAED,eAAeV,qBAAqB"}
|
|
@@ -33,7 +33,10 @@ function ListViewBlock({
|
|
|
33
33
|
block: {
|
|
34
34
|
clientId
|
|
35
35
|
},
|
|
36
|
+
displacement,
|
|
37
|
+
isAfterDraggedBlocks,
|
|
36
38
|
isDragged,
|
|
39
|
+
isNesting,
|
|
37
40
|
isSelected,
|
|
38
41
|
isBranchSelected,
|
|
39
42
|
selectBlock,
|
|
@@ -208,7 +211,12 @@ function ListViewBlock({
|
|
|
208
211
|
'is-dragging': isDragged,
|
|
209
212
|
'has-single-cell': !showBlockActions,
|
|
210
213
|
'is-synced': blockInformation?.isSynced,
|
|
211
|
-
'is-draggable': canMove
|
|
214
|
+
'is-draggable': canMove,
|
|
215
|
+
'is-displacement-normal': displacement === 'normal',
|
|
216
|
+
'is-displacement-up': displacement === 'up',
|
|
217
|
+
'is-displacement-down': displacement === 'down',
|
|
218
|
+
'is-after-dragged-blocks': isAfterDraggedBlocks,
|
|
219
|
+
'is-nesting': isNesting
|
|
212
220
|
});
|
|
213
221
|
|
|
214
222
|
// Only include all selected blocks if the currently clicked on block
|
|
@@ -230,6 +238,7 @@ function ListViewBlock({
|
|
|
230
238
|
const currentlyEditingBlockInCanvas = isSelected && selectedClientIds.length === 1;
|
|
231
239
|
return createElement(ListViewLeaf, {
|
|
232
240
|
className: classes,
|
|
241
|
+
isDragged: isDragged,
|
|
233
242
|
onKeyDown: onKeyDown,
|
|
234
243
|
onMouseEnter: onMouseEnter,
|
|
235
244
|
onMouseLeave: onMouseLeave,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","hasBlockSupport","__experimentalTreeGridCell","TreeGridCell","__experimentalTreeGridItem","TreeGridItem","useInstanceId","moreVertical","useCallback","useMemo","useState","useRef","memo","useDispatch","useSelect","sprintf","__","ESCAPE","ListViewLeaf","useListViewScrollIntoView","BlockMoverUpButton","BlockMoverDownButton","ListViewBlockContents","useListViewContext","getBlockPositionDescription","focusListItem","store","blockEditorStore","useBlockDisplayInformation","useBlockLock","AriaReferencedText","ListViewBlock","block","clientId","isDragged","isSelected","isBranchSelected","selectBlock","position","level","rowCount","siblingBlockCount","showBlockMovers","path","isExpanded","selectedClientIds","isSyncedBranch","cellRef","rowRef","settingsRef","isHovered","setIsHovered","settingsAnchorRect","setSettingsAnchorRect","isLocked","canEdit","canMove","isFirstSelectedBlock","isLastSelectedBlock","length","toggleBlockHighlight","blockInformation","blockTitle","name","title","blockName","blockEditingMode","select","getBlock","getBlockName","getBlockEditingMode","allowRightClickOverrides","getSettings","showBlockActions","instanceId","descriptionId","blockPositionDescription","blockAriaLabel","settingsAriaLabel","expand","collapse","BlockSettingsMenu","listViewInstanceId","expandedState","setInsertedBlock","treeGridElementRef","hasSiblings","hasRenderedMovers","moverCellClassName","listViewBlockSettingsClassName","onKeyDown","event","keyCode","defaultPrevented","stopPropagation","preventDefault","undefined","onMouseEnter","onMouseLeave","selectEditorBlock","updateFocusAndSelection","focusClientId","shouldSelectBlock","toggleExpanded","onContextMenu","current","click","window","DOMRect","clientX","clientY","onMouseDown","button","settingsPopoverAnchor","ownerDocument","getBoundingClientRect","clearSettingsAnchorRect","colSpan","classes","isSynced","dropdownClientIds","includes","rowItemRef","currentlyEditingBlockInCanvas","createElement","className","onFocus","onBlur","id","ref","tabIndex","onClick","onToggleExpanded","ariaLabel","ariaDescribedBy","Fragment","withoutGridItem","orientation","clientIds","icon","label","popoverProps","anchor","toggleProps","disableOpenOnArrowDown","__experimentalSelectBlock"],"sources":["@wordpress/block-editor/src/components/list-view/block.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalTreeGridCell as TreeGridCell,\n\t__experimentalTreeGridItem as TreeGridItem,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { moreVertical } from '@wordpress/icons';\nimport {\n\tuseCallback,\n\tuseMemo,\n\tuseState,\n\tuseRef,\n\tmemo,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { sprintf, __ } from '@wordpress/i18n';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport ListViewLeaf from './leaf';\nimport useListViewScrollIntoView from './use-list-view-scroll-into-view';\nimport {\n\tBlockMoverUpButton,\n\tBlockMoverDownButton,\n} from '../block-mover/button';\nimport ListViewBlockContents from './block-contents';\nimport { useListViewContext } from './context';\nimport { getBlockPositionDescription, focusListItem } from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { useBlockLock } from '../block-lock';\nimport AriaReferencedText from './aria-referenced-text';\n\nfunction ListViewBlock( {\n\tblock: { clientId },\n\tisDragged,\n\tisSelected,\n\tisBranchSelected,\n\tselectBlock,\n\tposition,\n\tlevel,\n\trowCount,\n\tsiblingBlockCount,\n\tshowBlockMovers,\n\tpath,\n\tisExpanded,\n\tselectedClientIds,\n\tisSyncedBranch,\n} ) {\n\tconst cellRef = useRef( null );\n\tconst rowRef = useRef( null );\n\tconst settingsRef = useRef( null );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst [ settingsAnchorRect, setSettingsAnchorRect ] = useState();\n\n\tconst { isLocked, canEdit, canMove } = useBlockLock( clientId );\n\n\tconst isFirstSelectedBlock =\n\t\tisSelected && selectedClientIds[ 0 ] === clientId;\n\tconst isLastSelectedBlock =\n\t\tisSelected &&\n\t\tselectedClientIds[ selectedClientIds.length - 1 ] === clientId;\n\n\tconst { toggleBlockHighlight } = useDispatch( blockEditorStore );\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst blockTitle =\n\t\tblockInformation?.name || blockInformation?.title || __( 'Untitled' );\n\n\tconst { block, blockName, blockEditingMode } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, getBlockName, getBlockEditingMode } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tblock: getBlock( clientId ),\n\t\t\t\tblockName: getBlockName( clientId ),\n\t\t\t\tblockEditingMode: getBlockEditingMode( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst allowRightClickOverrides = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().allowRightClickOverrides,\n\t\t[]\n\t);\n\n\tconst showBlockActions =\n\t\t// When a block hides its toolbar it also hides the block settings menu,\n\t\t// since that menu is part of the toolbar in the editor canvas.\n\t\t// List View respects this by also hiding the block settings menu.\n\t\thasBlockSupport( blockName, '__experimentalToolbar', true ) &&\n\t\t// Don't show the settings menu if block is disabled or content only.\n\t\tblockEditingMode === 'default';\n\tconst instanceId = useInstanceId( ListViewBlock );\n\tconst descriptionId = `list-view-block-select-button__${ instanceId }`;\n\tconst blockPositionDescription = getBlockPositionDescription(\n\t\tposition,\n\t\tsiblingBlockCount,\n\t\tlevel\n\t);\n\n\tconst blockAriaLabel = isLocked\n\t\t? sprintf(\n\t\t\t\t// translators: %s: The title of the block. This string indicates a link to select the locked block.\n\t\t\t\t__( '%s (locked)' ),\n\t\t\t\tblockTitle\n\t\t )\n\t\t: blockTitle;\n\n\tconst settingsAriaLabel = sprintf(\n\t\t// translators: %s: The title of the block.\n\t\t__( 'Options for %s' ),\n\t\tblockTitle\n\t);\n\n\tconst {\n\t\texpand,\n\t\tcollapse,\n\t\tBlockSettingsMenu,\n\t\tlistViewInstanceId,\n\t\texpandedState,\n\t\tsetInsertedBlock,\n\t\ttreeGridElementRef,\n\t} = useListViewContext();\n\n\tconst hasSiblings = siblingBlockCount > 0;\n\tconst hasRenderedMovers = showBlockMovers && hasSiblings;\n\tconst moverCellClassName = classnames(\n\t\t'block-editor-list-view-block__mover-cell',\n\t\t{ 'is-visible': isHovered || isSelected }\n\t);\n\n\tconst listViewBlockSettingsClassName = classnames(\n\t\t'block-editor-list-view-block__menu-cell',\n\t\t{ 'is-visible': isHovered || isFirstSelectedBlock }\n\t);\n\n\t// If multiple blocks are selected, deselect all blocks when the user\n\t// presses the escape key.\n\tconst onKeyDown = ( event ) => {\n\t\tif (\n\t\t\tevent.keyCode === ESCAPE &&\n\t\t\t! event.defaultPrevented &&\n\t\t\tselectedClientIds.length > 0\n\t\t) {\n\t\t\tevent.stopPropagation();\n\t\t\tevent.preventDefault();\n\t\t\tselectBlock( event, undefined );\n\t\t}\n\t};\n\n\tconst onMouseEnter = useCallback( () => {\n\t\tsetIsHovered( true );\n\t\ttoggleBlockHighlight( clientId, true );\n\t}, [ clientId, setIsHovered, toggleBlockHighlight ] );\n\tconst onMouseLeave = useCallback( () => {\n\t\tsetIsHovered( false );\n\t\ttoggleBlockHighlight( clientId, false );\n\t}, [ clientId, setIsHovered, toggleBlockHighlight ] );\n\n\tconst selectEditorBlock = useCallback(\n\t\t( event ) => {\n\t\t\tselectBlock( event, clientId );\n\t\t\tevent.preventDefault();\n\t\t},\n\t\t[ clientId, selectBlock ]\n\t);\n\n\tconst updateFocusAndSelection = useCallback(\n\t\t( focusClientId, shouldSelectBlock ) => {\n\t\t\tif ( shouldSelectBlock ) {\n\t\t\t\tselectBlock( undefined, focusClientId, null, null );\n\t\t\t}\n\n\t\t\tfocusListItem( focusClientId, treeGridElementRef );\n\t\t},\n\t\t[ selectBlock, treeGridElementRef ]\n\t);\n\n\tconst toggleExpanded = useCallback(\n\t\t( event ) => {\n\t\t\t// Prevent shift+click from opening link in a new window when toggling.\n\t\t\tevent.preventDefault();\n\t\t\tevent.stopPropagation();\n\t\t\tif ( isExpanded === true ) {\n\t\t\t\tcollapse( clientId );\n\t\t\t} else if ( isExpanded === false ) {\n\t\t\t\texpand( clientId );\n\t\t\t}\n\t\t},\n\t\t[ clientId, expand, collapse, isExpanded ]\n\t);\n\n\t// Allow right-clicking an item in the List View to open up the block settings dropdown.\n\tconst onContextMenu = useCallback(\n\t\t( event ) => {\n\t\t\tif ( showBlockActions && allowRightClickOverrides ) {\n\t\t\t\tsettingsRef.current?.click();\n\t\t\t\t// Ensure the position of the settings dropdown is at the cursor.\n\t\t\t\tsetSettingsAnchorRect(\n\t\t\t\t\tnew window.DOMRect( event.clientX, event.clientY, 0, 0 )\n\t\t\t\t);\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t},\n\t\t[ allowRightClickOverrides, settingsRef, showBlockActions ]\n\t);\n\n\tconst onMouseDown = useCallback(\n\t\t( event ) => {\n\t\t\t// Prevent right-click from focusing the block,\n\t\t\t// because focus will be handled when opening the block settings dropdown.\n\t\t\tif ( allowRightClickOverrides && event.button === 2 ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t},\n\t\t[ allowRightClickOverrides ]\n\t);\n\n\tconst settingsPopoverAnchor = useMemo( () => {\n\t\tconst { ownerDocument } = rowRef?.current || {};\n\n\t\t// If no custom position is set, the settings dropdown will be anchored to the\n\t\t// DropdownMenu toggle button.\n\t\tif ( ! settingsAnchorRect || ! ownerDocument ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Position the settings dropdown at the cursor when right-clicking a block.\n\t\treturn {\n\t\t\townerDocument,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\treturn settingsAnchorRect;\n\t\t\t},\n\t\t};\n\t}, [ settingsAnchorRect ] );\n\n\tconst clearSettingsAnchorRect = useCallback( () => {\n\t\t// Clear the custom position for the settings dropdown so that it is restored back\n\t\t// to being anchored to the DropdownMenu toggle button.\n\t\tsetSettingsAnchorRect( undefined );\n\t}, [ setSettingsAnchorRect ] );\n\n\tlet colSpan;\n\tif ( hasRenderedMovers ) {\n\t\tcolSpan = 2;\n\t} else if ( ! showBlockActions ) {\n\t\tcolSpan = 3;\n\t}\n\n\tconst classes = classnames( {\n\t\t'is-selected': isSelected,\n\t\t'is-first-selected': isFirstSelectedBlock,\n\t\t'is-last-selected': isLastSelectedBlock,\n\t\t'is-branch-selected': isBranchSelected,\n\t\t'is-synced-branch': isSyncedBranch,\n\t\t'is-dragging': isDragged,\n\t\t'has-single-cell': ! showBlockActions,\n\t\t'is-synced': blockInformation?.isSynced,\n\t\t'is-draggable': canMove,\n\t} );\n\n\t// Only include all selected blocks if the currently clicked on block\n\t// is one of the selected blocks. This ensures that if a user attempts\n\t// to alter a block that isn't part of the selection, they're still able\n\t// to do so.\n\tconst dropdownClientIds = selectedClientIds.includes( clientId )\n\t\t? selectedClientIds\n\t\t: [ clientId ];\n\n\t// Pass in a ref to the row, so that it can be scrolled\n\t// into view when selected. For long lists, the placeholder for the\n\t// selected block is also observed, within ListViewLeafPlaceholder.\n\tuseListViewScrollIntoView( {\n\t\tisSelected,\n\t\trowItemRef: rowRef,\n\t\tselectedClientIds,\n\t} );\n\n\t// Detect if there is a block in the canvas currently being edited and multi-selection is not happening.\n\tconst currentlyEditingBlockInCanvas =\n\t\tisSelected && selectedClientIds.length === 1;\n\n\treturn (\n\t\t<ListViewLeaf\n\t\t\tclassName={ classes }\n\t\t\tonKeyDown={ onKeyDown }\n\t\t\tonMouseEnter={ onMouseEnter }\n\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\tonFocus={ onMouseEnter }\n\t\t\tonBlur={ onMouseLeave }\n\t\t\tlevel={ level }\n\t\t\tposition={ position }\n\t\t\trowCount={ rowCount }\n\t\t\tpath={ path }\n\t\t\tid={ `list-view-${ listViewInstanceId }-block-${ clientId }` }\n\t\t\tdata-block={ clientId }\n\t\t\tdata-expanded={ canEdit ? isExpanded : undefined }\n\t\t\tref={ rowRef }\n\t\t>\n\t\t\t<TreeGridCell\n\t\t\t\tclassName=\"block-editor-list-view-block__contents-cell\"\n\t\t\t\tcolSpan={ colSpan }\n\t\t\t\tref={ cellRef }\n\t\t\t\taria-selected={ !! isSelected }\n\t\t\t>\n\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t<div className=\"block-editor-list-view-block__contents-container\">\n\t\t\t\t\t\t<ListViewBlockContents\n\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\tonClick={ selectEditorBlock }\n\t\t\t\t\t\t\tonContextMenu={ onContextMenu }\n\t\t\t\t\t\t\tonMouseDown={ onMouseDown }\n\t\t\t\t\t\t\tonToggleExpanded={ toggleExpanded }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\tsiblingBlockCount={ siblingBlockCount }\n\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\ttabIndex={\n\t\t\t\t\t\t\t\tcurrentlyEditingBlockInCanvas ? 0 : tabIndex\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\tisExpanded={ canEdit ? isExpanded : undefined }\n\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\tariaLabel={ blockAriaLabel }\n\t\t\t\t\t\t\tariaDescribedBy={ descriptionId }\n\t\t\t\t\t\t\tupdateFocusAndSelection={ updateFocusAndSelection }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<AriaReferencedText id={ descriptionId }>\n\t\t\t\t\t\t\t{ blockPositionDescription }\n\t\t\t\t\t\t</AriaReferencedText>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</TreeGridCell>\n\t\t\t{ hasRenderedMovers && (\n\t\t\t\t<>\n\t\t\t\t\t<TreeGridCell\n\t\t\t\t\t\tclassName={ moverCellClassName }\n\t\t\t\t\t\twithoutGridItem\n\t\t\t\t\t>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverUpButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverDownButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t</TreeGridCell>\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ showBlockActions && BlockSettingsMenu && (\n\t\t\t\t<TreeGridCell\n\t\t\t\t\tclassName={ listViewBlockSettingsClassName }\n\t\t\t\t\taria-selected={ !! isSelected }\n\t\t\t\t\tref={ settingsRef }\n\t\t\t\t>\n\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t<BlockSettingsMenu\n\t\t\t\t\t\t\tclientIds={ dropdownClientIds }\n\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ settingsAriaLabel }\n\t\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\t\tanchor: settingsPopoverAnchor, // Used to position the settings at the cursor on right-click.\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t\t\tclassName: 'block-editor-list-view-block__menu',\n\t\t\t\t\t\t\t\ttabIndex,\n\t\t\t\t\t\t\t\tonClick: clearSettingsAnchorRect,\n\t\t\t\t\t\t\t\tonFocus,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tdisableOpenOnArrowDown\n\t\t\t\t\t\t\texpand={ expand }\n\t\t\t\t\t\t\texpandedState={ expandedState }\n\t\t\t\t\t\t\tsetInsertedBlock={ setInsertedBlock }\n\t\t\t\t\t\t\t__experimentalSelectBlock={\n\t\t\t\t\t\t\t\tupdateFocusAndSelection\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</TreeGridCell>\n\t\t\t) }\n\t\t</ListViewLeaf>\n\t);\n}\n\nexport default memo( ListViewBlock );\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SACCC,0BAA0B,IAAIC,YAAY,EAC1CC,0BAA0B,IAAIC,YAAY,QACpC,uBAAuB;AAC9B,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SACCC,WAAW,EACXC,OAAO,EACPC,QAAQ,EACRC,MAAM,EACNC,IAAI,QACE,oBAAoB;AAC3B,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,OAAO,EAAEC,EAAE,QAAQ,iBAAiB;AAC7C,SAASC,MAAM,QAAQ,qBAAqB;;AAE5C;AACA;AACA;AACA,OAAOC,YAAY,MAAM,QAAQ;AACjC,OAAOC,yBAAyB,MAAM,kCAAkC;AACxE,SACCC,kBAAkB,EAClBC,oBAAoB,QACd,uBAAuB;AAC9B,OAAOC,qBAAqB,MAAM,kBAAkB;AACpD,SAASC,kBAAkB,QAAQ,WAAW;AAC9C,SAASC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Y;IAC/B8F,GAAG,EAAGhF;EAAa,GAEjB,CAAE;IAAEgF,GAAG;IAAEC,QAAQ;IAAEJ;EAAQ,CAAC,KAC7BF,aAAA,CAAC3C,iBAAiB;IACjByD,SAAS,EAAGlB,iBAAmB;IAC/BxF,KAAK,EAAGA,KAAO;IACf2G,IAAI,EAAGpI,YAAc;IACrBqI,KAAK,EAAG9D,iBAAmB;IAC3B+D,YAAY,EAAG;MACdC,MAAM,EAAE7B,qBAAqB,CAAE;IAChC,CAAG;;IACH8B,WAAW,EAAG;MACbd,GAAG;MACHJ,SAAS,EAAE,oCAAoC;MAC/CK,QAAQ;MACRC,OAAO,EAAEf,uBAAuB;MAChCU;IACD,CAAG;IACHkB,sBAAsB;IACtBjE,MAAM,EAAGA,MAAQ;IACjBI,aAAa,EAAGA,aAAe;IAC/BC,gBAAgB,EAAGA,gBAAkB;IACrC6D,yBAAyB,EACxB7C;EACA,CACD,CAEW,CAEF,CAAC;AAEjB;AAEA,eAAexF,IAAI,CAAEmB,aAAc,CAAC"}
|
|
1
|
+
{"version":3,"names":["classnames","hasBlockSupport","__experimentalTreeGridCell","TreeGridCell","__experimentalTreeGridItem","TreeGridItem","useInstanceId","moreVertical","useCallback","useMemo","useState","useRef","memo","useDispatch","useSelect","sprintf","__","ESCAPE","ListViewLeaf","useListViewScrollIntoView","BlockMoverUpButton","BlockMoverDownButton","ListViewBlockContents","useListViewContext","getBlockPositionDescription","focusListItem","store","blockEditorStore","useBlockDisplayInformation","useBlockLock","AriaReferencedText","ListViewBlock","block","clientId","displacement","isAfterDraggedBlocks","isDragged","isNesting","isSelected","isBranchSelected","selectBlock","position","level","rowCount","siblingBlockCount","showBlockMovers","path","isExpanded","selectedClientIds","isSyncedBranch","cellRef","rowRef","settingsRef","isHovered","setIsHovered","settingsAnchorRect","setSettingsAnchorRect","isLocked","canEdit","canMove","isFirstSelectedBlock","isLastSelectedBlock","length","toggleBlockHighlight","blockInformation","blockTitle","name","title","blockName","blockEditingMode","select","getBlock","getBlockName","getBlockEditingMode","allowRightClickOverrides","getSettings","showBlockActions","instanceId","descriptionId","blockPositionDescription","blockAriaLabel","settingsAriaLabel","expand","collapse","BlockSettingsMenu","listViewInstanceId","expandedState","setInsertedBlock","treeGridElementRef","hasSiblings","hasRenderedMovers","moverCellClassName","listViewBlockSettingsClassName","onKeyDown","event","keyCode","defaultPrevented","stopPropagation","preventDefault","undefined","onMouseEnter","onMouseLeave","selectEditorBlock","updateFocusAndSelection","focusClientId","shouldSelectBlock","toggleExpanded","onContextMenu","current","click","window","DOMRect","clientX","clientY","onMouseDown","button","settingsPopoverAnchor","ownerDocument","getBoundingClientRect","clearSettingsAnchorRect","colSpan","classes","isSynced","dropdownClientIds","includes","rowItemRef","currentlyEditingBlockInCanvas","createElement","className","onFocus","onBlur","id","ref","tabIndex","onClick","onToggleExpanded","ariaLabel","ariaDescribedBy","Fragment","withoutGridItem","orientation","clientIds","icon","label","popoverProps","anchor","toggleProps","disableOpenOnArrowDown","__experimentalSelectBlock"],"sources":["@wordpress/block-editor/src/components/list-view/block.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalTreeGridCell as TreeGridCell,\n\t__experimentalTreeGridItem as TreeGridItem,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { moreVertical } from '@wordpress/icons';\nimport {\n\tuseCallback,\n\tuseMemo,\n\tuseState,\n\tuseRef,\n\tmemo,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { sprintf, __ } from '@wordpress/i18n';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport ListViewLeaf from './leaf';\nimport useListViewScrollIntoView from './use-list-view-scroll-into-view';\nimport {\n\tBlockMoverUpButton,\n\tBlockMoverDownButton,\n} from '../block-mover/button';\nimport ListViewBlockContents from './block-contents';\nimport { useListViewContext } from './context';\nimport { getBlockPositionDescription, focusListItem } from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { useBlockLock } from '../block-lock';\nimport AriaReferencedText from './aria-referenced-text';\n\nfunction ListViewBlock( {\n\tblock: { clientId },\n\tdisplacement,\n\tisAfterDraggedBlocks,\n\tisDragged,\n\tisNesting,\n\tisSelected,\n\tisBranchSelected,\n\tselectBlock,\n\tposition,\n\tlevel,\n\trowCount,\n\tsiblingBlockCount,\n\tshowBlockMovers,\n\tpath,\n\tisExpanded,\n\tselectedClientIds,\n\tisSyncedBranch,\n} ) {\n\tconst cellRef = useRef( null );\n\tconst rowRef = useRef( null );\n\tconst settingsRef = useRef( null );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst [ settingsAnchorRect, setSettingsAnchorRect ] = useState();\n\n\tconst { isLocked, canEdit, canMove } = useBlockLock( clientId );\n\n\tconst isFirstSelectedBlock =\n\t\tisSelected && selectedClientIds[ 0 ] === clientId;\n\tconst isLastSelectedBlock =\n\t\tisSelected &&\n\t\tselectedClientIds[ selectedClientIds.length - 1 ] === clientId;\n\n\tconst { toggleBlockHighlight } = useDispatch( blockEditorStore );\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst blockTitle =\n\t\tblockInformation?.name || blockInformation?.title || __( 'Untitled' );\n\n\tconst { block, blockName, blockEditingMode } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, getBlockName, getBlockEditingMode } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tblock: getBlock( clientId ),\n\t\t\t\tblockName: getBlockName( clientId ),\n\t\t\t\tblockEditingMode: getBlockEditingMode( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst allowRightClickOverrides = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().allowRightClickOverrides,\n\t\t[]\n\t);\n\n\tconst showBlockActions =\n\t\t// When a block hides its toolbar it also hides the block settings menu,\n\t\t// since that menu is part of the toolbar in the editor canvas.\n\t\t// List View respects this by also hiding the block settings menu.\n\t\thasBlockSupport( blockName, '__experimentalToolbar', true ) &&\n\t\t// Don't show the settings menu if block is disabled or content only.\n\t\tblockEditingMode === 'default';\n\tconst instanceId = useInstanceId( ListViewBlock );\n\tconst descriptionId = `list-view-block-select-button__${ instanceId }`;\n\tconst blockPositionDescription = getBlockPositionDescription(\n\t\tposition,\n\t\tsiblingBlockCount,\n\t\tlevel\n\t);\n\n\tconst blockAriaLabel = isLocked\n\t\t? sprintf(\n\t\t\t\t// translators: %s: The title of the block. This string indicates a link to select the locked block.\n\t\t\t\t__( '%s (locked)' ),\n\t\t\t\tblockTitle\n\t\t )\n\t\t: blockTitle;\n\n\tconst settingsAriaLabel = sprintf(\n\t\t// translators: %s: The title of the block.\n\t\t__( 'Options for %s' ),\n\t\tblockTitle\n\t);\n\n\tconst {\n\t\texpand,\n\t\tcollapse,\n\t\tBlockSettingsMenu,\n\t\tlistViewInstanceId,\n\t\texpandedState,\n\t\tsetInsertedBlock,\n\t\ttreeGridElementRef,\n\t} = useListViewContext();\n\n\tconst hasSiblings = siblingBlockCount > 0;\n\tconst hasRenderedMovers = showBlockMovers && hasSiblings;\n\tconst moverCellClassName = classnames(\n\t\t'block-editor-list-view-block__mover-cell',\n\t\t{ 'is-visible': isHovered || isSelected }\n\t);\n\n\tconst listViewBlockSettingsClassName = classnames(\n\t\t'block-editor-list-view-block__menu-cell',\n\t\t{ 'is-visible': isHovered || isFirstSelectedBlock }\n\t);\n\n\t// If multiple blocks are selected, deselect all blocks when the user\n\t// presses the escape key.\n\tconst onKeyDown = ( event ) => {\n\t\tif (\n\t\t\tevent.keyCode === ESCAPE &&\n\t\t\t! event.defaultPrevented &&\n\t\t\tselectedClientIds.length > 0\n\t\t) {\n\t\t\tevent.stopPropagation();\n\t\t\tevent.preventDefault();\n\t\t\tselectBlock( event, undefined );\n\t\t}\n\t};\n\n\tconst onMouseEnter = useCallback( () => {\n\t\tsetIsHovered( true );\n\t\ttoggleBlockHighlight( clientId, true );\n\t}, [ clientId, setIsHovered, toggleBlockHighlight ] );\n\tconst onMouseLeave = useCallback( () => {\n\t\tsetIsHovered( false );\n\t\ttoggleBlockHighlight( clientId, false );\n\t}, [ clientId, setIsHovered, toggleBlockHighlight ] );\n\n\tconst selectEditorBlock = useCallback(\n\t\t( event ) => {\n\t\t\tselectBlock( event, clientId );\n\t\t\tevent.preventDefault();\n\t\t},\n\t\t[ clientId, selectBlock ]\n\t);\n\n\tconst updateFocusAndSelection = useCallback(\n\t\t( focusClientId, shouldSelectBlock ) => {\n\t\t\tif ( shouldSelectBlock ) {\n\t\t\t\tselectBlock( undefined, focusClientId, null, null );\n\t\t\t}\n\n\t\t\tfocusListItem( focusClientId, treeGridElementRef );\n\t\t},\n\t\t[ selectBlock, treeGridElementRef ]\n\t);\n\n\tconst toggleExpanded = useCallback(\n\t\t( event ) => {\n\t\t\t// Prevent shift+click from opening link in a new window when toggling.\n\t\t\tevent.preventDefault();\n\t\t\tevent.stopPropagation();\n\t\t\tif ( isExpanded === true ) {\n\t\t\t\tcollapse( clientId );\n\t\t\t} else if ( isExpanded === false ) {\n\t\t\t\texpand( clientId );\n\t\t\t}\n\t\t},\n\t\t[ clientId, expand, collapse, isExpanded ]\n\t);\n\n\t// Allow right-clicking an item in the List View to open up the block settings dropdown.\n\tconst onContextMenu = useCallback(\n\t\t( event ) => {\n\t\t\tif ( showBlockActions && allowRightClickOverrides ) {\n\t\t\t\tsettingsRef.current?.click();\n\t\t\t\t// Ensure the position of the settings dropdown is at the cursor.\n\t\t\t\tsetSettingsAnchorRect(\n\t\t\t\t\tnew window.DOMRect( event.clientX, event.clientY, 0, 0 )\n\t\t\t\t);\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t},\n\t\t[ allowRightClickOverrides, settingsRef, showBlockActions ]\n\t);\n\n\tconst onMouseDown = useCallback(\n\t\t( event ) => {\n\t\t\t// Prevent right-click from focusing the block,\n\t\t\t// because focus will be handled when opening the block settings dropdown.\n\t\t\tif ( allowRightClickOverrides && event.button === 2 ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t},\n\t\t[ allowRightClickOverrides ]\n\t);\n\n\tconst settingsPopoverAnchor = useMemo( () => {\n\t\tconst { ownerDocument } = rowRef?.current || {};\n\n\t\t// If no custom position is set, the settings dropdown will be anchored to the\n\t\t// DropdownMenu toggle button.\n\t\tif ( ! settingsAnchorRect || ! ownerDocument ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Position the settings dropdown at the cursor when right-clicking a block.\n\t\treturn {\n\t\t\townerDocument,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\treturn settingsAnchorRect;\n\t\t\t},\n\t\t};\n\t}, [ settingsAnchorRect ] );\n\n\tconst clearSettingsAnchorRect = useCallback( () => {\n\t\t// Clear the custom position for the settings dropdown so that it is restored back\n\t\t// to being anchored to the DropdownMenu toggle button.\n\t\tsetSettingsAnchorRect( undefined );\n\t}, [ setSettingsAnchorRect ] );\n\n\tlet colSpan;\n\tif ( hasRenderedMovers ) {\n\t\tcolSpan = 2;\n\t} else if ( ! showBlockActions ) {\n\t\tcolSpan = 3;\n\t}\n\n\tconst classes = classnames( {\n\t\t'is-selected': isSelected,\n\t\t'is-first-selected': isFirstSelectedBlock,\n\t\t'is-last-selected': isLastSelectedBlock,\n\t\t'is-branch-selected': isBranchSelected,\n\t\t'is-synced-branch': isSyncedBranch,\n\t\t'is-dragging': isDragged,\n\t\t'has-single-cell': ! showBlockActions,\n\t\t'is-synced': blockInformation?.isSynced,\n\t\t'is-draggable': canMove,\n\t\t'is-displacement-normal': displacement === 'normal',\n\t\t'is-displacement-up': displacement === 'up',\n\t\t'is-displacement-down': displacement === 'down',\n\t\t'is-after-dragged-blocks': isAfterDraggedBlocks,\n\t\t'is-nesting': isNesting,\n\t} );\n\n\t// Only include all selected blocks if the currently clicked on block\n\t// is one of the selected blocks. This ensures that if a user attempts\n\t// to alter a block that isn't part of the selection, they're still able\n\t// to do so.\n\tconst dropdownClientIds = selectedClientIds.includes( clientId )\n\t\t? selectedClientIds\n\t\t: [ clientId ];\n\n\t// Pass in a ref to the row, so that it can be scrolled\n\t// into view when selected. For long lists, the placeholder for the\n\t// selected block is also observed, within ListViewLeafPlaceholder.\n\tuseListViewScrollIntoView( {\n\t\tisSelected,\n\t\trowItemRef: rowRef,\n\t\tselectedClientIds,\n\t} );\n\n\t// Detect if there is a block in the canvas currently being edited and multi-selection is not happening.\n\tconst currentlyEditingBlockInCanvas =\n\t\tisSelected && selectedClientIds.length === 1;\n\n\treturn (\n\t\t<ListViewLeaf\n\t\t\tclassName={ classes }\n\t\t\tisDragged={ isDragged }\n\t\t\tonKeyDown={ onKeyDown }\n\t\t\tonMouseEnter={ onMouseEnter }\n\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\tonFocus={ onMouseEnter }\n\t\t\tonBlur={ onMouseLeave }\n\t\t\tlevel={ level }\n\t\t\tposition={ position }\n\t\t\trowCount={ rowCount }\n\t\t\tpath={ path }\n\t\t\tid={ `list-view-${ listViewInstanceId }-block-${ clientId }` }\n\t\t\tdata-block={ clientId }\n\t\t\tdata-expanded={ canEdit ? isExpanded : undefined }\n\t\t\tref={ rowRef }\n\t\t>\n\t\t\t<TreeGridCell\n\t\t\t\tclassName=\"block-editor-list-view-block__contents-cell\"\n\t\t\t\tcolSpan={ colSpan }\n\t\t\t\tref={ cellRef }\n\t\t\t\taria-selected={ !! isSelected }\n\t\t\t>\n\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t<div className=\"block-editor-list-view-block__contents-container\">\n\t\t\t\t\t\t<ListViewBlockContents\n\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\tonClick={ selectEditorBlock }\n\t\t\t\t\t\t\tonContextMenu={ onContextMenu }\n\t\t\t\t\t\t\tonMouseDown={ onMouseDown }\n\t\t\t\t\t\t\tonToggleExpanded={ toggleExpanded }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\tsiblingBlockCount={ siblingBlockCount }\n\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\ttabIndex={\n\t\t\t\t\t\t\t\tcurrentlyEditingBlockInCanvas ? 0 : tabIndex\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\tisExpanded={ canEdit ? isExpanded : undefined }\n\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\tariaLabel={ blockAriaLabel }\n\t\t\t\t\t\t\tariaDescribedBy={ descriptionId }\n\t\t\t\t\t\t\tupdateFocusAndSelection={ updateFocusAndSelection }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<AriaReferencedText id={ descriptionId }>\n\t\t\t\t\t\t\t{ blockPositionDescription }\n\t\t\t\t\t\t</AriaReferencedText>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</TreeGridCell>\n\t\t\t{ hasRenderedMovers && (\n\t\t\t\t<>\n\t\t\t\t\t<TreeGridCell\n\t\t\t\t\t\tclassName={ moverCellClassName }\n\t\t\t\t\t\twithoutGridItem\n\t\t\t\t\t>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverUpButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverDownButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t</TreeGridCell>\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ showBlockActions && BlockSettingsMenu && (\n\t\t\t\t<TreeGridCell\n\t\t\t\t\tclassName={ listViewBlockSettingsClassName }\n\t\t\t\t\taria-selected={ !! isSelected }\n\t\t\t\t\tref={ settingsRef }\n\t\t\t\t>\n\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t<BlockSettingsMenu\n\t\t\t\t\t\t\tclientIds={ dropdownClientIds }\n\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ settingsAriaLabel }\n\t\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\t\tanchor: settingsPopoverAnchor, // Used to position the settings at the cursor on right-click.\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t\t\tclassName: 'block-editor-list-view-block__menu',\n\t\t\t\t\t\t\t\ttabIndex,\n\t\t\t\t\t\t\t\tonClick: clearSettingsAnchorRect,\n\t\t\t\t\t\t\t\tonFocus,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tdisableOpenOnArrowDown\n\t\t\t\t\t\t\texpand={ expand }\n\t\t\t\t\t\t\texpandedState={ expandedState }\n\t\t\t\t\t\t\tsetInsertedBlock={ setInsertedBlock }\n\t\t\t\t\t\t\t__experimentalSelectBlock={\n\t\t\t\t\t\t\t\tupdateFocusAndSelection\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</TreeGridCell>\n\t\t\t) }\n\t\t</ListViewLeaf>\n\t);\n}\n\nexport default memo( ListViewBlock );\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SACCC,0BAA0B,IAAIC,YAAY,EAC1CC,0BAA0B,IAAIC,YAAY,QACpC,uBAAuB;AAC9B,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SACCC,WAAW,EACXC,OAAO,EACPC,QAAQ,EACRC,MAAM,EACNC,IAAI,QACE,oBAAoB;AAC3B,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,OAAO,EAAEC,EAAE,QAAQ,iBAAiB;AAC7C,SAASC,MAAM,QAAQ,qBAAqB;;AAE5C;AACA;AACA;AACA,OAAOC,YAAY,MAAM,QAAQ;AACjC,OAAOC,yBAAyB,MAAM,kCAAkC;AACxE,SACCC,kBAAkB,EAClBC,oBAAoB,QACd,uBAAuB;AAC9B,OAAOC,qBAAqB,MAAM,kBAAkB;AACpD,SAASC,kBAAkB,QAAQ,WAAW;AAC9C,SAASC,2BAA2B,EAAEC,aAAa,QAAQ,SAAS;AACpE,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,OAAOC,0BAA0B,MAAM,kCAAkC;AACzE,SAASC,YAAY,QAAQ,eAAe;AAC5C,OAAOC,kBAAkB,MAAM,wBAAwB;AAEvD,SAASC,aAAaA,CAAE;EACvBC,KAAK,EAAE;IAAEC;EAAS,CAAC;EACnBC,YAAY;EACZC,oBAAoB;EACpBC,SAAS;EACTC,SAAS;EACTC,UAAU;EACVC,gBAAg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EAAQ,CAAC,KAC7BF,aAAA,CAAC3C,iBAAiB;IACjByD,SAAS,EAAGlB,iBAAmB;IAC/B3F,KAAK,EAAGA,KAAO;IACf8G,IAAI,EAAGvI,YAAc;IACrBwI,KAAK,EAAG9D,iBAAmB;IAC3B+D,YAAY,EAAG;MACdC,MAAM,EAAE7B,qBAAqB,CAAE;IAChC,CAAG;;IACH8B,WAAW,EAAG;MACbd,GAAG;MACHJ,SAAS,EAAE,oCAAoC;MAC/CK,QAAQ;MACRC,OAAO,EAAEf,uBAAuB;MAChCU;IACD,CAAG;IACHkB,sBAAsB;IACtBjE,MAAM,EAAGA,MAAQ;IACjBI,aAAa,EAAGA,aAAe;IAC/BC,gBAAgB,EAAGA,gBAAkB;IACrC6D,yBAAyB,EACxB7C;EACA,CACD,CAEW,CAEF,CAAC;AAEjB;AAEA,eAAe3F,IAAI,CAAEmB,aAAc,CAAC"}
|
|
@@ -12,7 +12,7 @@ import { AsyncModeProvider, useSelect } from '@wordpress/data';
|
|
|
12
12
|
import { Appender } from './appender';
|
|
13
13
|
import ListViewBlock from './block';
|
|
14
14
|
import { useListViewContext } from './context';
|
|
15
|
-
import { isClientIdSelected } from './utils';
|
|
15
|
+
import { getDragDisplacementValues, isClientIdSelected } from './utils';
|
|
16
16
|
import { store as blockEditorStore } from '../../store';
|
|
17
17
|
import useBlockDisplayInformation from '../use-block-display-information';
|
|
18
18
|
|
|
@@ -62,7 +62,6 @@ function ListViewBranch(props) {
|
|
|
62
62
|
selectedClientIds,
|
|
63
63
|
level = 1,
|
|
64
64
|
path = '',
|
|
65
|
-
isBranchDragged = false,
|
|
66
65
|
isBranchSelected = false,
|
|
67
66
|
listPosition = 0,
|
|
68
67
|
fixedListWindow,
|
|
@@ -81,6 +80,10 @@ function ListViewBranch(props) {
|
|
|
81
80
|
return select(blockEditorStore).canEditBlock(parentId);
|
|
82
81
|
}, [parentId]);
|
|
83
82
|
const {
|
|
83
|
+
blockDropPosition,
|
|
84
|
+
blockDropTargetIndex,
|
|
85
|
+
firstDraggedBlockIndex,
|
|
86
|
+
blockIndexes,
|
|
84
87
|
expandedState,
|
|
85
88
|
draggedClientIds
|
|
86
89
|
} = useListViewContext();
|
|
@@ -104,6 +107,23 @@ function ListViewBranch(props) {
|
|
|
104
107
|
if (index > 0) {
|
|
105
108
|
nextPosition += countBlocks(filteredBlocks[index - 1], expandedState, draggedClientIds, isExpanded);
|
|
106
109
|
}
|
|
110
|
+
const isDragged = !!draggedClientIds?.includes(clientId);
|
|
111
|
+
|
|
112
|
+
// Determine the displacement of the block while dragging. This
|
|
113
|
+
// works out whether the current block should be displaced up or
|
|
114
|
+
// down, relative to the dragged blocks and the drop target.
|
|
115
|
+
const {
|
|
116
|
+
displacement,
|
|
117
|
+
isAfterDraggedBlocks,
|
|
118
|
+
isNesting
|
|
119
|
+
} = getDragDisplacementValues({
|
|
120
|
+
blockIndexes,
|
|
121
|
+
blockDropTargetIndex,
|
|
122
|
+
blockDropPosition,
|
|
123
|
+
clientId,
|
|
124
|
+
firstDraggedBlockIndex,
|
|
125
|
+
isDragged
|
|
126
|
+
});
|
|
107
127
|
const {
|
|
108
128
|
itemInView
|
|
109
129
|
} = fixedListWindow;
|
|
@@ -112,7 +132,6 @@ function ListViewBranch(props) {
|
|
|
112
132
|
const updatedPath = path.length > 0 ? `${path}_${position}` : `${position}`;
|
|
113
133
|
const hasNestedBlocks = !!innerBlocks?.length;
|
|
114
134
|
const shouldExpand = hasNestedBlocks && shouldShowInnerBlocks ? (_expandedState$client = expandedState[clientId]) !== null && _expandedState$client !== void 0 ? _expandedState$client : isExpanded : undefined;
|
|
115
|
-
const isDragged = !!draggedClientIds?.includes(clientId);
|
|
116
135
|
|
|
117
136
|
// Make updates to the selected or dragged blocks synchronous,
|
|
118
137
|
// but asynchronous for any other block.
|
|
@@ -125,7 +144,7 @@ function ListViewBranch(props) {
|
|
|
125
144
|
// This prevents the entire tree from being rendered when a branch is
|
|
126
145
|
// selected, or a user selects all blocks, while still enabling scroll
|
|
127
146
|
// into view behavior when selecting a block or opening the list view.
|
|
128
|
-
const showBlock = isDragged || blockInView ||
|
|
147
|
+
const showBlock = isDragged || blockInView || isSelected && clientId === selectedClientIds[0];
|
|
129
148
|
return createElement(AsyncModeProvider, {
|
|
130
149
|
key: clientId,
|
|
131
150
|
value: !isSelected
|
|
@@ -134,20 +153,23 @@ function ListViewBranch(props) {
|
|
|
134
153
|
selectBlock: selectBlock,
|
|
135
154
|
isSelected: isSelected,
|
|
136
155
|
isBranchSelected: isSelectedBranch,
|
|
137
|
-
isDragged: isDragged
|
|
156
|
+
isDragged: isDragged,
|
|
138
157
|
level: level,
|
|
139
158
|
position: position,
|
|
140
159
|
rowCount: rowCount,
|
|
141
160
|
siblingBlockCount: blockCount,
|
|
142
161
|
showBlockMovers: showBlockMovers,
|
|
143
162
|
path: updatedPath,
|
|
144
|
-
isExpanded: shouldExpand,
|
|
163
|
+
isExpanded: isDragged ? false : shouldExpand,
|
|
145
164
|
listPosition: nextPosition,
|
|
146
165
|
selectedClientIds: selectedClientIds,
|
|
147
|
-
isSyncedBranch: syncedBranch
|
|
166
|
+
isSyncedBranch: syncedBranch,
|
|
167
|
+
displacement: displacement,
|
|
168
|
+
isAfterDraggedBlocks: isAfterDraggedBlocks,
|
|
169
|
+
isNesting: isNesting
|
|
148
170
|
}), !showBlock && createElement("tr", null, createElement("td", {
|
|
149
171
|
className: "block-editor-list-view-placeholder"
|
|
150
|
-
})), hasNestedBlocks && shouldExpand && createElement(ListViewBranch, {
|
|
172
|
+
})), hasNestedBlocks && shouldExpand && !isDragged && createElement(ListViewBranch, {
|
|
151
173
|
parentId: clientId,
|
|
152
174
|
blocks: innerBlocks,
|
|
153
175
|
selectBlock: selectBlock,
|
|
@@ -157,7 +179,6 @@ function ListViewBranch(props) {
|
|
|
157
179
|
listPosition: nextPosition + 1,
|
|
158
180
|
fixedListWindow: fixedListWindow,
|
|
159
181
|
isBranchSelected: isSelectedBranch,
|
|
160
|
-
isBranchDragged: isDragged || isBranchDragged,
|
|
161
182
|
selectedClientIds: selectedClientIds,
|
|
162
183
|
isExpanded: isExpanded,
|
|
163
184
|
isSyncedBranch: syncedBranch
|