@wordpress/block-editor 11.3.6 → 11.5.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 +3 -1
- package/build/components/block-lock/modal.js +1 -0
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-popover/inbetween.js +10 -33
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/index.js +2 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-types-list/index.native.js +2 -0
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/child-layout-control/index.js +107 -0
- package/build/components/child-layout-control/index.js.map +1 -0
- package/build/components/colors-gradients/control.js +6 -3
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/date-format-picker/index.js +3 -3
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +0 -3
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +594 -0
- package/build/components/global-styles/dimensions-panel.js.map +1 -0
- package/build/components/global-styles/hooks.js +142 -45
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +38 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +434 -0
- package/build/components/global-styles/typography-panel.js.map +1 -0
- package/build/components/global-styles/use-global-styles-output.js +7 -3
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -0
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/iframe/index.js +17 -11
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js +2 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build/components/image-size-control/index.js +6 -11
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/index.native.js +23 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +9 -15
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.native.js +4 -1
- package/build/components/inserter/block-types-tab.native.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js +4 -1
- package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build/components/inserter/search-results.native.js +4 -1
- package/build/components/inserter/search-results.native.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls/fill.js +38 -9
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/link-control/index.js +55 -28
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/settings-drawer.js +72 -30
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/link-control/settings.js +53 -0
- package/build/components/link-control/settings.js.map +1 -0
- package/build/components/list-view/block.js +4 -2
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/expander.js +2 -1
- package/build/components/list-view/expander.js.map +1 -1
- package/build/components/list-view/index.js +6 -1
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +5 -10
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +3 -2
- package/build/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +1 -0
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +7 -3
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/leaf-more-menu.js +24 -4
- package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build/components/off-canvas-editor/link-ui.js +2 -0
- package/build/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build/components/responsive-block-control/index.js +1 -0
- package/build/components/responsive-block-control/index.js.map +1 -1
- package/build/components/rich-text/index.js +9 -45
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-delete.js +73 -0
- package/build/components/rich-text/use-delete.js.map +1 -0
- package/build/components/rich-text/use-input-rules.js +14 -6
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/url-input/index.js +2 -2
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +4 -1
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/hooks/align.js +3 -1
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/dimensions.js +78 -190
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +94 -25
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/font-family.js +2 -76
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +3 -51
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/gap.js +0 -201
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +14 -5
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/line-height.js +0 -42
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/margin.js +7 -163
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +7 -163
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/typography.js +98 -128
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +75 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/flex.js +1 -0
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +24 -12
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +53 -47
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +22 -1
- package/build/store/selectors.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +36 -3
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/components/block-lock/modal.js +1 -0
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +10 -33
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/index.js +2 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +2 -0
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +98 -0
- package/build-module/components/child-layout-control/index.js.map +1 -0
- package/build-module/components/colors-gradients/control.js +6 -3
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +4 -4
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +2 -1
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +574 -0
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +138 -46
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +3 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +415 -0
- package/build-module/components/global-styles/typography-panel.js.map +1 -0
- package/build-module/components/global-styles/use-global-styles-output.js +7 -3
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/iframe/index.js +17 -11
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js +2 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build-module/components/image-size-control/index.js +7 -12
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/index.native.js +2 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +9 -15
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.native.js +3 -1
- package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js +3 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build-module/components/inserter/search-results.native.js +3 -1
- package/build-module/components/inserter/search-results.native.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +39 -9
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/link-control/index.js +56 -28
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +68 -30
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/link-control/settings.js +44 -0
- package/build-module/components/link-control/settings.js.map +1 -0
- package/build-module/components/list-view/block.js +4 -2
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/expander.js +2 -1
- package/build-module/components/list-view/expander.js.map +1 -1
- package/build-module/components/list-view/index.js +6 -1
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +5 -10
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +3 -2
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +1 -0
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +7 -3
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/leaf-more-menu.js +27 -7
- package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build-module/components/off-canvas-editor/link-ui.js +2 -0
- package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build-module/components/responsive-block-control/index.js +1 -0
- package/build-module/components/responsive-block-control/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +9 -45
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-delete.js +62 -0
- package/build-module/components/rich-text/use-delete.js.map +1 -0
- package/build-module/components/rich-text/use-input-rules.js +14 -6
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/url-input/index.js +2 -2
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +4 -1
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/hooks/align.js +3 -1
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/dimensions.js +81 -187
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +86 -24
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/font-family.js +3 -69
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +6 -47
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/gap.js +0 -182
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +14 -5
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/line-height.js +0 -38
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/margin.js +4 -143
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +4 -143
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/typography.js +97 -123
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +70 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/flex.js +1 -0
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +24 -12
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +53 -45
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +22 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +36 -3
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-style/style-rtl.css +54 -64
- package/build-style/style.css +54 -64
- package/package.json +31 -31
- package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +24 -24
- package/src/components/block-lock/modal.js +1 -0
- package/src/components/block-lock/style.scss +0 -9
- package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +20 -20
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +15 -15
- package/src/components/block-popover/inbetween.js +21 -53
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/src/components/block-styles/index.js +5 -1
- package/src/components/block-types-list/index.native.js +2 -0
- package/src/components/child-layout-control/index.js +106 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/colors-gradients/control.js +3 -0
- package/src/components/date-format-picker/index.js +6 -8
- package/src/components/date-format-picker/style.scss +0 -5
- package/src/components/font-appearance-control/index.js +1 -1
- package/src/components/global-styles/dimensions-panel.js +627 -0
- package/src/components/global-styles/hooks.js +229 -66
- package/src/components/global-styles/index.js +9 -0
- package/src/components/global-styles/typography-panel.js +428 -0
- package/src/components/global-styles/use-global-styles-output.js +10 -5
- package/src/components/global-styles/utils.js +2 -0
- package/src/components/iframe/index.js +20 -18
- package/src/components/image-editor/aspect-ratio-dropdown.js +1 -0
- package/src/components/image-size-control/index.js +10 -12
- package/src/components/image-size-control/style.scss +3 -21
- package/src/components/index.native.js +5 -0
- package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
- package/src/components/inserter/block-patterns-tab.js +9 -23
- package/src/components/inserter/block-types-tab.native.js +2 -0
- package/src/components/inserter/reusable-blocks-tab.native.js +2 -0
- package/src/components/inserter/search-results.native.js +2 -0
- package/src/components/inserter/test/__snapshots__/index.native.js.snap +15 -15
- package/src/components/inspector-controls/block-support-tools-panel.js +0 -1
- package/src/components/inspector-controls/fill.js +32 -8
- package/src/components/link-control/index.js +69 -34
- package/src/components/link-control/settings-drawer.js +85 -29
- package/src/components/link-control/settings.js +42 -0
- package/src/components/link-control/style.scss +63 -37
- package/src/components/link-control/test/index.js +347 -9
- package/src/components/list-view/block.js +7 -1
- package/src/components/list-view/expander.js +1 -0
- package/src/components/list-view/index.js +5 -0
- package/src/components/media-replace-flow/style.scss +7 -9
- package/src/components/media-replace-flow/test/index.js +1 -1
- package/src/components/off-canvas-editor/appender.js +13 -16
- package/src/components/off-canvas-editor/block-contents.js +2 -1
- package/src/components/off-canvas-editor/branch.js +1 -0
- package/src/components/off-canvas-editor/index.js +8 -2
- package/src/components/off-canvas-editor/leaf-more-menu.js +52 -15
- package/src/components/off-canvas-editor/link-ui.js +2 -0
- package/src/components/responsive-block-control/index.js +1 -0
- package/src/components/rich-text/index.js +8 -46
- package/src/components/rich-text/use-delete.js +59 -0
- package/src/components/rich-text/use-input-rules.js +13 -5
- package/src/components/url-input/index.js +3 -2
- package/src/components/url-popover/stories/index.js +1 -0
- package/src/components/writing-flow/use-selection-observer.js +5 -1
- package/src/hooks/align.js +1 -1
- package/src/hooks/dimensions.js +97 -269
- package/src/hooks/duotone.js +100 -30
- package/src/hooks/font-family.js +0 -58
- package/src/hooks/font-size.js +1 -36
- package/src/hooks/gap.js +0 -201
- package/src/hooks/index.js +1 -0
- package/src/hooks/layout.js +19 -6
- package/src/hooks/line-height.js +0 -33
- package/src/hooks/margin.js +1 -164
- package/src/hooks/padding.js +1 -163
- package/src/hooks/test/__snapshots__/align.native.js.snap +24 -24
- package/src/hooks/test/duotone.js +102 -0
- package/src/hooks/typography.js +112 -213
- package/src/hooks/utils.js +90 -0
- package/src/layouts/flex.js +1 -0
- package/src/store/actions.js +12 -4
- package/src/store/reducer.js +68 -43
- package/src/store/selectors.js +20 -1
- package/src/store/test/actions.js +4 -2
- package/src/utils/parse-css-unit-to-px.js +35 -5
- package/src/utils/test/parse-css-unit-to-px.js +12 -0
- package/build/hooks/child-layout.js +0 -213
- package/build/hooks/child-layout.js.map +0 -1
- package/build/hooks/font-appearance.js +0 -188
- package/build/hooks/font-appearance.js.map +0 -1
- package/build/hooks/letter-spacing.js +0 -129
- package/build/hooks/letter-spacing.js.map +0 -1
- package/build/hooks/min-height.js +0 -139
- package/build/hooks/min-height.js.map +0 -1
- package/build/hooks/text-decoration.js +0 -130
- package/build/hooks/text-decoration.js.map +0 -1
- package/build/hooks/text-transform.js +0 -130
- package/build/hooks/text-transform.js.map +0 -1
- package/build-module/hooks/child-layout.js +0 -193
- package/build-module/hooks/child-layout.js.map +0 -1
- package/build-module/hooks/font-appearance.js +0 -161
- package/build-module/hooks/font-appearance.js.map +0 -1
- package/build-module/hooks/letter-spacing.js +0 -107
- package/build-module/hooks/letter-spacing.js.map +0 -1
- package/build-module/hooks/min-height.js +0 -116
- package/build-module/hooks/min-height.js.map +0 -1
- package/build-module/hooks/text-decoration.js +0 -108
- package/build-module/hooks/text-decoration.js.map +0 -1
- package/build-module/hooks/text-transform.js +0 -108
- package/build-module/hooks/text-transform.js.map +0 -1
- package/src/hooks/child-layout.js +0 -195
- package/src/hooks/font-appearance.js +0 -146
- package/src/hooks/letter-spacing.js +0 -101
- package/src/hooks/min-height.js +0 -104
- package/src/hooks/text-decoration.js +0 -102
- package/src/hooks/text-transform.js +0 -101
|
@@ -11,6 +11,7 @@ import { isEmpty } from 'lodash';
|
|
|
11
11
|
import { __experimentalStyleProvider as StyleProvider, __experimentalToolsPanelContext as ToolsPanelContext } from '@wordpress/components';
|
|
12
12
|
import warning from '@wordpress/warning';
|
|
13
13
|
import deprecated from '@wordpress/deprecated';
|
|
14
|
+
import { useEffect } from '@wordpress/element';
|
|
14
15
|
/**
|
|
15
16
|
* Internal dependencies
|
|
16
17
|
*/
|
|
@@ -23,7 +24,8 @@ export default function InspectorControlsFill(_ref) {
|
|
|
23
24
|
let {
|
|
24
25
|
children,
|
|
25
26
|
group = 'default',
|
|
26
|
-
__experimentalGroup
|
|
27
|
+
__experimentalGroup,
|
|
28
|
+
resetAllFilter
|
|
27
29
|
} = _ref;
|
|
28
30
|
|
|
29
31
|
if (__experimentalGroup) {
|
|
@@ -50,14 +52,42 @@ export default function InspectorControlsFill(_ref) {
|
|
|
50
52
|
return createElement(StyleProvider, {
|
|
51
53
|
document: document
|
|
52
54
|
}, createElement(Fill, null, fillProps => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return createElement(ToolsPanelContext.Provider, {
|
|
59
|
-
value: value
|
|
60
|
-
}, children);
|
|
55
|
+
return createElement(ToolsPanelInspectorControl, {
|
|
56
|
+
fillProps: fillProps,
|
|
57
|
+
children: children,
|
|
58
|
+
resetAllFilter: resetAllFilter
|
|
59
|
+
});
|
|
61
60
|
}));
|
|
62
61
|
}
|
|
62
|
+
|
|
63
|
+
function ToolsPanelInspectorControl(_ref2) {
|
|
64
|
+
let {
|
|
65
|
+
children,
|
|
66
|
+
resetAllFilter,
|
|
67
|
+
fillProps
|
|
68
|
+
} = _ref2;
|
|
69
|
+
const {
|
|
70
|
+
registerResetAllFilter,
|
|
71
|
+
deregisterResetAllFilter
|
|
72
|
+
} = fillProps;
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (resetAllFilter && registerResetAllFilter) {
|
|
75
|
+
registerResetAllFilter(resetAllFilter);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return () => {
|
|
79
|
+
if (resetAllFilter && deregisterResetAllFilter) {
|
|
80
|
+
deregisterResetAllFilter(resetAllFilter);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}, [resetAllFilter, registerResetAllFilter, deregisterResetAllFilter]); // Children passed to InspectorControlsFill will not have
|
|
84
|
+
// access to any React Context whose Provider is part of
|
|
85
|
+
// the InspectorControlsSlot tree. So we re-create the
|
|
86
|
+
// Provider in this subtree.
|
|
87
|
+
|
|
88
|
+
const value = !isEmpty(fillProps) ? fillProps : null;
|
|
89
|
+
return createElement(ToolsPanelContext.Provider, {
|
|
90
|
+
value: value
|
|
91
|
+
}, children);
|
|
92
|
+
}
|
|
63
93
|
//# sourceMappingURL=fill.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/fill.js"],"names":["isEmpty","__experimentalStyleProvider","StyleProvider","__experimentalToolsPanelContext","ToolsPanelContext","warning","deprecated","useDisplayBlockControls","groups","InspectorControlsFill","children","group","__experimentalGroup","since","version","alternative","isDisplayed","Fill","document","fillProps","value"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SACCC,2BAA2B,IAAIC,aADhC,EAECC,+BAA+B,IAAIC,iBAFpC,QAGO,uBAHP;AAIA,OAAOC,OAAP,MAAoB,oBAApB;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,+BAApC;AACA,OAAOC,MAAP,MAAmB,UAAnB;AAEA,eAAe,SAASC,qBAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/fill.js"],"names":["isEmpty","__experimentalStyleProvider","StyleProvider","__experimentalToolsPanelContext","ToolsPanelContext","warning","deprecated","useEffect","useDisplayBlockControls","groups","InspectorControlsFill","children","group","__experimentalGroup","resetAllFilter","since","version","alternative","isDisplayed","Fill","document","fillProps","ToolsPanelInspectorControl","registerResetAllFilter","deregisterResetAllFilter","value"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SACCC,2BAA2B,IAAIC,aADhC,EAECC,+BAA+B,IAAIC,iBAFpC,QAGO,uBAHP;AAIA,OAAOC,OAAP,MAAoB,oBAApB;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,+BAApC;AACA,OAA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ACD,WAAO,MAAM;AACZ,UAAKA,cAAc,IAAIU,wBAAvB,EAAkD;AACjDA,QAAAA,wBAAwB,CAAEV,cAAF,CAAxB;AACA;AACD,KAJD;AAKA,GATQ,EASN,CAAEA,cAAF,EAAkBS,sBAAlB,EAA0CC,wBAA1C,CATM,CAAT,CAF8E,CAa9E;AACA;AACA;AACA;;AACA,QAAMC,KAAK,GAAG,CAAEzB,OAAO,CAAEqB,SAAF,CAAT,GAAyBA,SAAzB,GAAqC,IAAnD;AACA,SACC,cAAC,iBAAD,CAAmB,QAAnB;AAA4B,IAAA,KAAK,EAAGI;AAApC,KACGd,QADH,CADD;AAKA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalStyleProvider as StyleProvider,\n\t__experimentalToolsPanelContext as ToolsPanelContext,\n} from '@wordpress/components';\nimport warning from '@wordpress/warning';\nimport deprecated from '@wordpress/deprecated';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useDisplayBlockControls from '../use-display-block-controls';\nimport groups from './groups';\n\nexport default function InspectorControlsFill( {\n\tchildren,\n\tgroup = 'default',\n\t__experimentalGroup,\n\tresetAllFilter,\n} ) {\n\tif ( __experimentalGroup ) {\n\t\tdeprecated(\n\t\t\t'`__experimentalGroup` property in `InspectorControlsFill`',\n\t\t\t{\n\t\t\t\tsince: '6.2',\n\t\t\t\tversion: '6.4',\n\t\t\t\talternative: '`group`',\n\t\t\t}\n\t\t);\n\t\tgroup = __experimentalGroup;\n\t}\n\n\tconst isDisplayed = useDisplayBlockControls();\n\tconst Fill = groups[ group ]?.Fill;\n\tif ( ! Fill ) {\n\t\twarning( `Unknown InspectorControl group \"${ group }\" provided.` );\n\t\treturn null;\n\t}\n\tif ( ! isDisplayed ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StyleProvider document={ document }>\n\t\t\t<Fill>\n\t\t\t\t{ ( fillProps ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<ToolsPanelInspectorControl\n\t\t\t\t\t\t\tfillProps={ fillProps }\n\t\t\t\t\t\t\tchildren={ children }\n\t\t\t\t\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t</Fill>\n\t\t</StyleProvider>\n\t);\n}\n\nfunction ToolsPanelInspectorControl( { children, resetAllFilter, fillProps } ) {\n\tconst { registerResetAllFilter, deregisterResetAllFilter } = fillProps;\n\tuseEffect( () => {\n\t\tif ( resetAllFilter && registerResetAllFilter ) {\n\t\t\tregisterResetAllFilter( resetAllFilter );\n\t\t}\n\t\treturn () => {\n\t\t\tif ( resetAllFilter && deregisterResetAllFilter ) {\n\t\t\t\tderegisterResetAllFilter( resetAllFilter );\n\t\t\t}\n\t\t};\n\t}, [ resetAllFilter, registerResetAllFilter, deregisterResetAllFilter ] );\n\n\t// Children passed to InspectorControlsFill will not have\n\t// access to any React Context whose Provider is part of\n\t// the InspectorControlsSlot tree. So we re-create the\n\t// Provider in this subtree.\n\tconst value = ! isEmpty( fillProps ) ? fillProps : null;\n\treturn (\n\t\t<ToolsPanelContext.Provider value={ value }>\n\t\t\t{ children }\n\t\t</ToolsPanelContext.Provider>\n\t);\n}\n"]}
|
|
@@ -8,8 +8,7 @@ import classnames from 'classnames';
|
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { Button, Spinner, Notice
|
|
12
|
-
import { keyboardReturn } from '@wordpress/icons';
|
|
11
|
+
import { Button, Spinner, Notice } from '@wordpress/components';
|
|
13
12
|
import { __ } from '@wordpress/i18n';
|
|
14
13
|
import { useRef, useState, useEffect } from '@wordpress/element';
|
|
15
14
|
import { focus } from '@wordpress/dom';
|
|
@@ -112,7 +111,7 @@ const noop = () => {};
|
|
|
112
111
|
|
|
113
112
|
|
|
114
113
|
function LinkControl(_ref) {
|
|
115
|
-
var
|
|
114
|
+
var _value$url, _value$url$trim, _currentUrlInputValue;
|
|
116
115
|
|
|
117
116
|
let {
|
|
118
117
|
searchInputPlaceholder,
|
|
@@ -120,6 +119,7 @@ function LinkControl(_ref) {
|
|
|
120
119
|
settings = DEFAULT_LINK_SETTINGS,
|
|
121
120
|
onChange = noop,
|
|
122
121
|
onRemove,
|
|
122
|
+
onCancel,
|
|
123
123
|
noDirectEntry = false,
|
|
124
124
|
showSuggestions = true,
|
|
125
125
|
showInitialSuggestions,
|
|
@@ -143,6 +143,7 @@ function LinkControl(_ref) {
|
|
|
143
143
|
const wrapperNode = useRef();
|
|
144
144
|
const textInputRef = useRef();
|
|
145
145
|
const isEndingEditWithFocus = useRef(false);
|
|
146
|
+
const [settingsOpen, setSettingsOpen] = useState(false);
|
|
146
147
|
const [internalUrlInputValue, setInternalUrlInputValue] = useInternalInputValue((value === null || value === void 0 ? void 0 : value.url) || '');
|
|
147
148
|
const [internalTextInputValue, setInternalTextInputValue] = useInternalInputValue((value === null || value === void 0 ? void 0 : value.title) || '');
|
|
148
149
|
const [isEditingLink, setIsEditingLink] = useState(forceIsEditingLink !== undefined ? forceIsEditingLink : !value || !value.url);
|
|
@@ -180,6 +181,7 @@ function LinkControl(_ref) {
|
|
|
180
181
|
nextFocusTarget.focus();
|
|
181
182
|
isEndingEditWithFocus.current = false;
|
|
182
183
|
}, [isEditingLink, isCreatingPage]);
|
|
184
|
+
const hasLinkValue = (value === null || value === void 0 ? void 0 : (_value$url = value.url) === null || _value$url === void 0 ? void 0 : (_value$url$trim = _value$url.trim()) === null || _value$url$trim === void 0 ? void 0 : _value$url$trim.length) > 0;
|
|
183
185
|
/**
|
|
184
186
|
* Cancels editing state and marks that focus may need to be restored after
|
|
185
187
|
* the next render, if focus was within the wrapper when editing finished.
|
|
@@ -189,6 +191,7 @@ function LinkControl(_ref) {
|
|
|
189
191
|
var _wrapperNode$current;
|
|
190
192
|
|
|
191
193
|
isEndingEditWithFocus.current = !!((_wrapperNode$current = wrapperNode.current) !== null && _wrapperNode$current !== void 0 && _wrapperNode$current.contains(wrapperNode.current.ownerDocument.activeElement));
|
|
194
|
+
setSettingsOpen(false);
|
|
192
195
|
setIsEditingLink(false);
|
|
193
196
|
};
|
|
194
197
|
|
|
@@ -222,34 +225,49 @@ function LinkControl(_ref) {
|
|
|
222
225
|
}
|
|
223
226
|
};
|
|
224
227
|
|
|
228
|
+
const resetInternalValues = () => {
|
|
229
|
+
setInternalUrlInputValue(value === null || value === void 0 ? void 0 : value.url);
|
|
230
|
+
setInternalTextInputValue(value === null || value === void 0 ? void 0 : value.title);
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
const handleCancel = event => {
|
|
234
|
+
event.preventDefault();
|
|
235
|
+
event.stopPropagation(); // Ensure that any unsubmitted input changes are reset.
|
|
236
|
+
|
|
237
|
+
resetInternalValues();
|
|
238
|
+
|
|
239
|
+
if (hasLinkValue) {
|
|
240
|
+
// If there is a link then exist editing mode and show preview.
|
|
241
|
+
stopEditing();
|
|
242
|
+
} else {
|
|
243
|
+
// If there is no link value, then remove the link entirely.
|
|
244
|
+
onRemove === null || onRemove === void 0 ? void 0 : onRemove();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
248
|
+
};
|
|
249
|
+
|
|
225
250
|
const currentUrlInputValue = propInputValue || internalUrlInputValue;
|
|
226
251
|
const currentInputIsEmpty = !(currentUrlInputValue !== null && currentUrlInputValue !== void 0 && (_currentUrlInputValue = currentUrlInputValue.trim()) !== null && _currentUrlInputValue !== void 0 && _currentUrlInputValue.length);
|
|
227
252
|
const shownUnlinkControl = onRemove && value && !isEditingLink && !isCreatingPage;
|
|
228
|
-
const
|
|
253
|
+
const showSettings = !!(settings !== null && settings !== void 0 && settings.length); // Only show text control once a URL value has been committed
|
|
229
254
|
// and it isn't just empty whitespace.
|
|
230
255
|
// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.
|
|
231
256
|
|
|
232
|
-
const showTextControl =
|
|
257
|
+
const showTextControl = hasLinkValue && hasTextControl;
|
|
258
|
+
const isEditing = (isEditingLink || !value) && !isCreatingPage;
|
|
233
259
|
return createElement("div", {
|
|
234
260
|
tabIndex: -1,
|
|
235
261
|
ref: wrapperNode,
|
|
236
262
|
className: "block-editor-link-control"
|
|
237
263
|
}, isCreatingPage && createElement("div", {
|
|
238
264
|
className: "block-editor-link-control__loading"
|
|
239
|
-
}, createElement(Spinner, null), " ", __('Creating'), "\u2026"),
|
|
265
|
+
}, createElement(Spinner, null), " ", __('Creating'), "\u2026"), isEditing && createElement(Fragment, null, createElement("div", {
|
|
240
266
|
className: classnames({
|
|
241
267
|
'block-editor-link-control__search-input-wrapper': true,
|
|
242
268
|
'has-text-control': showTextControl
|
|
243
269
|
})
|
|
244
|
-
},
|
|
245
|
-
__nextHasNoMarginBottom: true,
|
|
246
|
-
ref: textInputRef,
|
|
247
|
-
className: "block-editor-link-control__field block-editor-link-control__text-content",
|
|
248
|
-
label: "Text",
|
|
249
|
-
value: internalTextInputValue,
|
|
250
|
-
onChange: setInternalTextInputValue,
|
|
251
|
-
onKeyDown: handleSubmitWithEnter
|
|
252
|
-
}), createElement(LinkControlSearchInput, {
|
|
270
|
+
}, createElement(LinkControlSearchInput, {
|
|
253
271
|
currentLink: value,
|
|
254
272
|
className: "block-editor-link-control__field block-editor-link-control__search-input",
|
|
255
273
|
placeholder: searchInputPlaceholder,
|
|
@@ -265,16 +283,7 @@ function LinkControl(_ref) {
|
|
|
265
283
|
withURLSuggestion: !noURLSuggestion,
|
|
266
284
|
createSuggestionButtonText: createSuggestionButtonText,
|
|
267
285
|
useLabel: showTextControl
|
|
268
|
-
}, createElement(
|
|
269
|
-
className: "block-editor-link-control__search-actions"
|
|
270
|
-
}, createElement(Button, {
|
|
271
|
-
onClick: handleSubmit,
|
|
272
|
-
label: __('Submit'),
|
|
273
|
-
icon: keyboardReturn,
|
|
274
|
-
className: "block-editor-link-control__search-submit",
|
|
275
|
-
disabled: currentInputIsEmpty // Disallow submitting empty values.
|
|
276
|
-
|
|
277
|
-
})))), errorMessage && createElement(Notice, {
|
|
286
|
+
})), errorMessage && createElement(Notice, {
|
|
278
287
|
className: "block-editor-link-control__search-error",
|
|
279
288
|
status: "error",
|
|
280
289
|
isDismissible: false
|
|
@@ -286,13 +295,32 @@ function LinkControl(_ref) {
|
|
|
286
295
|
hasRichPreviews: hasRichPreviews,
|
|
287
296
|
hasUnlinkControl: shownUnlinkControl,
|
|
288
297
|
onRemove: onRemove
|
|
289
|
-
}),
|
|
298
|
+
}), isEditing && createElement("div", {
|
|
290
299
|
className: "block-editor-link-control__tools"
|
|
291
|
-
}, createElement(LinkControlSettingsDrawer, {
|
|
300
|
+
}, (showSettings || showTextControl) && createElement(LinkControlSettingsDrawer, {
|
|
301
|
+
settingsOpen: settingsOpen,
|
|
302
|
+
setSettingsOpen: setSettingsOpen,
|
|
303
|
+
showTextControl: showTextControl,
|
|
304
|
+
showSettings: showSettings,
|
|
305
|
+
textInputRef: textInputRef,
|
|
306
|
+
internalTextInputValue: internalTextInputValue,
|
|
307
|
+
setInternalTextInputValue: setInternalTextInputValue,
|
|
308
|
+
handleSubmitWithEnter: handleSubmitWithEnter,
|
|
292
309
|
value: value,
|
|
293
310
|
settings: settings,
|
|
294
311
|
onChange: onChange
|
|
295
|
-
})
|
|
312
|
+
}), createElement("div", {
|
|
313
|
+
className: "block-editor-link-control__search-actions"
|
|
314
|
+
}, createElement(Button, {
|
|
315
|
+
variant: "primary",
|
|
316
|
+
onClick: handleSubmit,
|
|
317
|
+
className: "xblock-editor-link-control__search-submit",
|
|
318
|
+
disabled: currentInputIsEmpty // Disallow submitting empty values.
|
|
319
|
+
|
|
320
|
+
}, __('Apply')), createElement(Button, {
|
|
321
|
+
variant: "tertiary",
|
|
322
|
+
onClick: handleCancel
|
|
323
|
+
}, __('Cancel')))), renderControlBottom && renderControlBottom());
|
|
296
324
|
}
|
|
297
325
|
|
|
298
326
|
LinkControl.ViewerFill = ViewerFill;
|
|
@@ -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,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,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AAA,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,IA1EF,EAoFGoD,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,CArFF,EA6FGe,mBAAmB,IAAIA,mBAAmB,EA7F7C,CADD;AAiGA;;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\t__nextHasNoMarginBottom\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","__","useRef","useState","useEffect","focus","ENTER","LinkControlSettingsDrawer","LinkControlSearchInput","LinkPreview","useCreatePage","useInternalInputValue","ViewerFill","DEFAULT_LINK_SETTINGS","noop","LinkControl","searchInputPlaceholder","value","settings","onChange","onRemove","onCancel","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","isMounting","wrapperNode","textInputRef","isEndingEditWithFocus","settingsOpen","setSettingsOpen","internalUrlInputValue","setInternalUrlInputValue","url","internalTextInputValue","setInternalTextInputValue","title","isEditingLink","setIsEditingLink","createPage","isCreatingPage","errorMessage","current","whichFocusTargetIndex","nextFocusTarget","focusable","find","hasLinkValue","trim","length","stopEditing","contains","ownerDocument","activeElement","handleSelectSuggestion","updatedValue","handleSubmit","currentUrlInputValue","handleSubmitWithEnter","event","keyCode","currentInputIsEmpty","preventDefault","resetInternalValues","handleCancel","stopPropagation","shownUnlinkControl","showSettings","showTextControl","isEditing"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,OAAjB,EAA0BC,MAA1B,QAAwC,uBAAxC;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;;AAEA;;AACA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;AAEA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gBAAgB,EAAG6C,kBALpB;AAMC,IAAA,QAAQ,EAAG1D;AANZ,IApDF,EA8DG6D,SAAS,IACV;AAAK,IAAA,SAAS,EAAC;AAAf,KACG,CAAEF,YAAY,IAAIC,eAAlB,KACD,cAAC,yBAAD;AACC,IAAA,YAAY,EAAGvC,YADhB;AAEC,IAAA,eAAe,EAAGC,eAFnB;AAGC,IAAA,eAAe,EAAGsC,eAHnB;AAIC,IAAA,YAAY,EAAGD,YAJhB;AAKC,IAAA,YAAY,EAAGxC,YALhB;AAMC,IAAA,sBAAsB,EAAGO,sBAN1B;AAOC,IAAA,yBAAyB,EACxBC,yBARF;AAUC,IAAA,qBAAqB,EAAGuB,qBAVzB;AAWC,IAAA,KAAK,EAAGrD,KAXT;AAYC,IAAA,QAAQ,EAAGC,QAZZ;AAaC,IAAA,QAAQ,EAAGC;AAbZ,IAFF,EAmBC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,OAAO,EAAGiD,YAFX;AAGC,IAAA,SAAS,EAAC,2CAHX;AAIC,IAAA,QAAQ,EAAGK,mBAJZ,CAIkC;;AAJlC,KAMGxE,EAAE,CAAE,OAAF,CANL,CADD,EASC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,UAAhB;AAA2B,IAAA,OAAO,EAAG2E;AAArC,KACG3E,EAAE,CAAE,QAAF,CADL,CATD,CAnBD,CA/DF,EAkGGkC,mBAAmB,IAAIA,mBAAmB,EAlG7C,CADD;AAsGA;;AAEDpB,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 } from '@wordpress/components';\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\tonCancel,\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 [ settingsOpen, setSettingsOpen ] = useState( 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\tconst hasLinkValue = value?.url?.trim()?.length > 0;\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\tsetSettingsOpen( false );\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 resetInternalValues = () => {\n\t\tsetInternalUrlInputValue( value?.url );\n\t\tsetInternalTextInputValue( value?.title );\n\t};\n\n\tconst handleCancel = ( event ) => {\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\n\t\t// Ensure that any unsubmitted input changes are reset.\n\t\tresetInternalValues();\n\n\t\tif ( hasLinkValue ) {\n\t\t\t// If there is a link then exist editing mode and show preview.\n\t\t\tstopEditing();\n\t\t} else {\n\t\t\t// If there is no link value, then remove the link entirely.\n\t\t\tonRemove?.();\n\t\t}\n\n\t\tonCancel?.();\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 showSettings = !! 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 = hasLinkValue && hasTextControl;\n\n\tconst isEditing = ( isEditingLink || ! value ) && ! isCreatingPage;\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{ isEditing && (\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<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</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{ isEditing && (\n\t\t\t\t<div className=\"block-editor-link-control__tools\">\n\t\t\t\t\t{ ( showSettings || showTextControl ) && (\n\t\t\t\t\t\t<LinkControlSettingsDrawer\n\t\t\t\t\t\t\tsettingsOpen={ settingsOpen }\n\t\t\t\t\t\t\tsetSettingsOpen={ setSettingsOpen }\n\t\t\t\t\t\t\tshowTextControl={ showTextControl }\n\t\t\t\t\t\t\tshowSettings={ showSettings }\n\t\t\t\t\t\t\ttextInputRef={ textInputRef }\n\t\t\t\t\t\t\tinternalTextInputValue={ internalTextInputValue }\n\t\t\t\t\t\t\tsetInternalTextInputValue={\n\t\t\t\t\t\t\t\tsetInternalTextInputValue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\thandleSubmitWithEnter={ handleSubmitWithEnter }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<div className=\"block-editor-link-control__search-actions\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tonClick={ handleSubmit }\n\t\t\t\t\t\t\tclassName=\"xblock-editor-link-control__search-submit\"\n\t\t\t\t\t\t\tdisabled={ currentInputIsEmpty } // Disallow submitting empty values.\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Apply' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ handleCancel }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ renderControlBottom && renderControlBottom() }\n\t\t</div>\n\t);\n}\n\nLinkControl.ViewerFill = ViewerFill;\n\nexport default LinkControl;\n"]}
|
|
@@ -3,41 +3,79 @@ import { createElement } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
+
import { Button, TextControl, __unstableMotion as motion, __unstableAnimatePresence as AnimatePresence } from '@wordpress/components';
|
|
7
|
+
import { settings as settingsIcon } from '@wordpress/icons';
|
|
8
|
+
import { useReducedMotion, useInstanceId } from '@wordpress/compose';
|
|
6
9
|
import { __ } from '@wordpress/i18n';
|
|
7
|
-
import {
|
|
10
|
+
import { Fragment } from '@wordpress/element';
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
8
14
|
|
|
9
|
-
|
|
15
|
+
import Settings from './settings';
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
function LinkSettingsDrawer(_ref) {
|
|
12
18
|
let {
|
|
19
|
+
settingsOpen,
|
|
20
|
+
setSettingsOpen,
|
|
21
|
+
showTextControl,
|
|
22
|
+
showSettings,
|
|
23
|
+
textInputRef,
|
|
24
|
+
internalTextInputValue,
|
|
25
|
+
setInternalTextInputValue,
|
|
26
|
+
handleSubmitWithEnter,
|
|
13
27
|
value,
|
|
14
|
-
|
|
15
|
-
|
|
28
|
+
settings,
|
|
29
|
+
onChange
|
|
16
30
|
} = _ref;
|
|
31
|
+
const prefersReducedMotion = useReducedMotion();
|
|
32
|
+
const MaybeAnimatePresence = prefersReducedMotion ? Fragment : AnimatePresence;
|
|
33
|
+
const MaybeMotionDiv = prefersReducedMotion ? 'div' : motion.div;
|
|
34
|
+
const id = useInstanceId(LinkSettingsDrawer);
|
|
35
|
+
const settingsDrawerId = `link-control-settings-drawer-${id}`;
|
|
36
|
+
return createElement(Fragment, null, createElement(Button, {
|
|
37
|
+
className: "block-editor-link-control__drawer-toggle",
|
|
38
|
+
"aria-expanded": settingsOpen,
|
|
39
|
+
onClick: () => setSettingsOpen(!settingsOpen),
|
|
40
|
+
icon: settingsIcon,
|
|
41
|
+
label: __('Link Settings'),
|
|
42
|
+
"aria-controls": settingsDrawerId
|
|
43
|
+
}), createElement(MaybeAnimatePresence, null, settingsOpen && createElement(MaybeMotionDiv, {
|
|
44
|
+
className: "block-editor-link-control__drawer",
|
|
45
|
+
hidden: !settingsOpen,
|
|
46
|
+
id: settingsDrawerId,
|
|
47
|
+
initial: "collapsed",
|
|
48
|
+
animate: "open",
|
|
49
|
+
exit: "collapsed",
|
|
50
|
+
variants: {
|
|
51
|
+
open: {
|
|
52
|
+
opacity: 1,
|
|
53
|
+
height: 'auto'
|
|
54
|
+
},
|
|
55
|
+
collapsed: {
|
|
56
|
+
opacity: 0,
|
|
57
|
+
height: 0
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
transition: {
|
|
61
|
+
duration: 0.1
|
|
62
|
+
}
|
|
63
|
+
}, createElement("div", {
|
|
64
|
+
className: "block-editor-link-control__drawer-inner"
|
|
65
|
+
}, showTextControl && createElement(TextControl, {
|
|
66
|
+
__nextHasNoMarginBottom: true,
|
|
67
|
+
ref: textInputRef,
|
|
68
|
+
className: "block-editor-link-control__setting block-editor-link-control__text-content",
|
|
69
|
+
label: "Text",
|
|
70
|
+
value: internalTextInputValue,
|
|
71
|
+
onChange: setInternalTextInputValue,
|
|
72
|
+
onKeyDown: handleSubmitWithEnter
|
|
73
|
+
}), showSettings && createElement(Settings, {
|
|
74
|
+
value: value,
|
|
75
|
+
settings: settings,
|
|
76
|
+
onChange: onChange
|
|
77
|
+
})))));
|
|
78
|
+
}
|
|
17
79
|
|
|
18
|
-
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const handleSettingChange = setting => newValue => {
|
|
23
|
-
onChange({ ...value,
|
|
24
|
-
[setting.id]: newValue
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const theSettings = settings.map(setting => createElement(ToggleControl, {
|
|
29
|
-
className: "block-editor-link-control__setting",
|
|
30
|
-
key: setting.id,
|
|
31
|
-
label: setting.title,
|
|
32
|
-
onChange: handleSettingChange(setting),
|
|
33
|
-
checked: value ? !!value[setting.id] : false
|
|
34
|
-
}));
|
|
35
|
-
return createElement("fieldset", {
|
|
36
|
-
className: "block-editor-link-control__settings"
|
|
37
|
-
}, createElement(VisuallyHidden, {
|
|
38
|
-
as: "legend"
|
|
39
|
-
}, __('Currently selected link settings')), theSettings);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export default LinkControlSettingsDrawer;
|
|
80
|
+
export default LinkSettingsDrawer;
|
|
43
81
|
//# sourceMappingURL=settings-drawer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/settings-drawer.js"],"names":["__","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/settings-drawer.js"],"names":["Button","TextControl","__unstableMotion","motion","__unstableAnimatePresence","AnimatePresence","settings","settingsIcon","useReducedMotion","useInstanceId","__","Fragment","Settings","LinkSettingsDrawer","settingsOpen","setSettingsOpen","showTextControl","showSettings","textInputRef","internalTextInputValue","setInternalTextInputValue","handleSubmitWithEnter","value","onChange","prefersReducedMotion","MaybeAnimatePresence","MaybeMotionDiv","div","id","settingsDrawerId","open","opacity","height","collapsed","duration"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,MADD,EAECC,WAFD,EAGCC,gBAAgB,IAAIC,MAHrB,EAICC,yBAAyB,IAAIC,eAJ9B,QAKO,uBALP;AAMA,SAASC,QAAQ,IAAIC,YAArB,QAAyC,kBAAzC;AACA,SAASC,gBAAT,EAA2BC,aAA3B,QAAgD,oBAAhD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,OAAOC,QAAP,MAAqB,YAArB;;AAEA,SAASC,kBAAT,OAYI;AAAA,MAZyB;AAC5BC,IAAAA,YAD4B;AAE5BC,IAAAA,eAF4B;AAG5BC,IAAAA,eAH4B;AAI5BC,IAAAA,YAJ4B;AAK5BC,IAAAA,YAL4B;AAM5BC,IAAAA,sBAN4B;AAO5BC,IAAAA,yBAP4B;AAQ5BC,IAAAA,qBAR4B;AAS5BC,IAAAA,KAT4B;AAU5BhB,IAAAA,QAV4B;AAW5BiB,IAAAA;AAX4B,GAYzB;AACH,QAAMC,oBAAoB,GAAGhB,gBAAgB,EAA7C;AACA,QAAMiB,oBAAoB,GAAGD,oBAAoB,GAC9Cb,QAD8C,GAE9CN,eAFH;AAGA,QAAMqB,cAAc,GAAGF,oBAAoB,GAAG,KAAH,GAAWrB,MAAM,CAACwB,GAA7D;AAEA,QAAMC,EAAE,GAAGnB,aAAa,CAAEI,kBAAF,CAAxB;AAEA,QAAMgB,gBAAgB,GAAI,gCAAgCD,EAAI,EAA9D;AAEA,SACC,8BACC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,0CADX;AAEC,qBAAgBd,YAFjB;AAGC,IAAA,OAAO,EAAG,MAAMC,eAAe,CAAE,CAAED,YAAJ,CAHhC;AAIC,IAAA,IAAI,EAAGP,YAJR;AAKC,IAAA,KAAK,EAAGG,EAAE,CAAE,eAAF,CALX;AAMC,qBAAgBmB;AANjB,IADD,EASC,cAAC,oBAAD,QACGf,YAAY,IACb,cAAC,cAAD;AACC,IAAA,SAAS,EAAC,mCADX;AAEC,IAAA,MAAM,EAAG,CAAEA,YAFZ;AAGC,IAAA,EAAE,EAAGe,gBAHN;AAIC,IAAA,OAAO,EAAC,WAJT;AAKC,IAAA,OAAO,EAAC,MALT;AAMC,IAAA,IAAI,EAAC,WANN;AAOC,IAAA,QAAQ,EAAG;AACVC,MAAAA,IAAI,EAAE;AAAEC,QAAAA,OAAO,EAAE,CAAX;AAAcC,QAAAA,MAAM,EAAE;AAAtB,OADI;AAEVC,MAAAA,SAAS,EAAE;AAAEF,QAAAA,OAAO,EAAE,CAAX;AAAcC,QAAAA,MAAM,EAAE;AAAtB;AAFD,KAPZ;AAWC,IAAA,UAAU,EAAG;AACZE,MAAAA,QAAQ,EAAE;AADE;AAXd,KAeC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGlB,eAAe,IAChB,cAAC,WAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,GAAG,EAAGE,YAFP;AAGC,IAAA,SAAS,EAAC,4EAHX;AAIC,IAAA,KAAK,EAAC,MAJP;AAKC,IAAA,KAAK,EAAGC,sBALT;AAMC,IAAA,QAAQ,EAAGC,yBANZ;AAOC,IAAA,SAAS,EAAGC;AAPb,IAFF,EAYGJ,YAAY,IACb,cAAC,QAAD;AACC,IAAA,KAAK,EAAGK,KADT;AAEC,IAAA,QAAQ,EAAGhB,QAFZ;AAGC,IAAA,QAAQ,EAAGiB;AAHZ,IAbF,CAfD,CAFF,CATD,CADD;AAoDA;;AAED,eAAeV,kBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tTextControl,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '@wordpress/components';\nimport { settings as settingsIcon } from '@wordpress/icons';\nimport { useReducedMotion, useInstanceId } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { Fragment } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Settings from './settings';\n\nfunction LinkSettingsDrawer( {\n\tsettingsOpen,\n\tsetSettingsOpen,\n\tshowTextControl,\n\tshowSettings,\n\ttextInputRef,\n\tinternalTextInputValue,\n\tsetInternalTextInputValue,\n\thandleSubmitWithEnter,\n\tvalue,\n\tsettings,\n\tonChange,\n} ) {\n\tconst prefersReducedMotion = useReducedMotion();\n\tconst MaybeAnimatePresence = prefersReducedMotion\n\t\t? Fragment\n\t\t: AnimatePresence;\n\tconst MaybeMotionDiv = prefersReducedMotion ? 'div' : motion.div;\n\n\tconst id = useInstanceId( LinkSettingsDrawer );\n\n\tconst settingsDrawerId = `link-control-settings-drawer-${ id }`;\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName=\"block-editor-link-control__drawer-toggle\"\n\t\t\t\taria-expanded={ settingsOpen }\n\t\t\t\tonClick={ () => setSettingsOpen( ! settingsOpen ) }\n\t\t\t\ticon={ settingsIcon }\n\t\t\t\tlabel={ __( 'Link Settings' ) }\n\t\t\t\taria-controls={ settingsDrawerId }\n\t\t\t/>\n\t\t\t<MaybeAnimatePresence>\n\t\t\t\t{ settingsOpen && (\n\t\t\t\t\t<MaybeMotionDiv\n\t\t\t\t\t\tclassName=\"block-editor-link-control__drawer\"\n\t\t\t\t\t\thidden={ ! settingsOpen }\n\t\t\t\t\t\tid={ settingsDrawerId }\n\t\t\t\t\t\tinitial=\"collapsed\"\n\t\t\t\t\t\tanimate=\"open\"\n\t\t\t\t\t\texit=\"collapsed\"\n\t\t\t\t\t\tvariants={ {\n\t\t\t\t\t\t\topen: { opacity: 1, height: 'auto' },\n\t\t\t\t\t\t\tcollapsed: { opacity: 0, height: 0 },\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ttransition={ {\n\t\t\t\t\t\t\tduration: 0.1,\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<div className=\"block-editor-link-control__drawer-inner\">\n\t\t\t\t\t\t\t{ showTextControl && (\n\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\tref={ textInputRef }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__setting block-editor-link-control__text-content\"\n\t\t\t\t\t\t\t\t\tlabel=\"Text\"\n\t\t\t\t\t\t\t\t\tvalue={ internalTextInputValue }\n\t\t\t\t\t\t\t\t\tonChange={ setInternalTextInputValue }\n\t\t\t\t\t\t\t\t\tonKeyDown={ handleSubmitWithEnter }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ showSettings && (\n\t\t\t\t\t\t\t\t<Settings\n\t\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</MaybeMotionDiv>\n\t\t\t\t) }\n\t\t\t</MaybeAnimatePresence>\n\t\t</>\n\t);\n}\n\nexport default LinkSettingsDrawer;\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { ToggleControl, VisuallyHidden } from '@wordpress/components';
|
|
8
|
+
|
|
9
|
+
const noop = () => {};
|
|
10
|
+
|
|
11
|
+
const LinkControlSettings = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
value,
|
|
14
|
+
onChange = noop,
|
|
15
|
+
settings
|
|
16
|
+
} = _ref;
|
|
17
|
+
|
|
18
|
+
if (!settings || !settings.length) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const handleSettingChange = setting => newValue => {
|
|
23
|
+
onChange({ ...value,
|
|
24
|
+
[setting.id]: newValue
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const theSettings = settings.map(setting => createElement(ToggleControl, {
|
|
29
|
+
__nextHasNoMarginBottom: true,
|
|
30
|
+
className: "block-editor-link-control__setting",
|
|
31
|
+
key: setting.id,
|
|
32
|
+
label: setting.title,
|
|
33
|
+
onChange: handleSettingChange(setting),
|
|
34
|
+
checked: value ? !!value[setting.id] : false
|
|
35
|
+
}));
|
|
36
|
+
return createElement("fieldset", {
|
|
37
|
+
className: "block-editor-link-control__settings"
|
|
38
|
+
}, createElement(VisuallyHidden, {
|
|
39
|
+
as: "legend"
|
|
40
|
+
}, __('Currently selected link settings')), theSettings);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default LinkControlSettings;
|
|
44
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/link-control/settings.js"],"names":["__","ToggleControl","VisuallyHidden","noop","LinkControlSettings","value","onChange","settings","length","handleSettingChange","setting","newValue","id","theSettings","map","title"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,aAAT,EAAwBC,cAAxB,QAA8C,uBAA9C;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,MAAMC,mBAAmB,GAAG,QAA4C;AAAA,MAA1C;AAAEC,IAAAA,KAAF;AAASC,IAAAA,QAAQ,GAAGH,IAApB;AAA0BI,IAAAA;AAA1B,GAA0C;;AACvE,MAAK,CAAEA,QAAF,IAAc,CAAEA,QAAQ,CAACC,MAA9B,EAAuC;AACtC,WAAO,IAAP;AACA;;AAED,QAAMC,mBAAmB,GAAKC,OAAF,IAAiBC,QAAF,IAAgB;AAC1DL,IAAAA,QAAQ,CAAE,EACT,GAAGD,KADM;AAET,OAAEK,OAAO,CAACE,EAAV,GAAgBD;AAFP,KAAF,CAAR;AAIA,GALD;;AAOA,QAAME,WAAW,GAAGN,QAAQ,CAACO,GAAT,CAAgBJ,OAAF,IACjC,cAAC,aAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,SAAS,EAAC,oCAFX;AAGC,IAAA,GAAG,EAAGA,OAAO,CAACE,EAHf;AAIC,IAAA,KAAK,EAAGF,OAAO,CAACK,KAJjB;AAKC,IAAA,QAAQ,EAAGN,mBAAmB,CAAEC,OAAF,CAL/B;AAMC,IAAA,OAAO,EAAGL,KAAK,GAAG,CAAC,CAAEA,KAAK,CAAEK,OAAO,CAACE,EAAV,CAAX,GAA4B;AAN5C,IADmB,CAApB;AAWA,SACC;AAAU,IAAA,SAAS,EAAC;AAApB,KACC,cAAC,cAAD;AAAgB,IAAA,EAAE,EAAC;AAAnB,KACGZ,EAAE,CAAE,kCAAF,CADL,CADD,EAIGa,WAJH,CADD;AAQA,CA/BD;;AAiCA,eAAeT,mBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ToggleControl, VisuallyHidden } from '@wordpress/components';\n\nconst noop = () => {};\n\nconst LinkControlSettings = ( { value, onChange = noop, settings } ) => {\n\tif ( ! settings || ! settings.length ) {\n\t\treturn null;\n\t}\n\n\tconst handleSettingChange = ( setting ) => ( newValue ) => {\n\t\tonChange( {\n\t\t\t...value,\n\t\t\t[ setting.id ]: newValue,\n\t\t} );\n\t};\n\n\tconst theSettings = settings.map( ( setting ) => (\n\t\t<ToggleControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName=\"block-editor-link-control__setting\"\n\t\t\tkey={ setting.id }\n\t\t\tlabel={ setting.title }\n\t\t\tonChange={ handleSettingChange( setting ) }\n\t\t\tchecked={ value ? !! value[ setting.id ] : false }\n\t\t/>\n\t) );\n\n\treturn (\n\t\t<fieldset className=\"block-editor-link-control__settings\">\n\t\t\t<VisuallyHidden as=\"legend\">\n\t\t\t\t{ __( 'Currently selected link settings' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t{ theSettings }\n\t\t</fieldset>\n\t);\n};\n\nexport default LinkControlSettings;\n"]}
|
|
@@ -173,7 +173,9 @@ function ListViewBlock(_ref) {
|
|
|
173
173
|
isSelected,
|
|
174
174
|
rowItemRef: rowRef,
|
|
175
175
|
selectedClientIds
|
|
176
|
-
});
|
|
176
|
+
}); // Detect if there is a block in the canvas currently being edited and multi-selection is not happening.
|
|
177
|
+
|
|
178
|
+
const currentlyEditingBlockInCanvas = isSelected && selectedClientIds.length === 1;
|
|
177
179
|
return createElement(ListViewLeaf, {
|
|
178
180
|
className: classes,
|
|
179
181
|
onMouseEnter: onMouseEnter,
|
|
@@ -214,7 +216,7 @@ function ListViewBlock(_ref) {
|
|
|
214
216
|
siblingBlockCount: siblingBlockCount,
|
|
215
217
|
level: level,
|
|
216
218
|
ref: ref,
|
|
217
|
-
tabIndex: tabIndex,
|
|
219
|
+
tabIndex: currentlyEditingBlockInCanvas ? 0 : tabIndex,
|
|
218
220
|
onFocus: onFocus,
|
|
219
221
|
isExpanded: isExpanded,
|
|
220
222
|
selectedClientIds: selectedClientIds,
|