@wordpress/block-editor 17.0.2-next.v.202608281122.0 → 17.1.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 +29 -1
- package/build/components/background-image-control/index.cjs +18 -1
- package/build/components/background-image-control/index.cjs.map +2 -2
- package/build/components/block-allowed-blocks/modal.cjs +2 -1
- package/build/components/block-allowed-blocks/modal.cjs.map +3 -3
- package/build/components/block-edit/edit.cjs.map +1 -1
- package/build/components/block-inspector/index.cjs +3 -12
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-is-hovered.cjs +17 -4
- package/build/components/block-list/use-block-props/use-is-hovered.cjs.map +2 -2
- package/build/components/block-preview/index.cjs +1 -2
- package/build/components/block-preview/index.cjs.map +2 -2
- package/build/components/block-switcher/index.cjs +2 -1
- package/build/components/block-switcher/index.cjs.map +3 -3
- package/build/components/block-toolbar/pattern-overrides-dropdown.cjs +2 -1
- package/build/components/block-toolbar/pattern-overrides-dropdown.cjs.map +3 -3
- package/build/components/global-styles/border-panel.cjs +19 -42
- package/build/components/global-styles/border-panel.cjs.map +2 -2
- package/build/components/global-styles/image-settings-panel.cjs.map +1 -1
- package/build/components/iframe/index.cjs.map +1 -1
- package/build/components/inserter/hooks/use-patterns-paging.cjs.map +1 -1
- package/build/components/inserter-draggable-blocks/index.cjs.map +1 -1
- package/build/components/inspector-controls-tabs/content-tab.cjs +2 -3
- package/build/components/inspector-controls-tabs/content-tab.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/styles-tab.cjs +1 -3
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs +1 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs.map +2 -2
- package/build/components/inspector-popover-header/index.cjs +5 -4
- package/build/components/inspector-popover-header/index.cjs.map +3 -3
- package/build/components/link-control/index.cjs.map +2 -2
- package/build/components/link-control/search-input.cjs.map +1 -1
- package/build/components/list-view/block-select-button.cjs +9 -1
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/block.cjs +2 -1
- package/build/components/list-view/block.cjs.map +2 -2
- package/build/components/list-view/use-list-view-drop-zone.cjs.map +1 -1
- package/build/components/media-replace-flow/index.cjs +4 -1
- package/build/components/media-replace-flow/index.cjs.map +2 -2
- package/build/components/navigable-toolbar/index.cjs +3 -0
- package/build/components/navigable-toolbar/index.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/enter.cjs +23 -11
- package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/index.cjs +0 -2
- package/build/components/rich-text/event-listeners/index.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/input-rules.cjs +4 -2
- package/build/components/rich-text/event-listeners/input-rules.cjs.map +2 -2
- package/build/components/use-block-drop-zone/index.cjs.map +1 -1
- package/build/components/writing-flow/index.cjs +5 -0
- package/build/components/writing-flow/index.cjs.map +3 -3
- package/build/components/writing-flow/use-arrow-nav.cjs.map +1 -1
- package/build/components/writing-flow/use-input.cjs +12 -2
- package/build/components/writing-flow/use-input.cjs.map +2 -2
- package/build/components/writing-flow/use-tab-nav.cjs +84 -41
- package/build/components/writing-flow/use-tab-nav.cjs.map +3 -3
- package/build/components/{rich-text/event-listeners/undo-automatic-change.cjs → writing-flow/use-undo-automatic-change.cjs} +18 -15
- package/build/components/writing-flow/use-undo-automatic-change.cjs.map +7 -0
- package/build/hooks/border.cjs +2 -46
- package/build/hooks/border.cjs.map +2 -2
- package/build/hooks/generate-fields-from-attributes.cjs.map +1 -1
- package/build/hooks/index.cjs +0 -2
- package/build/hooks/index.cjs.map +3 -3
- package/build/hooks/style.cjs +2 -2
- package/build/hooks/style.cjs.map +2 -2
- package/build/layouts/flex.cjs +3 -0
- package/build/layouts/flex.cjs.map +2 -2
- package/build/store/actions.cjs +12 -9
- package/build/store/actions.cjs.map +3 -3
- package/build-module/components/background-image-control/index.mjs +18 -1
- package/build-module/components/background-image-control/index.mjs.map +2 -2
- package/build-module/components/block-allowed-blocks/modal.mjs +2 -2
- package/build-module/components/block-allowed-blocks/modal.mjs.map +2 -2
- package/build-module/components/block-edit/edit.mjs.map +1 -1
- package/build-module/components/block-inspector/index.mjs +3 -12
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-is-hovered.mjs +17 -4
- package/build-module/components/block-list/use-block-props/use-is-hovered.mjs.map +2 -2
- package/build-module/components/block-preview/index.mjs +1 -2
- package/build-module/components/block-preview/index.mjs.map +2 -2
- package/build-module/components/block-switcher/index.mjs +2 -2
- package/build-module/components/block-switcher/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/pattern-overrides-dropdown.mjs +3 -6
- package/build-module/components/block-toolbar/pattern-overrides-dropdown.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +19 -42
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/image-settings-panel.mjs.map +1 -1
- package/build-module/components/iframe/index.mjs.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-paging.mjs.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.mjs.map +1 -1
- package/build-module/components/inspector-controls-tabs/content-tab.mjs +3 -4
- package/build-module/components/inspector-controls-tabs/content-tab.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +1 -3
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs +1 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs.map +2 -2
- package/build-module/components/inspector-popover-header/index.mjs +6 -7
- package/build-module/components/inspector-popover-header/index.mjs.map +2 -2
- package/build-module/components/link-control/index.mjs.map +2 -2
- package/build-module/components/link-control/search-input.mjs.map +1 -1
- package/build-module/components/list-view/block-select-button.mjs +9 -1
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +2 -1
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/list-view/use-list-view-drop-zone.mjs.map +1 -1
- package/build-module/components/media-replace-flow/index.mjs +4 -1
- package/build-module/components/media-replace-flow/index.mjs.map +2 -2
- package/build-module/components/navigable-toolbar/index.mjs +3 -0
- package/build-module/components/navigable-toolbar/index.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs +23 -11
- package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/index.mjs +0 -2
- package/build-module/components/rich-text/event-listeners/index.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/input-rules.mjs +4 -2
- package/build-module/components/rich-text/event-listeners/input-rules.mjs.map +2 -2
- package/build-module/components/use-block-drop-zone/index.mjs.map +1 -1
- package/build-module/components/writing-flow/index.mjs +5 -0
- package/build-module/components/writing-flow/index.mjs.map +2 -2
- package/build-module/components/writing-flow/use-arrow-nav.mjs.map +1 -1
- package/build-module/components/writing-flow/use-input.mjs +12 -2
- package/build-module/components/writing-flow/use-input.mjs.map +2 -2
- package/build-module/components/writing-flow/use-tab-nav.mjs +86 -43
- package/build-module/components/writing-flow/use-tab-nav.mjs.map +3 -3
- package/build-module/components/writing-flow/use-undo-automatic-change.mjs +36 -0
- package/build-module/components/writing-flow/use-undo-automatic-change.mjs.map +7 -0
- package/build-module/hooks/border.mjs +1 -45
- package/build-module/hooks/border.mjs.map +2 -2
- package/build-module/hooks/generate-fields-from-attributes.mjs.map +1 -1
- package/build-module/hooks/index.mjs +0 -2
- package/build-module/hooks/index.mjs.map +2 -2
- package/build-module/hooks/style.mjs +3 -2
- package/build-module/hooks/style.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +3 -0
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/store/actions.mjs +12 -9
- package/build-module/store/actions.mjs.map +2 -2
- package/build-style/content-rtl.css +9 -20
- package/build-style/content.css +9 -20
- package/build-style/style-rtl.css +100 -221
- package/build-style/style.css +100 -221
- package/package.json +42 -41
- package/src/autocompleters/test/block.js +1 -0
- package/src/components/alignment-control/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +34 -16
- package/src/components/alignment-control/test/{index.jsx → index.jsdom.test.jsx} +2 -1
- package/src/components/background-image-control/index.jsx +32 -1
- package/src/components/background-image-control/style.scss +5 -3
- package/src/components/background-image-control/test/{index.js → index.jsdom.test.js} +1 -0
- package/src/components/block-alignment-control/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +68 -13
- package/src/components/block-alignment-control/test/{index.jsx → index.jsdom.test.jsx} +2 -1
- package/src/components/block-allowed-blocks/modal.jsx +3 -3
- package/src/components/block-bindings/test/{use-block-bindings-utils.js → use-block-bindings-utils.jsdom.test.js} +2 -1
- package/src/components/block-breadcrumb/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +2 -2
- package/src/components/block-breadcrumb/test/{index.jsx → index.jsdom.test.jsx} +1 -0
- package/src/components/block-compare/test/__snapshots__/{block-view.jsx.snap → block-view.jsdom.test.jsx.snap} +2 -2
- package/src/components/block-compare/test/{block-view.jsx → block-view.jsdom.test.jsx} +1 -0
- package/src/components/block-controls/test/{index.jsx → index.jsdom.test.jsx} +1 -0
- package/src/components/block-edit/edit.jsx +1 -1
- package/src/components/block-edit/test/{edit.jsx → edit.jsdom.test.jsx} +1 -0
- package/src/components/block-icon/content.scss +0 -6
- package/src/components/block-icon/style.scss +0 -6
- package/src/components/block-icon/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +6 -2
- package/src/components/block-inspector/index.jsx +3 -11
- package/src/components/block-list/content.scss +4 -1
- package/src/components/block-list/use-block-props/use-is-hovered.js +24 -5
- package/src/components/block-manager/style.scss +2 -0
- package/src/components/block-mover/test/mover-description.js +1 -0
- package/src/components/block-preview/index.jsx +1 -2
- package/src/components/block-preview/test/{index.jsx → index.jsdom.test.jsx} +10 -6
- package/src/components/block-selection-clearer/test/{index.jsx → index.jsdom.test.jsx} +24 -19
- package/src/components/block-settings-menu/test/{block-mode-toggle.jsx → block-mode-toggle.jsdom.test.jsx} +5 -1
- package/src/components/block-styles/test/utils.js +1 -0
- package/src/components/block-switcher/index.jsx +3 -3
- package/src/components/block-switcher/test/{index.jsx → index.jsdom.test.jsx} +8 -4
- package/src/components/block-switcher/test/use-transformed.patterns.js +1 -0
- package/src/components/block-switcher/test/utils.js +1 -0
- package/src/components/block-title/test/{index.jsx → index.jsdom.test.jsx} +7 -3
- package/src/components/block-toolbar/pattern-overrides-dropdown.jsx +3 -6
- package/src/components/block-toolbar/style.scss +1 -1
- package/src/components/block-toolbar/test/{block-toolbar-icon.jsx → block-toolbar-icon.jsdom.test.jsx} +25 -21
- package/src/components/block-variation-picker/content.scss +5 -3
- package/src/components/block-vertical-alignment-control/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +55 -11
- package/src/components/block-vertical-alignment-control/test/{index.jsx → index.jsdom.test.jsx} +2 -1
- package/src/components/block-visibility/test/{use-block-visibility.js → use-block-visibility.jsdom.test.js} +6 -5
- package/src/components/block-visibility/test/utils.js +2 -1
- package/src/components/border-radius-control/test/{index.jsx → index.jsdom.test.jsx} +8 -1
- package/src/components/border-radius-control/test/utils.js +1 -0
- package/src/components/button-block-appender/content.scss +1 -1
- package/src/components/child-layout-control/test/{index.jsx → index.jsdom.test.jsx} +18 -15
- package/src/components/color-palette/test/{control.jsx → control.jsdom.test.jsx} +15 -4
- package/src/components/colors/test/utils.js +1 -0
- package/src/components/colors/test/{with-colors.jsx → with-colors.jsdom.test.jsx} +4 -3
- package/src/components/colors-gradients/test/{control.jsx → control.jsdom.test.jsx} +8 -3
- package/src/components/contrast-checker/test/{index.jsx → index.jsdom.test.jsx} +2 -1
- package/src/components/default-block-appender/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +4 -4
- package/src/components/default-block-appender/test/{index.jsx → index.jsdom.test.jsx} +8 -7
- package/src/components/dimensions-tool/test/{index.jsx → index.jsdom.test.jsx} +27 -22
- package/src/components/dimensions-tool/test/utils.js +1 -0
- package/src/components/duotone-control/test/{index.jsx → index.jsdom.test.jsx} +6 -3
- package/src/components/font-sizes/test/fluid-utils.js +1 -0
- package/src/components/font-sizes/test/utils.js +1 -0
- package/src/components/global-styles/border-panel.jsx +17 -40
- package/src/components/global-styles/image-settings-panel.jsx +1 -1
- package/src/components/global-styles/inheritance/test/{index.jsx → index.jsdom.test.jsx} +5 -2
- package/src/components/global-styles/test/{background-panel.jsx → background-panel.jsdom.test.jsx} +10 -5
- package/src/components/global-styles/test/{border-panel.jsx → border-panel.jsdom.test.jsx} +113 -13
- package/src/components/global-styles/test/{color-panel.jsx → color-panel.jsdom.test.jsx} +5 -0
- package/src/components/global-styles/test/{dimensions-panel.jsx → dimensions-panel.jsdom.test.jsx} +14 -14
- package/src/components/global-styles/test/{filters-panel.jsx → filters-panel.jsdom.test.jsx} +7 -4
- package/src/components/global-styles/test/{inherited-value-context-core.js → inherited-value-context-core.jsdom.test.js} +10 -9
- package/src/components/global-styles/test/{inherited-value-context.jsx → inherited-value-context.jsdom.test.jsx} +18 -17
- package/src/components/global-styles/test/{state-control-badges.jsx → state-control-badges.jsdom.test.jsx} +3 -2
- package/src/components/global-styles/test/{typography-panel-core.jsx → typography-panel-core.jsdom.test.jsx} +5 -2
- package/src/components/global-styles/test/{typography-panel.jsx → typography-panel.jsdom.test.jsx} +17 -12
- package/src/components/global-styles/test/typography-utils.js +1 -0
- package/src/components/global-styles/test/utils.js +1 -0
- package/src/components/grid/style.scss +0 -10
- package/src/components/iframe/index.jsx +3 -3
- package/src/components/image-editor/test/index.js +1 -0
- package/src/components/image-size-control/test/{index.jsx → index.jsdom.test.jsx} +8 -3
- package/src/components/inner-blocks/test/__snapshots__/index.jsdom.test.jsx.snap +15 -0
- package/src/components/inner-blocks/test/{index.jsx → index.jsdom.test.jsx} +2 -0
- package/src/components/inner-content/test/{index.jsx → index.jsdom.test.jsx} +1 -0
- package/src/components/inserter/hooks/use-patterns-paging.js +1 -1
- package/src/components/inserter/media-tab/test/{hooks.js → hooks.jsdom.test.js} +12 -11
- package/src/components/inserter/media-tab/test/{media-panel.jsx → media-panel.jsdom.test.jsx} +15 -12
- package/src/components/inserter/style.scss +2 -2
- package/src/components/inserter/test/get-appender-label.js +12 -11
- package/src/components/inserter/test/search-items.js +1 -0
- package/src/components/inserter-draggable-blocks/index.jsx +1 -1
- package/src/components/inserter-list-item/style.scss +1 -0
- package/src/components/inspector-controls-tabs/content-tab.jsx +7 -14
- package/src/components/inspector-controls-tabs/styles-tab.jsx +1 -4
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -8
- package/src/components/inspector-popover-header/index.jsx +6 -7
- package/src/components/line-height-control/test/{index.jsx → index.jsdom.test.jsx} +3 -0
- package/src/components/link-control/index.jsx +3 -0
- package/src/components/link-control/search-input.jsx +1 -1
- package/src/components/link-control/style.scss +1 -1
- package/src/components/link-control/test/{index.jsx → index.jsdom.test.jsx} +52 -42
- package/src/components/link-control/test/is-url-like.js +1 -0
- package/src/components/link-control/test/{url-normalization.test.jsx → url-normalization.jsdom.test.jsx} +21 -20
- package/src/components/link-picker/test/{index.jsx → index.jsdom.test.jsx} +31 -30
- package/src/components/list-view/block-select-button.jsx +6 -1
- package/src/components/list-view/block.jsx +6 -4
- package/src/components/list-view/style.scss +55 -35
- package/src/components/list-view/test/use-list-view-drop-zone.js +1 -0
- package/src/components/list-view/test/utils.js +1 -0
- package/src/components/list-view/use-list-view-drop-zone.js +1 -1
- package/src/components/media-placeholder/test/get-computed-accept-attribute.js +1 -0
- package/src/components/media-placeholder/test/{index.jsx → index.jsdom.test.jsx} +8 -2
- package/src/components/media-replace-flow/index.jsx +6 -1
- package/src/components/media-replace-flow/test/{index.jsx → index.jsdom.test.jsx} +3 -0
- package/src/components/navigable-toolbar/index.jsx +4 -0
- package/src/components/navigable-toolbar/test/index.browser.test.js +50 -0
- package/src/components/panel-color-settings/test/{index.jsx → index.jsdom.test.jsx} +3 -0
- package/src/components/preset-input-control/test/{index.jsx → index.jsdom.test.jsx} +8 -2
- package/src/components/preset-input-control/test/utils.js +1 -0
- package/src/components/provider/test/{experimental-provider.jsx → experimental-provider.jsdom.test.jsx} +3 -2
- package/src/components/provider/test/{use-block-sync.jsx → use-block-sync.jsdom.test.jsx} +45 -44
- package/src/components/recursion-provider/test/{index.jsx → index.jsdom.test.jsx} +1 -0
- package/src/components/responsive-block-control/style.scss +1 -0
- package/src/components/responsive-block-control/test/{index.jsx → index.jsdom.test.jsx} +6 -3
- package/src/components/rich-text/event-listeners/enter.js +29 -14
- package/src/components/rich-text/event-listeners/index.js +0 -2
- package/src/components/rich-text/event-listeners/input-rules.js +7 -2
- package/src/components/spacing-sizes-control/test/{index.jsx → index.jsdom.test.jsx} +23 -20
- package/src/components/spacing-sizes-control/test/utils.js +1 -0
- package/src/components/url-input/test/{button.jsx → button.jsdom.test.jsx} +4 -1
- package/src/components/url-input/test/fixtures/validated-input-control-deprecation.js +2 -0
- package/src/components/url-input/test/{index.jsx → index.jsdom.test.jsx} +23 -13
- package/src/components/use-block-display-information/test/{index.jsx → index.jsdom.test.jsx} +14 -10
- package/src/components/use-block-drop-zone/index.js +2 -2
- package/src/components/use-block-drop-zone/test/index.js +1 -0
- package/src/components/use-on-block-drop/test/index.js +28 -31
- package/src/components/warning/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +2 -2
- package/src/components/warning/test/{index.jsx → index.jsdom.test.jsx} +1 -0
- package/src/components/writing-flow/index.jsx +5 -0
- package/src/components/writing-flow/style.scss +48 -0
- package/src/components/writing-flow/test/{index.js → index.jsdom.test.js} +1 -0
- package/src/components/writing-flow/use-arrow-nav.js +2 -2
- package/src/components/writing-flow/use-input.js +29 -2
- package/src/components/writing-flow/use-tab-nav.jsx +155 -70
- package/src/components/writing-flow/use-undo-automatic-change.js +40 -0
- package/src/elements/test/{index.js → index.jsdom.test.js} +1 -0
- package/src/hooks/border.jsx +0 -53
- package/src/hooks/generate-fields-from-attributes.js +1 -1
- package/src/hooks/index.js +0 -2
- package/src/hooks/style.jsx +3 -2
- package/src/hooks/test/{align.jsx → align.jsdom.test.jsx} +1 -0
- package/src/hooks/test/allowed-blocks.js +1 -0
- package/src/hooks/test/{anchor.js → anchor.jsdom.test.js} +1 -0
- package/src/hooks/test/{auto-inspector-controls.js → auto-inspector-controls.jsdom.test.js} +1 -0
- package/src/hooks/test/{background.jsx → background.jsdom.test.jsx} +5 -2
- package/src/hooks/test/{block-style-state.js → block-style-state.jsdom.test.js} +4 -3
- package/src/hooks/test/{cross-origin-isolation.js → cross-origin-isolation.jsdom.test.js} +18 -25
- package/src/hooks/test/{custom-class-name.jsx → custom-class-name.jsdom.test.jsx} +1 -0
- package/src/hooks/test/{dimensions.js → dimensions.jsdom.test.js} +1 -0
- package/src/hooks/test/{duotone.js → duotone.jsdom.test.js} +1 -0
- package/src/hooks/test/{font-size.js → font-size.jsdom.test.js} +1 -0
- package/src/hooks/test/gap.js +1 -0
- package/src/hooks/test/generate-fields-from-attributes.js +1 -0
- package/src/hooks/test/generated-class-name.js +1 -0
- package/src/hooks/test/{inherited-value-wiring.jsx → inherited-value-wiring.jsdom.test.jsx} +49 -51
- package/src/hooks/test/{layout-child.js → layout-child.jsdom.test.js} +1 -0
- package/src/hooks/test/{layout.js → layout.jsdom.test.js} +1 -0
- package/src/hooks/test/metadata.js +1 -0
- package/src/hooks/test/preset-round-trip.js +2 -0
- package/src/hooks/test/settings.jsx +1 -0
- package/src/hooks/test/state-utils.js +1 -0
- package/src/hooks/test/{style.jsx → style.jsdom.test.jsx} +1 -0
- package/src/hooks/test/{text-align.jsx → text-align.jsdom.test.jsx} +1 -0
- package/src/hooks/test/{use-typography-props.js → use-typography-props.jsdom.test.js} +1 -0
- package/src/hooks/test/{utils.js → utils.jsdom.test.js} +1 -0
- package/src/layouts/flex.jsx +7 -0
- package/src/layouts/test/{constrained.jsx → constrained.jsdom.test.jsx} +6 -3
- package/src/layouts/test/{flex.jsx → flex.jsdom.test.jsx} +52 -2
- package/src/layouts/test/{flow.js → flow.jsdom.test.js} +1 -0
- package/src/layouts/test/{grid.jsx → grid.jsdom.test.jsx} +5 -2
- package/src/layouts/test/utils.js +1 -0
- package/src/store/actions.js +14 -12
- package/src/store/test/{actions.js → actions.jsdom.test.js} +50 -49
- package/src/store/test/array.js +1 -0
- package/src/store/test/get-block-settings.js +1 -0
- package/src/store/test/performance.js +2 -1
- package/src/store/test/private-actions.js +1 -0
- package/src/store/test/private-selectors.js +13 -3
- package/src/store/test/reducer.js +37 -8
- package/src/store/test/{registry-selectors.js → registry-selectors.jsdom.test.js} +9 -0
- package/src/store/test/{selectors.jsx → selectors.jsdom.test.jsx} +13 -3
- package/src/style.scss +1 -1
- package/src/utils/test/block-bindings.js +1 -0
- package/src/utils/test/color-values.js +1 -0
- package/src/utils/test/{dom.jsx → dom.jsdom.test.jsx} +38 -43
- package/src/utils/test/format-font-style.js +1 -0
- package/src/utils/test/format-font-weight.js +1 -0
- package/src/utils/test/get-font-styles-and-weights.js +1 -0
- package/src/utils/test/math.js +1 -0
- package/src/utils/test/object.js +1 -0
- package/src/utils/test/pasting.js +1 -0
- package/src/utils/test/selection.js +1 -0
- package/src/utils/test/sorting.js +1 -0
- package/src/utils/test/transform-styles.js +2 -1
- package/build/components/rich-text/event-listeners/undo-automatic-change.cjs.map +0 -7
- package/build/hooks/block-fields/fields-dropdown-menu.cjs +0 -67
- package/build/hooks/block-fields/fields-dropdown-menu.cjs.map +0 -7
- package/build/hooks/block-fields/index.cjs +0 -238
- package/build/hooks/block-fields/index.cjs.map +0 -7
- package/build/hooks/block-fields/link/index.cjs +0 -174
- package/build/hooks/block-fields/link/index.cjs.map +0 -7
- package/build/hooks/block-fields/media/index.cjs +0 -262
- package/build/hooks/block-fields/media/index.cjs.map +0 -7
- package/build/hooks/block-fields/rich-text/index.cjs +0 -146
- package/build/hooks/block-fields/rich-text/index.cjs.map +0 -7
- package/build/hooks/block-fields/use-inspector-popover-placement.cjs +0 -41
- package/build/hooks/block-fields/use-inspector-popover-placement.cjs.map +0 -7
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs +0 -33
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs.map +0 -7
- package/build-module/hooks/block-fields/fields-dropdown-menu.mjs +0 -46
- package/build-module/hooks/block-fields/fields-dropdown-menu.mjs.map +0 -7
- package/build-module/hooks/block-fields/index.mjs +0 -210
- package/build-module/hooks/block-fields/index.mjs.map +0 -7
- package/build-module/hooks/block-fields/link/index.mjs +0 -141
- package/build-module/hooks/block-fields/link/index.mjs.map +0 -7
- package/build-module/hooks/block-fields/media/index.mjs +0 -241
- package/build-module/hooks/block-fields/media/index.mjs.map +0 -7
- package/build-module/hooks/block-fields/rich-text/index.mjs +0 -115
- package/build-module/hooks/block-fields/rich-text/index.mjs.map +0 -7
- package/build-module/hooks/block-fields/use-inspector-popover-placement.mjs +0 -16
- package/build-module/hooks/block-fields/use-inspector-popover-placement.mjs.map +0 -7
- package/src/components/color-palette/test/__snapshots__/control.jsx.snap +0 -143
- package/src/components/inner-blocks/test/__snapshots__/index.jsx.snap +0 -15
- package/src/components/rich-text/event-listeners/undo-automatic-change.js +0 -39
- package/src/hooks/block-fields/fields-dropdown-menu.jsx +0 -47
- package/src/hooks/block-fields/index.jsx +0 -302
- package/src/hooks/block-fields/link/index.jsx +0 -155
- package/src/hooks/block-fields/link/styles.scss +0 -18
- package/src/hooks/block-fields/media/index.jsx +0 -269
- package/src/hooks/block-fields/media/styles.scss +0 -77
- package/src/hooks/block-fields/rich-text/index.jsx +0 -123
- package/src/hooks/block-fields/rich-text/styles.scss +0 -24
- package/src/hooks/block-fields/styles.scss +0 -33
- package/src/hooks/block-fields/use-inspector-popover-placement.js +0 -16
- /package/src/components/block-icon/test/{index.jsx → index.jsdom.test.jsx} +0 -0
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';
|
|
2
|
-
import { moreVertical, check } from '@wordpress/icons';
|
|
3
|
-
import { __ } from '@wordpress/i18n';
|
|
4
|
-
import { useInspectorPopoverPlacement } from './use-inspector-popover-placement';
|
|
5
|
-
|
|
6
|
-
export default function FieldsDropdownMenu( {
|
|
7
|
-
fields,
|
|
8
|
-
visibleFields,
|
|
9
|
-
onToggleField,
|
|
10
|
-
} ) {
|
|
11
|
-
const { popoverProps } = useInspectorPopoverPlacement();
|
|
12
|
-
|
|
13
|
-
if ( ! fields || fields.length === 0 ) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<DropdownMenu
|
|
19
|
-
icon={ moreVertical }
|
|
20
|
-
label={ __( 'Options' ) }
|
|
21
|
-
popoverProps={ popoverProps }
|
|
22
|
-
toggleProps={ { size: 'small' } }
|
|
23
|
-
>
|
|
24
|
-
{ ( { onClose } ) => (
|
|
25
|
-
<MenuGroup label={ __( 'Show / Hide' ) }>
|
|
26
|
-
{ fields.map( ( field ) => {
|
|
27
|
-
const isVisible = visibleFields.includes( field.id );
|
|
28
|
-
return (
|
|
29
|
-
<MenuItem
|
|
30
|
-
key={ field.id }
|
|
31
|
-
isSelected={ isVisible }
|
|
32
|
-
onClick={ () => {
|
|
33
|
-
onToggleField( field.id );
|
|
34
|
-
onClose();
|
|
35
|
-
} }
|
|
36
|
-
role="menuitemcheckbox"
|
|
37
|
-
icon={ isVisible ? check : null }
|
|
38
|
-
>
|
|
39
|
-
{ field.label }
|
|
40
|
-
</MenuItem>
|
|
41
|
-
);
|
|
42
|
-
} ) }
|
|
43
|
-
</MenuGroup>
|
|
44
|
-
) }
|
|
45
|
-
</DropdownMenu>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
privateApis as blocksPrivateApis,
|
|
3
|
-
getBlockType,
|
|
4
|
-
store as blocksStore,
|
|
5
|
-
} from '@wordpress/blocks';
|
|
6
|
-
import { useDebounce } from '@wordpress/compose';
|
|
7
|
-
import {
|
|
8
|
-
__experimentalHStack as HStack,
|
|
9
|
-
__experimentalTruncate as Truncate,
|
|
10
|
-
} from '@wordpress/components';
|
|
11
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
12
|
-
import { DataForm } from '@wordpress/dataviews';
|
|
13
|
-
import { useContext, useState, useMemo } from '@wordpress/element';
|
|
14
|
-
import { __ } from '@wordpress/i18n';
|
|
15
|
-
import { store as blockEditorStore } from '../../store';
|
|
16
|
-
import { unlock } from '../../lock-unlock';
|
|
17
|
-
import { replacePatternOverridesDefaultBinding } from '../../utils/block-bindings';
|
|
18
|
-
import BlockContext from '../../components/block-context';
|
|
19
|
-
import BlockIcon from '../../components/block-icon';
|
|
20
|
-
import useBlockDisplayTitle from '../../components/block-title/use-block-display-title';
|
|
21
|
-
import useBlockDisplayInformation from '../../components/use-block-display-information';
|
|
22
|
-
const { fieldsKey, formKey } = unlock( blocksPrivateApis );
|
|
23
|
-
import FieldsDropdownMenu from './fields-dropdown-menu';
|
|
24
|
-
import { PrivateBlockContext } from '../../components/block-list/private-block-context';
|
|
25
|
-
import InspectorControls from '../../components/inspector-controls/fill';
|
|
26
|
-
// controls
|
|
27
|
-
import RichText from './rich-text';
|
|
28
|
-
import Media from './media';
|
|
29
|
-
import Link from './link';
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Creates a configured control component that wraps a custom control
|
|
33
|
-
* and passes configuration as props.
|
|
34
|
-
*
|
|
35
|
-
* @param {Component} ControlComponent The React component for the control.
|
|
36
|
-
* @param {Object} config The control configuration passed as a prop.
|
|
37
|
-
*
|
|
38
|
-
* @return {Function} A wrapped control component
|
|
39
|
-
*/
|
|
40
|
-
function createConfiguredControl( ControlComponent, config = {} ) {
|
|
41
|
-
return function ConfiguredControl( props ) {
|
|
42
|
-
return <ControlComponent { ...props } config={ config } />;
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Component that renders a DataForm for a single block's attributes
|
|
48
|
-
* @param {Object} props
|
|
49
|
-
* @param {string} props.clientId The clientId of the block.
|
|
50
|
-
* @param {Object} props.blockType The blockType definition.
|
|
51
|
-
* @param {Function} props.setAttributes Action to set the block's attributes.
|
|
52
|
-
* @param {boolean} props.isMultiBlock Whether forms for multiple blocks are shown at the same time.
|
|
53
|
-
* This changes the behavior of the component:
|
|
54
|
-
* - Only the first field is shown for each block.
|
|
55
|
-
* - A dropdown is rendered allowing display of additional fields.
|
|
56
|
-
* - Hovering the block fields highlights the block in the canvas
|
|
57
|
-
* - Focusing a block field soft-selects the block in the canvas.
|
|
58
|
-
*/
|
|
59
|
-
function BlockFields( {
|
|
60
|
-
clientId,
|
|
61
|
-
blockType,
|
|
62
|
-
setAttributes,
|
|
63
|
-
isMultiBlock = false,
|
|
64
|
-
} ) {
|
|
65
|
-
const blockTitle = useBlockDisplayTitle( {
|
|
66
|
-
clientId,
|
|
67
|
-
context: 'list-view',
|
|
68
|
-
} );
|
|
69
|
-
const blockInformation = useBlockDisplayInformation( clientId );
|
|
70
|
-
|
|
71
|
-
const blockTypeFields = blockType?.[ fieldsKey ];
|
|
72
|
-
|
|
73
|
-
const blockContext = useContext( BlockContext );
|
|
74
|
-
|
|
75
|
-
const attributes = useSelect(
|
|
76
|
-
( select ) => {
|
|
77
|
-
const _attributes =
|
|
78
|
-
select( blockEditorStore ).getBlockAttributes( clientId );
|
|
79
|
-
if ( ! _attributes?.metadata?.bindings ) {
|
|
80
|
-
return _attributes;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/*
|
|
84
|
-
* The pattern overrides `__default` binding is a placeholder, not
|
|
85
|
-
* a real attribute: expand it to the block's bindable attributes
|
|
86
|
-
* before resolving values, as other bindings consumers do.
|
|
87
|
-
*/
|
|
88
|
-
const { __experimentalBlockBindingsSupportedAttributes } =
|
|
89
|
-
select( blockEditorStore ).getSettings();
|
|
90
|
-
const bindableAttributes =
|
|
91
|
-
__experimentalBlockBindingsSupportedAttributes?.[
|
|
92
|
-
blockType?.name
|
|
93
|
-
];
|
|
94
|
-
const bindings = bindableAttributes
|
|
95
|
-
? replacePatternOverridesDefaultBinding(
|
|
96
|
-
_attributes.metadata.bindings,
|
|
97
|
-
bindableAttributes
|
|
98
|
-
)
|
|
99
|
-
: _attributes.metadata.bindings;
|
|
100
|
-
|
|
101
|
-
const { getBlockBindingsSource } = unlock( select( blocksStore ) );
|
|
102
|
-
return Object.entries( bindings ).reduce(
|
|
103
|
-
( acc, [ attribute, binding ] ) => {
|
|
104
|
-
// Skip a `__default` binding that could not be expanded:
|
|
105
|
-
// it is not a real block attribute.
|
|
106
|
-
if ( attribute === '__default' ) {
|
|
107
|
-
return acc;
|
|
108
|
-
}
|
|
109
|
-
const source = getBlockBindingsSource( binding.source );
|
|
110
|
-
if ( ! source ) {
|
|
111
|
-
return acc;
|
|
112
|
-
}
|
|
113
|
-
const values = source.getValues( {
|
|
114
|
-
select,
|
|
115
|
-
clientId,
|
|
116
|
-
context: blockContext,
|
|
117
|
-
bindings: { [ attribute ]: binding },
|
|
118
|
-
} );
|
|
119
|
-
return { ...acc, ...values };
|
|
120
|
-
},
|
|
121
|
-
_attributes
|
|
122
|
-
);
|
|
123
|
-
},
|
|
124
|
-
[ blockContext, clientId, blockType?.name ]
|
|
125
|
-
);
|
|
126
|
-
const { selectBlock, toggleBlockHighlight } =
|
|
127
|
-
useDispatch( blockEditorStore );
|
|
128
|
-
|
|
129
|
-
const debouncedToggleBlockHighlight = useDebounce(
|
|
130
|
-
toggleBlockHighlight,
|
|
131
|
-
50
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
const computedForm = useMemo( () => {
|
|
135
|
-
if ( ! isMultiBlock ) {
|
|
136
|
-
return blockType?.[ formKey ];
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// For a collapsed form only show the first field by default.
|
|
140
|
-
return {
|
|
141
|
-
...blockType?.[ formKey ],
|
|
142
|
-
fields: [ blockType?.[ formKey ]?.fields?.[ 0 ] ],
|
|
143
|
-
};
|
|
144
|
-
}, [ blockType, isMultiBlock ] );
|
|
145
|
-
|
|
146
|
-
const [ form, setForm ] = useState( computedForm );
|
|
147
|
-
|
|
148
|
-
// Build DataForm fields with proper structure
|
|
149
|
-
const dataFormFields = useMemo( () => {
|
|
150
|
-
if ( ! blockTypeFields?.length ) {
|
|
151
|
-
return [];
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return blockTypeFields.map( ( fieldDef ) => {
|
|
155
|
-
const field = {
|
|
156
|
-
...fieldDef,
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
// These should be custom Edit components, not replaced here.
|
|
160
|
-
//
|
|
161
|
-
// - rich-text control: it needs clientId
|
|
162
|
-
// - link control: does not need anything extra
|
|
163
|
-
// - media control: needs the Edit config
|
|
164
|
-
if (
|
|
165
|
-
'string' === typeof fieldDef.Edit &&
|
|
166
|
-
fieldDef.Edit === 'rich-text'
|
|
167
|
-
) {
|
|
168
|
-
field.Edit = createConfiguredControl( RichText, {
|
|
169
|
-
clientId,
|
|
170
|
-
} );
|
|
171
|
-
} else if (
|
|
172
|
-
'string' === typeof fieldDef.Edit &&
|
|
173
|
-
fieldDef.Edit === 'link'
|
|
174
|
-
) {
|
|
175
|
-
field.Edit = createConfiguredControl( Link );
|
|
176
|
-
} else if (
|
|
177
|
-
'object' === typeof fieldDef.Edit &&
|
|
178
|
-
fieldDef.Edit.control === 'media'
|
|
179
|
-
) {
|
|
180
|
-
field.Edit = createConfiguredControl( Media, {
|
|
181
|
-
...fieldDef.Edit,
|
|
182
|
-
} );
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return field;
|
|
186
|
-
} );
|
|
187
|
-
}, [ blockTypeFields, clientId ] );
|
|
188
|
-
|
|
189
|
-
if ( ! blockTypeFields?.length ) {
|
|
190
|
-
// TODO - we might still want to show a placeholder for blocks with no fields.
|
|
191
|
-
// for example, a way to select the block.
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const handleToggleField = ( fieldId ) => {
|
|
196
|
-
setForm( ( prev ) => {
|
|
197
|
-
if ( prev.fields?.includes( fieldId ) ) {
|
|
198
|
-
return {
|
|
199
|
-
...prev,
|
|
200
|
-
fields: prev.fields.filter( ( id ) => id !== fieldId ),
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return {
|
|
205
|
-
...prev,
|
|
206
|
-
fields: [ ...( prev.fields || [] ), fieldId ],
|
|
207
|
-
};
|
|
208
|
-
} );
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
return (
|
|
212
|
-
<div
|
|
213
|
-
className="block-editor-block-fields__container"
|
|
214
|
-
onMouseEnter={
|
|
215
|
-
isMultiBlock
|
|
216
|
-
? () => debouncedToggleBlockHighlight( clientId, true )
|
|
217
|
-
: undefined
|
|
218
|
-
}
|
|
219
|
-
onMouseLeave={ () =>
|
|
220
|
-
isMultiBlock
|
|
221
|
-
? debouncedToggleBlockHighlight( clientId, false )
|
|
222
|
-
: undefined
|
|
223
|
-
}
|
|
224
|
-
onFocus={
|
|
225
|
-
isMultiBlock
|
|
226
|
-
? () => {
|
|
227
|
-
selectBlock(
|
|
228
|
-
clientId,
|
|
229
|
-
null /* null to avoid focus on the block in the canvas */
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
: undefined
|
|
233
|
-
}
|
|
234
|
-
>
|
|
235
|
-
<div className="block-editor-block-fields__header">
|
|
236
|
-
<HStack spacing={ 1 }>
|
|
237
|
-
{ isMultiBlock && (
|
|
238
|
-
<>
|
|
239
|
-
<BlockIcon
|
|
240
|
-
className="block-editor-block-fields__header-icon"
|
|
241
|
-
icon={ blockInformation?.icon }
|
|
242
|
-
/>
|
|
243
|
-
<h2 className="block-editor-block-fields__header-title">
|
|
244
|
-
<Truncate numberOfLines={ 1 }>
|
|
245
|
-
{ blockTitle }
|
|
246
|
-
</Truncate>
|
|
247
|
-
</h2>
|
|
248
|
-
<FieldsDropdownMenu
|
|
249
|
-
fields={ dataFormFields }
|
|
250
|
-
visibleFields={ form.fields }
|
|
251
|
-
onToggleField={ handleToggleField }
|
|
252
|
-
/>
|
|
253
|
-
</>
|
|
254
|
-
) }
|
|
255
|
-
{ ! isMultiBlock && (
|
|
256
|
-
<h2 className="block-editor-block-fields__header-title">
|
|
257
|
-
{ __( 'Content' ) }
|
|
258
|
-
</h2>
|
|
259
|
-
) }
|
|
260
|
-
</HStack>
|
|
261
|
-
</div>
|
|
262
|
-
<DataForm
|
|
263
|
-
data={ attributes }
|
|
264
|
-
fields={ dataFormFields }
|
|
265
|
-
form={ form }
|
|
266
|
-
onChange={ setAttributes }
|
|
267
|
-
/>
|
|
268
|
-
</div>
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function hasBlockFieldsSupport( blockName ) {
|
|
273
|
-
return !! (
|
|
274
|
-
window?.__experimentalContentOnlyInspectorFields &&
|
|
275
|
-
getBlockType( blockName )?.[ fieldsKey ]
|
|
276
|
-
);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
export function BlockFieldsPanel( props ) {
|
|
280
|
-
const { blockType, isSelectionWithinCurrentSection } =
|
|
281
|
-
useContext( PrivateBlockContext );
|
|
282
|
-
|
|
283
|
-
return (
|
|
284
|
-
<InspectorControls group="content">
|
|
285
|
-
<BlockFields
|
|
286
|
-
{ ...props }
|
|
287
|
-
blockType={ blockType }
|
|
288
|
-
isMultiBlock={ isSelectionWithinCurrentSection }
|
|
289
|
-
/>
|
|
290
|
-
</InspectorControls>
|
|
291
|
-
);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* Export block support definition.
|
|
296
|
-
*/
|
|
297
|
-
export default {
|
|
298
|
-
edit: BlockFieldsPanel,
|
|
299
|
-
hasSupport: hasBlockFieldsSupport,
|
|
300
|
-
attributeKeys: [],
|
|
301
|
-
supportsPatternEditing: true,
|
|
302
|
-
};
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Button,
|
|
3
|
-
Icon as WCIcon,
|
|
4
|
-
__experimentalGrid as Grid,
|
|
5
|
-
Popover,
|
|
6
|
-
} from '@wordpress/components';
|
|
7
|
-
import { useMemo, useState } from '@wordpress/element';
|
|
8
|
-
import { __ } from '@wordpress/i18n';
|
|
9
|
-
import { link } from '@wordpress/icons';
|
|
10
|
-
import { prependHTTP } from '@wordpress/url';
|
|
11
|
-
import LinkControl from '../../../components/link-control';
|
|
12
|
-
import { useInspectorPopoverPlacement } from '../use-inspector-popover-placement';
|
|
13
|
-
|
|
14
|
-
export const NEW_TAB_REL = 'noopener';
|
|
15
|
-
export const NEW_TAB_TARGET = '_blank';
|
|
16
|
-
export const NOFOLLOW_REL = 'nofollow';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Updates the link attributes.
|
|
20
|
-
*
|
|
21
|
-
* @param {Object} attributes The current block attributes.
|
|
22
|
-
* @param {string} attributes.rel The current link rel attribute.
|
|
23
|
-
* @param {string} attributes.url The current link url.
|
|
24
|
-
* @param {boolean} attributes.opensInNewTab Whether the link should open in a new window.
|
|
25
|
-
* @param {boolean} attributes.nofollow Whether the link should be marked as nofollow.
|
|
26
|
-
*/
|
|
27
|
-
export function getUpdatedLinkAttributes( {
|
|
28
|
-
rel = '',
|
|
29
|
-
url = '',
|
|
30
|
-
opensInNewTab,
|
|
31
|
-
nofollow,
|
|
32
|
-
} ) {
|
|
33
|
-
let newLinkTarget;
|
|
34
|
-
// Since `rel` is editable attribute, we need to check for existing values and proceed accordingly.
|
|
35
|
-
let updatedRel = rel;
|
|
36
|
-
|
|
37
|
-
if ( opensInNewTab ) {
|
|
38
|
-
newLinkTarget = NEW_TAB_TARGET;
|
|
39
|
-
updatedRel = updatedRel?.includes( NEW_TAB_REL )
|
|
40
|
-
? updatedRel
|
|
41
|
-
: updatedRel + ` ${ NEW_TAB_REL }`;
|
|
42
|
-
} else {
|
|
43
|
-
const relRegex = new RegExp( `\\b${ NEW_TAB_REL }\\s*`, 'g' );
|
|
44
|
-
updatedRel = updatedRel?.replace( relRegex, '' ).trim();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if ( nofollow ) {
|
|
48
|
-
updatedRel = updatedRel?.includes( NOFOLLOW_REL )
|
|
49
|
-
? updatedRel
|
|
50
|
-
: ( updatedRel + ` ${ NOFOLLOW_REL }` ).trim();
|
|
51
|
-
} else {
|
|
52
|
-
const relRegex = new RegExp( `\\b${ NOFOLLOW_REL }\\s*`, 'g' );
|
|
53
|
-
updatedRel = updatedRel?.replace( relRegex, '' ).trim();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
url: prependHTTP( url ),
|
|
58
|
-
linkTarget: newLinkTarget,
|
|
59
|
-
rel: updatedRel || undefined,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export default function Link( { data, field, onChange } ) {
|
|
64
|
-
const [ isLinkControlOpen, setIsLinkControlOpen ] = useState( false );
|
|
65
|
-
const { popoverProps } = useInspectorPopoverPlacement( {
|
|
66
|
-
isControl: true,
|
|
67
|
-
} );
|
|
68
|
-
const value = field.getValue( { item: data } );
|
|
69
|
-
const url = value?.url;
|
|
70
|
-
const rel = value?.rel || '';
|
|
71
|
-
const target = value?.linkTarget;
|
|
72
|
-
|
|
73
|
-
const opensInNewTab = target === NEW_TAB_TARGET;
|
|
74
|
-
const nofollow = rel === NOFOLLOW_REL;
|
|
75
|
-
|
|
76
|
-
// Memoize link value to avoid overriding the LinkControl's internal state.
|
|
77
|
-
// This is a temporary fix. See https://github.com/WordPress/gutenberg/issues/51256.
|
|
78
|
-
const linkValue = useMemo(
|
|
79
|
-
() => ( { url, opensInNewTab, nofollow } ),
|
|
80
|
-
[ url, opensInNewTab, nofollow ]
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
<>
|
|
85
|
-
<Button
|
|
86
|
-
__next40pxDefaultSize
|
|
87
|
-
className="block-editor-content-only-controls__link"
|
|
88
|
-
onClick={ () => {
|
|
89
|
-
setIsLinkControlOpen( true );
|
|
90
|
-
} }
|
|
91
|
-
>
|
|
92
|
-
<Grid
|
|
93
|
-
rowGap={ 0 }
|
|
94
|
-
columnGap={ 8 }
|
|
95
|
-
templateColumns="24px 1fr"
|
|
96
|
-
className="block-editor-content-only-controls__link-row"
|
|
97
|
-
>
|
|
98
|
-
{ url && (
|
|
99
|
-
<>
|
|
100
|
-
<WCIcon icon={ link } size={ 24 } />
|
|
101
|
-
<span className="block-editor-content-only-controls__link-title">
|
|
102
|
-
{ url }
|
|
103
|
-
</span>
|
|
104
|
-
</>
|
|
105
|
-
) }
|
|
106
|
-
{ ! url && (
|
|
107
|
-
<>
|
|
108
|
-
<WCIcon
|
|
109
|
-
icon={ link }
|
|
110
|
-
size={ 24 }
|
|
111
|
-
style={ { opacity: 0.3 } }
|
|
112
|
-
/>
|
|
113
|
-
<span className="block-editor-content-only-controls__link-title">
|
|
114
|
-
{ __( 'Link' ) }
|
|
115
|
-
</span>
|
|
116
|
-
</>
|
|
117
|
-
) }
|
|
118
|
-
</Grid>
|
|
119
|
-
</Button>
|
|
120
|
-
{ isLinkControlOpen && (
|
|
121
|
-
<Popover
|
|
122
|
-
onClose={ () => {
|
|
123
|
-
setIsLinkControlOpen( false );
|
|
124
|
-
} }
|
|
125
|
-
{ ...( popoverProps ?? {} ) }
|
|
126
|
-
>
|
|
127
|
-
<LinkControl
|
|
128
|
-
value={ linkValue }
|
|
129
|
-
onChange={ ( newValues ) => {
|
|
130
|
-
const updatedAttrs = getUpdatedLinkAttributes( {
|
|
131
|
-
rel,
|
|
132
|
-
...newValues,
|
|
133
|
-
} );
|
|
134
|
-
|
|
135
|
-
onChange(
|
|
136
|
-
field.setValue( {
|
|
137
|
-
item: data,
|
|
138
|
-
value: updatedAttrs,
|
|
139
|
-
} )
|
|
140
|
-
);
|
|
141
|
-
} }
|
|
142
|
-
onRemove={ () => {
|
|
143
|
-
onChange(
|
|
144
|
-
field.setValue( {
|
|
145
|
-
item: data,
|
|
146
|
-
value: {},
|
|
147
|
-
} )
|
|
148
|
-
);
|
|
149
|
-
} }
|
|
150
|
-
/>
|
|
151
|
-
</Popover>
|
|
152
|
-
) }
|
|
153
|
-
</>
|
|
154
|
-
);
|
|
155
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
@use "@wordpress/base-styles/colors" as *;
|
|
2
|
-
@use "@wordpress/base-styles/variables" as *;
|
|
3
|
-
|
|
4
|
-
.block-editor-content-only-controls__link {
|
|
5
|
-
width: 100%;
|
|
6
|
-
border-color: $gray-400;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.block-editor-content-only-controls__link-row {
|
|
10
|
-
align-items: center;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.block-editor-content-only-controls__link-title {
|
|
14
|
-
width: 100%;
|
|
15
|
-
white-space: nowrap;
|
|
16
|
-
text-overflow: ellipsis;
|
|
17
|
-
overflow: hidden;
|
|
18
|
-
}
|