@wordpress/block-editor 10.5.0 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/build/autocompleters/block.js +2 -6
- package/build/autocompleters/block.js.map +1 -1
- package/build/autocompleters/link.js +2 -0
- package/build/autocompleters/link.js.map +1 -1
- package/build/components/block-card/index.js +51 -3
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-draggable/index.native.js +46 -39
- package/build/components/block-draggable/index.native.js.map +1 -1
- package/build/components/block-edit/edit.js +4 -3
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-edit/edit.native.js +4 -7
- package/build/components/block-edit/edit.native.js.map +1 -1
- package/build/components/block-inspector/index.js +35 -33
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-list-context.native.js +5 -8
- package/build/components/block-list/block-list-context.native.js.map +1 -1
- package/build/components/block-list/block.js +55 -24
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +61 -28
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +12 -4
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +3 -2
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +33 -11
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-preview/auto.js +9 -3
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +5 -9
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +5 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-toolbar/index.js +5 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +8 -49
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-variation-picker/index.js +1 -2
- package/build/components/block-variation-picker/index.js.map +1 -1
- package/build/components/height-control/index.js +115 -0
- package/build/components/height-control/index.js.map +1 -0
- package/build/components/iframe/index.js +11 -8
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +2 -0
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/image-editor/zoom-dropdown.js +1 -0
- package/build/components/image-editor/zoom-dropdown.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +20 -6
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.js +25 -10
- package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +25 -46
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +3 -1
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-debounced-input.js +27 -0
- package/build/components/inserter/hooks/use-debounced-input.js.map +1 -0
- package/build/components/inserter/index.js +8 -3
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +3 -4
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +103 -0
- package/build/components/inserter/media-tab/hooks.js.map +1 -0
- package/build/components/inserter/media-tab/index.js +32 -0
- package/build/components/inserter/media-tab/index.js.map +1 -0
- package/build/components/inserter/media-tab/media-list.js +100 -0
- package/build/components/inserter/media-tab/media-list.js.map +1 -0
- package/build/components/inserter/media-tab/media-panel.js +96 -0
- package/build/components/inserter/media-tab/media-panel.js.map +1 -0
- package/build/components/inserter/media-tab/media-tab.js +120 -0
- package/build/components/inserter/media-tab/media-tab.js.map +1 -0
- package/build/components/inserter/media-tab/utils.js +54 -0
- package/build/components/inserter/media-tab/utils.js.map +1 -0
- package/build/components/inserter/menu.js +35 -12
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/mobile-tab-navigation.js +70 -0
- package/build/components/inserter/mobile-tab-navigation.js.map +1 -0
- package/build/components/inserter/quick-inserter.js +1 -0
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-results.js +3 -1
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +16 -2
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inserter-list-item/index.js +4 -1
- package/build/components/inserter-list-item/index.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/advanced-controls-panel.js +46 -0
- package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
- package/build/components/inspector-controls-tabs/index.js +71 -0
- package/build/components/inspector-controls-tabs/index.js.map +1 -0
- package/build/components/inspector-controls-tabs/settings-tab.js +28 -0
- package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -0
- package/build/components/inspector-controls-tabs/styles-tab.js +61 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -0
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +97 -0
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
- package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +18 -0
- package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
- package/build/components/inspector-controls-tabs/utils.js +37 -0
- package/build/components/inspector-controls-tabs/utils.js.map +1 -0
- package/build/components/link-control/index.js +1 -0
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +0 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/use-internal-input-value.js +3 -3
- package/build/components/link-control/use-internal-input-value.js.map +1 -1
- package/build/components/list-view/block.js +5 -2
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +13 -12
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/media-upload/index.native.js +2 -3
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +104 -0
- package/build/components/off-canvas-editor/appender.js.map +1 -0
- package/build/components/off-canvas-editor/block-edit-button.js +50 -0
- package/build/components/off-canvas-editor/block-edit-button.js.map +1 -0
- package/build/components/off-canvas-editor/block.js +36 -4
- package/build/components/off-canvas-editor/block.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +3 -5
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +20 -11
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/leaf.js +1 -1
- package/build/components/off-canvas-editor/leaf.js.map +1 -1
- package/build/components/off-canvas-editor/link-ui.js +185 -0
- package/build/components/off-canvas-editor/link-ui.js.map +1 -0
- package/build/components/off-canvas-editor/update-attributes.js +108 -0
- package/build/components/off-canvas-editor/update-attributes.js.map +1 -0
- package/build/components/rich-text/format-toolbar/index.js +8 -4
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/index.js +3 -3
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +0 -2
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-insert-replacement-text.js +43 -0
- package/build/components/rich-text/use-insert-replacement-text.js.map +1 -0
- package/build/components/rich-text/use-undo-automatic-change.js +9 -1
- package/build/components/rich-text/use-undo-automatic-change.js.map +1 -1
- package/build/components/rich-text/utils.js +1 -19
- package/build/components/rich-text/utils.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +12 -3
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/ungroup-button/index.native.js +4 -2
- package/build/components/ungroup-button/index.native.js.map +1 -1
- package/build/components/url-input/index.js +46 -43
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-display-information/index.js +8 -4
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-setting/index.js +9 -1
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/child-layout.js +209 -0
- package/build/hooks/child-layout.js.map +1 -0
- package/build/hooks/content-lock-ui.js +1 -1
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/dimensions.js +25 -7
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/layout.js +57 -1
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/min-height.js +4 -10
- package/build/hooks/min-height.js.map +1 -1
- package/build/store/reducer.js +393 -270
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +57 -47
- package/build/store/selectors.js.map +1 -1
- package/build/utils/sorting.js +63 -0
- package/build/utils/sorting.js.map +1 -0
- package/build-module/autocompleters/block.js +2 -6
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/autocompleters/link.js +2 -0
- package/build-module/autocompleters/link.js.map +1 -1
- package/build-module/components/block-card/index.js +45 -3
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-draggable/index.native.js +40 -31
- package/build-module/components/block-draggable/index.native.js.map +1 -1
- package/build-module/components/block-edit/edit.js +4 -2
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-edit/edit.native.js +4 -6
- package/build-module/components/block-edit/edit.native.js.map +1 -1
- package/build-module/components/block-inspector/index.js +32 -30
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-list-context.native.js +5 -8
- package/build-module/components/block-list/block-list-context.native.js.map +1 -1
- package/build-module/components/block-list/block.js +55 -25
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +61 -28
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +13 -6
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +3 -2
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +35 -13
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +9 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +5 -8
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +5 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +6 -2
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +8 -49
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-variation-picker/index.js +1 -2
- package/build-module/components/block-variation-picker/index.js.map +1 -1
- package/build-module/components/height-control/index.js +103 -0
- package/build-module/components/height-control/index.js.map +1 -0
- package/build-module/components/iframe/index.js +11 -8
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +2 -0
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/image-editor/zoom-dropdown.js +1 -0
- package/build-module/components/image-editor/zoom-dropdown.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +22 -8
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js +23 -10
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +27 -49
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +3 -2
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-debounced-input.js +18 -0
- package/build-module/components/inserter/hooks/use-debounced-input.js.map +1 -0
- package/build-module/components/inserter/index.js +8 -3
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +3 -5
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +89 -0
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -0
- package/build-module/components/inserter/media-tab/index.js +4 -0
- package/build-module/components/inserter/media-tab/index.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-list.js +86 -0
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-panel.js +77 -0
- package/build-module/components/inserter/media-tab/media-panel.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-tab.js +100 -0
- package/build-module/components/inserter/media-tab/media-tab.js.map +1 -0
- package/build-module/components/inserter/media-tab/utils.js +45 -0
- package/build-module/components/inserter/media-tab/utils.js.map +1 -0
- package/build-module/components/inserter/menu.js +33 -12
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js +61 -0
- package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -0
- package/build-module/components/inserter/quick-inserter.js +1 -0
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-results.js +3 -2
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +15 -2
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +5 -2
- package/build-module/components/inserter-list-item/index.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/advanced-controls-panel.js +32 -0
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/index.js +56 -0
- package/build-module/components/inspector-controls-tabs/index.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/settings-tab.js +17 -0
- package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js +46 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +81 -0
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +8 -0
- package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/utils.js +26 -0
- package/build-module/components/inspector-controls-tabs/utils.js.map +1 -0
- package/build-module/components/link-control/index.js +1 -0
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +0 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/use-internal-input-value.js +3 -3
- package/build-module/components/link-control/use-internal-input-value.js.map +1 -1
- package/build-module/components/list-view/block.js +5 -2
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +12 -11
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +2 -4
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +89 -0
- package/build-module/components/off-canvas-editor/appender.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-edit-button.js +35 -0
- package/build-module/components/off-canvas-editor/block-edit-button.js.map +1 -0
- package/build-module/components/off-canvas-editor/block.js +36 -6
- package/build-module/components/off-canvas-editor/block.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +3 -4
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +20 -12
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/leaf.js +1 -1
- package/build-module/components/off-canvas-editor/leaf.js.map +1 -1
- package/build-module/components/off-canvas-editor/link-ui.js +165 -0
- package/build-module/components/off-canvas-editor/link-ui.js.map +1 -0
- package/build-module/components/off-canvas-editor/update-attributes.js +97 -0
- package/build-module/components/off-canvas-editor/update-attributes.js.map +1 -0
- package/build-module/components/rich-text/format-toolbar/index.js +6 -2
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +2 -3
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +0 -2
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-insert-replacement-text.js +33 -0
- package/build-module/components/rich-text/use-insert-replacement-text.js.map +1 -0
- package/build-module/components/rich-text/use-undo-automatic-change.js +9 -1
- package/build-module/components/rich-text/use-undo-automatic-change.js.map +1 -1
- package/build-module/components/rich-text/utils.js +1 -16
- package/build-module/components/rich-text/utils.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -3
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/ungroup-button/index.native.js +3 -2
- package/build-module/components/ungroup-button/index.native.js.map +1 -1
- package/build-module/components/url-input/index.js +46 -43
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +9 -5
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +8 -1
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/child-layout.js +189 -0
- package/build-module/hooks/child-layout.js.map +1 -0
- package/build-module/hooks/content-lock-ui.js +1 -1
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/dimensions.js +25 -8
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/layout.js +55 -0
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/min-height.js +3 -9
- package/build-module/hooks/min-height.js.map +1 -1
- package/build-module/store/reducer.js +391 -271
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +54 -47
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/sorting.js +56 -0
- package/build-module/utils/sorting.js.map +1 -0
- package/build-style/content-rtl.css +701 -0
- package/build-style/content.css +701 -0
- package/build-style/default-editor-styles-rtl.css +14 -0
- package/build-style/default-editor-styles.css +14 -0
- package/build-style/style-rtl.css +286 -662
- package/build-style/style.css +286 -662
- package/package.json +32 -30
- package/src/autocompleters/block.js +2 -6
- package/src/autocompleters/link.js +2 -0
- package/src/components/alignment-control/test/index.js +4 -1
- package/src/components/block-alignment-control/test/index.js +4 -1
- package/src/components/block-card/index.js +46 -2
- package/src/components/block-card/style.scss +4 -0
- package/src/components/block-content-overlay/{style.scss → content.scss} +7 -1
- package/src/components/block-draggable/content.scss +20 -0
- package/src/components/block-draggable/index.native.js +54 -40
- package/src/components/block-draggable/style.scss +0 -21
- package/src/components/block-draggable/test/helpers.native.js +7 -9
- package/src/components/block-draggable/test/index.native.js +35 -45
- package/src/components/block-edit/edit.js +5 -2
- package/src/components/block-edit/edit.native.js +5 -6
- package/src/components/block-inspector/index.js +96 -81
- package/src/components/block-inspector/style.scss +9 -1
- package/src/components/block-list/block-list-context.native.js +5 -8
- package/src/components/block-list/block.js +74 -23
- package/src/components/block-list/block.native.js +78 -23
- package/src/components/block-list/{style.scss → content.scss} +1 -15
- package/src/components/block-list-appender/{style.scss → content.scss} +0 -0
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +24 -6
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +0 -2
- package/src/components/block-pattern-setup/index.js +2 -1
- package/src/components/block-patterns-list/index.js +47 -24
- package/src/components/block-preview/README.md +15 -10
- package/src/components/block-preview/auto.js +7 -1
- package/src/components/block-preview/content.scss +4 -0
- package/src/components/block-preview/index.js +7 -12
- package/src/components/block-preview/style.scss +0 -7
- package/src/components/block-preview/test/index.js +18 -35
- package/src/components/block-selection-clearer/test/index.js +12 -12
- package/src/components/block-settings-menu/block-settings-dropdown.js +32 -20
- package/src/components/block-switcher/test/index.js +4 -0
- package/src/components/block-toolbar/index.js +12 -5
- package/src/components/block-toolbar/style.scss +10 -0
- package/src/components/block-tools/insertion-point.js +3 -47
- package/src/components/block-tools/style.scss +12 -5
- package/src/components/block-variation-picker/index.js +1 -4
- package/src/components/block-vertical-alignment-control/test/index.js +4 -1
- package/src/components/default-block-appender/{style.scss → content.scss} +0 -0
- package/src/components/height-control/index.js +123 -0
- package/src/components/height-control/stories/index.js +21 -0
- package/src/components/height-control/style.scss +5 -0
- package/src/components/iframe/index.js +25 -18
- package/src/components/image-editor/use-save-image.js +2 -0
- package/src/components/image-editor/zoom-dropdown.js +1 -0
- package/src/components/index.js +1 -0
- package/src/components/inner-blocks/{style.scss → content.scss} +0 -0
- package/src/components/inner-blocks/index.js +23 -6
- package/src/components/inner-blocks/use-inner-block-template-sync.js +28 -10
- package/src/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/src/components/inserter/block-patterns-tab.js +28 -71
- package/src/components/inserter/block-types-tab.js +3 -2
- package/src/components/inserter/hooks/use-debounced-input.js +17 -0
- package/src/components/inserter/index.js +10 -2
- package/src/components/inserter/index.native.js +1 -1
- package/src/components/inserter/media-tab/hooks.js +88 -0
- package/src/components/inserter/media-tab/index.js +3 -0
- package/src/components/inserter/media-tab/media-list.js +93 -0
- package/src/components/inserter/media-tab/media-panel.js +83 -0
- package/src/components/inserter/media-tab/media-tab.js +135 -0
- package/src/components/inserter/media-tab/utils.js +37 -0
- package/src/components/inserter/menu.js +55 -13
- package/src/components/inserter/mobile-tab-navigation.js +85 -0
- package/src/components/inserter/quick-inserter.js +1 -0
- package/src/components/inserter/search-results.js +3 -2
- package/src/components/inserter/stories/index.js +1 -1
- package/src/components/inserter/stories/{fixtures.js → utils/fixtures.js} +0 -0
- package/src/components/inserter/style.scss +176 -11
- package/src/components/inserter/tabs.js +12 -1
- package/src/components/inserter-list-item/index.js +11 -1
- package/src/components/inserter-list-item/style.scss +26 -0
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/advanced-controls-panel.js +37 -0
- package/src/components/inspector-controls-tabs/index.js +62 -0
- package/src/components/inspector-controls-tabs/settings-tab.js +18 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +51 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +89 -0
- package/src/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +9 -0
- package/src/components/inspector-controls-tabs/utils.js +28 -0
- package/src/components/line-height-control/test/index.js +5 -5
- package/src/components/link-control/README.md +1 -1
- package/src/components/link-control/index.js +1 -0
- package/src/components/link-control/search-input.js +0 -1
- package/src/components/link-control/test/index.js +188 -401
- package/src/components/link-control/use-internal-input-value.js +3 -3
- package/src/components/list-view/block.js +3 -0
- package/src/components/list-view/branch.js +10 -8
- package/src/components/list-view/style.scss +20 -9
- package/src/components/media-placeholder/{style.scss → content.scss} +0 -0
- package/src/components/media-replace-flow/test/index.js +37 -9
- package/src/components/media-upload/test/index.native.js +2 -0
- package/src/components/off-canvas-editor/appender.js +93 -0
- package/src/components/off-canvas-editor/block-edit-button.js +27 -0
- package/src/components/off-canvas-editor/block.js +88 -22
- package/src/components/off-canvas-editor/branch.js +3 -5
- package/src/components/off-canvas-editor/index.js +59 -33
- package/src/components/off-canvas-editor/leaf.js +5 -1
- package/src/components/off-canvas-editor/link-ui.js +166 -0
- package/src/components/off-canvas-editor/style.scss +17 -388
- package/src/components/off-canvas-editor/update-attributes.js +99 -0
- package/src/components/plain-text/{style.scss → content.scss} +0 -0
- package/src/components/recursion-provider/test/index.js +27 -29
- package/src/components/rich-text/content.scss +42 -0
- package/src/components/rich-text/format-toolbar/index.js +6 -4
- package/src/components/rich-text/index.js +2 -2
- package/src/components/rich-text/index.native.js +0 -2
- package/src/components/rich-text/style.scss +0 -43
- package/src/components/rich-text/use-insert-replacement-text.js +31 -0
- package/src/components/rich-text/use-undo-automatic-change.js +7 -1
- package/src/components/rich-text/utils.js +2 -21
- package/src/components/spacing-sizes-control/spacing-input-control.js +9 -0
- package/src/components/ungroup-button/index.native.js +6 -2
- package/src/components/url-input/index.js +57 -73
- package/src/components/url-popover/test/__snapshots__/index.js.snap +8 -6
- package/src/components/url-popover/test/index.js +21 -9
- package/src/components/use-block-display-information/index.js +14 -5
- package/src/components/use-setting/index.js +13 -1
- package/src/components/use-setting/test/index.js +99 -0
- package/src/content.scss +10 -0
- package/src/hooks/child-layout.js +190 -0
- package/src/hooks/content-lock-ui.js +1 -1
- package/src/hooks/dimensions.js +45 -7
- package/src/hooks/layout.js +60 -0
- package/src/hooks/min-height.js +2 -19
- package/src/store/reducer.js +459 -423
- package/src/store/selectors.js +56 -57
- package/src/store/test/performance.js +71 -0
- package/src/store/test/reducer.js +623 -491
- package/src/store/test/selectors.js +1820 -1306
- package/src/style.scss +4 -7
- package/src/utils/sorting.js +54 -0
- package/src/utils/test/sorting.js +49 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-preview/live.js +0 -30
- package/build/components/block-preview/live.js.map +0 -1
- package/build-module/components/block-preview/live.js +0 -20
- package/build-module/components/block-preview/live.js.map +0 -1
- package/src/components/block-preview/live.js +0 -19
|
@@ -3,6 +3,7 @@ import { createElement } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
+
import { symbol as reusableBlockIcon } from '@wordpress/icons';
|
|
6
7
|
import { useMemo } from '@wordpress/element';
|
|
7
8
|
import { TabPanel } from '@wordpress/components';
|
|
8
9
|
import { __ } from '@wordpress/i18n';
|
|
@@ -22,7 +23,14 @@ const reusableBlocksTab = {
|
|
|
22
23
|
name: 'reusable',
|
|
23
24
|
|
|
24
25
|
/* translators: Reusable blocks tab title in the block inserter. */
|
|
25
|
-
title: __('Reusable')
|
|
26
|
+
title: __('Reusable'),
|
|
27
|
+
icon: reusableBlockIcon
|
|
28
|
+
};
|
|
29
|
+
const mediaTab = {
|
|
30
|
+
name: 'media',
|
|
31
|
+
|
|
32
|
+
/* translators: Media tab title in the block inserter. */
|
|
33
|
+
title: __('Media')
|
|
26
34
|
};
|
|
27
35
|
|
|
28
36
|
function InserterTabs(_ref) {
|
|
@@ -30,6 +38,7 @@ function InserterTabs(_ref) {
|
|
|
30
38
|
children,
|
|
31
39
|
showPatterns = false,
|
|
32
40
|
showReusableBlocks = false,
|
|
41
|
+
showMedia = false,
|
|
33
42
|
onSelect,
|
|
34
43
|
prioritizePatterns
|
|
35
44
|
} = _ref;
|
|
@@ -46,12 +55,16 @@ function InserterTabs(_ref) {
|
|
|
46
55
|
tempTabs.push(patternsTab);
|
|
47
56
|
}
|
|
48
57
|
|
|
58
|
+
if (showMedia) {
|
|
59
|
+
tempTabs.push(mediaTab);
|
|
60
|
+
}
|
|
61
|
+
|
|
49
62
|
if (showReusableBlocks) {
|
|
50
63
|
tempTabs.push(reusableBlocksTab);
|
|
51
64
|
}
|
|
52
65
|
|
|
53
66
|
return tempTabs;
|
|
54
|
-
}, [prioritizePatterns, blocksTab, showPatterns, patternsTab, showReusableBlocks, reusableBlocksTab]);
|
|
67
|
+
}, [prioritizePatterns, blocksTab, showPatterns, patternsTab, showReusableBlocks, showMedia, reusableBlocksTab]);
|
|
55
68
|
return createElement(TabPanel, {
|
|
56
69
|
className: "block-editor-inserter__tabs",
|
|
57
70
|
tabs: tabs,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/tabs.js"],"names":["useMemo","TabPanel","__","blocksTab","name","title","patternsTab","reusableBlocksTab","InserterTabs","children","showPatterns","showReusableBlocks","onSelect","prioritizePatterns","tabs","tempTabs","push"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AACA,SAASC,QAAT,QAAyB,uBAAzB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA,MAAMC,SAAS,GAAG;AACjBC,EAAAA,IAAI,EAAE,QADW;;AAEjB;AACAC,EAAAA,KAAK,EAAEH,EAAE,CAAE,QAAF;AAHQ,CAAlB;AAKA,MAAMI,WAAW,GAAG;AACnBF,EAAAA,IAAI,EAAE,UADa;;AAEnB;AACAC,EAAAA,KAAK,EAAEH,EAAE,CAAE,UAAF;AAHU,CAApB;AAKA,MAAMK,iBAAiB,GAAG;AACzBH,EAAAA,IAAI,EAAE,UADmB;;AAEzB;AACAC,EAAAA,KAAK,EAAEH,EAAE,CAAE,UAAF;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/tabs.js"],"names":["symbol","reusableBlockIcon","useMemo","TabPanel","__","blocksTab","name","title","patternsTab","reusableBlocksTab","icon","mediaTab","InserterTabs","children","showPatterns","showReusableBlocks","showMedia","onSelect","prioritizePatterns","tabs","tempTabs","push"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAM,IAAIC,iBAAnB,QAA4C,kBAA5C;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,QAAT,QAAyB,uBAAzB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA,MAAMC,SAAS,GAAG;AACjBC,EAAAA,IAAI,EAAE,QADW;;AAEjB;AACAC,EAAAA,KAAK,EAAEH,EAAE,CAAE,QAAF;AAHQ,CAAlB;AAKA,MAAMI,WAAW,GAAG;AACnBF,EAAAA,IAAI,EAAE,UADa;;AAEnB;AACAC,EAAAA,KAAK,EAAEH,EAAE,CAAE,UAAF;AAHU,CAApB;AAKA,MAAMK,iBAAiB,GAAG;AACzBH,EAAAA,IAAI,EAAE,UADmB;;AAEzB;AACAC,EAAAA,KAAK,EAAEH,EAAE,CAAE,UAAF,CAHgB;AAIzBM,EAAAA,IAAI,EAAET;AAJmB,CAA1B;AAMA,MAAMU,QAAQ,GAAG;AAChBL,EAAAA,IAAI,EAAE,OADU;;AAEhB;AACAC,EAAAA,KAAK,EAAEH,EAAE,CAAE,OAAF;AAHO,CAAjB;;AAMA,SAASQ,YAAT,OAOI;AAAA,MAPmB;AACtBC,IAAAA,QADsB;AAEtBC,IAAAA,YAAY,GAAG,KAFO;AAGtBC,IAAAA,kBAAkB,GAAG,KAHC;AAItBC,IAAAA,SAAS,GAAG,KAJU;AAKtBC,IAAAA,QALsB;AAMtBC,IAAAA;AANsB,GAOnB;AACH,QAAMC,IAAI,GAAGjB,OAAO,CAAE,MAAM;AAC3B,UAAMkB,QAAQ,GAAG,EAAjB;;AACA,QAAKF,kBAAkB,IAAIJ,YAA3B,EAA0C;AACzCM,MAAAA,QAAQ,CAACC,IAAT,CAAeb,WAAf;AACA;;AACDY,IAAAA,QAAQ,CAACC,IAAT,CAAehB,SAAf;;AACA,QAAK,CAAEa,kBAAF,IAAwBJ,YAA7B,EAA4C;AAC3CM,MAAAA,QAAQ,CAACC,IAAT,CAAeb,WAAf;AACA;;AACD,QAAKQ,SAAL,EAAiB;AAChBI,MAAAA,QAAQ,CAACC,IAAT,CAAeV,QAAf;AACA;;AACD,QAAKI,kBAAL,EAA0B;AACzBK,MAAAA,QAAQ,CAACC,IAAT,CAAeZ,iBAAf;AACA;;AACD,WAAOW,QAAP;AACA,GAhBmB,EAgBjB,CACFF,kBADE,EAEFb,SAFE,EAGFS,YAHE,EAIFN,WAJE,EAKFO,kBALE,EAMFC,SANE,EAOFP,iBAPE,CAhBiB,CAApB;AA0BA,SACC,cAAC,QAAD;AACC,IAAA,SAAS,EAAC,6BADX;AAEC,IAAA,IAAI,EAAGU,IAFR;AAGC,IAAA,QAAQ,EAAGF;AAHZ,KAKGJ,QALH,CADD;AASA;;AAED,eAAeD,YAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { symbol as reusableBlockIcon } from '@wordpress/icons';\nimport { useMemo } from '@wordpress/element';\nimport { TabPanel } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nconst blocksTab = {\n\tname: 'blocks',\n\t/* translators: Blocks tab title in the block inserter. */\n\ttitle: __( 'Blocks' ),\n};\nconst patternsTab = {\n\tname: 'patterns',\n\t/* translators: Patterns tab title in the block inserter. */\n\ttitle: __( 'Patterns' ),\n};\nconst reusableBlocksTab = {\n\tname: 'reusable',\n\t/* translators: Reusable blocks tab title in the block inserter. */\n\ttitle: __( 'Reusable' ),\n\ticon: reusableBlockIcon,\n};\nconst mediaTab = {\n\tname: 'media',\n\t/* translators: Media tab title in the block inserter. */\n\ttitle: __( 'Media' ),\n};\n\nfunction InserterTabs( {\n\tchildren,\n\tshowPatterns = false,\n\tshowReusableBlocks = false,\n\tshowMedia = false,\n\tonSelect,\n\tprioritizePatterns,\n} ) {\n\tconst tabs = useMemo( () => {\n\t\tconst tempTabs = [];\n\t\tif ( prioritizePatterns && showPatterns ) {\n\t\t\ttempTabs.push( patternsTab );\n\t\t}\n\t\ttempTabs.push( blocksTab );\n\t\tif ( ! prioritizePatterns && showPatterns ) {\n\t\t\ttempTabs.push( patternsTab );\n\t\t}\n\t\tif ( showMedia ) {\n\t\t\ttempTabs.push( mediaTab );\n\t\t}\n\t\tif ( showReusableBlocks ) {\n\t\t\ttempTabs.push( reusableBlocksTab );\n\t\t}\n\t\treturn tempTabs;\n\t}, [\n\t\tprioritizePatterns,\n\t\tblocksTab,\n\t\tshowPatterns,\n\t\tpatternsTab,\n\t\tshowReusableBlocks,\n\t\tshowMedia,\n\t\treusableBlocksTab,\n\t] );\n\n\treturn (\n\t\t<TabPanel\n\t\t\tclassName=\"block-editor-inserter__tabs\"\n\t\t\ttabs={ tabs }\n\t\t\tonSelect={ onSelect }\n\t\t>\n\t\t\t{ children }\n\t\t</TabPanel>\n\t);\n}\n\nexport default InserterTabs;\n"]}
|
|
@@ -10,7 +10,7 @@ import classnames from 'classnames';
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { useMemo, useRef, memo } from '@wordpress/element';
|
|
13
|
-
import { createBlock, createBlocksFromInnerBlocksTemplate } from '@wordpress/blocks';
|
|
13
|
+
import { createBlock, createBlocksFromInnerBlocksTemplate, isReusableBlock, isTemplatePart } from '@wordpress/blocks';
|
|
14
14
|
import { __experimentalTruncate as Truncate } from '@wordpress/components';
|
|
15
15
|
import { ENTER, isAppleOS } from '@wordpress/keycodes';
|
|
16
16
|
/**
|
|
@@ -39,6 +39,7 @@ function InserterListItem(_ref) {
|
|
|
39
39
|
const blocks = useMemo(() => {
|
|
40
40
|
return [createBlock(item.name, item.initialAttributes, createBlocksFromInnerBlocksTemplate(item.innerBlocks))];
|
|
41
41
|
}, [item.name, item.initialAttributes, item.initialAttributes]);
|
|
42
|
+
const isSynced = isReusableBlock(item) || isTemplatePart(item);
|
|
42
43
|
return createElement(InserterDraggableBlocks, {
|
|
43
44
|
isEnabled: isDraggable && !item.disabled,
|
|
44
45
|
blocks: blocks,
|
|
@@ -50,7 +51,9 @@ function InserterListItem(_ref) {
|
|
|
50
51
|
onDragEnd
|
|
51
52
|
} = _ref2;
|
|
52
53
|
return createElement("div", {
|
|
53
|
-
className:
|
|
54
|
+
className: classnames('block-editor-block-types-list__list-item', {
|
|
55
|
+
'is-synced': isSynced
|
|
56
|
+
}),
|
|
54
57
|
draggable: draggable,
|
|
55
58
|
onDragStart: event => {
|
|
56
59
|
isDragging.current = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter-list-item/index.js"],"names":["classnames","useMemo","useRef","memo","createBlock","createBlocksFromInnerBlocksTemplate","__experimentalTruncate","Truncate","ENTER","isAppleOS","BlockIcon","InserterListboxItem","InserterDraggableBlocks","InserterListItem","className","isFirst","item","onSelect","onHover","isDraggable","props","isDragging","itemIconStyle","icon","backgroundColor","background","color","foreground","blocks","name","initialAttributes","innerBlocks","disabled","draggable","onDragStart","onDragEnd","event","current","isDisabled","preventDefault","metaKey","ctrlKey","keyCode","title"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,OAAT,EAAkBC,MAAlB,EAA0BC,IAA1B,QAAsC,oBAAtC;AACA,SACCC,WADD,EAECC,mCAFD,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter-list-item/index.js"],"names":["classnames","useMemo","useRef","memo","createBlock","createBlocksFromInnerBlocksTemplate","isReusableBlock","isTemplatePart","__experimentalTruncate","Truncate","ENTER","isAppleOS","BlockIcon","InserterListboxItem","InserterDraggableBlocks","InserterListItem","className","isFirst","item","onSelect","onHover","isDraggable","props","isDragging","itemIconStyle","icon","backgroundColor","background","color","foreground","blocks","name","initialAttributes","innerBlocks","isSynced","disabled","draggable","onDragStart","onDragEnd","event","current","isDisabled","preventDefault","metaKey","ctrlKey","keyCode","title"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,OAAT,EAAkBC,MAAlB,EAA0BC,IAA1B,QAAsC,oBAAtC;AACA,SACCC,WADD,EAECC,mCAFD,EAGCC,eAHD,EAICC,cAJD,QAKO,mBALP;AAMA,SAASC,sBAAsB,IAAIC,QAAnC,QAAmD,uBAAnD;AACA,SAASC,KAAT,EAAgBC,SAAhB,QAAiC,qBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,eAAtB;AACA,SAASC,mBAAT,QAAoC,qBAApC;AACA,OAAOC,uBAAP,MAAoC,8BAApC;;AAEA,SAASC,gBAAT,OAQI;AAAA,MARuB;AAC1BC,IAAAA,SAD0B;AAE1BC,IAAAA,OAF0B;AAG1BC,IAAAA,IAH0B;AAI1BC,IAAAA,QAJ0B;AAK1BC,IAAAA,OAL0B;AAM1BC,IAAAA,WAN0B;AAO1B,OAAGC;AAPuB,GAQvB;AACH,QAAMC,UAAU,GAAGrB,MAAM,CAAE,KAAF,CAAzB;AACA,QAAMsB,aAAa,GAAGN,IAAI,CAACO,IAAL,GACnB;AACAC,IAAAA,eAAe,EAAER,IAAI,CAACO,IAAL,CAAUE,UAD3B;AAEAC,IAAAA,KAAK,EAAEV,IAAI,CAACO,IAAL,CAAUI;AAFjB,GADmB,GAKnB,EALH;AAMA,QAAMC,MAAM,GAAG7B,OAAO,CAAE,MAA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P,IAAI,CAAC4B,KADR,CADD,CAhDD,CAvBD,CADC;AAAA,GALH,CADD;AAwFA;;AAED,eAAe3C,IAAI,CAAEY,gBAAF,CAAnB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useRef, memo } from '@wordpress/element';\nimport {\n\tcreateBlock,\n\tcreateBlocksFromInnerBlocksTemplate,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { __experimentalTruncate as Truncate } from '@wordpress/components';\nimport { ENTER, isAppleOS } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport { InserterListboxItem } from '../inserter-listbox';\nimport InserterDraggableBlocks from '../inserter-draggable-blocks';\n\nfunction InserterListItem( {\n\tclassName,\n\tisFirst,\n\titem,\n\tonSelect,\n\tonHover,\n\tisDraggable,\n\t...props\n} ) {\n\tconst isDragging = useRef( false );\n\tconst itemIconStyle = item.icon\n\t\t? {\n\t\t\t\tbackgroundColor: item.icon.background,\n\t\t\t\tcolor: item.icon.foreground,\n\t\t }\n\t\t: {};\n\tconst blocks = useMemo( () => {\n\t\treturn [\n\t\t\tcreateBlock(\n\t\t\t\titem.name,\n\t\t\t\titem.initialAttributes,\n\t\t\t\tcreateBlocksFromInnerBlocksTemplate( item.innerBlocks )\n\t\t\t),\n\t\t];\n\t}, [ item.name, item.initialAttributes, item.initialAttributes ] );\n\n\tconst isSynced = isReusableBlock( item ) || isTemplatePart( item );\n\n\treturn (\n\t\t<InserterDraggableBlocks\n\t\t\tisEnabled={ isDraggable && ! item.disabled }\n\t\t\tblocks={ blocks }\n\t\t\ticon={ item.icon }\n\t\t>\n\t\t\t{ ( { draggable, onDragStart, onDragEnd } ) => (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-block-types-list__list-item',\n\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'is-synced': isSynced,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tdraggable={ draggable }\n\t\t\t\t\tonDragStart={ ( event ) => {\n\t\t\t\t\t\tisDragging.current = true;\n\t\t\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\t\t\tonHover( null );\n\t\t\t\t\t\t\tonDragStart( event );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonDragEnd={ ( event ) => {\n\t\t\t\t\t\tisDragging.current = false;\n\t\t\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\t\t\tonDragEnd( event );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<InserterListboxItem\n\t\t\t\t\t\tisFirst={ isFirst }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-block-types-list__item',\n\t\t\t\t\t\t\tclassName\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tdisabled={ item.isDisabled }\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tonSelect(\n\t\t\t\t\t\t\t\titem,\n\t\t\t\t\t\t\t\tisAppleOS() ? event.metaKey : event.ctrlKey\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tonHover( null );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\t\t\tconst { keyCode } = event;\n\t\t\t\t\t\t\tif ( keyCode === ENTER ) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tonSelect(\n\t\t\t\t\t\t\t\t\titem,\n\t\t\t\t\t\t\t\t\tisAppleOS() ? event.metaKey : event.ctrlKey\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tonHover( null );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonFocus={ () => {\n\t\t\t\t\t\t\tif ( isDragging.current ) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonHover( item );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonMouseEnter={ () => {\n\t\t\t\t\t\t\tif ( isDragging.current ) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonHover( item );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonMouseLeave={ () => onHover( null ) }\n\t\t\t\t\t\tonBlur={ () => onHover( null ) }\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"block-editor-block-types-list__item-icon\"\n\t\t\t\t\t\t\tstyle={ itemIconStyle }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockIcon icon={ item.icon } showColors />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span className=\"block-editor-block-types-list__item-title\">\n\t\t\t\t\t\t\t<Truncate numberOfLines={ 3 }>\n\t\t\t\t\t\t\t\t{ item.title }\n\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</InserterListboxItem>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</InserterDraggableBlocks>\n\t);\n}\n\nexport default memo( InserterListItem );\n"]}
|
|
@@ -8,12 +8,14 @@ const InspectorControlsBorder = createSlotFill('InspectorControlsBorder');
|
|
|
8
8
|
const InspectorControlsColor = createSlotFill('InspectorControlsColor');
|
|
9
9
|
const InspectorControlsDimensions = createSlotFill('InspectorControlsDimensions');
|
|
10
10
|
const InspectorControlsTypography = createSlotFill('InspectorControlsTypography');
|
|
11
|
+
const InspectorControlsListView = createSlotFill('InspectorControlsListView');
|
|
11
12
|
const groups = {
|
|
12
13
|
default: InspectorControlsDefault,
|
|
13
14
|
advanced: InspectorControlsAdvanced,
|
|
14
15
|
border: InspectorControlsBorder,
|
|
15
16
|
color: InspectorControlsColor,
|
|
16
17
|
dimensions: InspectorControlsDimensions,
|
|
18
|
+
list: InspectorControlsListView,
|
|
17
19
|
typography: InspectorControlsTypography
|
|
18
20
|
};
|
|
19
21
|
export default groups;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/groups.js"],"names":["createSlotFill","InspectorControlsDefault","InspectorControlsAdvanced","InspectorControlsBorder","InspectorControlsColor","InspectorControlsDimensions","InspectorControlsTypography","groups","default","advanced","border","color","dimensions","typography"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,cAAT,QAA+B,uBAA/B;AAEA,MAAMC,wBAAwB,GAAGD,cAAc,CAAE,mBAAF,CAA/C;AACA,MAAME,yBAAyB,GAAGF,cAAc,CAAE,2BAAF,CAAhD;AACA,MAAMG,uBAAuB,GAAGH,cAAc,CAAE,yBAAF,CAA9C;AACA,MAAMI,sBAAsB,GAAGJ,cAAc,CAAE,wBAAF,CAA7C;AACA,MAAMK,2BAA2B,GAAGL,cAAc,CACjD,6BADiD,CAAlD;AAGA,MAAMM,2BAA2B,GAAGN,cAAc,CACjD,6BADiD,CAAlD;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/groups.js"],"names":["createSlotFill","InspectorControlsDefault","InspectorControlsAdvanced","InspectorControlsBorder","InspectorControlsColor","InspectorControlsDimensions","InspectorControlsTypography","InspectorControlsListView","groups","default","advanced","border","color","dimensions","list","typography"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,cAAT,QAA+B,uBAA/B;AAEA,MAAMC,wBAAwB,GAAGD,cAAc,CAAE,mBAAF,CAA/C;AACA,MAAME,yBAAyB,GAAGF,cAAc,CAAE,2BAAF,CAAhD;AACA,MAAMG,uBAAuB,GAAGH,cAAc,CAAE,yBAAF,CAA9C;AACA,MAAMI,sBAAsB,GAAGJ,cAAc,CAAE,wBAAF,CAA7C;AACA,MAAMK,2BAA2B,GAAGL,cAAc,CACjD,6BADiD,CAAlD;AAGA,MAAMM,2BAA2B,GAAGN,cAAc,CACjD,6BADiD,CAAlD;AAGA,MAAMO,yBAAyB,GAAGP,cAAc,CAAE,2BAAF,CAAhD;AAEA,MAAMQ,MAAM,GAAG;AACdC,EAAAA,OAAO,EAAER,wBADK;AAEdS,EAAAA,QAAQ,EAAER,yBAFI;AAGdS,EAAAA,MAAM,EAAER,uBAHM;AAIdS,EAAAA,KAAK,EAAER,sBAJO;AAKdS,EAAAA,UAAU,EAAER,2BALE;AAMdS,EAAAA,IAAI,EAAEP,yBANQ;AAOdQ,EAAAA,UAAU,EAAET;AAPE,CAAf;AAUA,eAAeE,MAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSlotFill } from '@wordpress/components';\n\nconst InspectorControlsDefault = createSlotFill( 'InspectorControls' );\nconst InspectorControlsAdvanced = createSlotFill( 'InspectorAdvancedControls' );\nconst InspectorControlsBorder = createSlotFill( 'InspectorControlsBorder' );\nconst InspectorControlsColor = createSlotFill( 'InspectorControlsColor' );\nconst InspectorControlsDimensions = createSlotFill(\n\t'InspectorControlsDimensions'\n);\nconst InspectorControlsTypography = createSlotFill(\n\t'InspectorControlsTypography'\n);\nconst InspectorControlsListView = createSlotFill( 'InspectorControlsListView' );\n\nconst groups = {\n\tdefault: InspectorControlsDefault,\n\tadvanced: InspectorControlsAdvanced,\n\tborder: InspectorControlsBorder,\n\tcolor: InspectorControlsColor,\n\tdimensions: InspectorControlsDimensions,\n\tlist: InspectorControlsListView,\n\ttypography: InspectorControlsTypography,\n};\n\nexport default groups;\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { PanelBody, __experimentalUseSlotFills as useSlotFills } from '@wordpress/components';
|
|
7
|
+
import { __ } from '@wordpress/i18n';
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { default as InspectorControls, InspectorAdvancedControls } from '../inspector-controls';
|
|
13
|
+
|
|
14
|
+
const AdvancedControls = () => {
|
|
15
|
+
const fills = useSlotFills(InspectorAdvancedControls.slotName);
|
|
16
|
+
const hasFills = Boolean(fills && fills.length);
|
|
17
|
+
|
|
18
|
+
if (!hasFills) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return createElement(PanelBody, {
|
|
23
|
+
className: "block-editor-block-inspector__advanced",
|
|
24
|
+
title: __('Advanced'),
|
|
25
|
+
initialOpen: false
|
|
26
|
+
}, createElement(InspectorControls.Slot, {
|
|
27
|
+
__experimentalGroup: "advanced"
|
|
28
|
+
}));
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default AdvancedControls;
|
|
32
|
+
//# sourceMappingURL=advanced-controls-panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls-tabs/advanced-controls-panel.js"],"names":["PanelBody","__experimentalUseSlotFills","useSlotFills","__","default","InspectorControls","InspectorAdvancedControls","AdvancedControls","fills","slotName","hasFills","Boolean","length"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,SADD,EAECC,0BAA0B,IAAIC,YAF/B,QAGO,uBAHP;AAIA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SACCC,OAAO,IAAIC,iBADZ,EAECC,yBAFD,QAGO,uBAHP;;AAKA,MAAMC,gBAAgB,GAAG,MAAM;AAC9B,QAAMC,KAAK,GAAGN,YAAY,CAAEI,yBAAyB,CAACG,QAA5B,CAA1B;AACA,QAAMC,QAAQ,GAAGC,OAAO,CAAEH,KAAK,IAAIA,KAAK,CAACI,MAAjB,CAAxB;;AAEA,MAAK,CAAEF,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,SACC,cAAC,SAAD;AACC,IAAA,SAAS,EAAC,wCADX;AAEC,IAAA,KAAK,EAAGP,EAAE,CAAE,UAAF,CAFX;AAGC,IAAA,WAAW,EAAG;AAHf,KAKC,cAAC,iBAAD,CAAmB,IAAnB;AAAwB,IAAA,mBAAmB,EAAC;AAA5C,IALD,CADD;AASA,CAjBD;;AAmBA,eAAeI,gBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\t__experimentalUseSlotFills as useSlotFills,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tdefault as InspectorControls,\n\tInspectorAdvancedControls,\n} from '../inspector-controls';\n\nconst AdvancedControls = () => {\n\tconst fills = useSlotFills( InspectorAdvancedControls.slotName );\n\tconst hasFills = Boolean( fills && fills.length );\n\n\tif ( ! hasFills ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PanelBody\n\t\t\tclassName=\"block-editor-block-inspector__advanced\"\n\t\t\ttitle={ __( 'Advanced' ) }\n\t\t\tinitialOpen={ false }\n\t\t>\n\t\t\t<InspectorControls.Slot __experimentalGroup=\"advanced\" />\n\t\t</PanelBody>\n\t);\n};\n\nexport default AdvancedControls;\n"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { TabPanel } from '@wordpress/components';
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { TAB_SETTINGS, TAB_STYLES, TAB_LIST_VIEW } from './utils';
|
|
12
|
+
import SettingsTab from './settings-tab';
|
|
13
|
+
import StylesTab from './styles-tab';
|
|
14
|
+
import InspectorControls from '../inspector-controls';
|
|
15
|
+
import useIsListViewTabDisabled from './use-is-list-view-tab-disabled';
|
|
16
|
+
export default function InspectorControlsTabs(_ref) {
|
|
17
|
+
let {
|
|
18
|
+
blockName,
|
|
19
|
+
clientId,
|
|
20
|
+
hasBlockStyles,
|
|
21
|
+
tabs
|
|
22
|
+
} = _ref;
|
|
23
|
+
// The tabs panel will mount before fills are rendered to the list view
|
|
24
|
+
// slot. This means the list view tab isn't initially included in the
|
|
25
|
+
// available tabs so the panel defaults selection to the styles tab
|
|
26
|
+
// which at the time is the first tab. This check allows blocks known to
|
|
27
|
+
// include the list view tab to set it as the tab selected by default.
|
|
28
|
+
const initialTabName = !useIsListViewTabDisabled(blockName) ? TAB_LIST_VIEW.name : undefined;
|
|
29
|
+
return createElement(TabPanel, {
|
|
30
|
+
className: "block-editor-block-inspector__tabs",
|
|
31
|
+
tabs: tabs,
|
|
32
|
+
initialTabName: initialTabName,
|
|
33
|
+
key: clientId
|
|
34
|
+
}, tab => {
|
|
35
|
+
if (tab.name === TAB_SETTINGS.name) {
|
|
36
|
+
return createElement(SettingsTab, {
|
|
37
|
+
showAdvancedControls: !!blockName
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (tab.name === TAB_STYLES.name) {
|
|
42
|
+
return createElement(StylesTab, {
|
|
43
|
+
blockName: blockName,
|
|
44
|
+
clientId: clientId,
|
|
45
|
+
hasBlockStyles: hasBlockStyles
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (tab.name === TAB_LIST_VIEW.name) {
|
|
50
|
+
return createElement(InspectorControls.Slot, {
|
|
51
|
+
__experimentalGroup: "list"
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls-tabs/index.js"],"names":["TabPanel","TAB_SETTINGS","TAB_STYLES","TAB_LIST_VIEW","SettingsTab","StylesTab","InspectorControls","useIsListViewTabDisabled","InspectorControlsTabs","blockName","clientId","hasBlockStyles","tabs","initialTabName","name","undefined","tab"],"mappings":";;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dependencies\n */\nimport { TabPanel } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { TAB_SETTINGS, TAB_STYLES, TAB_LIST_VIEW } from './utils';\nimport SettingsTab from './settings-tab';\nimport StylesTab from './styles-tab';\nimport InspectorControls from '../inspector-controls';\nimport useIsListViewTabDisabled from './use-is-list-view-tab-disabled';\n\nexport default function InspectorControlsTabs( {\n\tblockName,\n\tclientId,\n\thasBlockStyles,\n\ttabs,\n} ) {\n\t// The tabs panel will mount before fills are rendered to the list view\n\t// slot. This means the list view tab isn't initially included in the\n\t// available tabs so the panel defaults selection to the styles tab\n\t// which at the time is the first tab. This check allows blocks known to\n\t// include the list view tab to set it as the tab selected by default.\n\tconst initialTabName = ! useIsListViewTabDisabled( blockName )\n\t\t? TAB_LIST_VIEW.name\n\t\t: undefined;\n\n\treturn (\n\t\t<TabPanel\n\t\t\tclassName=\"block-editor-block-inspector__tabs\"\n\t\t\ttabs={ tabs }\n\t\t\tinitialTabName={ initialTabName }\n\t\t\tkey={ clientId }\n\t\t>\n\t\t\t{ ( tab ) => {\n\t\t\t\tif ( tab.name === TAB_SETTINGS.name ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<SettingsTab showAdvancedControls={ !! blockName } />\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif ( tab.name === TAB_STYLES.name ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<StylesTab\n\t\t\t\t\t\t\tblockName={ blockName }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\thasBlockStyles={ hasBlockStyles }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif ( tab.name === TAB_LIST_VIEW.name ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<InspectorControls.Slot __experimentalGroup=\"list\" />\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} }\n\t\t</TabPanel>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Internal dependencies
|
|
5
|
+
*/
|
|
6
|
+
import AdvancedControls from './advanced-controls-panel';
|
|
7
|
+
import { default as InspectorControls } from '../inspector-controls';
|
|
8
|
+
|
|
9
|
+
const SettingsTab = _ref => {
|
|
10
|
+
let {
|
|
11
|
+
showAdvancedControls = false
|
|
12
|
+
} = _ref;
|
|
13
|
+
return createElement(Fragment, null, createElement(InspectorControls.Slot, null), showAdvancedControls && createElement("div", null, createElement(AdvancedControls, null)));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default SettingsTab;
|
|
17
|
+
//# sourceMappingURL=settings-tab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls-tabs/settings-tab.js"],"names":["AdvancedControls","default","InspectorControls","SettingsTab","showAdvancedControls"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,gBAAP,MAA6B,2BAA7B;AACA,SAASC,OAAO,IAAIC,iBAApB,QAA6C,uBAA7C;;AAEA,MAAMC,WAAW,GAAG;AAAA,MAAE;AAAEC,IAAAA,oBAAoB,GAAG;AAAzB,GAAF;AAAA,SACnB,8BACC,cAAC,iBAAD,CAAmB,IAAnB,OADD,EAEGA,oBAAoB,IACrB,2BACC,cAAC,gBAAD,OADD,CAHF,CADmB;AAAA,CAApB;;AAWA,eAAeD,WAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport AdvancedControls from './advanced-controls-panel';\nimport { default as InspectorControls } from '../inspector-controls';\n\nconst SettingsTab = ( { showAdvancedControls = false } ) => (\n\t<>\n\t\t<InspectorControls.Slot />\n\t\t{ showAdvancedControls && (\n\t\t\t<div>\n\t\t\t\t<AdvancedControls />\n\t\t\t</div>\n\t\t) }\n\t</>\n);\n\nexport default SettingsTab;\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { hasBlockSupport } from '@wordpress/blocks';
|
|
7
|
+
import { PanelBody } from '@wordpress/components';
|
|
8
|
+
import { __ } from '@wordpress/i18n';
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import BlockStyles from '../block-styles';
|
|
14
|
+
import DefaultStylePicker from '../default-style-picker';
|
|
15
|
+
import InspectorControls from '../inspector-controls';
|
|
16
|
+
|
|
17
|
+
const StylesTab = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
blockName,
|
|
20
|
+
clientId,
|
|
21
|
+
hasBlockStyles
|
|
22
|
+
} = _ref;
|
|
23
|
+
return createElement(Fragment, null, hasBlockStyles && createElement("div", null, createElement(PanelBody, {
|
|
24
|
+
title: __('Styles')
|
|
25
|
+
}, createElement(BlockStyles, {
|
|
26
|
+
clientId: clientId
|
|
27
|
+
}), hasBlockSupport(blockName, 'defaultStylePicker', true) && createElement(DefaultStylePicker, {
|
|
28
|
+
blockName: blockName
|
|
29
|
+
}))), createElement(InspectorControls.Slot, {
|
|
30
|
+
__experimentalGroup: "color",
|
|
31
|
+
label: __('Color'),
|
|
32
|
+
className: "color-block-support-panel__inner-wrapper"
|
|
33
|
+
}), createElement(InspectorControls.Slot, {
|
|
34
|
+
__experimentalGroup: "typography",
|
|
35
|
+
label: __('Typography')
|
|
36
|
+
}), createElement(InspectorControls.Slot, {
|
|
37
|
+
__experimentalGroup: "dimensions",
|
|
38
|
+
label: __('Dimensions')
|
|
39
|
+
}), createElement(InspectorControls.Slot, {
|
|
40
|
+
__experimentalGroup: "border",
|
|
41
|
+
label: __('Border')
|
|
42
|
+
}));
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default StylesTab;
|
|
46
|
+
//# sourceMappingURL=styles-tab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls-tabs/styles-tab.js"],"names":["hasBlockSupport","PanelBody","__","BlockStyles","DefaultStylePicker","InspectorControls","StylesTab","blockName","clientId","hasBlockStyles"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,mBAAhC;AACA,SAASC,SAAT,QAA0B,uBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;;AAEA,MAAMC,SAAS,GAAG,QAA+C;AAAA,MAA7C;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,QAAb;AAAuBC,IAAAA;AAAvB,GAA6C;AAChE,SACC,8BACGA,cAAc,IACf,2BACC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAGP,EAAE,CAAE,QAAF;AAArB,KACC,cAAC,WAAD;AAAa,IAAA,QAAQ,EAAGM;AAAxB,IADD,EAEGR,eAAe,CAChBO,SADgB,EAEhB,oBAFgB,EAGhB,IAHgB,CAAf,IAIG,cAAC,kBAAD;AAAoB,IAAA,SAAS,EAAGA;AAAhC,IANN,CADD,CAFF,EAaC,cAAC,iBAAD,CAAmB,IAAnB;AACC,IAAA,mBAAmB,EAAC,OADrB;AAEC,IAAA,KAAK,EAAGL,EAAE,CAAE,OAAF,CAFX;AAGC,IAAA,SAAS,EAAC;AAHX,IAbD,EAkBC,cAAC,iBAAD,CAAmB,IAAnB;AACC,IAAA,mBAAmB,EAAC,YADrB;AAEC,IAAA,KAAK,EAAGA,EAAE,CAAE,YAAF;AAFX,IAlBD,EAsBC,cAAC,iBAAD,CAAmB,IAAnB;AACC,IAAA,mBAAmB,EAAC,YADrB;AAEC,IAAA,KAAK,EAAGA,EAAE,CAAE,YAAF;AAFX,IAtBD,EA0BC,cAAC,iBAAD,CAAmB,IAAnB;AACC,IAAA,mBAAmB,EAAC,QADrB;AAEC,IAAA,KAAK,EAAGA,EAAE,CAAE,QAAF;AAFX,IA1BD,CADD;AAiCA,CAlCD;;AAoCA,eAAeI,SAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { PanelBody } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockStyles from '../block-styles';\nimport DefaultStylePicker from '../default-style-picker';\nimport InspectorControls from '../inspector-controls';\n\nconst StylesTab = ( { blockName, clientId, hasBlockStyles } ) => {\n\treturn (\n\t\t<>\n\t\t\t{ hasBlockStyles && (\n\t\t\t\t<div>\n\t\t\t\t\t<PanelBody title={ __( 'Styles' ) }>\n\t\t\t\t\t\t<BlockStyles clientId={ clientId } />\n\t\t\t\t\t\t{ hasBlockSupport(\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\t'defaultStylePicker',\n\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t) && <DefaultStylePicker blockName={ blockName } /> }\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<InspectorControls.Slot\n\t\t\t\t__experimentalGroup=\"color\"\n\t\t\t\tlabel={ __( 'Color' ) }\n\t\t\t\tclassName=\"color-block-support-panel__inner-wrapper\"\n\t\t\t/>\n\t\t\t<InspectorControls.Slot\n\t\t\t\t__experimentalGroup=\"typography\"\n\t\t\t\tlabel={ __( 'Typography' ) }\n\t\t\t/>\n\t\t\t<InspectorControls.Slot\n\t\t\t\t__experimentalGroup=\"dimensions\"\n\t\t\t\tlabel={ __( 'Dimensions' ) }\n\t\t\t/>\n\t\t\t<InspectorControls.Slot\n\t\t\t\t__experimentalGroup=\"border\"\n\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t/>\n\t\t</>\n\t);\n};\n\nexport default StylesTab;\n"]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __experimentalUseSlotFills as useSlotFills } from '@wordpress/components';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import InspectorControlsGroups from '../inspector-controls/groups';
|
|
11
|
+
import useIsListViewTabDisabled from './use-is-list-view-tab-disabled';
|
|
12
|
+
import { InspectorAdvancedControls } from '../inspector-controls';
|
|
13
|
+
import { TAB_LIST_VIEW, TAB_SETTINGS, TAB_STYLES } from './utils';
|
|
14
|
+
import { store as blockEditorStore } from '../../store';
|
|
15
|
+
const EMPTY_ARRAY = [];
|
|
16
|
+
|
|
17
|
+
function getShowTabs(blockName) {
|
|
18
|
+
var _window;
|
|
19
|
+
|
|
20
|
+
let tabSettings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
21
|
+
|
|
22
|
+
// Don't allow settings to force the display of tabs if the block inspector
|
|
23
|
+
// tabs experiment hasn't been opted into.
|
|
24
|
+
if (!((_window = window) !== null && _window !== void 0 && _window.__experimentalEnableBlockInspectorTabs)) {
|
|
25
|
+
return false;
|
|
26
|
+
} // Block specific setting takes precedence over generic default.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
if (tabSettings[blockName] !== undefined) {
|
|
30
|
+
return tabSettings[blockName];
|
|
31
|
+
} // Use generic default if set over the Gutenberg experiment option.
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
if (tabSettings.default !== undefined) {
|
|
35
|
+
return tabSettings.default;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default function useInspectorControlsTabs(blockName) {
|
|
42
|
+
const tabs = [];
|
|
43
|
+
const {
|
|
44
|
+
border: borderGroup,
|
|
45
|
+
color: colorGroup,
|
|
46
|
+
default: defaultGroup,
|
|
47
|
+
dimensions: dimensionsGroup,
|
|
48
|
+
list: listGroup,
|
|
49
|
+
typography: typographyGroup
|
|
50
|
+
} = InspectorControlsGroups; // List View Tab: If there are any fills for the list group add that tab.
|
|
51
|
+
|
|
52
|
+
const listViewDisabled = useIsListViewTabDisabled(blockName);
|
|
53
|
+
const listFills = useSlotFills(listGroup.Slot.__unstableName);
|
|
54
|
+
|
|
55
|
+
if (!listViewDisabled && !!listFills && listFills.length) {
|
|
56
|
+
tabs.push(TAB_LIST_VIEW);
|
|
57
|
+
} // Styles Tab: Add this tab if there are any fills for block supports
|
|
58
|
+
// e.g. border, color, spacing, typography, etc.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
const styleFills = [...(useSlotFills(borderGroup.Slot.__unstableName) || []), ...(useSlotFills(colorGroup.Slot.__unstableName) || []), ...(useSlotFills(dimensionsGroup.Slot.__unstableName) || []), ...(useSlotFills(typographyGroup.Slot.__unstableName) || [])];
|
|
62
|
+
|
|
63
|
+
if (styleFills.length) {
|
|
64
|
+
tabs.push(TAB_STYLES);
|
|
65
|
+
} // Settings Tab: If there are any fills for the general InspectorControls
|
|
66
|
+
// or Advanced Controls slot, then add this tab.
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
const settingsFills = [...(useSlotFills(defaultGroup.Slot.__unstableName) || []), ...(useSlotFills(InspectorAdvancedControls.slotName) || [])];
|
|
70
|
+
|
|
71
|
+
if (settingsFills.length) {
|
|
72
|
+
tabs.push(TAB_SETTINGS);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const tabSettings = useSelect(select => {
|
|
76
|
+
return select(blockEditorStore).getSettings().__experimentalBlockInspectorTabs;
|
|
77
|
+
}, []);
|
|
78
|
+
const showTabs = getShowTabs(blockName, tabSettings);
|
|
79
|
+
return showTabs ? tabs : EMPTY_ARRAY;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=use-inspector-controls-tabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js"],"names":["__experimentalUseSlotFills","useSlotFills","useSelect","InspectorControlsGroups","useIsListViewTabDisabled","InspectorAdvancedControls","TAB_LIST_VIEW","TAB_SETTINGS","TAB_STYLES","store","blockEditorStore","EMPTY_ARRAY","getShowTabs","blockName","tabSettings","window","__experimentalEnableBlockInspectorTabs","undefined","default","useInspectorControlsTabs","tabs","border","borderGroup","color","colorGroup","defaultGroup","dimensions","dimensionsGroup","list","listGroup","typography","typographyGroup","listViewDisabled","listFills","Slot","__unstableName","length","push","styleFills","settingsFills","slotName","select","getSettings","__experimentalBlockInspectorTabs","showTabs"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,0BAA0B,IAAIC,YAAvC,QAA2D,uBAA3D;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,OAAOC,wBAAP,MAAqC,iCAArC;AACA,SAASC,yBAAT,QAA0C,uBAA1C;AACA,SAASC,aAAT,EAAwBC,YAAxB,EAAsCC,UAAtC,QAAwD,SAAxD;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,MAAMC,WAAW,GAAG,EAApB;;AAEA,SAASC,WAAT,CAAsBC,SAAtB,EAAoD;AAAA;;AAAA,MAAnBC,WAAmB,uEAAL,EAAK;;AACnD;AACA;AACA,MAAK,aAAEC,MAAF,oCAAE,QAAQC,sCAAV,CAAL,EAAwD;AACvD,WAAO,KAAP;AACA,GALkD,CAOnD;;;AACA,MAAKF,WAAW,CAAED,SAAF,CAAX,KAA6BI,SAAlC,EAA8C;AAC7C,WAAOH,WAAW,CAAED,SAAF,CAAlB;AACA,GAVkD,CAYnD;;;AACA,MAAKC,WAAW,CAACI,OAAZ,KAAwBD,SAA7B,EAAyC;AACxC,WAAOH,WAAW,CAACI,OAAnB;AACA;;AAED,SAAO,IAAP;AACA;;AAED,eAAe,SAASC,wBAAT,CAAmCN,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AErB,IAAKlC,YAAY,CAAEI,yBAAyB,CAACmC,QAA5B,CAAZ,IAAsD,EAA3D,CAFqB,CAAtB;;AAKA,MAAKD,aAAa,CAACH,MAAnB,EAA4B;AAC3BhB,IAAAA,IAAI,CAACiB,IAAL,CAAW9B,YAAX;AACA;;AAED,QAAMO,WAAW,GAAGZ,SAAS,CAAIuC,MAAF,IAAc;AAC5C,WAAOA,MAAM,CAAE/B,gBAAF,CAAN,CAA2BgC,WAA3B,GACLC,gCADF;AAEA,GAH4B,EAG1B,EAH0B,CAA7B;AAKA,QAAMC,QAAQ,GAAGhC,WAAW,CAAEC,SAAF,EAAaC,WAAb,CAA5B;AAEA,SAAO8B,QAAQ,GAAGxB,IAAH,GAAUT,WAAzB;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalUseSlotFills as useSlotFills } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport InspectorControlsGroups from '../inspector-controls/groups';\nimport useIsListViewTabDisabled from './use-is-list-view-tab-disabled';\nimport { InspectorAdvancedControls } from '../inspector-controls';\nimport { TAB_LIST_VIEW, TAB_SETTINGS, TAB_STYLES } from './utils';\nimport { store as blockEditorStore } from '../../store';\n\nconst EMPTY_ARRAY = [];\n\nfunction getShowTabs( blockName, tabSettings = {} ) {\n\t// Don't allow settings to force the display of tabs if the block inspector\n\t// tabs experiment hasn't been opted into.\n\tif ( ! window?.__experimentalEnableBlockInspectorTabs ) {\n\t\treturn false;\n\t}\n\n\t// Block specific setting takes precedence over generic default.\n\tif ( tabSettings[ blockName ] !== undefined ) {\n\t\treturn tabSettings[ blockName ];\n\t}\n\n\t// Use generic default if set over the Gutenberg experiment option.\n\tif ( tabSettings.default !== undefined ) {\n\t\treturn tabSettings.default;\n\t}\n\n\treturn true;\n}\n\nexport default function useInspectorControlsTabs( blockName ) {\n\tconst tabs = [];\n\tconst {\n\t\tborder: borderGroup,\n\t\tcolor: colorGroup,\n\t\tdefault: defaultGroup,\n\t\tdimensions: dimensionsGroup,\n\t\tlist: listGroup,\n\t\ttypography: typographyGroup,\n\t} = InspectorControlsGroups;\n\n\t// List View Tab: If there are any fills for the list group add that tab.\n\tconst listViewDisabled = useIsListViewTabDisabled( blockName );\n\tconst listFills = useSlotFills( listGroup.Slot.__unstableName );\n\n\tif ( ! listViewDisabled && !! listFills && listFills.length ) {\n\t\ttabs.push( TAB_LIST_VIEW );\n\t}\n\n\t// Styles Tab: Add this tab if there are any fills for block supports\n\t// e.g. border, color, spacing, typography, etc.\n\tconst styleFills = [\n\t\t...( useSlotFills( borderGroup.Slot.__unstableName ) || [] ),\n\t\t...( useSlotFills( colorGroup.Slot.__unstableName ) || [] ),\n\t\t...( useSlotFills( dimensionsGroup.Slot.__unstableName ) || [] ),\n\t\t...( useSlotFills( typographyGroup.Slot.__unstableName ) || [] ),\n\t];\n\n\tif ( styleFills.length ) {\n\t\ttabs.push( TAB_STYLES );\n\t}\n\n\t// Settings Tab: If there are any fills for the general InspectorControls\n\t// or Advanced Controls slot, then add this tab.\n\tconst settingsFills = [\n\t\t...( useSlotFills( defaultGroup.Slot.__unstableName ) || [] ),\n\t\t...( useSlotFills( InspectorAdvancedControls.slotName ) || [] ),\n\t];\n\n\tif ( settingsFills.length ) {\n\t\ttabs.push( TAB_SETTINGS );\n\t}\n\n\tconst tabSettings = useSelect( ( select ) => {\n\t\treturn select( blockEditorStore ).getSettings()\n\t\t\t.__experimentalBlockInspectorTabs;\n\t}, [] );\n\n\tconst showTabs = getShowTabs( blockName, tabSettings );\n\n\treturn showTabs ? tabs : EMPTY_ARRAY;\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// List view tab restricts the blocks that may render to it via the
|
|
2
|
+
// allowlist below.
|
|
3
|
+
const allowlist = ['core/navigation'];
|
|
4
|
+
export const useIsListViewTabDisabled = blockName => {
|
|
5
|
+
return !allowlist.includes(blockName);
|
|
6
|
+
};
|
|
7
|
+
export default useIsListViewTabDisabled;
|
|
8
|
+
//# sourceMappingURL=use-is-list-view-tab-disabled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js"],"names":["allowlist","useIsListViewTabDisabled","blockName","includes"],"mappings":"AAAA;AACA;AACA,MAAMA,SAAS,GAAG,CAAE,iBAAF,CAAlB;AAEA,OAAO,MAAMC,wBAAwB,GAAKC,SAAF,IAAiB;AACxD,SAAO,CAAEF,SAAS,CAACG,QAAV,CAAoBD,SAApB,CAAT;AACA,CAFM;AAIP,eAAeD,wBAAf","sourcesContent":["// List view tab restricts the blocks that may render to it via the\n// allowlist below.\nconst allowlist = [ 'core/navigation' ];\n\nexport const useIsListViewTabDisabled = ( blockName ) => {\n\treturn ! allowlist.includes( blockName );\n};\n\nexport default useIsListViewTabDisabled;\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { cog, styles, listView } from '@wordpress/icons';
|
|
5
|
+
export const TAB_SETTINGS = {
|
|
6
|
+
name: 'settings',
|
|
7
|
+
title: 'Settings',
|
|
8
|
+
value: 'settings',
|
|
9
|
+
icon: cog,
|
|
10
|
+
className: 'block-editor-block-inspector__tab-item'
|
|
11
|
+
};
|
|
12
|
+
export const TAB_STYLES = {
|
|
13
|
+
name: 'styles',
|
|
14
|
+
title: 'Styles',
|
|
15
|
+
value: 'styles',
|
|
16
|
+
icon: styles,
|
|
17
|
+
className: 'block-editor-block-inspector__tab-item'
|
|
18
|
+
};
|
|
19
|
+
export const TAB_LIST_VIEW = {
|
|
20
|
+
name: 'list',
|
|
21
|
+
title: 'List View',
|
|
22
|
+
value: 'list-view',
|
|
23
|
+
icon: listView,
|
|
24
|
+
className: 'block-editor-block-inspector__tab-item'
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls-tabs/utils.js"],"names":["cog","styles","listView","TAB_SETTINGS","name","title","value","icon","className","TAB_STYLES","TAB_LIST_VIEW"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,EAAcC,MAAd,EAAsBC,QAAtB,QAAsC,kBAAtC;AAEA,OAAO,MAAMC,YAAY,GAAG;AAC3BC,EAAAA,IAAI,EAAE,UADqB;AAE3BC,EAAAA,KAAK,EAAE,UAFoB;AAG3BC,EAAAA,KAAK,EAAE,UAHoB;AAI3BC,EAAAA,IAAI,EAAEP,GAJqB;AAK3BQ,EAAAA,SAAS,EAAE;AALgB,CAArB;AAQP,OAAO,MAAMC,UAAU,GAAG;AACzBL,EAAAA,IAAI,EAAE,QADmB;AAEzBC,EAAAA,KAAK,EAAE,QAFkB;AAGzBC,EAAAA,KAAK,EAAE,QAHkB;AAIzBC,EAAAA,IAAI,EAAEN,MAJmB;AAKzBO,EAAAA,SAAS,EAAE;AALc,CAAnB;AAQP,OAAO,MAAME,aAAa,GAAG;AAC5BN,EAAAA,IAAI,EAAE,MADsB;AAE5BC,EAAAA,KAAK,EAAE,WAFqB;AAG5BC,EAAAA,KAAK,EAAE,WAHqB;AAI5BC,EAAAA,IAAI,EAAEL,QAJsB;AAK5BM,EAAAA,SAAS,EAAE;AALiB,CAAtB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cog, styles, listView } from '@wordpress/icons';\n\nexport const TAB_SETTINGS = {\n\tname: 'settings',\n\ttitle: 'Settings',\n\tvalue: 'settings',\n\ticon: cog,\n\tclassName: 'block-editor-block-inspector__tab-item',\n};\n\nexport const TAB_STYLES = {\n\tname: 'styles',\n\ttitle: 'Styles',\n\tvalue: 'styles',\n\ticon: styles,\n\tclassName: 'block-editor-block-inspector__tab-item',\n};\n\nexport const TAB_LIST_VIEW = {\n\tname: 'list',\n\ttitle: 'List View',\n\tvalue: 'list-view',\n\ticon: listView,\n\tclassName: 'block-editor-block-inspector__tab-item',\n};\n"]}
|
|
@@ -96,6 +96,7 @@ import { DEFAULT_LINK_SETTINGS } from './constants';
|
|
|
96
96
|
* @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.
|
|
97
97
|
* @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.
|
|
98
98
|
* @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.
|
|
99
|
+
* @property {boolean=} hasTextControl Whether to add a text field to the UI to update the value.title.
|
|
99
100
|
* @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.
|
|
100
101
|
* @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.
|
|
101
102
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/index.js"],"names":["classnames","Button","Spinner","Notice","TextControl","keyboardReturn","__","useRef","useState","useEffect","focus","ENTER","LinkControlSettingsDrawer","LinkControlSearchInput","LinkPreview","useCreatePage","useInternalInputValue","ViewerFill","DEFAULT_LINK_SETTINGS","noop","LinkControl","searchInputPlaceholder","value","settings","onChange","onRemove","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","isMounting","wrapperNode","textInputRef","isEndingEditWithFocus","internalUrlInputValue","setInternalUrlInputValue","url","internalTextInputValue","setInternalTextInputValue","title","isEditingLink","setIsEditingLink","createPage","isCreatingPage","errorMessage","current","whichFocusTargetIndex","nextFocusTarget","focusable","find","stopEditing","contains","ownerDocument","activeElement","handleSelectSuggestion","updatedValue","handleSubmit","currentUrlInputValue","handleSubmitWithEnter","event","keyCode","currentInputIsEmpty","preventDefault","trim","length","shownUnlinkControl","showSettingsDrawer","showTextControl"],"mappings":";;AAAA;AACA;AACA;AACA,OAAO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C,IAAA,KAAK,EAAG7D,EAAE,CAAE,QAAF,CAFX;AAGC,IAAA,IAAI,EAAGD,cAHR;AAIC,IAAA,SAAS,EAAC,0CAJX;AAKC,IAAA,QAAQ,EAAGmE,mBALZ,CAKkC;;AALlC,IADD,CAnBD,CAjBD,CADD,EAgDGjB,YAAY,IACb,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,yCADX;AAEC,IAAA,MAAM,EAAC,OAFR;AAGC,IAAA,aAAa,EAAG;AAHjB,KAKGA,YALH,CAjDF,CAZF,EAwEGjC,KAAK,IAAI,CAAE6B,aAAX,IAA4B,CAAEG,cAA9B,IACD,cAAC,WAAD;AACC,IAAA,GAAG,EAAGhC,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEyB,GADd,CACoB;AADpB;AAEC,IAAA,KAAK,EAAGzB,KAFT;AAGC,IAAA,WAAW,EAAG,MAAM8B,gBAAgB,CAAE,IAAF,CAHrC;AAIC,IAAA,eAAe,EAAGf,eAJnB;AAKC,IAAA,gBAAgB,EAAGuC,kBALpB;AAMC,IAAA,QAAQ,EAAGnD;AANZ,IAzEF,EAmFGoD,kBAAkB,IACnB;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,yBAAD;AACC,IAAA,KAAK,EAAGvD,KADT;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IADD,CApFF,EA4FGe,mBAAmB,IAAIA,mBAAmB,EA5F7C,CADD;AAgGA;;AAEDnB,WAAW,CAACH,UAAZ,GAAyBA,UAAzB;AAEA,eAAeG,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, Spinner, Notice, TextControl } from '@wordpress/components';\nimport { keyboardReturn } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useEffect } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport { ENTER } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSettingsDrawer from './settings-drawer';\nimport LinkControlSearchInput from './search-input';\nimport LinkPreview from './link-preview';\nimport useCreatePage from './use-create-page';\nimport useInternalInputValue from './use-internal-input-value';\nimport { ViewerFill } from './viewer-slot';\nimport { DEFAULT_LINK_SETTINGS } from './constants';\n\n/**\n * Default properties associated with a link control value.\n *\n * @typedef WPLinkControlDefaultValue\n *\n * @property {string} url Link URL.\n * @property {string=} title Link title.\n * @property {boolean=} opensInNewTab Whether link should open in a new browser\n * tab. This value is only assigned if not\n * providing a custom `settings` prop.\n */\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Custom settings values associated with a link.\n *\n * @typedef {{[setting:string]:any}} WPLinkControlSettingsValue\n */\n/* eslint-enable */\n\n/**\n * Custom settings values associated with a link.\n *\n * @typedef WPLinkControlSetting\n *\n * @property {string} id Identifier to use as property for setting value.\n * @property {string} title Human-readable label to show in user interface.\n */\n\n/**\n * Properties associated with a link control value, composed as a union of the\n * default properties and any custom settings values.\n *\n * @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue\n */\n\n/** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */\n\n/**\n * Properties associated with a search suggestion used within the LinkControl.\n *\n * @typedef WPLinkControlSuggestion\n *\n * @property {string} id Identifier to use to uniquely identify the suggestion.\n * @property {string} type Identifies the type of the suggestion (eg: `post`,\n * `page`, `url`...etc)\n * @property {string} title Human-readable label to show in user interface.\n * @property {string} url A URL for the suggestion.\n */\n\n/** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */\n\n/**\n * @typedef WPLinkControlProps\n *\n * @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to\n * render a `ToggleControl` for that setting.\n * @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the\n * internal editing state of the component to respective\n * show or not show the URL input field.\n * @property {WPLinkControlValue=} value Current link value.\n * @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if\n * the user selects a new link or updates settings.\n * @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link.\n * @property {boolean=} showSuggestions Whether to present suggestions when typing the URL.\n * @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately.\n * @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.\n * @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.\n * @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.\n * @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.\n * @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.\n */\n\nconst noop = () => {};\n\n/**\n * Renders a link control. A link control is a controlled input which maintains\n * a value associated with a link (HTML anchor element) and relevant settings\n * for how that link is expected to behave.\n *\n * @param {WPLinkControlProps} props Component props.\n */\nfunction LinkControl( {\n\tsearchInputPlaceholder,\n\tvalue,\n\tsettings = DEFAULT_LINK_SETTINGS,\n\tonChange = noop,\n\tonRemove,\n\tnoDirectEntry = false,\n\tshowSuggestions = true,\n\tshowInitialSuggestions,\n\tforceIsEditingLink,\n\tcreateSuggestion,\n\twithCreateSuggestion,\n\tinputValue: propInputValue = '',\n\tsuggestionsQuery = {},\n\tnoURLSuggestion = false,\n\tcreateSuggestionButtonText,\n\thasRichPreviews = false,\n\thasTextControl = false,\n\trenderControlBottom = null,\n} ) {\n\tif ( withCreateSuggestion === undefined && createSuggestion ) {\n\t\twithCreateSuggestion = true;\n\t}\n\n\tconst isMounting = useRef( true );\n\tconst wrapperNode = useRef();\n\tconst textInputRef = useRef();\n\tconst isEndingEditWithFocus = useRef( false );\n\n\tconst [ internalUrlInputValue, setInternalUrlInputValue ] =\n\t\tuseInternalInputValue( value?.url || '' );\n\n\tconst [ internalTextInputValue, setInternalTextInputValue ] =\n\t\tuseInternalInputValue( value?.title || '' );\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState(\n\t\tforceIsEditingLink !== undefined\n\t\t\t? forceIsEditingLink\n\t\t\t: ! value || ! value.url\n\t);\n\n\tconst { createPage, isCreatingPage, errorMessage } =\n\t\tuseCreatePage( createSuggestion );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tforceIsEditingLink !== undefined &&\n\t\t\tforceIsEditingLink !== isEditingLink\n\t\t) {\n\t\t\tsetIsEditingLink( forceIsEditingLink );\n\t\t}\n\t}, [ forceIsEditingLink ] );\n\n\tuseEffect( () => {\n\t\t// We don't auto focus into the Link UI on mount\n\t\t// because otherwise using the keyboard to select text\n\t\t// *within* the link format is not possible.\n\t\tif ( isMounting.current ) {\n\t\t\tisMounting.current = false;\n\t\t\treturn;\n\t\t}\n\t\t// Unless we are mounting, we always want to focus either:\n\t\t// - the URL input\n\t\t// - the first focusable element in the Link UI.\n\t\t// But in editing mode if there is a text input present then\n\t\t// the URL input is at index 1. If not then it is at index 0.\n\t\tconst whichFocusTargetIndex = textInputRef?.current ? 1 : 0;\n\n\t\t// Scenario - when:\n\t\t// - switching between editable and non editable LinkControl\n\t\t// - clicking on a link\n\t\t// ...then move focus to the *first* element to avoid focus loss\n\t\t// and to ensure focus is *within* the Link UI.\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperNode.current )[\n\t\t\t\twhichFocusTargetIndex\n\t\t\t] || wrapperNode.current;\n\n\t\tnextFocusTarget.focus();\n\n\t\tisEndingEditWithFocus.current = false;\n\t}, [ isEditingLink, isCreatingPage ] );\n\n\t/**\n\t * Cancels editing state and marks that focus may need to be restored after\n\t * the next render, if focus was within the wrapper when editing finished.\n\t */\n\tconst stopEditing = () => {\n\t\tisEndingEditWithFocus.current = !! wrapperNode.current?.contains(\n\t\t\twrapperNode.current.ownerDocument.activeElement\n\t\t);\n\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst handleSelectSuggestion = ( updatedValue ) => {\n\t\tonChange( {\n\t\t\t...updatedValue,\n\t\t\ttitle: internalTextInputValue || updatedValue?.title,\n\t\t} );\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif (\n\t\t\tcurrentUrlInputValue !== value?.url ||\n\t\t\tinternalTextInputValue !== value?.title\n\t\t) {\n\t\t\tonChange( {\n\t\t\t\t...value,\n\t\t\t\turl: currentUrlInputValue,\n\t\t\t\ttitle: internalTextInputValue,\n\t\t\t} );\n\t\t}\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmitWithEnter = ( event ) => {\n\t\tconst { keyCode } = event;\n\t\tif (\n\t\t\tkeyCode === ENTER &&\n\t\t\t! currentInputIsEmpty // Disallow submitting empty values.\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\thandleSubmit();\n\t\t}\n\t};\n\n\tconst currentUrlInputValue = propInputValue || internalUrlInputValue;\n\n\tconst currentInputIsEmpty = ! currentUrlInputValue?.trim()?.length;\n\n\tconst shownUnlinkControl =\n\t\tonRemove && value && ! isEditingLink && ! isCreatingPage;\n\n\tconst showSettingsDrawer = !! settings?.length;\n\n\t// Only show text control once a URL value has been committed\n\t// and it isn't just empty whitespace.\n\t// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.\n\tconst showTextControl = value?.url?.trim()?.length > 0 && hasTextControl;\n\n\treturn (\n\t\t<div\n\t\t\ttabIndex={ -1 }\n\t\t\tref={ wrapperNode }\n\t\t\tclassName=\"block-editor-link-control\"\n\t\t>\n\t\t\t{ isCreatingPage && (\n\t\t\t\t<div className=\"block-editor-link-control__loading\">\n\t\t\t\t\t<Spinner /> { __( 'Creating' ) }…\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ ( isEditingLink || ! value ) && ! isCreatingPage && (\n\t\t\t\t<>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( {\n\t\t\t\t\t\t\t'block-editor-link-control__search-input-wrapper': true,\n\t\t\t\t\t\t\t'has-text-control': showTextControl,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ showTextControl && (\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\tref={ textInputRef }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__text-content\"\n\t\t\t\t\t\t\t\tlabel=\"Text\"\n\t\t\t\t\t\t\t\tvalue={ internalTextInputValue }\n\t\t\t\t\t\t\t\tonChange={ setInternalTextInputValue }\n\t\t\t\t\t\t\t\tonKeyDown={ handleSubmitWithEnter }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t<LinkControlSearchInput\n\t\t\t\t\t\t\tcurrentLink={ value }\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__search-input\"\n\t\t\t\t\t\t\tplaceholder={ searchInputPlaceholder }\n\t\t\t\t\t\t\tvalue={ currentUrlInputValue }\n\t\t\t\t\t\t\twithCreateSuggestion={ withCreateSuggestion }\n\t\t\t\t\t\t\tonCreateSuggestion={ createPage }\n\t\t\t\t\t\t\tonChange={ setInternalUrlInputValue }\n\t\t\t\t\t\t\tonSelect={ handleSelectSuggestion }\n\t\t\t\t\t\t\tshowInitialSuggestions={ showInitialSuggestions }\n\t\t\t\t\t\t\tallowDirectEntry={ ! noDirectEntry }\n\t\t\t\t\t\t\tshowSuggestions={ showSuggestions }\n\t\t\t\t\t\t\tsuggestionsQuery={ suggestionsQuery }\n\t\t\t\t\t\t\twithURLSuggestion={ ! noURLSuggestion }\n\t\t\t\t\t\t\tcreateSuggestionButtonText={\n\t\t\t\t\t\t\t\tcreateSuggestionButtonText\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tuseLabel={ showTextControl }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"block-editor-link-control__search-actions\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tonClick={ handleSubmit }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Submit' ) }\n\t\t\t\t\t\t\t\t\ticon={ keyboardReturn }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-submit\"\n\t\t\t\t\t\t\t\t\tdisabled={ currentInputIsEmpty } // Disallow submitting empty values.\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</LinkControlSearchInput>\n\t\t\t\t\t</div>\n\t\t\t\t\t{ errorMessage && (\n\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-error\"\n\t\t\t\t\t\t\tstatus=\"error\"\n\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ errorMessage }\n\t\t\t\t\t\t</Notice>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ value && ! isEditingLink && ! isCreatingPage && (\n\t\t\t\t<LinkPreview\n\t\t\t\t\tkey={ value?.url } // force remount when URL changes to avoid race conditions for rich previews\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonEditClick={ () => setIsEditingLink( true ) }\n\t\t\t\t\thasRichPreviews={ hasRichPreviews }\n\t\t\t\t\thasUnlinkControl={ shownUnlinkControl }\n\t\t\t\t\tonRemove={ onRemove }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ showSettingsDrawer && (\n\t\t\t\t<div className=\"block-editor-link-control__tools\">\n\t\t\t\t\t<LinkControlSettingsDrawer\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ renderControlBottom && renderControlBottom() }\n\t\t</div>\n\t);\n}\n\nLinkControl.ViewerFill = ViewerFill;\n\nexport default LinkControl;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/index.js"],"names":["classnames","Button","Spinner","Notice","TextControl","keyboardReturn","__","useRef","useState","useEffect","focus","ENTER","LinkControlSettingsDrawer","LinkControlSearchInput","LinkPreview","useCreatePage","useInternalInputValue","ViewerFill","DEFAULT_LINK_SETTINGS","noop","LinkControl","searchInputPlaceholder","value","settings","onChange","onRemove","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","isMounting","wrapperNode","textInputRef","isEndingEditWithFocus","internalUrlInputValue","setInternalUrlInputValue","url","internalTextInputValue","setInternalTextInputValue","title","isEditingLink","setIsEditingLink","createPage","isCreatingPage","errorMessage","current","whichFocusTargetIndex","nextFocusTarget","focusable","find","stopEditing","contains","ownerDocument","activeElement","handleSelectSuggestion","updatedValue","handleSubmit","currentUrlInputValue","handleSubmitWithEnter","event","keyCode","currentInputIsEmpty","preventDefault","trim","length","shownUnlinkControl","showSettingsDrawer","showTextControl"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,OAAjB,EAA0BC,MAA1B,EAAkCC,WAAlC,QAAqD,uBAArD;AACA,SAASC,cAAT,QAA+B,kBAA/B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,QAAjB,EAA2BC,SAA3B,QAA4C,oBAA5C;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,KAAT,QAAsB,qBAAtB;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,mBAAtC;AACA,OAAOC,sBAAP,MAAmC,gBAAnC;AACA,OAAOC,WAAP,MAAwB,gBAAxB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,SAASC,UAAT,QAA2B,eAA3B;AACA,SAASC,qBAAT,QAAsC,aAAtC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;AAKC,IAAA,gBAAgB,EAAGuC,kBALpB;AAMC,IAAA,QAAQ,EAAGnD;AANZ,IAzEF,EAmFGoD,kBAAkB,IACnB;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,yBAAD;AACC,IAAA,KAAK,EAAGvD,KADT;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IADD,CApFF,EA4FGe,mBAAmB,IAAIA,mBAAmB,EA5F7C,CADD;AAgGA;;AAEDnB,WAAW,CAACH,UAAZ,GAAyBA,UAAzB;AAEA,eAAeG,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, Spinner, Notice, TextControl } from '@wordpress/components';\nimport { keyboardReturn } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useEffect } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport { ENTER } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSettingsDrawer from './settings-drawer';\nimport LinkControlSearchInput from './search-input';\nimport LinkPreview from './link-preview';\nimport useCreatePage from './use-create-page';\nimport useInternalInputValue from './use-internal-input-value';\nimport { ViewerFill } from './viewer-slot';\nimport { DEFAULT_LINK_SETTINGS } from './constants';\n\n/**\n * Default properties associated with a link control value.\n *\n * @typedef WPLinkControlDefaultValue\n *\n * @property {string} url Link URL.\n * @property {string=} title Link title.\n * @property {boolean=} opensInNewTab Whether link should open in a new browser\n * tab. This value is only assigned if not\n * providing a custom `settings` prop.\n */\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Custom settings values associated with a link.\n *\n * @typedef {{[setting:string]:any}} WPLinkControlSettingsValue\n */\n/* eslint-enable */\n\n/**\n * Custom settings values associated with a link.\n *\n * @typedef WPLinkControlSetting\n *\n * @property {string} id Identifier to use as property for setting value.\n * @property {string} title Human-readable label to show in user interface.\n */\n\n/**\n * Properties associated with a link control value, composed as a union of the\n * default properties and any custom settings values.\n *\n * @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue\n */\n\n/** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */\n\n/**\n * Properties associated with a search suggestion used within the LinkControl.\n *\n * @typedef WPLinkControlSuggestion\n *\n * @property {string} id Identifier to use to uniquely identify the suggestion.\n * @property {string} type Identifies the type of the suggestion (eg: `post`,\n * `page`, `url`...etc)\n * @property {string} title Human-readable label to show in user interface.\n * @property {string} url A URL for the suggestion.\n */\n\n/** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */\n\n/**\n * @typedef WPLinkControlProps\n *\n * @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to\n * render a `ToggleControl` for that setting.\n * @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the\n * internal editing state of the component to respective\n * show or not show the URL input field.\n * @property {WPLinkControlValue=} value Current link value.\n * @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if\n * the user selects a new link or updates settings.\n * @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link.\n * @property {boolean=} showSuggestions Whether to present suggestions when typing the URL.\n * @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately.\n * @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.\n * @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.\n * @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.\n * @property {boolean=} hasTextControl Whether to add a text field to the UI to update the value.title.\n * @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.\n * @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.\n */\n\nconst noop = () => {};\n\n/**\n * Renders a link control. A link control is a controlled input which maintains\n * a value associated with a link (HTML anchor element) and relevant settings\n * for how that link is expected to behave.\n *\n * @param {WPLinkControlProps} props Component props.\n */\nfunction LinkControl( {\n\tsearchInputPlaceholder,\n\tvalue,\n\tsettings = DEFAULT_LINK_SETTINGS,\n\tonChange = noop,\n\tonRemove,\n\tnoDirectEntry = false,\n\tshowSuggestions = true,\n\tshowInitialSuggestions,\n\tforceIsEditingLink,\n\tcreateSuggestion,\n\twithCreateSuggestion,\n\tinputValue: propInputValue = '',\n\tsuggestionsQuery = {},\n\tnoURLSuggestion = false,\n\tcreateSuggestionButtonText,\n\thasRichPreviews = false,\n\thasTextControl = false,\n\trenderControlBottom = null,\n} ) {\n\tif ( withCreateSuggestion === undefined && createSuggestion ) {\n\t\twithCreateSuggestion = true;\n\t}\n\n\tconst isMounting = useRef( true );\n\tconst wrapperNode = useRef();\n\tconst textInputRef = useRef();\n\tconst isEndingEditWithFocus = useRef( false );\n\n\tconst [ internalUrlInputValue, setInternalUrlInputValue ] =\n\t\tuseInternalInputValue( value?.url || '' );\n\n\tconst [ internalTextInputValue, setInternalTextInputValue ] =\n\t\tuseInternalInputValue( value?.title || '' );\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState(\n\t\tforceIsEditingLink !== undefined\n\t\t\t? forceIsEditingLink\n\t\t\t: ! value || ! value.url\n\t);\n\n\tconst { createPage, isCreatingPage, errorMessage } =\n\t\tuseCreatePage( createSuggestion );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tforceIsEditingLink !== undefined &&\n\t\t\tforceIsEditingLink !== isEditingLink\n\t\t) {\n\t\t\tsetIsEditingLink( forceIsEditingLink );\n\t\t}\n\t}, [ forceIsEditingLink ] );\n\n\tuseEffect( () => {\n\t\t// We don't auto focus into the Link UI on mount\n\t\t// because otherwise using the keyboard to select text\n\t\t// *within* the link format is not possible.\n\t\tif ( isMounting.current ) {\n\t\t\tisMounting.current = false;\n\t\t\treturn;\n\t\t}\n\t\t// Unless we are mounting, we always want to focus either:\n\t\t// - the URL input\n\t\t// - the first focusable element in the Link UI.\n\t\t// But in editing mode if there is a text input present then\n\t\t// the URL input is at index 1. If not then it is at index 0.\n\t\tconst whichFocusTargetIndex = textInputRef?.current ? 1 : 0;\n\n\t\t// Scenario - when:\n\t\t// - switching between editable and non editable LinkControl\n\t\t// - clicking on a link\n\t\t// ...then move focus to the *first* element to avoid focus loss\n\t\t// and to ensure focus is *within* the Link UI.\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperNode.current )[\n\t\t\t\twhichFocusTargetIndex\n\t\t\t] || wrapperNode.current;\n\n\t\tnextFocusTarget.focus();\n\n\t\tisEndingEditWithFocus.current = false;\n\t}, [ isEditingLink, isCreatingPage ] );\n\n\t/**\n\t * Cancels editing state and marks that focus may need to be restored after\n\t * the next render, if focus was within the wrapper when editing finished.\n\t */\n\tconst stopEditing = () => {\n\t\tisEndingEditWithFocus.current = !! wrapperNode.current?.contains(\n\t\t\twrapperNode.current.ownerDocument.activeElement\n\t\t);\n\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst handleSelectSuggestion = ( updatedValue ) => {\n\t\tonChange( {\n\t\t\t...updatedValue,\n\t\t\ttitle: internalTextInputValue || updatedValue?.title,\n\t\t} );\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif (\n\t\t\tcurrentUrlInputValue !== value?.url ||\n\t\t\tinternalTextInputValue !== value?.title\n\t\t) {\n\t\t\tonChange( {\n\t\t\t\t...value,\n\t\t\t\turl: currentUrlInputValue,\n\t\t\t\ttitle: internalTextInputValue,\n\t\t\t} );\n\t\t}\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmitWithEnter = ( event ) => {\n\t\tconst { keyCode } = event;\n\t\tif (\n\t\t\tkeyCode === ENTER &&\n\t\t\t! currentInputIsEmpty // Disallow submitting empty values.\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\thandleSubmit();\n\t\t}\n\t};\n\n\tconst currentUrlInputValue = propInputValue || internalUrlInputValue;\n\n\tconst currentInputIsEmpty = ! currentUrlInputValue?.trim()?.length;\n\n\tconst shownUnlinkControl =\n\t\tonRemove && value && ! isEditingLink && ! isCreatingPage;\n\n\tconst showSettingsDrawer = !! settings?.length;\n\n\t// Only show text control once a URL value has been committed\n\t// and it isn't just empty whitespace.\n\t// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.\n\tconst showTextControl = value?.url?.trim()?.length > 0 && hasTextControl;\n\n\treturn (\n\t\t<div\n\t\t\ttabIndex={ -1 }\n\t\t\tref={ wrapperNode }\n\t\t\tclassName=\"block-editor-link-control\"\n\t\t>\n\t\t\t{ isCreatingPage && (\n\t\t\t\t<div className=\"block-editor-link-control__loading\">\n\t\t\t\t\t<Spinner /> { __( 'Creating' ) }…\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ ( isEditingLink || ! value ) && ! isCreatingPage && (\n\t\t\t\t<>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( {\n\t\t\t\t\t\t\t'block-editor-link-control__search-input-wrapper': true,\n\t\t\t\t\t\t\t'has-text-control': showTextControl,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ showTextControl && (\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\tref={ textInputRef }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__text-content\"\n\t\t\t\t\t\t\t\tlabel=\"Text\"\n\t\t\t\t\t\t\t\tvalue={ internalTextInputValue }\n\t\t\t\t\t\t\t\tonChange={ setInternalTextInputValue }\n\t\t\t\t\t\t\t\tonKeyDown={ handleSubmitWithEnter }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t<LinkControlSearchInput\n\t\t\t\t\t\t\tcurrentLink={ value }\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__search-input\"\n\t\t\t\t\t\t\tplaceholder={ searchInputPlaceholder }\n\t\t\t\t\t\t\tvalue={ currentUrlInputValue }\n\t\t\t\t\t\t\twithCreateSuggestion={ withCreateSuggestion }\n\t\t\t\t\t\t\tonCreateSuggestion={ createPage }\n\t\t\t\t\t\t\tonChange={ setInternalUrlInputValue }\n\t\t\t\t\t\t\tonSelect={ handleSelectSuggestion }\n\t\t\t\t\t\t\tshowInitialSuggestions={ showInitialSuggestions }\n\t\t\t\t\t\t\tallowDirectEntry={ ! noDirectEntry }\n\t\t\t\t\t\t\tshowSuggestions={ showSuggestions }\n\t\t\t\t\t\t\tsuggestionsQuery={ suggestionsQuery }\n\t\t\t\t\t\t\twithURLSuggestion={ ! noURLSuggestion }\n\t\t\t\t\t\t\tcreateSuggestionButtonText={\n\t\t\t\t\t\t\t\tcreateSuggestionButtonText\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tuseLabel={ showTextControl }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"block-editor-link-control__search-actions\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tonClick={ handleSubmit }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Submit' ) }\n\t\t\t\t\t\t\t\t\ticon={ keyboardReturn }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-submit\"\n\t\t\t\t\t\t\t\t\tdisabled={ currentInputIsEmpty } // Disallow submitting empty values.\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</LinkControlSearchInput>\n\t\t\t\t\t</div>\n\t\t\t\t\t{ errorMessage && (\n\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-error\"\n\t\t\t\t\t\t\tstatus=\"error\"\n\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ errorMessage }\n\t\t\t\t\t\t</Notice>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ value && ! isEditingLink && ! isCreatingPage && (\n\t\t\t\t<LinkPreview\n\t\t\t\t\tkey={ value?.url } // force remount when URL changes to avoid race conditions for rich previews\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonEditClick={ () => setIsEditingLink( true ) }\n\t\t\t\t\thasRichPreviews={ hasRichPreviews }\n\t\t\t\t\thasUnlinkControl={ shownUnlinkControl }\n\t\t\t\t\tonRemove={ onRemove }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ showSettingsDrawer && (\n\t\t\t\t<div className=\"block-editor-link-control__tools\">\n\t\t\t\t\t<LinkControlSettingsDrawer\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ renderControlBottom && renderControlBottom() }\n\t\t</div>\n\t);\n}\n\nLinkControl.ViewerFill = ViewerFill;\n\nexport default LinkControl;\n"]}
|