@wordpress/block-editor 12.1.0 → 12.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/autocompleters/block.js +13 -5
- package/build/autocompleters/block.js.map +1 -1
- package/build/components/block-breadcrumb/index.js +6 -3
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-editing-mode/index.js +84 -0
- package/build/components/block-editing-mode/index.js.map +1 -0
- package/build/components/block-list/block-list-block-context.js +15 -0
- package/build/components/block-list/block-list-block-context.js.map +1 -0
- package/build/components/block-list/block.js +29 -37
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +14 -22
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +107 -108
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +2 -2
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +7 -5
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-list-appender/index.js +15 -1
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +19 -4
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-styles/preview-panel.js +1 -2
- package/build/components/block-styles/preview-panel.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.js +8 -0
- package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build/components/block-switcher/block-variation-transformations.js +125 -0
- package/build/components/block-switcher/block-variation-transformations.js.map +1 -0
- package/build/components/block-switcher/index.js +34 -12
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/pattern-transformations-menu.js +3 -3
- package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build/components/block-toolbar/index.js +9 -7
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +5 -3
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +11 -5
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/convert-to-group-buttons/index.js +7 -2
- package/build/components/convert-to-group-buttons/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/index.native.js +87 -3
- package/build/components/convert-to-group-buttons/index.native.js.map +1 -1
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +23 -37
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +3 -2
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/iframe/index.js +14 -7
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +2 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +7 -7
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +13 -5
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/index.js +3 -7
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +2 -4
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-results.js +19 -6
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/list-view/appender.js +6 -1
- package/build/components/list-view/appender.js.map +1 -1
- package/build/components/list-view/block-contents.js +4 -2
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block.js +21 -25
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +1 -3
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +14 -7
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +27 -3
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/publish-date-time-picker/index.js +0 -2
- package/build/components/publish-date-time-picker/index.js.map +1 -1
- package/build/components/url-input/index.js +3 -0
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +25 -15
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-resize-canvas/index.js +8 -1
- package/build/components/use-resize-canvas/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +13 -7
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/hooks/align.js +3 -7
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/behaviors.js +115 -0
- package/build/hooks/behaviors.js.map +1 -0
- package/build/hooks/dimensions.js +0 -30
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +4 -8
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +8 -9
- package/build/hooks/layout.js.map +1 -1
- package/build/private-apis.js +4 -7
- package/build/private-apis.js.map +1 -1
- package/build/store/private-actions.js +46 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +88 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +36 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +28 -18
- package/build/store/selectors.js.map +1 -1
- package/build/utils/order-inserter-block-items.js +41 -0
- package/build/utils/order-inserter-block-items.js.map +1 -0
- package/build-module/autocompleters/block.js +12 -5
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js +5 -3
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-editing-mode/index.js +72 -0
- package/build-module/components/block-editing-mode/index.js.map +1 -0
- package/build-module/components/block-list/block-list-block-context.js +6 -0
- package/build-module/components/block-list/block-list-block-context.js.map +1 -0
- package/build-module/components/block-list/block.js +26 -34
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +14 -22
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +108 -110
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +1 -1
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +6 -5
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +15 -1
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +18 -4
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-styles/preview-panel.js +1 -2
- package/build-module/components/block-styles/preview-panel.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.js +7 -0
- package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build-module/components/block-switcher/block-variation-transformations.js +108 -0
- package/build-module/components/block-switcher/block-variation-transformations.js.map +1 -0
- package/build-module/components/block-switcher/index.js +33 -12
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/pattern-transformations-menu.js +3 -3
- package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +8 -7
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +4 -3
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +11 -5
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/index.js +7 -2
- package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/index.native.js +76 -1
- package/build-module/components/convert-to-group-buttons/index.native.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +22 -36
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +3 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/iframe/index.js +15 -8
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +2 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +7 -6
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +13 -5
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/index.js +3 -7
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +2 -4
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-results.js +16 -6
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/list-view/appender.js +6 -2
- package/build-module/components/list-view/appender.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +4 -2
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block.js +20 -25
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +1 -3
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +15 -8
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +26 -3
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/publish-date-time-picker/index.js +0 -2
- package/build-module/components/publish-date-time-picker/index.js.map +1 -1
- package/build-module/components/url-input/index.js +3 -0
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +25 -16
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-resize-canvas/index.js +8 -1
- package/build-module/components/use-resize-canvas/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +13 -7
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/hooks/align.js +3 -6
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/behaviors.js +97 -0
- package/build-module/hooks/behaviors.js.map +1 -0
- package/build-module/hooks/dimensions.js +0 -28
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +3 -6
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +7 -9
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/private-apis.js +3 -5
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/private-actions.js +42 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +79 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +34 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +26 -17
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/order-inserter-block-items.js +32 -0
- package/build-module/utils/order-inserter-block-items.js.map +1 -0
- package/build-style/content-rtl.css +32 -13
- package/build-style/content.css +32 -13
- 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 +19 -64
- package/build-style/style.css +20 -64
- package/package.json +32 -31
- package/src/autocompleters/block.js +15 -7
- package/src/components/block-breadcrumb/index.js +11 -3
- package/src/components/block-editing-mode/index.js +71 -0
- package/src/components/block-list/block-list-block-context.js +6 -0
- package/src/components/block-list/block.js +38 -56
- package/src/components/block-list/block.native.js +30 -41
- package/src/components/block-list/content.scss +5 -5
- package/src/components/block-list/index.native.js +164 -153
- package/src/components/block-list/test/index.native.js +2 -2
- package/src/components/block-list/use-block-props/index.js +1 -1
- package/src/components/block-list/use-in-between-inserter.js +7 -3
- package/src/components/block-list-appender/index.js +22 -4
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +23 -0
- package/src/components/block-mover/style.scss +1 -0
- package/src/components/block-styles/preview-panel.js +1 -3
- package/src/components/block-switcher/block-transformations-menu.js +12 -0
- package/src/components/block-switcher/block-variation-transformations.js +115 -0
- package/src/components/block-switcher/index.js +38 -5
- package/src/components/block-switcher/pattern-transformations-menu.js +5 -5
- package/src/components/block-switcher/style.scss +6 -5
- package/src/components/block-toolbar/index.js +10 -11
- package/src/components/block-tools/block-contextual-toolbar.js +4 -5
- package/src/components/block-tools/insertion-point.js +23 -9
- package/src/components/button-block-appender/content.scss +22 -0
- package/src/components/convert-to-group-buttons/index.js +9 -2
- package/src/components/convert-to-group-buttons/index.native.js +79 -1
- package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +32 -38
- package/src/components/global-styles/dimensions-panel.js +3 -2
- package/src/components/global-styles/style.scss +3 -0
- package/src/components/iframe/index.js +22 -12
- package/src/components/inner-blocks/README.md +5 -0
- package/src/components/inner-blocks/index.js +2 -0
- package/src/components/inner-blocks/index.native.js +16 -6
- package/src/components/inner-blocks/use-nested-settings-update.js +20 -3
- package/src/components/inserter/index.js +1 -9
- package/src/components/inserter/quick-inserter.js +0 -2
- package/src/components/inserter/search-results.js +32 -6
- package/src/components/list-view/appender.js +3 -2
- package/src/components/list-view/block-contents.js +8 -2
- package/src/components/list-view/block.js +29 -35
- package/src/components/list-view/branch.js +1 -7
- package/src/components/list-view/index.js +17 -4
- package/src/components/list-view/style.scss +2 -5
- package/src/components/list-view/use-list-view-client-ids.js +21 -4
- package/src/components/publish-date-time-picker/index.js +0 -2
- package/src/components/url-input/README.md +6 -0
- package/src/components/url-input/index.js +1 -0
- package/src/components/use-block-drop-zone/index.js +31 -17
- package/src/components/use-resize-canvas/index.js +9 -1
- package/src/components/writing-flow/test/index.js +15 -0
- package/src/components/writing-flow/use-arrow-nav.js +17 -4
- package/src/hooks/align.js +3 -11
- package/src/hooks/behaviors.js +104 -0
- package/src/hooks/dimensions.js +0 -40
- package/src/hooks/duotone.js +3 -11
- package/src/hooks/index.js +1 -0
- package/src/hooks/layout.js +10 -18
- package/src/private-apis.js +2 -4
- package/src/store/private-actions.js +39 -0
- package/src/store/private-selectors.js +95 -0
- package/src/store/reducer.js +27 -0
- package/src/store/selectors.js +25 -15
- package/src/store/test/private-actions.js +32 -1
- package/src/store/test/private-selectors.js +158 -0
- package/src/store/test/reducer.js +48 -0
- package/src/style.scss +0 -3
- package/src/utils/order-inserter-block-items.js +26 -0
- package/build/components/block-list/block-list-compact.native.js +0 -75
- package/build/components/block-list/block-list-compact.native.js.map +0 -1
- package/build/components/off-canvas-editor/appender.js +0 -125
- package/build/components/off-canvas-editor/appender.js.map +0 -1
- package/build/components/off-canvas-editor/block-contents.js +0 -141
- package/build/components/off-canvas-editor/block-contents.js.map +0 -1
- package/build/components/off-canvas-editor/block-select-button.js +0 -126
- package/build/components/off-canvas-editor/block-select-button.js.map +0 -1
- package/build/components/off-canvas-editor/block.js +0 -297
- package/build/components/off-canvas-editor/block.js.map +0 -1
- package/build/components/off-canvas-editor/branch.js +0 -197
- package/build/components/off-canvas-editor/branch.js.map +0 -1
- package/build/components/off-canvas-editor/context.js +0 -19
- package/build/components/off-canvas-editor/context.js.map +0 -1
- package/build/components/off-canvas-editor/drop-indicator.js +0 -118
- package/build/components/off-canvas-editor/drop-indicator.js.map +0 -1
- package/build/components/off-canvas-editor/expander.js +0 -41
- package/build/components/off-canvas-editor/expander.js.map +0 -1
- package/build/components/off-canvas-editor/index.js +0 -236
- package/build/components/off-canvas-editor/index.js.map +0 -1
- package/build/components/off-canvas-editor/leaf-more-menu.js +0 -148
- package/build/components/off-canvas-editor/leaf-more-menu.js.map +0 -1
- package/build/components/off-canvas-editor/leaf.js +0 -60
- package/build/components/off-canvas-editor/leaf.js.map +0 -1
- package/build/components/off-canvas-editor/link-ui.js +0 -186
- package/build/components/off-canvas-editor/link-ui.js.map +0 -1
- package/build/components/off-canvas-editor/update-attributes.js +0 -108
- package/build/components/off-canvas-editor/update-attributes.js.map +0 -1
- package/build/components/off-canvas-editor/use-block-selection.js +0 -139
- package/build/components/off-canvas-editor/use-block-selection.js.map +0 -1
- package/build/components/off-canvas-editor/use-inserted-block.js +0 -58
- package/build/components/off-canvas-editor/use-inserted-block.js.map +0 -1
- package/build/components/off-canvas-editor/use-list-view-client-ids.js +0 -33
- package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +0 -1
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js +0 -235
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +0 -1
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -60
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +0 -1
- package/build/components/off-canvas-editor/utils.js +0 -60
- package/build/components/off-canvas-editor/utils.js.map +0 -1
- package/build-module/components/block-list/block-list-compact.native.js +0 -60
- package/build-module/components/block-list/block-list-compact.native.js.map +0 -1
- package/build-module/components/off-canvas-editor/appender.js +0 -108
- package/build-module/components/off-canvas-editor/appender.js.map +0 -1
- package/build-module/components/off-canvas-editor/block-contents.js +0 -121
- package/build-module/components/off-canvas-editor/block-contents.js.map +0 -1
- package/build-module/components/off-canvas-editor/block-select-button.js +0 -107
- package/build-module/components/off-canvas-editor/block-select-button.js.map +0 -1
- package/build-module/components/off-canvas-editor/block.js +0 -273
- package/build-module/components/off-canvas-editor/block.js.map +0 -1
- package/build-module/components/off-canvas-editor/branch.js +0 -179
- package/build-module/components/off-canvas-editor/branch.js.map +0 -1
- package/build-module/components/off-canvas-editor/context.js +0 -7
- package/build-module/components/off-canvas-editor/context.js.map +0 -1
- package/build-module/components/off-canvas-editor/drop-indicator.js +0 -111
- package/build-module/components/off-canvas-editor/drop-indicator.js.map +0 -1
- package/build-module/components/off-canvas-editor/expander.js +0 -32
- package/build-module/components/off-canvas-editor/expander.js.map +0 -1
- package/build-module/components/off-canvas-editor/index.js +0 -213
- package/build-module/components/off-canvas-editor/index.js.map +0 -1
- package/build-module/components/off-canvas-editor/leaf-more-menu.js +0 -130
- package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +0 -1
- package/build-module/components/off-canvas-editor/leaf.js +0 -45
- package/build-module/components/off-canvas-editor/leaf.js.map +0 -1
- package/build-module/components/off-canvas-editor/link-ui.js +0 -166
- package/build-module/components/off-canvas-editor/link-ui.js.map +0 -1
- package/build-module/components/off-canvas-editor/update-attributes.js +0 -97
- package/build-module/components/off-canvas-editor/update-attributes.js.map +0 -1
- package/build-module/components/off-canvas-editor/use-block-selection.js +0 -124
- package/build-module/components/off-canvas-editor/use-block-selection.js.map +0 -1
- package/build-module/components/off-canvas-editor/use-inserted-block.js +0 -47
- package/build-module/components/off-canvas-editor/use-inserted-block.js.map +0 -1
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +0 -24
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +0 -1
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +0 -220
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +0 -1
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -50
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +0 -1
- package/build-module/components/off-canvas-editor/utils.js +0 -44
- package/build-module/components/off-canvas-editor/utils.js.map +0 -1
- package/src/components/block-list/block-list-compact.native.js +0 -63
- package/src/components/off-canvas-editor/README.md +0 -5
- package/src/components/off-canvas-editor/appender.js +0 -124
- package/src/components/off-canvas-editor/block-contents.js +0 -156
- package/src/components/off-canvas-editor/block-select-button.js +0 -128
- package/src/components/off-canvas-editor/block.js +0 -347
- package/src/components/off-canvas-editor/branch.js +0 -238
- package/src/components/off-canvas-editor/context.js +0 -8
- package/src/components/off-canvas-editor/drop-indicator.js +0 -126
- package/src/components/off-canvas-editor/expander.js +0 -26
- package/src/components/off-canvas-editor/index.js +0 -271
- package/src/components/off-canvas-editor/leaf-more-menu.js +0 -158
- package/src/components/off-canvas-editor/leaf.js +0 -52
- package/src/components/off-canvas-editor/link-ui.js +0 -167
- package/src/components/off-canvas-editor/style.scss +0 -34
- package/src/components/off-canvas-editor/test/use-inserted-block.js +0 -108
- package/src/components/off-canvas-editor/test/utils.js +0 -50
- package/src/components/off-canvas-editor/update-attributes.js +0 -99
- package/src/components/off-canvas-editor/use-block-selection.js +0 -169
- package/src/components/off-canvas-editor/use-inserted-block.js +0 -47
- package/src/components/off-canvas-editor/use-list-view-client-ids.js +0 -29
- package/src/components/off-canvas-editor/use-list-view-drop-zone.js +0 -260
- package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -58
- package/src/components/off-canvas-editor/utils.js +0 -58
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
-
|
|
16
|
-
var _data = require("@wordpress/data");
|
|
17
|
-
|
|
18
|
-
var _lockUnlock = require("../../lock-unlock");
|
|
19
|
-
|
|
20
|
-
var _blockSelectButton = _interopRequireDefault(require("./block-select-button"));
|
|
21
|
-
|
|
22
|
-
var _blockDraggable = _interopRequireDefault(require("../block-draggable"));
|
|
23
|
-
|
|
24
|
-
var _store = require("../../store");
|
|
25
|
-
|
|
26
|
-
var _updateAttributes = require("./update-attributes");
|
|
27
|
-
|
|
28
|
-
var _linkUi = require("./link-ui");
|
|
29
|
-
|
|
30
|
-
var _useInsertedBlock = require("./use-inserted-block");
|
|
31
|
-
|
|
32
|
-
var _context = require("./context");
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* External dependencies
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* WordPress dependencies
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Internal dependencies
|
|
44
|
-
*/
|
|
45
|
-
const BLOCKS_WITH_LINK_UI_SUPPORT = ['core/navigation-link', 'core/navigation-submenu'];
|
|
46
|
-
const ListViewBlockContents = (0, _element.forwardRef)((_ref, ref) => {
|
|
47
|
-
let {
|
|
48
|
-
onClick,
|
|
49
|
-
onToggleExpanded,
|
|
50
|
-
block,
|
|
51
|
-
isSelected,
|
|
52
|
-
position,
|
|
53
|
-
siblingBlockCount,
|
|
54
|
-
level,
|
|
55
|
-
isExpanded,
|
|
56
|
-
selectedClientIds,
|
|
57
|
-
...props
|
|
58
|
-
} = _ref;
|
|
59
|
-
const {
|
|
60
|
-
clientId
|
|
61
|
-
} = block;
|
|
62
|
-
const [isLinkUIOpen, setIsLinkUIOpen] = (0, _element.useState)();
|
|
63
|
-
const {
|
|
64
|
-
blockMovingClientId,
|
|
65
|
-
selectedBlockInBlockEditor,
|
|
66
|
-
lastInsertedBlockClientId
|
|
67
|
-
} = (0, _data.useSelect)(select => {
|
|
68
|
-
const {
|
|
69
|
-
hasBlockMovingClientId,
|
|
70
|
-
getSelectedBlockClientId,
|
|
71
|
-
getLastInsertedBlocksClientIds
|
|
72
|
-
} = (0, _lockUnlock.unlock)(select(_store.store));
|
|
73
|
-
const lastInsertedBlocksClientIds = getLastInsertedBlocksClientIds();
|
|
74
|
-
return {
|
|
75
|
-
blockMovingClientId: hasBlockMovingClientId(),
|
|
76
|
-
selectedBlockInBlockEditor: getSelectedBlockClientId(),
|
|
77
|
-
lastInsertedBlockClientId: lastInsertedBlocksClientIds && lastInsertedBlocksClientIds[0]
|
|
78
|
-
};
|
|
79
|
-
}, [clientId]);
|
|
80
|
-
const {
|
|
81
|
-
insertedBlockAttributes,
|
|
82
|
-
insertedBlockName,
|
|
83
|
-
setInsertedBlockAttributes
|
|
84
|
-
} = (0, _useInsertedBlock.useInsertedBlock)(lastInsertedBlockClientId);
|
|
85
|
-
const hasExistingLinkValue = insertedBlockAttributes === null || insertedBlockAttributes === void 0 ? void 0 : insertedBlockAttributes.url;
|
|
86
|
-
(0, _element.useEffect)(() => {
|
|
87
|
-
if (clientId === lastInsertedBlockClientId && BLOCKS_WITH_LINK_UI_SUPPORT !== null && BLOCKS_WITH_LINK_UI_SUPPORT !== void 0 && BLOCKS_WITH_LINK_UI_SUPPORT.includes(insertedBlockName) && !hasExistingLinkValue // don't re-show the Link UI if the block already has a link value.
|
|
88
|
-
) {
|
|
89
|
-
setIsLinkUIOpen(true);
|
|
90
|
-
}
|
|
91
|
-
}, [lastInsertedBlockClientId, clientId, insertedBlockName, hasExistingLinkValue]);
|
|
92
|
-
const {
|
|
93
|
-
renderAdditionalBlockUI
|
|
94
|
-
} = (0, _context.useListViewContext)();
|
|
95
|
-
const isBlockMoveTarget = blockMovingClientId && selectedBlockInBlockEditor === clientId;
|
|
96
|
-
const className = (0, _classnames.default)('block-editor-list-view-block-contents', {
|
|
97
|
-
'is-dropping-before': isBlockMoveTarget
|
|
98
|
-
}); // Only include all selected blocks if the currently clicked on block
|
|
99
|
-
// is one of the selected blocks. This ensures that if a user attempts
|
|
100
|
-
// to drag a block that isn't part of the selection, they're still able
|
|
101
|
-
// to drag it and rearrange its position.
|
|
102
|
-
|
|
103
|
-
const draggableClientIds = selectedClientIds.includes(clientId) ? selectedClientIds : [clientId];
|
|
104
|
-
return (0, _element.createElement)(_element.Fragment, null, renderAdditionalBlockUI && renderAdditionalBlockUI(block), isLinkUIOpen && (0, _element.createElement)(_linkUi.LinkUI, {
|
|
105
|
-
clientId: lastInsertedBlockClientId,
|
|
106
|
-
link: insertedBlockAttributes,
|
|
107
|
-
onClose: () => setIsLinkUIOpen(false),
|
|
108
|
-
hasCreateSuggestion: false,
|
|
109
|
-
onChange: updatedValue => {
|
|
110
|
-
(0, _updateAttributes.updateAttributes)(updatedValue, setInsertedBlockAttributes, insertedBlockAttributes);
|
|
111
|
-
setIsLinkUIOpen(false);
|
|
112
|
-
},
|
|
113
|
-
onCancel: () => setIsLinkUIOpen(false)
|
|
114
|
-
}), (0, _element.createElement)(_blockDraggable.default, {
|
|
115
|
-
clientIds: draggableClientIds
|
|
116
|
-
}, _ref2 => {
|
|
117
|
-
let {
|
|
118
|
-
draggable,
|
|
119
|
-
onDragStart,
|
|
120
|
-
onDragEnd
|
|
121
|
-
} = _ref2;
|
|
122
|
-
return (0, _element.createElement)(_blockSelectButton.default, (0, _extends2.default)({
|
|
123
|
-
ref: ref,
|
|
124
|
-
className: className,
|
|
125
|
-
block: block,
|
|
126
|
-
onClick: onClick,
|
|
127
|
-
onToggleExpanded: onToggleExpanded,
|
|
128
|
-
isSelected: isSelected,
|
|
129
|
-
position: position,
|
|
130
|
-
siblingBlockCount: siblingBlockCount,
|
|
131
|
-
level: level,
|
|
132
|
-
draggable: draggable,
|
|
133
|
-
onDragStart: onDragStart,
|
|
134
|
-
onDragEnd: onDragEnd,
|
|
135
|
-
isExpanded: isExpanded
|
|
136
|
-
}, props));
|
|
137
|
-
}));
|
|
138
|
-
});
|
|
139
|
-
var _default = ListViewBlockContents;
|
|
140
|
-
exports.default = _default;
|
|
141
|
-
//# sourceMappingURL=block-contents.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/block-contents.js"],"names":["BLOCKS_WITH_LINK_UI_SUPPORT","ListViewBlockContents","ref","onClick","onToggleExpanded","block","isSelected","position","siblingBlockCount","level","isExpanded","selectedClientIds","props","clientId","isLinkUIOpen","setIsLinkUIOpen","blockMovingClientId","selectedBlockInBlockEditor","lastInsertedBlockClientId","select","hasBlockMovingClientId","getSelectedBlockClientId","getLastInsertedBlocksClientIds","blockEditorStore","lastInsertedBlocksClientIds","insertedBlockAttributes","insertedBlockName","setInsertedBlockAttributes","hasExistingLinkValue","url","includes","renderAdditionalBlockUI","isBlockMoveTarget","className","draggableClientIds","updatedValue","draggable","onDragStart","onDragEnd"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAKA;;AAMA;;AACA;;AACA;;AACA;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MAAA,SAAS,EAAG+B,SAFb;AAGC,MAAA,KAAK,EAAG5B,KAHT;AAIC,MAAA,OAAO,EAAGF,OAJX;AAKC,MAAA,gBAAgB,EAAGC,gBALpB;AAMC,MAAA,UAAU,EAAGE,UANd;AAOC,MAAA,QAAQ,EAAGC,QAPZ;AAQC,MAAA,iBAAiB,EAAGC,iBARrB;AASC,MAAA,KAAK,EAAGC,KATT;AAUC,MAAA,SAAS,EAAG2B,SAVb;AAWC,MAAA,WAAW,EAAGC,WAXf;AAYC,MAAA,SAAS,EAAGC,SAZb;AAaC,MAAA,UAAU,EAAG5B;AAbd,OAcME,KAdN,EADC;AAAA,GADH,CAnBD,CADD;AA0CA,CA5H4B,CAA9B;eA+HeX,qB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { forwardRef, useEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport ListViewBlockSelectButton from './block-select-button';\nimport BlockDraggable from '../block-draggable';\nimport { store as blockEditorStore } from '../../store';\nimport { updateAttributes } from './update-attributes';\nimport { LinkUI } from './link-ui';\nimport { useInsertedBlock } from './use-inserted-block';\nimport { useListViewContext } from './context';\n\nconst BLOCKS_WITH_LINK_UI_SUPPORT = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n];\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\t\tconst [ isLinkUIOpen, setIsLinkUIOpen ] = useState();\n\t\tconst {\n\t\t\tblockMovingClientId,\n\t\t\tselectedBlockInBlockEditor,\n\t\t\tlastInsertedBlockClientId,\n\t\t} = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\thasBlockMovingClientId,\n\t\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\t\tgetLastInsertedBlocksClientIds,\n\t\t\t\t} = unlock( select( blockEditorStore ) );\n\t\t\t\tconst lastInsertedBlocksClientIds =\n\t\t\t\t\tgetLastInsertedBlocksClientIds();\n\t\t\t\treturn {\n\t\t\t\t\tblockMovingClientId: hasBlockMovingClientId(),\n\t\t\t\t\tselectedBlockInBlockEditor: getSelectedBlockClientId(),\n\t\t\t\t\tlastInsertedBlockClientId:\n\t\t\t\t\t\tlastInsertedBlocksClientIds &&\n\t\t\t\t\t\tlastInsertedBlocksClientIds[ 0 ],\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId ]\n\t\t);\n\n\t\tconst {\n\t\t\tinsertedBlockAttributes,\n\t\t\tinsertedBlockName,\n\t\t\tsetInsertedBlockAttributes,\n\t\t} = useInsertedBlock( lastInsertedBlockClientId );\n\n\t\tconst hasExistingLinkValue = insertedBlockAttributes?.url;\n\n\t\tuseEffect( () => {\n\t\t\tif (\n\t\t\t\tclientId === lastInsertedBlockClientId &&\n\t\t\t\tBLOCKS_WITH_LINK_UI_SUPPORT?.includes( insertedBlockName ) &&\n\t\t\t\t! hasExistingLinkValue // don't re-show the Link UI if the block already has a link value.\n\t\t\t) {\n\t\t\t\tsetIsLinkUIOpen( true );\n\t\t\t}\n\t\t}, [\n\t\t\tlastInsertedBlockClientId,\n\t\t\tclientId,\n\t\t\tinsertedBlockName,\n\t\t\thasExistingLinkValue,\n\t\t] );\n\n\t\tconst { renderAdditionalBlockUI } = useListViewContext();\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{ renderAdditionalBlockUI && renderAdditionalBlockUI( block ) }\n\t\t\t\t{ isLinkUIOpen && (\n\t\t\t\t\t<LinkUI\n\t\t\t\t\t\tclientId={ lastInsertedBlockClientId }\n\t\t\t\t\t\tlink={ insertedBlockAttributes }\n\t\t\t\t\t\tonClose={ () => setIsLinkUIOpen( false ) }\n\t\t\t\t\t\thasCreateSuggestion={ false }\n\t\t\t\t\t\tonChange={ ( updatedValue ) => {\n\t\t\t\t\t\t\tupdateAttributes(\n\t\t\t\t\t\t\t\tupdatedValue,\n\t\t\t\t\t\t\t\tsetInsertedBlockAttributes,\n\t\t\t\t\t\t\t\tinsertedBlockAttributes\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tsetIsLinkUIOpen( false );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonCancel={ () => setIsLinkUIOpen( false ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<BlockDraggable clientIds={ draggableClientIds }>\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"]}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
|
-
var _components = require("@wordpress/components");
|
|
15
|
-
|
|
16
|
-
var _icons = require("@wordpress/icons");
|
|
17
|
-
|
|
18
|
-
var _keycodes = require("@wordpress/keycodes");
|
|
19
|
-
|
|
20
|
-
var _i18n = require("@wordpress/i18n");
|
|
21
|
-
|
|
22
|
-
var _blockIcon = _interopRequireDefault(require("../block-icon"));
|
|
23
|
-
|
|
24
|
-
var _useBlockDisplayInformation = _interopRequireDefault(require("../use-block-display-information"));
|
|
25
|
-
|
|
26
|
-
var _useBlockDisplayTitle = _interopRequireDefault(require("../block-title/use-block-display-title"));
|
|
27
|
-
|
|
28
|
-
var _expander = _interopRequireDefault(require("./expander"));
|
|
29
|
-
|
|
30
|
-
var _blockLock = require("../block-lock");
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* External dependencies
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* WordPress dependencies
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Internal dependencies
|
|
42
|
-
*/
|
|
43
|
-
function ListViewBlockSelectButton(_ref, ref) {
|
|
44
|
-
let {
|
|
45
|
-
className,
|
|
46
|
-
block,
|
|
47
|
-
onClick,
|
|
48
|
-
onToggleExpanded,
|
|
49
|
-
tabIndex,
|
|
50
|
-
onFocus,
|
|
51
|
-
onDragStart,
|
|
52
|
-
onDragEnd,
|
|
53
|
-
draggable
|
|
54
|
-
} = _ref;
|
|
55
|
-
const {
|
|
56
|
-
clientId
|
|
57
|
-
} = block;
|
|
58
|
-
const blockInformation = (0, _useBlockDisplayInformation.default)(clientId);
|
|
59
|
-
const blockTitle = (0, _useBlockDisplayTitle.default)({
|
|
60
|
-
clientId,
|
|
61
|
-
context: 'list-view'
|
|
62
|
-
});
|
|
63
|
-
const {
|
|
64
|
-
isLocked
|
|
65
|
-
} = (0, _blockLock.useBlockLock)(clientId); // The `href` attribute triggers the browser's native HTML drag operations.
|
|
66
|
-
// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.
|
|
67
|
-
// We need to clear any HTML drag data to prevent `pasteHandler` from firing
|
|
68
|
-
// inside the `useOnBlockDrop` hook.
|
|
69
|
-
|
|
70
|
-
const onDragStartHandler = event => {
|
|
71
|
-
event.dataTransfer.clearData();
|
|
72
|
-
onDragStart === null || onDragStart === void 0 ? void 0 : onDragStart(event);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
function onKeyDownHandler(event) {
|
|
76
|
-
if (event.keyCode === _keycodes.ENTER || event.keyCode === _keycodes.SPACE) {
|
|
77
|
-
onClick(event);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const editAriaLabel = blockInformation ? (0, _i18n.sprintf)( // translators: %s: The title of the block.
|
|
82
|
-
(0, _i18n.__)('Edit %s block'), blockInformation.title) : (0, _i18n.__)('Edit');
|
|
83
|
-
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.Button, {
|
|
84
|
-
className: (0, _classnames.default)('block-editor-list-view-block-select-button', className),
|
|
85
|
-
onClick: onClick,
|
|
86
|
-
onKeyDown: onKeyDownHandler,
|
|
87
|
-
ref: ref,
|
|
88
|
-
tabIndex: tabIndex,
|
|
89
|
-
onFocus: onFocus,
|
|
90
|
-
onDragStart: onDragStartHandler,
|
|
91
|
-
onDragEnd: onDragEnd,
|
|
92
|
-
draggable: draggable,
|
|
93
|
-
href: `#block-${clientId}`,
|
|
94
|
-
"aria-hidden": true,
|
|
95
|
-
title: editAriaLabel
|
|
96
|
-
}, (0, _element.createElement)(_expander.default, {
|
|
97
|
-
onClick: onToggleExpanded
|
|
98
|
-
}), (0, _element.createElement)(_blockIcon.default, {
|
|
99
|
-
icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon,
|
|
100
|
-
showColors: true,
|
|
101
|
-
context: "list-view"
|
|
102
|
-
}), (0, _element.createElement)(_components.__experimentalHStack, {
|
|
103
|
-
alignment: "center",
|
|
104
|
-
className: "block-editor-list-view-block-select-button__label-wrapper",
|
|
105
|
-
justify: "flex-start",
|
|
106
|
-
spacing: 1
|
|
107
|
-
}, (0, _element.createElement)("span", {
|
|
108
|
-
className: "block-editor-list-view-block-select-button__title"
|
|
109
|
-
}, (0, _element.createElement)(_components.__experimentalTruncate, {
|
|
110
|
-
ellipsizeMode: "auto"
|
|
111
|
-
}, blockTitle)), (blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.anchor) && (0, _element.createElement)("span", {
|
|
112
|
-
className: "block-editor-list-view-block-select-button__anchor-wrapper"
|
|
113
|
-
}, (0, _element.createElement)(_components.__experimentalTruncate, {
|
|
114
|
-
className: "block-editor-list-view-block-select-button__anchor",
|
|
115
|
-
ellipsizeMode: "auto"
|
|
116
|
-
}, blockInformation.anchor)), isLocked && (0, _element.createElement)("span", {
|
|
117
|
-
className: "block-editor-list-view-block-select-button__lock"
|
|
118
|
-
}, (0, _element.createElement)(_icons.Icon, {
|
|
119
|
-
icon: _icons.lockSmall
|
|
120
|
-
})))));
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
var _default = (0, _element.forwardRef)(ListViewBlockSelectButton);
|
|
124
|
-
|
|
125
|
-
exports.default = _default;
|
|
126
|
-
//# sourceMappingURL=block-select-button.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/block-select-button.js"],"names":["ListViewBlockSelectButton","ref","className","block","onClick","onToggleExpanded","tabIndex","onFocus","onDragStart","onDragEnd","draggable","clientId","blockInformation","blockTitle","context","isLocked","onDragStartHandler","event","dataTransfer","clearData","onKeyDownHandler","keyCode","ENTER","SPACE","editAriaLabel","title","icon","anchor","lock"],"mappings":";;;;;;;;;AAaA;;AAVA;;AAKA;;AAMA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAzBA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;AAOA,SAASA,yBAAT,OAYCC,GAZD,EAaE;AAAA,MAZD;AACCC,IAAAA,SADD;AAECC,IAAAA,KAFD;AAGCC,IAAAA,OAHD;AAICC,IAAAA,gBAJD;AAKCC,IAAAA,QALD;AAMCC,IAAAA,OAND;AAOCC,IAAAA,WAPD;AAQCC,IAAAA,SARD;AASCC,IAAAA;AATD,GAYC;AACD,QAAM;AAAEC,IAAAA;AAAF,MAAeR,KAArB;AACA,QAAMS,gBAAgB,GAAG,yCAA4BD,QAA5B,CAAzB;AACA,QAAME,UAAU,GAAG,mCAAsB;AACxCF,IAAAA,QADwC;AAExCG,IAAAA,OAAO,EAAE;AAF+B,GAAtB,CAAnB;AAIA,QAAM;AAAEC,IAAAA;AAAF,MAAe,6BAAcJ,QAAd,CAArB,CAPC,CASD;AACA;AACA;AACA;;AACA,QAAMK,kBAAkB,GAAKC,KAAF,IAAa;AACvCA,IAAAA,KAAK,CAACC,YAAN,CAAmBC,SAAnB;AACAX,IAAAA,WAAW,SAAX,IAAAA,WAAW,WAAX,YAAAA,WAAW,CAAIS,KAAJ,CAAX;AACA,GAHD;;AAKA,WAASG,gBAAT,CAA2BH,KA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AAA,gBAAgB,WAAhB,YAAAA,gBAAgB,CAAEe,MAAlB,KACD;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC,4BAAC,kCAAD;AACC,IAAA,SAAS,EAAC,oDADX;AAEC,IAAA,aAAa,EAAC;AAFf,KAIGf,gBAAgB,CAACe,MAJpB,CADD,CAVF,EAmBGZ,QAAQ,IACT;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC,4BAAC,WAAD;AAAM,IAAA,IAAI,EAAGa;AAAb,IADD,CApBF,CAvBD,CADD,CADD;AAqDA;;eAEc,yBAAY5B,yBAAZ,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { forwardRef } from '@wordpress/element';\nimport { Icon, lockSmall as lock } from '@wordpress/icons';\nimport { SPACE, ENTER } from '@wordpress/keycodes';\nimport { sprintf, __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\nimport ListViewExpander from './expander';\nimport { useBlockLock } from '../block-lock';\n\nfunction ListViewBlockSelectButton(\n\t{\n\t\tclassName,\n\t\tblock,\n\t\tonClick,\n\t\tonToggleExpanded,\n\t\ttabIndex,\n\t\tonFocus,\n\t\tonDragStart,\n\t\tonDragEnd,\n\t\tdraggable,\n\t},\n\tref\n) {\n\tconst { clientId } = block;\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId,\n\t\tcontext: 'list-view',\n\t} );\n\tconst { isLocked } = useBlockLock( clientId );\n\n\t// The `href` attribute triggers the browser's native HTML drag operations.\n\t// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.\n\t// We need to clear any HTML drag data to prevent `pasteHandler` from firing\n\t// inside the `useOnBlockDrop` hook.\n\tconst onDragStartHandler = ( event ) => {\n\t\tevent.dataTransfer.clearData();\n\t\tonDragStart?.( event );\n\t};\n\n\tfunction onKeyDownHandler( event ) {\n\t\tif ( event.keyCode === ENTER || event.keyCode === SPACE ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\tconst editAriaLabel = blockInformation\n\t\t? sprintf(\n\t\t\t\t// translators: %s: The title of the block.\n\t\t\t\t__( 'Edit %s block' ),\n\t\t\t\tblockInformation.title\n\t\t )\n\t\t: __( 'Edit' );\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-list-view-block-select-button',\n\t\t\t\t\tclassName\n\t\t\t\t) }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tonKeyDown={ onKeyDownHandler }\n\t\t\t\tref={ ref }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\tonFocus={ onFocus }\n\t\t\t\tonDragStart={ onDragStartHandler }\n\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\tdraggable={ draggable }\n\t\t\t\thref={ `#block-${ clientId }` }\n\t\t\t\taria-hidden={ true }\n\t\t\t\ttitle={ editAriaLabel }\n\t\t\t>\n\t\t\t\t<ListViewExpander onClick={ onToggleExpanded } />\n\t\t\t\t<BlockIcon\n\t\t\t\t\ticon={ blockInformation?.icon }\n\t\t\t\t\tshowColors\n\t\t\t\t\tcontext=\"list-view\"\n\t\t\t\t/>\n\t\t\t\t<HStack\n\t\t\t\t\talignment=\"center\"\n\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__label-wrapper\"\n\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\tspacing={ 1 }\n\t\t\t\t>\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__title\">\n\t\t\t\t\t\t<Truncate ellipsizeMode=\"auto\">{ blockTitle }</Truncate>\n\t\t\t\t\t</span>\n\t\t\t\t\t{ blockInformation?.anchor && (\n\t\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__anchor-wrapper\">\n\t\t\t\t\t\t\t<Truncate\n\t\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__anchor\"\n\t\t\t\t\t\t\t\tellipsizeMode=\"auto\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ blockInformation.anchor }\n\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isLocked && (\n\t\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__lock\">\n\t\t\t\t\t\t\t<Icon icon={ lock } />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t</Button>\n\t\t</>\n\t);\n}\n\nexport default forwardRef( ListViewBlockSelectButton );\n"]}
|
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
|
-
var _blocks = require("@wordpress/blocks");
|
|
15
|
-
|
|
16
|
-
var _components = require("@wordpress/components");
|
|
17
|
-
|
|
18
|
-
var _compose = require("@wordpress/compose");
|
|
19
|
-
|
|
20
|
-
var _icons = require("@wordpress/icons");
|
|
21
|
-
|
|
22
|
-
var _data = require("@wordpress/data");
|
|
23
|
-
|
|
24
|
-
var _i18n = require("@wordpress/i18n");
|
|
25
|
-
|
|
26
|
-
var _leaf = _interopRequireDefault(require("./leaf"));
|
|
27
|
-
|
|
28
|
-
var _button = require("../block-mover/button");
|
|
29
|
-
|
|
30
|
-
var _blockContents = _interopRequireDefault(require("./block-contents"));
|
|
31
|
-
|
|
32
|
-
var _blockSettingsDropdown = _interopRequireDefault(require("../block-settings-menu/block-settings-dropdown"));
|
|
33
|
-
|
|
34
|
-
var _context = require("./context");
|
|
35
|
-
|
|
36
|
-
var _utils = require("./utils");
|
|
37
|
-
|
|
38
|
-
var _store = require("../../store");
|
|
39
|
-
|
|
40
|
-
var _useBlockDisplayInformation = _interopRequireDefault(require("../use-block-display-information"));
|
|
41
|
-
|
|
42
|
-
var _blockLock = require("../block-lock");
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* External dependencies
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* WordPress dependencies
|
|
50
|
-
*/
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Internal dependencies
|
|
54
|
-
*/
|
|
55
|
-
function ListViewBlock(_ref) {
|
|
56
|
-
let {
|
|
57
|
-
block: {
|
|
58
|
-
clientId
|
|
59
|
-
},
|
|
60
|
-
isDragged,
|
|
61
|
-
isSelected,
|
|
62
|
-
isBranchSelected,
|
|
63
|
-
selectBlock,
|
|
64
|
-
position,
|
|
65
|
-
level,
|
|
66
|
-
rowCount,
|
|
67
|
-
siblingBlockCount,
|
|
68
|
-
showBlockMovers,
|
|
69
|
-
path,
|
|
70
|
-
isExpanded,
|
|
71
|
-
selectedClientIds,
|
|
72
|
-
preventAnnouncement
|
|
73
|
-
} = _ref;
|
|
74
|
-
const cellRef = (0, _element.useRef)(null);
|
|
75
|
-
const [isHovered, setIsHovered] = (0, _element.useState)(false);
|
|
76
|
-
const {
|
|
77
|
-
isLocked,
|
|
78
|
-
isContentLocked
|
|
79
|
-
} = (0, _blockLock.useBlockLock)(clientId);
|
|
80
|
-
const forceSelectionContentLock = (0, _data.useSelect)(select => {
|
|
81
|
-
if (isSelected) {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (!isContentLocked) {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return select(_store.store).hasSelectedInnerBlock(clientId, true);
|
|
90
|
-
}, [isContentLocked, clientId, isSelected]);
|
|
91
|
-
const isFirstSelectedBlock = forceSelectionContentLock || isSelected && selectedClientIds[0] === clientId;
|
|
92
|
-
const isLastSelectedBlock = forceSelectionContentLock || isSelected && selectedClientIds[selectedClientIds.length - 1] === clientId;
|
|
93
|
-
const {
|
|
94
|
-
toggleBlockHighlight
|
|
95
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
96
|
-
const blockInformation = (0, _useBlockDisplayInformation.default)(clientId);
|
|
97
|
-
const block = (0, _data.useSelect)(select => select(_store.store).getBlock(clientId), [clientId]); // If ListView has experimental features related to the Persistent List View,
|
|
98
|
-
// only focus the selected list item on mount; otherwise the list would always
|
|
99
|
-
// try to steal the focus from the editor canvas.
|
|
100
|
-
|
|
101
|
-
(0, _element.useEffect)(() => {
|
|
102
|
-
if (!isTreeGridMounted && isSelected) {
|
|
103
|
-
cellRef.current.focus();
|
|
104
|
-
}
|
|
105
|
-
}, []);
|
|
106
|
-
const onMouseEnter = (0, _element.useCallback)(() => {
|
|
107
|
-
setIsHovered(true);
|
|
108
|
-
toggleBlockHighlight(clientId, true);
|
|
109
|
-
}, [clientId, setIsHovered, toggleBlockHighlight]);
|
|
110
|
-
const onMouseLeave = (0, _element.useCallback)(() => {
|
|
111
|
-
setIsHovered(false);
|
|
112
|
-
toggleBlockHighlight(clientId, false);
|
|
113
|
-
}, [clientId, setIsHovered, toggleBlockHighlight]);
|
|
114
|
-
const selectEditorBlock = (0, _element.useCallback)(event => {
|
|
115
|
-
selectBlock(event, clientId);
|
|
116
|
-
event.preventDefault();
|
|
117
|
-
}, [clientId, selectBlock]);
|
|
118
|
-
const updateSelection = (0, _element.useCallback)(newClientId => {
|
|
119
|
-
selectBlock(undefined, newClientId);
|
|
120
|
-
}, [selectBlock]);
|
|
121
|
-
const {
|
|
122
|
-
isTreeGridMounted,
|
|
123
|
-
expand,
|
|
124
|
-
collapse,
|
|
125
|
-
LeafMoreMenu
|
|
126
|
-
} = (0, _context.useListViewContext)();
|
|
127
|
-
const toggleExpanded = (0, _element.useCallback)(event => {
|
|
128
|
-
// Prevent shift+click from opening link in a new window when toggling.
|
|
129
|
-
event.preventDefault();
|
|
130
|
-
event.stopPropagation();
|
|
131
|
-
|
|
132
|
-
if (isExpanded === true) {
|
|
133
|
-
collapse(clientId);
|
|
134
|
-
} else if (isExpanded === false) {
|
|
135
|
-
expand(clientId);
|
|
136
|
-
}
|
|
137
|
-
}, [clientId, expand, collapse, isExpanded]);
|
|
138
|
-
const instanceId = (0, _compose.useInstanceId)(ListViewBlock);
|
|
139
|
-
|
|
140
|
-
if (!block) {
|
|
141
|
-
return null;
|
|
142
|
-
} // When a block hides its toolbar it also hides the block settings menu,
|
|
143
|
-
// since that menu is part of the toolbar in the editor canvas.
|
|
144
|
-
// List View respects this by also hiding the block settings menu.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const showBlockActions = !!block && (0, _blocks.hasBlockSupport)(block.name, '__experimentalToolbar', true);
|
|
148
|
-
const descriptionId = `list-view-block-select-button__${instanceId}`;
|
|
149
|
-
const blockPositionDescription = (0, _utils.getBlockPositionDescription)(position, siblingBlockCount, level);
|
|
150
|
-
let blockAriaLabel = (0, _i18n.__)('Link');
|
|
151
|
-
|
|
152
|
-
if (blockInformation) {
|
|
153
|
-
blockAriaLabel = isLocked ? (0, _i18n.sprintf)( // translators: %s: The title of the block. This string indicates a link to select the locked block.
|
|
154
|
-
(0, _i18n.__)('%s link (locked)'), blockInformation.title) : (0, _i18n.sprintf)( // translators: %s: The title of the block. This string indicates a link to select the block.
|
|
155
|
-
(0, _i18n.__)('%s link'), blockInformation.title);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const settingsAriaLabel = blockInformation ? (0, _i18n.sprintf)( // translators: %s: The title of the block.
|
|
159
|
-
(0, _i18n.__)('Options for %s block'), blockInformation.title) : (0, _i18n.__)('Options');
|
|
160
|
-
const hasSiblings = siblingBlockCount > 0;
|
|
161
|
-
const hasRenderedMovers = showBlockMovers && hasSiblings;
|
|
162
|
-
const moverCellClassName = (0, _classnames.default)('block-editor-list-view-block__mover-cell', {
|
|
163
|
-
'is-visible': isHovered || isSelected
|
|
164
|
-
});
|
|
165
|
-
const listViewBlockSettingsClassName = (0, _classnames.default)('block-editor-list-view-block__menu-cell', {
|
|
166
|
-
'is-visible': isHovered || isFirstSelectedBlock
|
|
167
|
-
});
|
|
168
|
-
let colSpan;
|
|
169
|
-
|
|
170
|
-
if (hasRenderedMovers) {
|
|
171
|
-
colSpan = 1;
|
|
172
|
-
} else if (!showBlockActions) {
|
|
173
|
-
colSpan = 2;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const classes = (0, _classnames.default)({
|
|
177
|
-
'is-selected': isSelected || forceSelectionContentLock,
|
|
178
|
-
'is-first-selected': isFirstSelectedBlock,
|
|
179
|
-
'is-last-selected': isLastSelectedBlock,
|
|
180
|
-
'is-branch-selected': isBranchSelected,
|
|
181
|
-
'is-dragging': isDragged,
|
|
182
|
-
'has-single-cell': !showBlockActions
|
|
183
|
-
}); // Only include all selected blocks if the currently clicked on block
|
|
184
|
-
// is one of the selected blocks. This ensures that if a user attempts
|
|
185
|
-
// to alter a block that isn't part of the selection, they're still able
|
|
186
|
-
// to do so.
|
|
187
|
-
|
|
188
|
-
const dropdownClientIds = selectedClientIds.includes(clientId) ? selectedClientIds : [clientId];
|
|
189
|
-
const MoreMenuComponent = LeafMoreMenu ? LeafMoreMenu : _blockSettingsDropdown.default;
|
|
190
|
-
return (0, _element.createElement)(_leaf.default, {
|
|
191
|
-
className: classes,
|
|
192
|
-
onMouseEnter: onMouseEnter,
|
|
193
|
-
onMouseLeave: onMouseLeave,
|
|
194
|
-
onFocus: onMouseEnter,
|
|
195
|
-
onBlur: onMouseLeave,
|
|
196
|
-
level: level,
|
|
197
|
-
position: position,
|
|
198
|
-
rowCount: rowCount,
|
|
199
|
-
path: path,
|
|
200
|
-
id: `list-view-block-${clientId}`,
|
|
201
|
-
"data-block": clientId,
|
|
202
|
-
isExpanded: isContentLocked ? undefined : isExpanded,
|
|
203
|
-
"aria-selected": !!isSelected || forceSelectionContentLock
|
|
204
|
-
}, (0, _element.createElement)(_components.__experimentalTreeGridCell, {
|
|
205
|
-
className: "block-editor-list-view-block__contents-cell",
|
|
206
|
-
colSpan: colSpan,
|
|
207
|
-
ref: cellRef,
|
|
208
|
-
"aria-label": blockAriaLabel,
|
|
209
|
-
"aria-selected": !!isSelected || forceSelectionContentLock,
|
|
210
|
-
"aria-expanded": isContentLocked ? undefined : isExpanded,
|
|
211
|
-
"aria-describedby": descriptionId
|
|
212
|
-
}, _ref2 => {
|
|
213
|
-
let {
|
|
214
|
-
ref,
|
|
215
|
-
tabIndex,
|
|
216
|
-
onFocus
|
|
217
|
-
} = _ref2;
|
|
218
|
-
return (0, _element.createElement)("div", {
|
|
219
|
-
className: "block-editor-list-view-block__contents-container"
|
|
220
|
-
}, (0, _element.createElement)(_blockContents.default, {
|
|
221
|
-
block: block,
|
|
222
|
-
onClick: selectEditorBlock,
|
|
223
|
-
onToggleExpanded: toggleExpanded,
|
|
224
|
-
isSelected: isSelected,
|
|
225
|
-
position: position,
|
|
226
|
-
siblingBlockCount: siblingBlockCount,
|
|
227
|
-
level: level,
|
|
228
|
-
ref: ref,
|
|
229
|
-
tabIndex: tabIndex,
|
|
230
|
-
onFocus: onFocus,
|
|
231
|
-
isExpanded: isExpanded,
|
|
232
|
-
selectedClientIds: selectedClientIds,
|
|
233
|
-
preventAnnouncement: preventAnnouncement
|
|
234
|
-
}), (0, _element.createElement)("div", {
|
|
235
|
-
className: "block-editor-list-view-block-select-button__description",
|
|
236
|
-
id: descriptionId
|
|
237
|
-
}, blockPositionDescription));
|
|
238
|
-
}), hasRenderedMovers && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.__experimentalTreeGridCell, {
|
|
239
|
-
className: moverCellClassName,
|
|
240
|
-
withoutGridItem: true
|
|
241
|
-
}, (0, _element.createElement)(_components.__experimentalTreeGridItem, null, _ref3 => {
|
|
242
|
-
let {
|
|
243
|
-
ref,
|
|
244
|
-
tabIndex,
|
|
245
|
-
onFocus
|
|
246
|
-
} = _ref3;
|
|
247
|
-
return (0, _element.createElement)(_button.BlockMoverUpButton, {
|
|
248
|
-
orientation: "vertical",
|
|
249
|
-
clientIds: [clientId],
|
|
250
|
-
ref: ref,
|
|
251
|
-
tabIndex: tabIndex,
|
|
252
|
-
onFocus: onFocus
|
|
253
|
-
});
|
|
254
|
-
}), (0, _element.createElement)(_components.__experimentalTreeGridItem, null, _ref4 => {
|
|
255
|
-
let {
|
|
256
|
-
ref,
|
|
257
|
-
tabIndex,
|
|
258
|
-
onFocus
|
|
259
|
-
} = _ref4;
|
|
260
|
-
return (0, _element.createElement)(_button.BlockMoverDownButton, {
|
|
261
|
-
orientation: "vertical",
|
|
262
|
-
clientIds: [clientId],
|
|
263
|
-
ref: ref,
|
|
264
|
-
tabIndex: tabIndex,
|
|
265
|
-
onFocus: onFocus
|
|
266
|
-
});
|
|
267
|
-
}))), showBlockActions && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.__experimentalTreeGridCell, {
|
|
268
|
-
className: listViewBlockSettingsClassName,
|
|
269
|
-
"aria-selected": !!isSelected || forceSelectionContentLock
|
|
270
|
-
}, _ref5 => {
|
|
271
|
-
let {
|
|
272
|
-
ref,
|
|
273
|
-
tabIndex,
|
|
274
|
-
onFocus
|
|
275
|
-
} = _ref5;
|
|
276
|
-
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(MoreMenuComponent, {
|
|
277
|
-
clientIds: dropdownClientIds,
|
|
278
|
-
block: block,
|
|
279
|
-
clientId: clientId,
|
|
280
|
-
icon: _icons.moreVertical,
|
|
281
|
-
label: settingsAriaLabel,
|
|
282
|
-
toggleProps: {
|
|
283
|
-
ref,
|
|
284
|
-
className: 'block-editor-list-view-block__menu',
|
|
285
|
-
tabIndex,
|
|
286
|
-
onFocus
|
|
287
|
-
},
|
|
288
|
-
disableOpenOnArrowDown: true,
|
|
289
|
-
__experimentalSelectBlock: updateSelection
|
|
290
|
-
}));
|
|
291
|
-
})));
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
var _default = (0, _element.memo)(ListViewBlock);
|
|
295
|
-
|
|
296
|
-
exports.default = _default;
|
|
297
|
-
//# sourceMappingURL=block.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/block.js"],"names":["ListViewBlock","block","clientId","isDragged","isSelected","isBranchSelected","selectBlock","position","level","rowCount","siblingBlockCount","showBlockMovers","path","isExpanded","selectedClientIds","preventAnnouncement","cellRef","isHovered","setIsHovered","isLocked","isContentLocked","forceSelectionContentLock","select","blockEditorStore","hasSelectedInnerBlock","isFirstSelectedBlock","isLastSelectedBlock","length","toggleBlockHighlight","blockInformation","getBlock","isTreeGridMounted","current","focus","onMouseEnter","onMouseLeave","selectEditorBlock","event","preventDefault","updateSelection","newClientId","undefined","expand","collapse","LeafMoreMenu","toggleExpanded","stopPropagation","instanceId","showBlockActions","name","descriptionId","blockPositionDescription","blockAriaLabel","title","settingsAriaLabel","hasSiblings","hasRenderedMovers","moverCellClassName","listViewBlockSettingsClassName","colSpan","classes","dropdownClientIds","includes","MoreMenuComponent","BlockSettingsDropdown","ref","tabIndex","onFocus","moreVertical","className"],"mappings":";;;;;;;;;AAeA;;AAZA;;AAKA;;AACA;;AAIA;;AACA;;AAQA;;AACA;;AAKA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAvCA;AACA;AACA;;AAGA;AACA;AACA;;AAkBA;AACA;AACA;AAcA,SAASA,aAAT,OAeI;AAAA,MAfoB;AACvBC,IAAAA,KAAK,EAAE;AAAEC,MAAAA;AAAF,KADgB;AAEvBC,IAAAA,SAFuB;AAGvBC,IAAAA,UA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AA,QAAQ,EAAGC,QAJZ;AAKC,MAAA,OAAO,EAAGC;AALX,MADC;AAAA,GADH,CAJD,EAeC,4BAAC,sCAAD,QACG;AAAA,QAAE;AAAEF,MAAAA,GAAF;AAAOC,MAAAA,QAAP;AAAiBC,MAAAA;AAAjB,KAAF;AAAA,WACD,4BAAC,4BAAD;AACC,MAAA,WAAW,EAAC,UADb;AAEC,MAAA,SAAS,EAAG,CAAEjE,QAAF,CAFb;AAGC,MAAA,GAAG,EAAG+D,GAHP;AAIC,MAAA,QAAQ,EAAGC,QAJZ;AAKC,MAAA,OAAO,EAAGC;AALX,MADC;AAAA,GADH,CAfD,CADD,CAnDF,EAkFGnB,gBAAgB,IACjB,qDACC,4BAAC,sCAAD;AACC,IAAA,SAAS,EAAGU,8BADb;AAEC,qBACC,CAAC,CAAEtD,UAAH,IAAiBiB;AAHnB,KAMG;AAAA,QAAE;AAAE4C,MAAAA,GAAF;AAAOC,MAAAA,QAAP;AAAiBC,MAAAA;AAAjB,KAAF;AAAA,WACD,qDACC,4BAAC,iBAAD;AACC,MAAA,SAAS,EAAGN,iBADb;AAEC,MAAA,KAAK,EAAG5D,KAFT;AAGC,MAAA,QAAQ,EAAGC,QAHZ;AAIC,MAAA,IAAI,EAAGkE,mBAJR;AAKC,MAAA,KAAK,EAAGd,iBALT;AAMC,MAAA,WAAW,EAAG;AACbW,QAAAA,GADa;AAEbI,QAAAA,SAAS,EACR,oCAHY;AAIbH,QAAAA,QAJa;AAKbC,QAAAA;AALa,OANf;AAaC,MAAA,sBAAsB,MAbvB;AAcC,MAAA,yBAAyB,EACxB5B;AAfF,MADD,CADC;AAAA,GANH,CADD,CAnFF,CADD;AAsHA;;eAEc,mBAAMvC,aAAN,C","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\tuseState,\n\tuseRef,\n\tuseEffect,\n\tuseCallback,\n\tmemo,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { sprintf, __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewLeaf from './leaf';\nimport {\n\tBlockMoverUpButton,\n\tBlockMoverDownButton,\n} from '../block-mover/button';\nimport ListViewBlockContents from './block-contents';\nimport BlockSettingsDropdown from '../block-settings-menu/block-settings-dropdown';\nimport { useListViewContext } from './context';\nimport { getBlockPositionDescription } from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { useBlockLock } from '../block-lock';\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\tpreventAnnouncement,\n} ) {\n\tconst cellRef = useRef( null );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\n\tconst { isLocked, isContentLocked } = useBlockLock( clientId );\n\tconst forceSelectionContentLock = useSelect(\n\t\t( select ) => {\n\t\t\tif ( isSelected ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif ( ! isContentLocked ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn select( blockEditorStore ).hasSelectedInnerBlock(\n\t\t\t\tclientId,\n\t\t\t\ttrue\n\t\t\t);\n\t\t},\n\t\t[ isContentLocked, clientId, isSelected ]\n\t);\n\n\tconst isFirstSelectedBlock =\n\t\tforceSelectionContentLock ||\n\t\t( isSelected && selectedClientIds[ 0 ] === clientId );\n\tconst isLastSelectedBlock =\n\t\tforceSelectionContentLock ||\n\t\t( isSelected &&\n\t\t\tselectedClientIds[ selectedClientIds.length - 1 ] === clientId );\n\n\tconst { toggleBlockHighlight } = useDispatch( blockEditorStore );\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst block = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlock( clientId ),\n\t\t[ clientId ]\n\t);\n\n\t// If ListView has experimental features related to the Persistent List View,\n\t// only focus the selected list item on mount; otherwise the list would always\n\t// try to steal the focus from the editor canvas.\n\tuseEffect( () => {\n\t\tif ( ! isTreeGridMounted && isSelected ) {\n\t\t\tcellRef.current.focus();\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 updateSelection = useCallback(\n\t\t( newClientId ) => {\n\t\t\tselectBlock( undefined, newClientId );\n\t\t},\n\t\t[ selectBlock ]\n\t);\n\n\tconst { isTreeGridMounted, expand, collapse, LeafMoreMenu } =\n\t\tuseListViewContext();\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\tconst instanceId = useInstanceId( ListViewBlock );\n\n\tif ( ! block ) {\n\t\treturn null;\n\t}\n\n\t// When a block hides its toolbar it also hides the block settings menu,\n\t// since that menu is part of the toolbar in the editor canvas.\n\t// List View respects this by also hiding the block settings menu.\n\tconst showBlockActions =\n\t\t!! block &&\n\t\thasBlockSupport( block.name, '__experimentalToolbar', true );\n\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\tlet blockAriaLabel = __( 'Link' );\n\tif ( blockInformation ) {\n\t\tblockAriaLabel = isLocked\n\t\t\t? sprintf(\n\t\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\t__( '%s link (locked)' ),\n\t\t\t\t\tblockInformation.title\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %s: The title of the block. This string indicates a link to select the block.\n\t\t\t\t\t__( '%s link' ),\n\t\t\t\t\tblockInformation.title\n\t\t\t );\n\t}\n\n\tconst settingsAriaLabel = blockInformation\n\t\t? sprintf(\n\t\t\t\t// translators: %s: The title of the block.\n\t\t\t\t__( 'Options for %s block' ),\n\t\t\t\tblockInformation.title\n\t\t )\n\t\t: __( 'Options' );\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\tlet colSpan;\n\tif ( hasRenderedMovers ) {\n\t\tcolSpan = 1;\n\t} else if ( ! showBlockActions ) {\n\t\tcolSpan = 2;\n\t}\n\n\tconst classes = classnames( {\n\t\t'is-selected': isSelected || forceSelectionContentLock,\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-dragging': isDragged,\n\t\t'has-single-cell': ! showBlockActions,\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\tconst MoreMenuComponent = LeafMoreMenu\n\t\t? LeafMoreMenu\n\t\t: BlockSettingsDropdown;\n\n\treturn (\n\t\t<ListViewLeaf\n\t\t\tclassName={ classes }\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-block-${ clientId }` }\n\t\t\tdata-block={ clientId }\n\t\t\tisExpanded={ isContentLocked ? undefined : isExpanded }\n\t\t\taria-selected={ !! isSelected || forceSelectionContentLock }\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-label={ blockAriaLabel }\n\t\t\t\taria-selected={ !! isSelected || forceSelectionContentLock }\n\t\t\t\taria-expanded={ isContentLocked ? undefined : isExpanded }\n\t\t\t\taria-describedby={ descriptionId }\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\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={ tabIndex }\n\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\tpreventAnnouncement={ preventAnnouncement }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__description\"\n\t\t\t\t\t\t\tid={ descriptionId }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ blockPositionDescription }\n\t\t\t\t\t\t</div>\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 && (\n\t\t\t\t<>\n\t\t\t\t\t<TreeGridCell\n\t\t\t\t\t\tclassName={ listViewBlockSettingsClassName }\n\t\t\t\t\t\taria-selected={\n\t\t\t\t\t\t\t!! isSelected || forceSelectionContentLock\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<MoreMenuComponent\n\t\t\t\t\t\t\t\t\tclientIds={ dropdownClientIds }\n\t\t\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\t\t\tlabel={ settingsAriaLabel }\n\t\t\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-list-view-block__menu',\n\t\t\t\t\t\t\t\t\t\ttabIndex,\n\t\t\t\t\t\t\t\t\t\tonFocus,\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tdisableOpenOnArrowDown\n\t\t\t\t\t\t\t\t\t__experimentalSelectBlock={\n\t\t\t\t\t\t\t\t\t\tupdateSelection\n\t\t\t\t\t\t\t\t\t}\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</TreeGridCell>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</ListViewLeaf>\n\t);\n}\n\nexport default memo( ListViewBlock );\n"]}
|