@wordpress/block-editor 9.4.0 → 9.7.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 +6 -0
- package/README.md +1 -8
- package/build/components/block-list/block-invalid-warning.native.js +54 -6
- package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build/components/block-list/block.js +14 -4
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +2 -1
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +5 -4
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/layout.js +20 -5
- package/build/components/block-list/layout.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-class-names.js +5 -2
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build/components/block-lock/modal.js +37 -7
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mover/mover-description.js +95 -32
- package/build/components/block-mover/mover-description.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +5 -17
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-popover/inbetween.js +2 -2
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +1 -1
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-settings-menu/block-mode-toggle.js +1 -1
- package/build/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +1 -1
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-styles/index.js +3 -6
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-styles/preview.native.js.map +1 -1
- package/build/components/block-switcher/index.js +7 -1
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-title/index.js +8 -2
- package/build/components/block-title/index.js.map +1 -1
- package/build/components/block-title/use-block-display-title.js +12 -5
- package/build/components/block-title/use-block-display-title.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +1 -7
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +4 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-types-list/index.js +1 -1
- package/build/components/block-types-list/index.js.map +1 -1
- package/build/components/block-types-list/index.native.js +65 -23
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/border-radius-control/index.js +5 -1
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/colors/utils.js +6 -2
- package/build/components/colors/utils.js.map +1 -1
- package/build/components/colors/with-colors.js +1 -1
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/colors-gradients/control.js +49 -39
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +9 -3
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/date-format-picker/index.js +1 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +10 -4
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/iframe/index.js +19 -6
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/cropper.js +4 -3
- package/build/components/image-editor/cropper.js.map +1 -1
- package/build/components/image-editor/index.js +3 -1
- package/build/components/image-editor/index.js.map +1 -1
- package/build/components/image-size-control/index.js +3 -1
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/index.js +13 -6
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +11 -4
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/block-types-tab.native.js +30 -16
- package/build/components/inserter/block-types-tab.native.js.map +1 -1
- package/build/components/inserter/index.native.js +8 -3
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/preview-panel.js +8 -8
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js +5 -1
- package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build/components/inserter/search-results.native.js +5 -2
- package/build/components/inserter/search-results.native.js.map +1 -1
- package/build/components/inserter/utils.native.js +21 -0
- package/build/components/inserter/utils.native.js.map +1 -1
- package/build/components/inserter-list-item/index.js +7 -20
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +6 -3
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/line-height-control/index.js +6 -3
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/index.js +1 -1
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/is-url-like.js +1 -7
- package/build/components/link-control/is-url-like.js.map +1 -1
- package/build/components/link-control/use-search-handler.js +1 -7
- package/build/components/link-control/use-search-handler.js.map +1 -1
- package/build/components/list-view/block-select-button.js +15 -7
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/branch.js +1 -7
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +1 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/expander.js +3 -1
- package/build/components/list-view/expander.js.map +1 -1
- package/build/components/media-placeholder/index.js +13 -2
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +3 -6
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/media-upload/index.native.js +8 -3
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/observe-typing/index.js +22 -8
- package/build/components/observe-typing/index.js.map +1 -1
- package/build/components/preview-options/index.js +2 -2
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/{use-no-recursive-renders → recursion-provider}/index.js +40 -18
- package/build/components/recursion-provider/index.js.map +1 -0
- package/build/components/rich-text/format-toolbar-container.js +61 -12
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/index.js +8 -2
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +3 -1
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-before-input-rules.js +110 -0
- package/build/components/rich-text/use-before-input-rules.js.map +1 -0
- package/build/components/rich-text/use-format-types.js +36 -16
- package/build/components/rich-text/use-format-types.js.map +1 -1
- package/build/components/text-decoration-control/index.js +3 -1
- package/build/components/text-decoration-control/index.js.map +1 -1
- package/build/components/text-transform-control/index.js +3 -1
- package/build/components/text-transform-control/index.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +4 -1
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/url-popover/index.js +2 -1
- package/build/components/url-popover/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +38 -27
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/components/writing-flow/use-drag-selection.js +9 -2
- package/build/components/writing-flow/use-drag-selection.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +3 -47
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-select-all.js +3 -1
- package/build/components/writing-flow/use-select-all.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +1 -3
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +1 -1
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/color.js +2 -4
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/index.js +8 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +61 -15
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/style.js +41 -31
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/utils.js +5 -3
- package/build/hooks/utils.js.map +1 -1
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/layouts/flex.js +40 -36
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +35 -37
- package/build/layouts/flow.js.map +1 -1
- package/build/layouts/utils.js +35 -3
- package/build/layouts/utils.js.map +1 -1
- package/build/store/actions.js +15 -18
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +0 -4
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +5 -3
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +3 -3
- package/build/store/selectors.js.map +1 -1
- package/build/utils/block-variation-transforms.js +15 -9
- package/build/utils/block-variation-transforms.js.map +1 -1
- package/build/utils/pasting.js +9 -1
- package/build/utils/pasting.js.map +1 -1
- package/build-module/components/block-list/block-invalid-warning.native.js +50 -6
- package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build-module/components/block-list/block.js +15 -5
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +2 -1
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +4 -2
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/layout.js +19 -4
- package/build-module/components/block-list/layout.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +5 -2
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build-module/components/block-lock/modal.js +39 -8
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +2 -2
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-mover/mover-description.js +97 -33
- package/build-module/components/block-mover/mover-description.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +6 -18
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +2 -2
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +1 -1
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-mode-toggle.js +1 -1
- package/build-module/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +2 -2
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +4 -7
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/block-switcher/index.js +7 -1
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-title/index.js +8 -2
- package/build-module/components/block-title/index.js.map +1 -1
- package/build-module/components/block-title/use-block-display-title.js +12 -5
- package/build-module/components/block-title/use-block-display-title.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +1 -7
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +4 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-types-list/index.js +1 -1
- package/build-module/components/block-types-list/index.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +67 -25
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +6 -2
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/colors/utils.js +7 -3
- package/build-module/components/colors/utils.js.map +1 -1
- package/build-module/components/colors/with-colors.js +2 -2
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +50 -40
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +10 -4
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +1 -1
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +7 -4
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/iframe/index.js +19 -6
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/cropper.js +4 -3
- package/build-module/components/image-editor/cropper.js.map +1 -1
- package/build-module/components/image-editor/index.js +3 -1
- package/build-module/components/image-editor/index.js.map +1 -1
- package/build-module/components/image-size-control/index.js +3 -1
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/index.js +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.native.js +31 -15
- package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
- package/build-module/components/inserter/index.native.js +9 -2
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +9 -9
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js +6 -2
- package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build-module/components/inserter/search-results.native.js +6 -3
- package/build-module/components/inserter/search-results.native.js.map +1 -1
- package/build-module/components/inserter/utils.native.js +19 -0
- package/build-module/components/inserter/utils.native.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +5 -18
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +5 -3
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/line-height-control/index.js +5 -3
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +1 -1
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/is-url-like.js +1 -6
- package/build-module/components/link-control/is-url-like.js.map +1 -1
- package/build-module/components/link-control/use-search-handler.js +1 -6
- package/build-module/components/link-control/use-search-handler.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +16 -8
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/branch.js +1 -6
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +1 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/expander.js +3 -2
- package/build-module/components/list-view/expander.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +13 -2
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +4 -7
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +9 -2
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/observe-typing/index.js +22 -8
- package/build-module/components/observe-typing/index.js.map +1 -1
- package/build-module/components/preview-options/index.js +2 -2
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/{use-no-recursive-renders → recursion-provider}/index.js +39 -19
- package/build-module/components/recursion-provider/index.js.map +1 -0
- package/build-module/components/rich-text/format-toolbar-container.js +58 -12
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/index.js +7 -2
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +3 -1
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-before-input-rules.js +96 -0
- package/build-module/components/rich-text/use-before-input-rules.js.map +1 -0
- package/build-module/components/rich-text/use-format-types.js +37 -18
- package/build-module/components/rich-text/use-format-types.js.map +1 -1
- package/build-module/components/text-decoration-control/index.js +4 -2
- package/build-module/components/text-decoration-control/index.js.map +1 -1
- package/build-module/components/text-transform-control/index.js +4 -2
- package/build-module/components/text-transform-control/index.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +4 -1
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/url-popover/index.js +2 -1
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +40 -29
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/components/writing-flow/use-drag-selection.js +9 -2
- package/build-module/components/writing-flow/use-drag-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +3 -45
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-select-all.js +3 -1
- package/build-module/components/writing-flow/use-select-all.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +1 -3
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/color.js +2 -3
- package/build-module/hooks/color.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 +62 -16
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/style.js +44 -35
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/utils.js +5 -2
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/flex.js +41 -33
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +35 -38
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/layouts/utils.js +33 -3
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/store/actions.js +9 -10
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +0 -4
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +5 -2
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +4 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/block-variation-transforms.js +14 -7
- package/build-module/utils/block-variation-transforms.js.map +1 -1
- package/build-module/utils/pasting.js +9 -1
- package/build-module/utils/pasting.js.map +1 -1
- package/build-style/style-rtl.css +72 -14
- package/build-style/style.css +72 -14
- package/package.json +28 -28
- package/src/components/block-list/block-invalid-warning.native.js +42 -7
- package/src/components/block-list/block.js +15 -4
- package/src/components/block-list/block.native.js +1 -0
- package/src/components/block-list/index.native.js +2 -2
- package/src/components/block-list/layout.js +15 -3
- package/src/components/block-list/style.scss +1 -1
- package/src/components/block-list/use-block-props/use-block-class-names.js +5 -1
- package/src/components/block-lock/modal.js +47 -9
- package/src/components/block-lock/style.scss +10 -0
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +3 -3
- package/src/components/block-mover/mover-description.js +131 -48
- package/src/components/block-mover/test/mover-description.js +55 -3
- package/src/components/block-pattern-setup/index.js +3 -15
- package/src/components/block-pattern-setup/style.scss +4 -2
- package/src/components/block-popover/inbetween.js +2 -1
- package/src/components/block-popover/index.js +1 -1
- package/src/components/block-popover/style.scss +25 -2
- package/src/components/block-settings-menu/block-mode-toggle.js +1 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/src/components/block-settings-menu-controls/index.js +2 -2
- package/src/components/block-styles/index.js +4 -7
- package/src/components/block-styles/preview.native.js +1 -0
- package/src/components/block-styles/style.scss +10 -0
- package/src/components/block-switcher/index.js +7 -1
- package/src/components/block-title/index.js +3 -2
- package/src/components/block-title/use-block-display-title.js +11 -5
- package/src/components/block-tools/block-contextual-toolbar.js +3 -1
- package/src/components/block-tools/block-selection-button.js +0 -5
- package/src/components/block-tools/index.js +4 -1
- package/src/components/block-types-list/index.js +1 -1
- package/src/components/block-types-list/index.native.js +76 -24
- package/src/components/block-types-list/style.native.scss +18 -0
- package/src/components/border-radius-control/index.js +6 -1
- package/src/components/color-palette/test/__snapshots__/control.js.snap +91 -79
- package/src/components/colors/test/__snapshots__/with-colors.js.snap +1 -1
- package/src/components/colors/test/with-colors.js +1 -1
- package/src/components/colors/utils.js +5 -2
- package/src/components/colors/with-colors.js +2 -2
- package/src/components/colors-gradients/control.js +82 -65
- package/src/components/colors-gradients/dropdown.js +14 -3
- package/src/components/colors-gradients/style.scss +34 -9
- package/src/components/colors-gradients/test/control.js +16 -23
- package/src/components/date-format-picker/index.js +1 -0
- package/src/components/font-appearance-control/index.js +3 -0
- package/src/components/iframe/index.js +25 -6
- package/src/components/image-editor/cropper.js +9 -3
- package/src/components/image-editor/index.js +2 -0
- package/src/components/image-size-control/README.md +7 -0
- package/src/components/image-size-control/index.js +2 -0
- package/src/components/index.js +4 -1
- package/src/components/index.native.js +4 -1
- package/src/components/inserter/block-types-tab.native.js +42 -21
- package/src/components/inserter/index.native.js +7 -2
- package/src/components/inserter/preview-panel.js +6 -14
- package/src/components/inserter/reusable-blocks-tab.native.js +4 -2
- package/src/components/inserter/search-results.native.js +4 -2
- package/src/components/inserter/style.scss +1 -1
- package/src/components/inserter/test/block-types-tab.native.js +2 -0
- package/src/components/inserter/test/utils.native.js +37 -0
- package/src/components/inserter/utils.native.js +11 -0
- package/src/components/inserter-list-item/index.js +5 -18
- package/src/components/letter-spacing-control/index.js +2 -0
- package/src/components/line-height-control/index.js +2 -0
- package/src/components/link-control/index.js +1 -0
- package/src/components/link-control/is-url-like.js +1 -6
- package/src/components/link-control/test/index.js +6 -4
- package/src/components/link-control/use-search-handler.js +1 -6
- package/src/components/list-view/block-select-button.js +29 -14
- package/src/components/list-view/branch.js +1 -6
- package/src/components/list-view/drop-indicator.js +1 -1
- package/src/components/list-view/expander.js +4 -2
- package/src/components/list-view/style.scss +18 -4
- package/src/components/media-placeholder/index.js +19 -0
- package/src/components/media-replace-flow/index.js +3 -6
- package/src/components/media-replace-flow/test/index.js +14 -4
- package/src/components/media-upload/index.native.js +7 -3
- package/src/components/observe-typing/index.js +17 -14
- package/src/components/preview-options/index.js +2 -2
- package/src/components/{use-no-recursive-renders → recursion-provider}/index.js +39 -28
- package/src/components/{use-no-recursive-renders/test/use-no-recursive-renders.js → recursion-provider/test/index.js} +5 -6
- package/src/components/rich-text/README.md +13 -1
- package/src/components/rich-text/format-toolbar-container.js +63 -14
- package/src/components/rich-text/index.js +3 -0
- package/src/components/rich-text/index.native.js +2 -0
- package/src/components/rich-text/use-before-input-rules.js +91 -0
- package/src/components/rich-text/use-format-types.js +38 -17
- package/src/components/text-decoration-control/index.js +4 -2
- package/src/components/text-transform-control/index.js +4 -2
- package/src/components/url-popover/image-url-input-ui.js +3 -0
- package/src/components/url-popover/index.js +1 -0
- package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -0
- package/src/components/writing-flow/use-arrow-nav.js +36 -34
- package/src/components/writing-flow/use-drag-selection.js +7 -1
- package/src/components/writing-flow/use-multi-selection.js +1 -48
- package/src/components/writing-flow/use-select-all.js +2 -1
- package/src/components/writing-flow/use-selection-observer.js +2 -3
- package/src/components/writing-flow/use-tab-nav.js +1 -1
- package/src/hooks/color.js +10 -3
- package/src/hooks/index.js +1 -0
- package/src/hooks/layout.js +66 -23
- package/src/hooks/style.js +46 -39
- package/src/hooks/utils.js +7 -3
- package/src/index.js +1 -0
- package/src/layouts/flex.js +47 -41
- package/src/layouts/flow.js +35 -34
- package/src/layouts/test/flex.js +21 -0
- package/src/layouts/test/flow.js +21 -0
- package/src/layouts/test/utils.js +138 -0
- package/src/layouts/utils.js +44 -3
- package/src/store/actions.js +10 -11
- package/src/store/index.js +0 -4
- package/src/store/reducer.js +3 -2
- package/src/store/selectors.js +3 -4
- package/src/utils/block-variation-transforms.js +13 -6
- package/src/utils/pasting.js +10 -1
- package/src/utils/test/block-variation-transforms.js +24 -0
- package/src/utils/test/pasting.js +10 -0
- package/tsconfig.json +2 -1
- package/build/components/use-no-recursive-renders/index.js.map +0 -1
- package/build-module/components/use-no-recursive-renders/index.js.map +0 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useBeforeInputRules = useBeforeInputRules;
|
|
7
|
+
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
|
|
10
|
+
var _compose = require("@wordpress/compose");
|
|
11
|
+
|
|
12
|
+
var _richText = require("@wordpress/rich-text");
|
|
13
|
+
|
|
14
|
+
var _data = require("@wordpress/data");
|
|
15
|
+
|
|
16
|
+
var _hooks = require("@wordpress/hooks");
|
|
17
|
+
|
|
18
|
+
var _store = require("../../store");
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* WordPress dependencies
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Internal dependencies
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* When typing over a selection, the selection will we wrapped by a matching
|
|
30
|
+
* character pair. The second character is optional, it defaults to the first
|
|
31
|
+
* character.
|
|
32
|
+
*
|
|
33
|
+
* @type {string[]} Array of character pairs.
|
|
34
|
+
*/
|
|
35
|
+
const wrapSelectionSettings = ['`', '"', "'", '“”', '‘’'];
|
|
36
|
+
|
|
37
|
+
function useBeforeInputRules(props) {
|
|
38
|
+
const {
|
|
39
|
+
__unstableMarkLastChangeAsPersistent,
|
|
40
|
+
__unstableMarkAutomaticChange
|
|
41
|
+
} = (0, _data.useDispatch)(_store.store);
|
|
42
|
+
const propsRef = (0, _element.useRef)(props);
|
|
43
|
+
propsRef.current = props;
|
|
44
|
+
return (0, _compose.useRefEffect)(element => {
|
|
45
|
+
function onInput(event) {
|
|
46
|
+
const {
|
|
47
|
+
inputType,
|
|
48
|
+
data
|
|
49
|
+
} = event;
|
|
50
|
+
const {
|
|
51
|
+
value,
|
|
52
|
+
onChange
|
|
53
|
+
} = propsRef.current; // Only run the rules when inserting text.
|
|
54
|
+
|
|
55
|
+
if (inputType !== 'insertText') {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if ((0, _richText.isCollapsed)(value)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const pair = (0, _hooks.applyFilters)('blockEditor.wrapSelectionSettings', wrapSelectionSettings).find(_ref => {
|
|
64
|
+
let [startChar, endChar] = _ref;
|
|
65
|
+
return startChar === data || endChar === data;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
if (!pair) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const [startChar, endChar = startChar] = pair;
|
|
73
|
+
const start = value.start;
|
|
74
|
+
const end = value.end + startChar.length;
|
|
75
|
+
let newValue = (0, _richText.insert)(value, startChar, start, start);
|
|
76
|
+
newValue = (0, _richText.insert)(newValue, endChar, end, end);
|
|
77
|
+
|
|
78
|
+
__unstableMarkLastChangeAsPersistent();
|
|
79
|
+
|
|
80
|
+
onChange(newValue);
|
|
81
|
+
|
|
82
|
+
__unstableMarkAutomaticChange();
|
|
83
|
+
|
|
84
|
+
const init = {};
|
|
85
|
+
|
|
86
|
+
for (const key in event) {
|
|
87
|
+
init[key] = event[key];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
init.data = endChar;
|
|
91
|
+
const {
|
|
92
|
+
ownerDocument
|
|
93
|
+
} = element;
|
|
94
|
+
const {
|
|
95
|
+
defaultView
|
|
96
|
+
} = ownerDocument;
|
|
97
|
+
const newEvent = new defaultView.InputEvent('input', init); // Dispatch an input event with the new data. This will trigger the
|
|
98
|
+
// input rules.
|
|
99
|
+
|
|
100
|
+
event.target.dispatchEvent(newEvent);
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
element.addEventListener('beforeinput', onInput);
|
|
105
|
+
return () => {
|
|
106
|
+
element.removeEventListener('beforeinput', onInput);
|
|
107
|
+
};
|
|
108
|
+
}, []);
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=use-before-input-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-before-input-rules.js"],"names":["wrapSelectionSettings","useBeforeInputRules","props","__unstableMarkLastChangeAsPersistent","__unstableMarkAutomaticChange","blockEditorStore","propsRef","current","element","onInput","event","inputType","data","value","onChange","pair","find","startChar","endChar","start","end","length","newValue","init","key","ownerDocument","defaultView","newEvent","InputEvent","target","dispatchEvent","preventDefault","addEventListener","removeEventListener"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,qBAAqB,GAAG,CAAE,GAAF,EAAO,GAAP,EAAY,GAAZ,EAAiB,IAAjB,EAAuB,IAAvB,CAA9B;;AAEO,SAASC,mBAAT,CAA8BC,KAA9B,EAAsC;AAC5C,QAAM;AACLC,IAAAA,oCADK;AAELC,IAAAA;AAFK,MAGF,uBAAaC,YAAb,CAHJ;AAIA,QAAMC,QAAQ,GAAG,qBAAQJ,KAAR,CAAjB;AACAI,EAAAA,QAAQ,CAACC,OAAT,GAAmBL,KAAnB;AACA,SAAO,2BAAgBM,OAAF,IAAe;AACnC,aAASC,OAAT,CAAkBC,KAAlB,EAA0B;AACzB,YAAM;AAAEC,QAAAA,SAAF;AAAaC,QAAAA;AAAb,UAAsBF,KAA5B;AACA,YAAM;AAAEG,QAAAA,KAAF;AAASC,QAAAA;AAAT,UAAsBR,QAAQ,CAACC,OAArC,CAFyB,CAIzB;;AACA,UAAKI,SAAS,KAAK,YAAnB,EAAkC;AACjC;AACA;;AAED,UAAK,2BAAaE,KAAb,CAAL,EAA4B;AAC3B;AACA;;AAED,YAAME,IAAI,GAAG,yBACZ,mCADY,EAEZf,qBAFY,EAGXgB,IAHW,CAIZ;AAAA,YAAE,CAAEC,SAAF,EAAaC,OAAb,CAAF;AAAA,eACCD,SAAS,KAAKL,IAAd,IAAsBM,OAAO,KAAKN,IADnC;AAAA,OAJY,CAAb;;AAQA,UAAK,CAAEG,IAAP,EAAc;AACb;AACA;;AAED,YAAM,CAAEE,SAAF,EAAaC,OAAO,GAAGD,SAAvB,IAAqCF,IAA3C;AACA,YAAMI,KAAK,GAAGN,KAAK,CAACM,KAApB;AACA,YAAMC,GAAG,GAAGP,KAAK,CAACO,GAAN,GAAYH,SAAS,CAACI,MAAlC;AAEA,UAAIC,QAAQ,GAAG,sBAAQT,KAAR,EAAeI,SAAf,EAA0BE,KAA1B,EAAiCA,KAAjC,CAAf;AACAG,MAAAA,QAAQ,GAAG,sBAAQA,QAAR,EAAkBJ,OAAlB,EAA2BE,GAA3B,EAAgCA,GAAhC,CAAX;;AAEAjB,MAAAA,oCAAoC;;AACpCW,MAAAA,QAAQ,CAAEQ,QAAF,CAAR;;AACAlB,MAAAA,6BAA6B;;AAE7B,YAAMmB,IAAI,GAAG,EAAb;;AAEA,WAAM,MAAMC,GAAZ,IAAmBd,KAAnB,EAA2B;AAC1Ba,QAAAA,IAAI,CAAEC,GAAF,CAAJ,GAAcd,KAAK,CAAEc,GAAF,CAAnB;AACA;;AAEDD,MAAAA,IAAI,CAACX,IAAL,GAAYM,OAAZ;AAEA,YAAM;AAAEO,QAAAA;AAAF,UAAoBjB,OAA1B;AACA,YAAM;AAAEkB,QAAAA;AAAF,UAAkBD,aAAxB;AACA,YAAME,QAAQ,GAAG,IAAID,WAAW,CAACE,UAAhB,CAA4B,OAA5B,EAAqCL,IAArC,CAAjB,CA9CyB,CAgDzB;AACA;;AACAb,MAAAA,KAAK,CAACmB,MAAN,CAAaC,aAAb,CAA4BH,QAA5B;AACAjB,MAAAA,KAAK,CAACqB,cAAN;AACA;;AAEDvB,IAAAA,OAAO,CAACwB,gBAAR,CAA0B,aAA1B,EAAyCvB,OAAzC;AACA,WAAO,MAAM;AACZD,MAAAA,OAAO,CAACyB,mBAAR,CAA6B,aAA7B,EAA4CxB,OAA5C;AACA,KAFD;AAGA,GA3DM,EA2DJ,EA3DI,CAAP;AA4DA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { insert, isCollapsed } from '@wordpress/rich-text';\nimport { useDispatch } from '@wordpress/data';\nimport { applyFilters } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * When typing over a selection, the selection will we wrapped by a matching\n * character pair. The second character is optional, it defaults to the first\n * character.\n *\n * @type {string[]} Array of character pairs.\n */\nconst wrapSelectionSettings = [ '`', '\"', \"'\", '“”', '‘’' ];\n\nexport function useBeforeInputRules( props ) {\n\tconst {\n\t\t__unstableMarkLastChangeAsPersistent,\n\t\t__unstableMarkAutomaticChange,\n\t} = useDispatch( blockEditorStore );\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction onInput( event ) {\n\t\t\tconst { inputType, data } = event;\n\t\t\tconst { value, onChange } = propsRef.current;\n\n\t\t\t// Only run the rules when inserting text.\n\t\t\tif ( inputType !== 'insertText' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( isCollapsed( value ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst pair = applyFilters(\n\t\t\t\t'blockEditor.wrapSelectionSettings',\n\t\t\t\twrapSelectionSettings\n\t\t\t).find(\n\t\t\t\t( [ startChar, endChar ] ) =>\n\t\t\t\t\tstartChar === data || endChar === data\n\t\t\t);\n\n\t\t\tif ( ! pair ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst [ startChar, endChar = startChar ] = pair;\n\t\t\tconst start = value.start;\n\t\t\tconst end = value.end + startChar.length;\n\n\t\t\tlet newValue = insert( value, startChar, start, start );\n\t\t\tnewValue = insert( newValue, endChar, end, end );\n\n\t\t\t__unstableMarkLastChangeAsPersistent();\n\t\t\tonChange( newValue );\n\t\t\t__unstableMarkAutomaticChange();\n\n\t\t\tconst init = {};\n\n\t\t\tfor ( const key in event ) {\n\t\t\t\tinit[ key ] = event[ key ];\n\t\t\t}\n\n\t\t\tinit.data = endChar;\n\n\t\t\tconst { ownerDocument } = element;\n\t\t\tconst { defaultView } = ownerDocument;\n\t\t\tconst newEvent = new defaultView.InputEvent( 'input', init );\n\n\t\t\t// Dispatch an input event with the new data. This will trigger the\n\t\t\t// input rules.\n\t\t\tevent.target.dispatchEvent( newEvent );\n\t\t\tevent.preventDefault();\n\t\t}\n\n\t\telement.addEventListener( 'beforeinput', onInput );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'beforeinput', onInput );\n\t\t};\n\t}, [] );\n}\n"]}
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useFormatTypes = useFormatTypes;
|
|
7
7
|
|
|
8
|
+
var _lodash = require("lodash");
|
|
9
|
+
|
|
8
10
|
var _element = require("@wordpress/element");
|
|
9
11
|
|
|
10
12
|
var _data = require("@wordpress/data");
|
|
@@ -12,11 +14,11 @@ var _data = require("@wordpress/data");
|
|
|
12
14
|
var _richText = require("@wordpress/rich-text");
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
|
-
*
|
|
17
|
+
* External dependencies
|
|
16
18
|
*/
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
|
-
*
|
|
21
|
+
* WordPress dependencies
|
|
20
22
|
*/
|
|
21
23
|
function formatTypesSelector(select) {
|
|
22
24
|
return select(_richText.store).getFormatTypes();
|
|
@@ -29,6 +31,21 @@ function formatTypesSelector(select) {
|
|
|
29
31
|
|
|
30
32
|
|
|
31
33
|
const interactiveContentTags = new Set(['a', 'audio', 'button', 'details', 'embed', 'iframe', 'input', 'label', 'select', 'textarea', 'video']);
|
|
34
|
+
|
|
35
|
+
function prefixSelectKeys(selected, prefix) {
|
|
36
|
+
if (typeof selected !== 'object') return {
|
|
37
|
+
[prefix]: selected
|
|
38
|
+
};
|
|
39
|
+
return (0, _lodash.mapKeys)(selected, (value, key) => `${prefix}.${key}`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function getPrefixedSelectKeys(selected, prefix) {
|
|
43
|
+
if (selected[prefix]) return selected[prefix];
|
|
44
|
+
return Object.keys(selected).filter(key => key.startsWith(prefix + '.')).reduce((accumulator, key) => {
|
|
45
|
+
accumulator[key.slice(prefix.length + 1)] = selected[key];
|
|
46
|
+
return accumulator;
|
|
47
|
+
}, {});
|
|
48
|
+
}
|
|
32
49
|
/**
|
|
33
50
|
* This hook provides RichText with the `formatTypes` and its derived props from
|
|
34
51
|
* experimental format type settings.
|
|
@@ -40,6 +57,7 @@ const interactiveContentTags = new Set(['a', 'audio', 'button', 'details', 'embe
|
|
|
40
57
|
* @param {Array} $0.allowedFormats Allowed formats
|
|
41
58
|
*/
|
|
42
59
|
|
|
60
|
+
|
|
43
61
|
function useFormatTypes(_ref) {
|
|
44
62
|
let {
|
|
45
63
|
clientId,
|
|
@@ -67,25 +85,30 @@ function useFormatTypes(_ref) {
|
|
|
67
85
|
});
|
|
68
86
|
}, [allFormatTypes, allowedFormats, interactiveContentTags]);
|
|
69
87
|
const keyedSelected = (0, _data.useSelect)(select => formatTypes.reduce((accumulator, type) => {
|
|
70
|
-
if (type.__experimentalGetPropsForEditableTreePreparation) {
|
|
71
|
-
accumulator
|
|
72
|
-
richTextIdentifier: identifier,
|
|
73
|
-
blockClientId: clientId
|
|
74
|
-
});
|
|
88
|
+
if (!type.__experimentalGetPropsForEditableTreePreparation) {
|
|
89
|
+
return accumulator;
|
|
75
90
|
}
|
|
76
91
|
|
|
77
|
-
return accumulator
|
|
92
|
+
return { ...accumulator,
|
|
93
|
+
...prefixSelectKeys(type.__experimentalGetPropsForEditableTreePreparation(select, {
|
|
94
|
+
richTextIdentifier: identifier,
|
|
95
|
+
blockClientId: clientId
|
|
96
|
+
}), type.name)
|
|
97
|
+
};
|
|
78
98
|
}, {}), [formatTypes, clientId, identifier]);
|
|
79
99
|
const dispatch = (0, _data.useDispatch)();
|
|
80
100
|
const prepareHandlers = [];
|
|
81
101
|
const valueHandlers = [];
|
|
82
102
|
const changeHandlers = [];
|
|
83
103
|
const dependencies = [];
|
|
104
|
+
|
|
105
|
+
for (const key in keyedSelected) {
|
|
106
|
+
dependencies.push(keyedSelected[key]);
|
|
107
|
+
}
|
|
108
|
+
|
|
84
109
|
formatTypes.forEach(type => {
|
|
85
110
|
if (type.__experimentalCreatePrepareEditableTree) {
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
const handler = type.__experimentalCreatePrepareEditableTree(selected, {
|
|
111
|
+
const handler = type.__experimentalCreatePrepareEditableTree(getPrefixedSelectKeys(keyedSelected, type.name), {
|
|
89
112
|
richTextIdentifier: identifier,
|
|
90
113
|
blockClientId: clientId
|
|
91
114
|
});
|
|
@@ -95,10 +118,6 @@ function useFormatTypes(_ref) {
|
|
|
95
118
|
} else {
|
|
96
119
|
prepareHandlers.push(handler);
|
|
97
120
|
}
|
|
98
|
-
|
|
99
|
-
for (const key in selected) {
|
|
100
|
-
dependencies.push(selected[key]);
|
|
101
|
-
}
|
|
102
121
|
}
|
|
103
122
|
|
|
104
123
|
if (type.__experimentalCreateOnChangeEditableValue) {
|
|
@@ -111,7 +130,8 @@ function useFormatTypes(_ref) {
|
|
|
111
130
|
});
|
|
112
131
|
}
|
|
113
132
|
|
|
114
|
-
|
|
133
|
+
const selected = getPrefixedSelectKeys(keyedSelected, type.name);
|
|
134
|
+
changeHandlers.push(type.__experimentalCreateOnChangeEditableValue({ ...(typeof selected === 'object' ? selected : {}),
|
|
115
135
|
...dispatchers
|
|
116
136
|
}, {
|
|
117
137
|
richTextIdentifier: identifier,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-format-types.js"],"names":["formatTypesSelector","select","richTextStore","getFormatTypes","interactiveContentTags","Set","useFormatTypes","clientId","identifier","withoutInteractiveFormatting","allowedFormats","allFormatTypes","formatTypes","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-format-types.js"],"names":["formatTypesSelector","select","richTextStore","getFormatTypes","interactiveContentTags","Set","prefixSelectKeys","selected","prefix","value","key","getPrefixedSelectKeys","Object","keys","filter","startsWith","reduce","accumulator","slice","length","useFormatTypes","clientId","identifier","withoutInteractiveFormatting","allowedFormats","allFormatTypes","formatTypes","name","tagName","includes","has","keyedSelected","type","__experimentalGetPropsForEditableTreePreparation","richTextIdentifier","blockClientId","dispatch","prepareHandlers","valueHandlers","changeHandlers","dependencies","push","forEach","__experimentalCreatePrepareEditableTree","handler","__experimentalCreateOnChangeEditableValue","dispatchers","__experimentalGetPropsForEditableTreeChangeHandler"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAKA,SAASA,mBAAT,CAA8BC,MAA9B,EAAuC;AACtC,SAAOA,MAAM,CAAEC,eAAF,CAAN,CAAwBC,cAAxB,EAAP;AACA;AAED;AACA;AACA;AACA;AACA;;;AACA,MAAMC,sBAAsB,GAAG,IAAIC,GAAJ,CAAS,CACvC,GADuC,EAEvC,OAFuC,EAGvC,QAHuC,EAIvC,SAJuC,EAKvC,OALuC,EAMvC,QANuC,EAOvC,OAPuC,EAQvC,OARuC,EASvC,QATuC,EAUvC,UAVuC,EAWvC,OAXuC,CAAT,CAA/B;;AAcA,SAASC,gBAAT,CAA2BC,QAA3B,EAAqCC,MAArC,EAA8C;AAC7C,MAAK,OAAOD,QAAP,KAAoB,QAAzB,EAAoC,OAAO;AAAE,KAAEC,MAAF,GAAYD;AAAd,GAAP;AACpC,SAAO,qBAASA,QAAT,EAAmB,CAAEE,KAAF,EAASC,GAAT,KAAmB,GAAGF,MAAQ,IAAIE,GAAK,EAA1D,CAAP;AACA;;AAED,SAASC,qBAAT,CAAgCJ,QAAhC,EAA0CC,MAA1C,EAAmD;AAClD,MAAKD,QAAQ,CAAEC,MAAF,CAAb,EAA0B,OAAOD,QAAQ,CAAEC,MAAF,CAAf;AAC1B,SAAOI,MAAM,CAACC,IAAP,CAAaN,QAAb,EACLO,MADK,CACKJ,GAAF,IAAWA,GAAG,CAACK,UAAJ,CAAgBP,MAAM,GAAG,GAAzB,CADd,EAELQ,MAFK,CAEG,CA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Q,GAAGI,qBAAqB,CAAEoB,aAAF,EAAiBC,IAAI,CAACL,IAAtB,CAAtC;AACAY,MAAAA,cAAc,CAACE,IAAf,CACCT,IAAI,CAACa,yCAAL,CACC,EACC,IAAK,OAAOtC,QAAP,KAAoB,QAApB,GAA+BA,QAA/B,GAA0C,EAA/C,CADD;AAEC,WAAGuC;AAFJ,OADD,EAKC;AACCZ,QAAAA,kBAAkB,EAAEZ,UADrB;AAECa,QAAAA,aAAa,EAAEd;AAFhB,OALD,CADD;AAYA;AACD,GA7CD;AA+CA,SAAO;AACNK,IAAAA,WADM;AAENW,IAAAA,eAFM;AAGNC,IAAAA,aAHM;AAINC,IAAAA,cAJM;AAKNC,IAAAA;AALM,GAAP;AAOA","sourcesContent":["/**\n * External dependencies\n */\nimport { mapKeys } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as richTextStore } from '@wordpress/rich-text';\n\nfunction formatTypesSelector( select ) {\n\treturn select( richTextStore ).getFormatTypes();\n}\n\n/**\n * Set of all interactive content tags.\n *\n * @see https://html.spec.whatwg.org/multipage/dom.html#interactive-content\n */\nconst interactiveContentTags = new Set( [\n\t'a',\n\t'audio',\n\t'button',\n\t'details',\n\t'embed',\n\t'iframe',\n\t'input',\n\t'label',\n\t'select',\n\t'textarea',\n\t'video',\n] );\n\nfunction prefixSelectKeys( selected, prefix ) {\n\tif ( typeof selected !== 'object' ) return { [ prefix ]: selected };\n\treturn mapKeys( selected, ( value, key ) => `${ prefix }.${ key }` );\n}\n\nfunction getPrefixedSelectKeys( selected, prefix ) {\n\tif ( selected[ prefix ] ) return selected[ prefix ];\n\treturn Object.keys( selected )\n\t\t.filter( ( key ) => key.startsWith( prefix + '.' ) )\n\t\t.reduce( ( accumulator, key ) => {\n\t\t\taccumulator[ key.slice( prefix.length + 1 ) ] = selected[ key ];\n\t\t\treturn accumulator;\n\t\t}, {} );\n}\n\n/**\n * This hook provides RichText with the `formatTypes` and its derived props from\n * experimental format type settings.\n *\n * @param {Object} $0 Options\n * @param {string} $0.clientId Block client ID.\n * @param {string} $0.identifier Block attribute.\n * @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formattings or not.\n * @param {Array} $0.allowedFormats Allowed formats\n */\nexport function useFormatTypes( {\n\tclientId,\n\tidentifier,\n\twithoutInteractiveFormatting,\n\tallowedFormats,\n} ) {\n\tconst allFormatTypes = useSelect( formatTypesSelector, [] );\n\tconst formatTypes = useMemo( () => {\n\t\treturn allFormatTypes.filter( ( { name, tagName } ) => {\n\t\t\tif ( allowedFormats && ! allowedFormats.includes( name ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\twithoutInteractiveFormatting &&\n\t\t\t\tinteractiveContentTags.has( tagName )\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t} );\n\t}, [ allFormatTypes, allowedFormats, interactiveContentTags ] );\n\tconst keyedSelected = useSelect(\n\t\t( select ) =>\n\t\t\tformatTypes.reduce( ( accumulator, type ) => {\n\t\t\t\tif ( ! type.__experimentalGetPropsForEditableTreePreparation ) {\n\t\t\t\t\treturn accumulator;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...accumulator,\n\t\t\t\t\t...prefixSelectKeys(\n\t\t\t\t\t\ttype.__experimentalGetPropsForEditableTreePreparation(\n\t\t\t\t\t\t\tselect,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttype.name\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t}, {} ),\n\t\t[ formatTypes, clientId, identifier ]\n\t);\n\tconst dispatch = useDispatch();\n\tconst prepareHandlers = [];\n\tconst valueHandlers = [];\n\tconst changeHandlers = [];\n\tconst dependencies = [];\n\n\tfor ( const key in keyedSelected ) {\n\t\tdependencies.push( keyedSelected[ key ] );\n\t}\n\n\tformatTypes.forEach( ( type ) => {\n\t\tif ( type.__experimentalCreatePrepareEditableTree ) {\n\t\t\tconst handler = type.__experimentalCreatePrepareEditableTree(\n\t\t\t\tgetPrefixedSelectKeys( keyedSelected, type.name ),\n\t\t\t\t{\n\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( type.__experimentalCreateOnChangeEditableValue ) {\n\t\t\t\tvalueHandlers.push( handler );\n\t\t\t} else {\n\t\t\t\tprepareHandlers.push( handler );\n\t\t\t}\n\t\t}\n\n\t\tif ( type.__experimentalCreateOnChangeEditableValue ) {\n\t\t\tlet dispatchers = {};\n\n\t\t\tif ( type.__experimentalGetPropsForEditableTreeChangeHandler ) {\n\t\t\t\tdispatchers =\n\t\t\t\t\ttype.__experimentalGetPropsForEditableTreeChangeHandler(\n\t\t\t\t\t\tdispatch,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst selected = getPrefixedSelectKeys( keyedSelected, type.name );\n\t\t\tchangeHandlers.push(\n\t\t\t\ttype.__experimentalCreateOnChangeEditableValue(\n\t\t\t\t\t{\n\t\t\t\t\t\t...( typeof selected === 'object' ? selected : {} ),\n\t\t\t\t\t\t...dispatchers,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t} );\n\n\treturn {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t};\n}\n"]}
|
|
@@ -42,7 +42,9 @@ function TextDecorationControl(_ref) {
|
|
|
42
42
|
} = _ref;
|
|
43
43
|
return (0, _element.createElement)("fieldset", {
|
|
44
44
|
className: "block-editor-text-decoration-control"
|
|
45
|
-
}, (0, _element.createElement)(
|
|
45
|
+
}, (0, _element.createElement)(_components.BaseControl.VisualLabel, {
|
|
46
|
+
as: "legend"
|
|
47
|
+
}, (0, _i18n.__)('Decoration')), (0, _element.createElement)("div", {
|
|
46
48
|
className: "block-editor-text-decoration-control__buttons"
|
|
47
49
|
}, TEXT_DECORATIONS.map(textDecoration => {
|
|
48
50
|
return (0, _element.createElement)(_components.Button, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/text-decoration-control/index.js"],"names":["TEXT_DECORATIONS","name","value","icon","formatUnderline","formatStrikethrough","TextDecorationControl","onChange","map","textDecoration","undefined"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAKA,MAAMA,gBAAgB,GAAG,CACxB;AACCC,EAAAA,IAAI,EAAE,cAAI,WAAJ,CADP;AAECC,EAAAA,KAAK,EAAE,WAFR;AAGCC,EAAAA,IAAI,EAAEC;AAHP,CADwB,EAMxB;AACCH,EAAAA,IAAI,EAAE,cAAI,eAAJ,CADP;AAECC,EAAAA,KAAK,EAAE,cAFR;AAGCC,EAAAA,IAAI,EAAEE;AAHP,CANwB,CAAzB;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACe,SAASC,qBAAT,OAAsD;AAAA,MAAtB;AAAEJ,IAAAA,KAAF;AAASK,IAAAA;AAAT,GAAsB;AACpE,SACC;AAAU,IAAA,SAAS,EAAC;AAApB,KACC,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/text-decoration-control/index.js"],"names":["TEXT_DECORATIONS","name","value","icon","formatUnderline","formatStrikethrough","TextDecorationControl","onChange","map","textDecoration","undefined"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAKA,MAAMA,gBAAgB,GAAG,CACxB;AACCC,EAAAA,IAAI,EAAE,cAAI,WAAJ,CADP;AAECC,EAAAA,KAAK,EAAE,WAFR;AAGCC,EAAAA,IAAI,EAAEC;AAHP,CADwB,EAMxB;AACCH,EAAAA,IAAI,EAAE,cAAI,eAAJ,CADP;AAECC,EAAAA,KAAK,EAAE,cAFR;AAGCC,EAAAA,IAAI,EAAEE;AAHP,CANwB,CAAzB;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACe,SAASC,qBAAT,OAAsD;AAAA,MAAtB;AAAEJ,IAAAA,KAAF;AAASK,IAAAA;AAAT,GAAsB;AACpE,SACC;AAAU,IAAA,SAAS,EAAC;AAApB,KACC,4BAAC,uBAAD,CAAa,WAAb;AAAyB,IAAA,EAAE,EAAC;AAA5B,KACG,cAAI,YAAJ,CADH,CADD,EAIC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGP,gBAAgB,CAACQ,GAAjB,CAAwBC,cAAF,IAAsB;AAC7C,WACC,4BAAC,kBAAD;AACC,MAAA,GAAG,EAAGA,cAAc,CAACP,KADtB;AAEC,MAAA,IAAI,EAAGO,cAAc,CAACN,IAFvB;AAGC,MAAA,OAAO,MAHR;AAIC,MAAA,SAAS,EAAGM,cAAc,CAACP,KAAf,KAAyBA,KAJtC;AAKC,MAAA,OAAO,EAAG,MACTK,QAAQ,CACPE,cAAc,CAACP,KAAf,KAAyBA,KAAzB,GACGQ,SADH,GAEGD,cAAc,CAACP,KAHX,CANV;AAYC,oBAAaO,cAAc,CAACR;AAZ7B,MADD;AAgBA,GAjBC,CADH,CAJD,CADD;AA2BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { BaseControl, Button } from '@wordpress/components';\nimport { formatStrikethrough, formatUnderline } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\nconst TEXT_DECORATIONS = [\n\t{\n\t\tname: __( 'Underline' ),\n\t\tvalue: 'underline',\n\t\ticon: formatUnderline,\n\t},\n\t{\n\t\tname: __( 'Strikethrough' ),\n\t\tvalue: 'line-through',\n\t\ticon: formatStrikethrough,\n\t},\n];\n\n/**\n * Control to facilitate text decoration selections.\n *\n * @param {Object} props Component props.\n * @param {string} props.value Currently selected text decoration.\n * @param {Function} props.onChange Handles change in text decoration selection.\n *\n * @return {WPElement} Text decoration control.\n */\nexport default function TextDecorationControl( { value, onChange } ) {\n\treturn (\n\t\t<fieldset className=\"block-editor-text-decoration-control\">\n\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t{ __( 'Decoration' ) }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<div className=\"block-editor-text-decoration-control__buttons\">\n\t\t\t\t{ TEXT_DECORATIONS.map( ( textDecoration ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ textDecoration.value }\n\t\t\t\t\t\t\ticon={ textDecoration.icon }\n\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\tisPressed={ textDecoration.value === value }\n\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\ttextDecoration.value === value\n\t\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t\t: textDecoration.value\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\taria-label={ textDecoration.name }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n}\n"]}
|
|
@@ -46,7 +46,9 @@ function TextTransformControl(_ref) {
|
|
|
46
46
|
} = _ref;
|
|
47
47
|
return (0, _element.createElement)("fieldset", {
|
|
48
48
|
className: "block-editor-text-transform-control"
|
|
49
|
-
}, (0, _element.createElement)(
|
|
49
|
+
}, (0, _element.createElement)(_components.BaseControl.VisualLabel, {
|
|
50
|
+
as: "legend"
|
|
51
|
+
}, (0, _i18n.__)('Letter case')), (0, _element.createElement)("div", {
|
|
50
52
|
className: "block-editor-text-transform-control__buttons"
|
|
51
53
|
}, TEXT_TRANSFORMS.map(textTransform => {
|
|
52
54
|
return (0, _element.createElement)(_components.Button, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/text-transform-control/index.js"],"names":["TEXT_TRANSFORMS","name","value","icon","formatUppercase","formatLowercase","formatCapitalize","TextTransformControl","onChange","map","textTransform","undefined"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AASA,MAAMA,eAAe,GAAG,CACvB;AACCC,EAAAA,IAAI,EAAE,cAAI,WAAJ,CADP;AAECC,EAAAA,KAAK,EAAE,WAFR;AAGCC,EAAAA,IAAI,EAAEC;AAHP,CADuB,EAMvB;AACCH,EAAAA,IAAI,EAAE,cAAI,WAAJ,CADP;AAECC,EAAAA,KAAK,EAAE,WAFR;AAGCC,EAAAA,IAAI,EAAEE;AAHP,CANuB,EAWvB;AACCJ,EAAAA,IAAI,EAAE,cAAI,YAAJ,CADP;AAECC,EAAAA,KAAK,EAAE,YAFR;AAGCC,EAAAA,IAAI,EAAEG;AAHP,CAXuB,CAAxB;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACe,SAASC,oBAAT,OAAqD;AAAA,MAAtB;AAAEL,IAAAA,KAAF;AAASM,IAAAA;AAAT,GAAsB;AACnE,SACC;AAAU,IAAA,SAAS,EAAC;AAApB,KACC,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/text-transform-control/index.js"],"names":["TEXT_TRANSFORMS","name","value","icon","formatUppercase","formatLowercase","formatCapitalize","TextTransformControl","onChange","map","textTransform","undefined"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AASA,MAAMA,eAAe,GAAG,CACvB;AACCC,EAAAA,IAAI,EAAE,cAAI,WAAJ,CADP;AAECC,EAAAA,KAAK,EAAE,WAFR;AAGCC,EAAAA,IAAI,EAAEC;AAHP,CADuB,EAMvB;AACCH,EAAAA,IAAI,EAAE,cAAI,WAAJ,CADP;AAECC,EAAAA,KAAK,EAAE,WAFR;AAGCC,EAAAA,IAAI,EAAEE;AAHP,CANuB,EAWvB;AACCJ,EAAAA,IAAI,EAAE,cAAI,YAAJ,CADP;AAECC,EAAAA,KAAK,EAAE,YAFR;AAGCC,EAAAA,IAAI,EAAEG;AAHP,CAXuB,CAAxB;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACe,SAASC,oBAAT,OAAqD;AAAA,MAAtB;AAAEL,IAAAA,KAAF;AAASM,IAAAA;AAAT,GAAsB;AACnE,SACC;AAAU,IAAA,SAAS,EAAC;AAApB,KACC,4BAAC,uBAAD,CAAa,WAAb;AAAyB,IAAA,EAAE,EAAC;AAA5B,KACG,cAAI,aAAJ,CADH,CADD,EAIC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGR,eAAe,CAACS,GAAhB,CAAuBC,aAAF,IAAqB;AAC3C,WACC,4BAAC,kBAAD;AACC,MAAA,GAAG,EAAGA,aAAa,CAACR,KADrB;AAEC,MAAA,IAAI,EAAGQ,aAAa,CAACP,IAFtB;AAGC,MAAA,OAAO,MAHR;AAIC,MAAA,SAAS,EAAGD,KAAK,KAAKQ,aAAa,CAACR,KAJrC;AAKC,oBAAaQ,aAAa,CAACT,IAL5B;AAMC,MAAA,OAAO,EAAG,MACTO,QAAQ,CACPN,KAAK,KAAKQ,aAAa,CAACR,KAAxB,GACGS,SADH,GAEGD,aAAa,CAACR,KAHV;AAPV,MADD;AAgBA,GAjBC,CADH,CAJD,CADD;AA2BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { BaseControl, Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tformatCapitalize,\n\tformatLowercase,\n\tformatUppercase,\n} from '@wordpress/icons';\n\nconst TEXT_TRANSFORMS = [\n\t{\n\t\tname: __( 'Uppercase' ),\n\t\tvalue: 'uppercase',\n\t\ticon: formatUppercase,\n\t},\n\t{\n\t\tname: __( 'Lowercase' ),\n\t\tvalue: 'lowercase',\n\t\ticon: formatLowercase,\n\t},\n\t{\n\t\tname: __( 'Capitalize' ),\n\t\tvalue: 'capitalize',\n\t\ticon: formatCapitalize,\n\t},\n];\n\n/**\n * Control to facilitate text transform selections.\n *\n * @param {Object} props Component props.\n * @param {string} props.value Currently selected text transform.\n * @param {Function} props.onChange Handles change in text transform selection.\n *\n * @return {WPElement} Text transform control.\n */\nexport default function TextTransformControl( { value, onChange } ) {\n\treturn (\n\t\t<fieldset className=\"block-editor-text-transform-control\">\n\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t{ __( 'Letter case' ) }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<div className=\"block-editor-text-transform-control__buttons\">\n\t\t\t\t{ TEXT_TRANSFORMS.map( ( textTransform ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ textTransform.value }\n\t\t\t\t\t\t\ticon={ textTransform.icon }\n\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\tisPressed={ value === textTransform.value }\n\t\t\t\t\t\t\taria-label={ textTransform.name }\n\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\tvalue === textTransform.value\n\t\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t\t: textTransform.value\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n}\n"]}
|
|
@@ -60,6 +60,7 @@ const ImageURLInputUI = _ref => {
|
|
|
60
60
|
rel
|
|
61
61
|
} = _ref;
|
|
62
62
|
const [isOpen, setIsOpen] = (0, _element.useState)(false);
|
|
63
|
+
const buttonRef = (0, _element.useRef)(null);
|
|
63
64
|
const openLinkUI = (0, _element.useCallback)(() => {
|
|
64
65
|
setIsOpen(true);
|
|
65
66
|
});
|
|
@@ -233,8 +234,10 @@ const ImageURLInputUI = _ref => {
|
|
|
233
234
|
className: "components-toolbar__control",
|
|
234
235
|
label: url ? (0, _i18n.__)('Edit link') : (0, _i18n.__)('Insert link'),
|
|
235
236
|
"aria-expanded": isOpen,
|
|
236
|
-
onClick: openLinkUI
|
|
237
|
+
onClick: openLinkUI,
|
|
238
|
+
ref: buttonRef
|
|
237
239
|
}), isOpen && (0, _element.createElement)(_index.default, {
|
|
240
|
+
anchorRef: buttonRef,
|
|
238
241
|
onFocusOutside: onFocusOutside(),
|
|
239
242
|
onClose: closeLinkUI,
|
|
240
243
|
renderSettings: () => advancedOptions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/url-popover/image-url-input-ui.js"],"names":["LINK_DESTINATION_NONE","LINK_DESTINATION_CUSTOM","LINK_DESTINATION_MEDIA","LINK_DESTINATION_ATTACHMENT","NEW_TAB_REL","icon","ImageURLInputUI","linkDestination","onChangeUrl","url","mediaType","mediaUrl","mediaLink","linkTarget","linkClass","rel","isOpen","setIsOpen","openLinkUI","isEditingLink","setIsEditingLink","urlInput","setUrlInput","autocompleteRef","startEditLink","stopEditLink","closeLinkUI","getUpdatedLinkTargetSettings","value","newLinkTarget","undefined","updatedRel","rels","split","forEach","relVal","includes","push","join","filter","length","onFocusOutside","event","autocompleteElement","current","contains","target","onSubmitLinkChange","selectedDestination","getLinkDestinations","find","destination","href","preventDefault","onLinkRemove","linkDestinations","title","onSetHref","linkDestinationInput","onSetNewTab","updatedLinkTarget","onSetLinkRel","onSetLinkClass","advancedOptions","linkEditorValue","urlLabel","linkIcon","link","close"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AAUA;;AAKA;;AAzBA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;AAGA,MAAM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*/\nimport { find, map } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useCallback } from '@wordpress/element';\nimport {\n\tToolbarButton,\n\tButton,\n\tNavigableMenu,\n\tMenuItem,\n\tToggleControl,\n\tTextControl,\n\tSVG,\n\tPath,\n} from '@wordpress/components';\nimport { link as linkIcon, close } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport URLPopover from './index';\n\nconst LINK_DESTINATION_NONE = 'none';\nconst LINK_DESTINATION_CUSTOM = 'custom';\nconst LINK_DESTINATION_MEDIA = 'media';\nconst LINK_DESTINATION_ATTACHMENT = 'attachment';\nconst NEW_TAB_REL = [ 'noreferrer', 'noopener' ];\n\nconst icon = (\n\t<SVG viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t<Path d=\"M0,0h24v24H0V0z\" fill=\"none\" />\n\t\t<Path d=\"m19 5v14h-14v-14h14m0-2h-14c-1.1 0-2 0.9-2 2v14c0 1.1 0.9 2 2 2h14c1.1 0 2-0.9 2-2v-14c0-1.1-0.9-2-2-2z\" />\n\t\t<Path d=\"m14.14 11.86l-3 3.87-2.14-2.59-3 3.86h12l-3.86-5.14z\" />\n\t</SVG>\n);\n\nconst ImageURLInputUI = ( {\n\tlinkDestination,\n\tonChangeUrl,\n\turl,\n\tmediaType = 'image',\n\tmediaUrl,\n\tmediaLink,\n\tlinkTarget,\n\tlinkClass,\n\trel,\n} ) => {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\tconst openLinkUI = useCallback( () => {\n\t\tsetIsOpen( true );\n\t} );\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState( false );\n\tconst [ urlInput, setUrlInput ] = useState( null );\n\n\tconst autocompleteRef = useRef( null );\n\n\tconst startEditLink = useCallback( () => {\n\t\tif (\n\t\t\tlinkDestination === LINK_DESTINATION_MEDIA ||\n\t\t\tlinkDestination === LINK_DESTINATION_ATTACHMENT\n\t\t) {\n\t\t\tsetUrlInput( '' );\n\t\t}\n\t\tsetIsEditingLink( true );\n\t} );\n\n\tconst stopEditLink = useCallback( () => {\n\t\tsetIsEditingLink( false );\n\t} );\n\n\tconst closeLinkUI = useCallback( () => {\n\t\tsetUrlInput( null );\n\t\tstopEditLink();\n\t\tsetIsOpen( false );\n\t} );\n\n\tconst getUpdatedLinkTargetSettings = ( value ) => {\n\t\tconst newLinkTarget = value ? '_blank' : undefined;\n\n\t\tlet updatedRel;\n\t\tif ( newLinkTarget ) {\n\t\t\tconst rels = ( rel ?? '' ).split( ' ' );\n\t\t\tNEW_TAB_REL.forEach( ( relVal ) => {\n\t\t\t\tif ( ! rels.includes( relVal ) ) {\n\t\t\t\t\trels.push( relVal );\n\t\t\t\t}\n\t\t\t} );\n\t\t\tupdatedRel = rels.join( ' ' );\n\t\t} else {\n\t\t\tconst rels = ( rel ?? '' )\n\t\t\t\t.split( ' ' )\n\t\t\t\t.filter(\n\t\t\t\t\t( relVal ) => NEW_TAB_REL.includes( relVal ) === false\n\t\t\t\t);\n\t\t\tupdatedRel = rels.length ? rels.join( ' ' ) : undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tlinkTarget: newLinkTarget,\n\t\t\trel: updatedRel,\n\t\t};\n\t};\n\n\tconst onFocusOutside = useCallback( () => {\n\t\treturn ( event ) => {\n\t\t\t// The autocomplete suggestions list renders in a separate popover (in a portal),\n\t\t\t// so onFocusOutside fails to detect that a click on a suggestion occurred in the\n\t\t\t// LinkContainer. Detect clicks on autocomplete suggestions using a ref here, and\n\t\t\t// return to avoid the popover being closed.\n\t\t\tconst autocompleteElement = autocompleteRef.current;\n\t\t\tif (\n\t\t\t\tautocompleteElement &&\n\t\t\t\tautocompleteElement.contains( event.target )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetIsOpen( false );\n\t\t\tsetUrlInput( null );\n\t\t\tstopEditLink();\n\t\t};\n\t} );\n\n\tconst onSubmitLinkChange = useCallback( () => {\n\t\treturn ( event ) => {\n\t\t\tif ( urlInput ) {\n\t\t\t\t// It is possible the entered URL actually matches a named link destination.\n\t\t\t\t// This check will ensure our link destination is correct.\n\t\t\t\tconst selectedDestination =\n\t\t\t\t\tgetLinkDestinations().find(\n\t\t\t\t\t\t( destination ) => destination.url === urlInput\n\t\t\t\t\t)?.linkDestination || LINK_DESTINATION_CUSTOM;\n\n\t\t\t\tonChangeUrl( {\n\t\t\t\t\thref: urlInput,\n\t\t\t\t\tlinkDestination: selectedDestination,\n\t\t\t\t} );\n\t\t\t}\n\t\t\tstopEditLink();\n\t\t\tsetUrlInput( null );\n\t\t\tevent.preventDefault();\n\t\t};\n\t} );\n\n\tconst onLinkRemove = useCallback( () => {\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: LINK_DESTINATION_NONE,\n\t\t\thref: '',\n\t\t} );\n\t} );\n\n\tconst getLinkDestinations = () => {\n\t\tconst linkDestinations = [\n\t\t\t{\n\t\t\t\tlinkDestination: LINK_DESTINATION_MEDIA,\n\t\t\t\ttitle: __( 'Media File' ),\n\t\t\t\turl: mediaType === 'image' ? mediaUrl : undefined,\n\t\t\t\ticon,\n\t\t\t},\n\t\t];\n\t\tif ( mediaType === 'image' && mediaLink ) {\n\t\t\tlinkDestinations.push( {\n\t\t\t\tlinkDestination: LINK_DESTINATION_ATTACHMENT,\n\t\t\t\ttitle: __( 'Attachment Page' ),\n\t\t\t\turl: mediaType === 'image' ? mediaLink : undefined,\n\t\t\t\ticon: (\n\t\t\t\t\t<SVG viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t\t\t\t\t<Path d=\"M0 0h24v24H0V0z\" fill=\"none\" />\n\t\t\t\t\t\t<Path d=\"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zM6 20V4h7v5h5v11H6z\" />\n\t\t\t\t\t</SVG>\n\t\t\t\t),\n\t\t\t} );\n\t\t}\n\t\treturn linkDestinations;\n\t};\n\n\tconst onSetHref = ( value ) => {\n\t\tconst linkDestinations = getLinkDestinations();\n\t\tlet linkDestinationInput;\n\t\tif ( ! value ) {\n\t\t\tlinkDestinationInput = LINK_DESTINATION_NONE;\n\t\t} else {\n\t\t\tlinkDestinationInput = (\n\t\t\t\tfind( linkDestinations, ( destination ) => {\n\t\t\t\t\treturn destination.url === value;\n\t\t\t\t} ) || { linkDestination: LINK_DESTINATION_CUSTOM }\n\t\t\t).linkDestination;\n\t\t}\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: linkDestinationInput,\n\t\t\thref: value,\n\t\t} );\n\t};\n\n\tconst onSetNewTab = ( value ) => {\n\t\tconst updatedLinkTarget = getUpdatedLinkTargetSettings( value );\n\t\tonChangeUrl( updatedLinkTarget );\n\t};\n\n\tconst onSetLinkRel = ( value ) => {\n\t\tonChangeUrl( { rel: value } );\n\t};\n\n\tconst onSetLinkClass = ( value ) => {\n\t\tonChangeUrl( { linkClass: value } );\n\t};\n\n\tconst advancedOptions = (\n\t\t<>\n\t\t\t<ToggleControl\n\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\tonChange={ onSetNewTab }\n\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\tlabel={ __( 'Link Rel' ) }\n\t\t\t\tvalue={ rel ?? '' }\n\t\t\t\tonChange={ onSetLinkRel }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\tlabel={ __( 'Link CSS Class' ) }\n\t\t\t\tvalue={ linkClass || '' }\n\t\t\t\tonChange={ onSetLinkClass }\n\t\t\t/>\n\t\t</>\n\t);\n\n\tconst linkEditorValue = urlInput !== null ? urlInput : url;\n\n\tconst urlLabel = (\n\t\tfind( getLinkDestinations(), [ 'linkDestination', linkDestination ] ) ||\n\t\t{}\n\t).title;\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ linkIcon }\n\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\tlabel={ url ? __( 'Edit link' ) : __( 'Insert link' ) }\n\t\t\t\taria-expanded={ isOpen }\n\t\t\t\tonClick={ openLinkUI }\n\t\t\t/>\n\t\t\t{ isOpen && (\n\t\t\t\t<URLPopover\n\t\t\t\t\tonFocusOutside={ onFocusOutside() }\n\t\t\t\t\tonClose={ closeLinkUI }\n\t\t\t\t\trenderSettings={ () => advancedOptions }\n\t\t\t\t\tadditionalControls={\n\t\t\t\t\t\t! linkEditorValue && (\n\t\t\t\t\t\t\t<NavigableMenu>\n\t\t\t\t\t\t\t\t{ map( getLinkDestinations(), ( link ) => (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey={ link.linkDestination }\n\t\t\t\t\t\t\t\t\t\ticon={ link.icon }\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonSetHref( link.url );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ link.title }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ ( ! url || isEditingLink ) && (\n\t\t\t\t\t\t<URLPopover.LinkEditor\n\t\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\t\tvalue={ linkEditorValue }\n\t\t\t\t\t\t\tonChangeInputValue={ setUrlInput }\n\t\t\t\t\t\t\tonSubmit={ onSubmitLinkChange() }\n\t\t\t\t\t\t\tautocompleteRef={ autocompleteRef }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ url && ! isEditingLink && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<URLPopover.LinkViewer\n\t\t\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\t\tonEditLinkClick={ startEditLink }\n\t\t\t\t\t\t\t\turlLabel={ urlLabel }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\ticon={ close }\n\t\t\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\t\t\tonClick={ onLinkRemove }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</URLPopover>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport { ImageURLInputUI as __experimentalImageURLInputUI };\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/url-popover/image-url-input-ui.js"],"names":["LINK_DESTINATION_NONE","LINK_DESTINATION_CUSTOM","LINK_DESTINATION_MEDIA","LINK_DESTINATION_ATTACHMENT","NEW_TAB_REL","icon","ImageURLInputUI","linkDestination","onChangeUrl","url","mediaType","mediaUrl","mediaLink","linkTarget","linkClass","rel","isOpen","setIsOpen","buttonRef","openLinkUI","isEditingLink","setIsEditingLink","urlInput","setUrlInput","autocompleteRef","startEditLink","stopEditLink","closeLinkUI","getUpdatedLinkTargetSettings","value","newLinkTarget","undefined","updatedRel","rels","split","forEach","relVal","includes","push","join","filter","length","onFocusOutside","event","autocompleteElement","current","contains","target","onSubmitLinkChange","selectedDestination","getLinkDestinations","find","destination","href","preventDefault","onLinkRemove","linkDestinations","title","onSetHref","linkDestinationInput","onSetNewTab","updatedLinkTarget","onSetLinkRel","onSetLinkClass","advancedOptions","linkEditorValue","urlLabel","linkIcon","link","close"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AAUA;;AAKA;;AAzBA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;AAGA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G,cAAI,aAAJ,CAFT;AAGC,IAAA,OAAO,EAAGd;AAHX,IAPD,CAnCF,CAVF,CADD;AAgEA,CAvQD","sourcesContent":["/**\n * External dependencies\n */\nimport { find, map } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useCallback } from '@wordpress/element';\nimport {\n\tToolbarButton,\n\tButton,\n\tNavigableMenu,\n\tMenuItem,\n\tToggleControl,\n\tTextControl,\n\tSVG,\n\tPath,\n} from '@wordpress/components';\nimport { link as linkIcon, close } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport URLPopover from './index';\n\nconst LINK_DESTINATION_NONE = 'none';\nconst LINK_DESTINATION_CUSTOM = 'custom';\nconst LINK_DESTINATION_MEDIA = 'media';\nconst LINK_DESTINATION_ATTACHMENT = 'attachment';\nconst NEW_TAB_REL = [ 'noreferrer', 'noopener' ];\n\nconst icon = (\n\t<SVG viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t<Path d=\"M0,0h24v24H0V0z\" fill=\"none\" />\n\t\t<Path d=\"m19 5v14h-14v-14h14m0-2h-14c-1.1 0-2 0.9-2 2v14c0 1.1 0.9 2 2 2h14c1.1 0 2-0.9 2-2v-14c0-1.1-0.9-2-2-2z\" />\n\t\t<Path d=\"m14.14 11.86l-3 3.87-2.14-2.59-3 3.86h12l-3.86-5.14z\" />\n\t</SVG>\n);\n\nconst ImageURLInputUI = ( {\n\tlinkDestination,\n\tonChangeUrl,\n\turl,\n\tmediaType = 'image',\n\tmediaUrl,\n\tmediaLink,\n\tlinkTarget,\n\tlinkClass,\n\trel,\n} ) => {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\tconst buttonRef = useRef( null );\n\tconst openLinkUI = useCallback( () => {\n\t\tsetIsOpen( true );\n\t} );\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState( false );\n\tconst [ urlInput, setUrlInput ] = useState( null );\n\n\tconst autocompleteRef = useRef( null );\n\n\tconst startEditLink = useCallback( () => {\n\t\tif (\n\t\t\tlinkDestination === LINK_DESTINATION_MEDIA ||\n\t\t\tlinkDestination === LINK_DESTINATION_ATTACHMENT\n\t\t) {\n\t\t\tsetUrlInput( '' );\n\t\t}\n\t\tsetIsEditingLink( true );\n\t} );\n\n\tconst stopEditLink = useCallback( () => {\n\t\tsetIsEditingLink( false );\n\t} );\n\n\tconst closeLinkUI = useCallback( () => {\n\t\tsetUrlInput( null );\n\t\tstopEditLink();\n\t\tsetIsOpen( false );\n\t} );\n\n\tconst getUpdatedLinkTargetSettings = ( value ) => {\n\t\tconst newLinkTarget = value ? '_blank' : undefined;\n\n\t\tlet updatedRel;\n\t\tif ( newLinkTarget ) {\n\t\t\tconst rels = ( rel ?? '' ).split( ' ' );\n\t\t\tNEW_TAB_REL.forEach( ( relVal ) => {\n\t\t\t\tif ( ! rels.includes( relVal ) ) {\n\t\t\t\t\trels.push( relVal );\n\t\t\t\t}\n\t\t\t} );\n\t\t\tupdatedRel = rels.join( ' ' );\n\t\t} else {\n\t\t\tconst rels = ( rel ?? '' )\n\t\t\t\t.split( ' ' )\n\t\t\t\t.filter(\n\t\t\t\t\t( relVal ) => NEW_TAB_REL.includes( relVal ) === false\n\t\t\t\t);\n\t\t\tupdatedRel = rels.length ? rels.join( ' ' ) : undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tlinkTarget: newLinkTarget,\n\t\t\trel: updatedRel,\n\t\t};\n\t};\n\n\tconst onFocusOutside = useCallback( () => {\n\t\treturn ( event ) => {\n\t\t\t// The autocomplete suggestions list renders in a separate popover (in a portal),\n\t\t\t// so onFocusOutside fails to detect that a click on a suggestion occurred in the\n\t\t\t// LinkContainer. Detect clicks on autocomplete suggestions using a ref here, and\n\t\t\t// return to avoid the popover being closed.\n\t\t\tconst autocompleteElement = autocompleteRef.current;\n\t\t\tif (\n\t\t\t\tautocompleteElement &&\n\t\t\t\tautocompleteElement.contains( event.target )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetIsOpen( false );\n\t\t\tsetUrlInput( null );\n\t\t\tstopEditLink();\n\t\t};\n\t} );\n\n\tconst onSubmitLinkChange = useCallback( () => {\n\t\treturn ( event ) => {\n\t\t\tif ( urlInput ) {\n\t\t\t\t// It is possible the entered URL actually matches a named link destination.\n\t\t\t\t// This check will ensure our link destination is correct.\n\t\t\t\tconst selectedDestination =\n\t\t\t\t\tgetLinkDestinations().find(\n\t\t\t\t\t\t( destination ) => destination.url === urlInput\n\t\t\t\t\t)?.linkDestination || LINK_DESTINATION_CUSTOM;\n\n\t\t\t\tonChangeUrl( {\n\t\t\t\t\thref: urlInput,\n\t\t\t\t\tlinkDestination: selectedDestination,\n\t\t\t\t} );\n\t\t\t}\n\t\t\tstopEditLink();\n\t\t\tsetUrlInput( null );\n\t\t\tevent.preventDefault();\n\t\t};\n\t} );\n\n\tconst onLinkRemove = useCallback( () => {\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: LINK_DESTINATION_NONE,\n\t\t\thref: '',\n\t\t} );\n\t} );\n\n\tconst getLinkDestinations = () => {\n\t\tconst linkDestinations = [\n\t\t\t{\n\t\t\t\tlinkDestination: LINK_DESTINATION_MEDIA,\n\t\t\t\ttitle: __( 'Media File' ),\n\t\t\t\turl: mediaType === 'image' ? mediaUrl : undefined,\n\t\t\t\ticon,\n\t\t\t},\n\t\t];\n\t\tif ( mediaType === 'image' && mediaLink ) {\n\t\t\tlinkDestinations.push( {\n\t\t\t\tlinkDestination: LINK_DESTINATION_ATTACHMENT,\n\t\t\t\ttitle: __( 'Attachment Page' ),\n\t\t\t\turl: mediaType === 'image' ? mediaLink : undefined,\n\t\t\t\ticon: (\n\t\t\t\t\t<SVG viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t\t\t\t\t<Path d=\"M0 0h24v24H0V0z\" fill=\"none\" />\n\t\t\t\t\t\t<Path d=\"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zM6 20V4h7v5h5v11H6z\" />\n\t\t\t\t\t</SVG>\n\t\t\t\t),\n\t\t\t} );\n\t\t}\n\t\treturn linkDestinations;\n\t};\n\n\tconst onSetHref = ( value ) => {\n\t\tconst linkDestinations = getLinkDestinations();\n\t\tlet linkDestinationInput;\n\t\tif ( ! value ) {\n\t\t\tlinkDestinationInput = LINK_DESTINATION_NONE;\n\t\t} else {\n\t\t\tlinkDestinationInput = (\n\t\t\t\tfind( linkDestinations, ( destination ) => {\n\t\t\t\t\treturn destination.url === value;\n\t\t\t\t} ) || { linkDestination: LINK_DESTINATION_CUSTOM }\n\t\t\t).linkDestination;\n\t\t}\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: linkDestinationInput,\n\t\t\thref: value,\n\t\t} );\n\t};\n\n\tconst onSetNewTab = ( value ) => {\n\t\tconst updatedLinkTarget = getUpdatedLinkTargetSettings( value );\n\t\tonChangeUrl( updatedLinkTarget );\n\t};\n\n\tconst onSetLinkRel = ( value ) => {\n\t\tonChangeUrl( { rel: value } );\n\t};\n\n\tconst onSetLinkClass = ( value ) => {\n\t\tonChangeUrl( { linkClass: value } );\n\t};\n\n\tconst advancedOptions = (\n\t\t<>\n\t\t\t<ToggleControl\n\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\tonChange={ onSetNewTab }\n\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\tlabel={ __( 'Link Rel' ) }\n\t\t\t\tvalue={ rel ?? '' }\n\t\t\t\tonChange={ onSetLinkRel }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\tlabel={ __( 'Link CSS Class' ) }\n\t\t\t\tvalue={ linkClass || '' }\n\t\t\t\tonChange={ onSetLinkClass }\n\t\t\t/>\n\t\t</>\n\t);\n\n\tconst linkEditorValue = urlInput !== null ? urlInput : url;\n\n\tconst urlLabel = (\n\t\tfind( getLinkDestinations(), [ 'linkDestination', linkDestination ] ) ||\n\t\t{}\n\t).title;\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ linkIcon }\n\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\tlabel={ url ? __( 'Edit link' ) : __( 'Insert link' ) }\n\t\t\t\taria-expanded={ isOpen }\n\t\t\t\tonClick={ openLinkUI }\n\t\t\t\tref={ buttonRef }\n\t\t\t/>\n\t\t\t{ isOpen && (\n\t\t\t\t<URLPopover\n\t\t\t\t\tanchorRef={ buttonRef }\n\t\t\t\t\tonFocusOutside={ onFocusOutside() }\n\t\t\t\t\tonClose={ closeLinkUI }\n\t\t\t\t\trenderSettings={ () => advancedOptions }\n\t\t\t\t\tadditionalControls={\n\t\t\t\t\t\t! linkEditorValue && (\n\t\t\t\t\t\t\t<NavigableMenu>\n\t\t\t\t\t\t\t\t{ map( getLinkDestinations(), ( link ) => (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey={ link.linkDestination }\n\t\t\t\t\t\t\t\t\t\ticon={ link.icon }\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonSetHref( link.url );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ link.title }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ ( ! url || isEditingLink ) && (\n\t\t\t\t\t\t<URLPopover.LinkEditor\n\t\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\t\tvalue={ linkEditorValue }\n\t\t\t\t\t\t\tonChangeInputValue={ setUrlInput }\n\t\t\t\t\t\t\tonSubmit={ onSubmitLinkChange() }\n\t\t\t\t\t\t\tautocompleteRef={ autocompleteRef }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ url && ! isEditingLink && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<URLPopover.LinkViewer\n\t\t\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\t\tonEditLinkClick={ startEditLink }\n\t\t\t\t\t\t\t\turlLabel={ urlLabel }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\ticon={ close }\n\t\t\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\t\t\tonClick={ onLinkRemove }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</URLPopover>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport { ImageURLInputUI as __experimentalImageURLInputUI };\n"]}
|
|
@@ -47,7 +47,8 @@ function URLPopover(_ref) {
|
|
|
47
47
|
return (0, _element.createElement)(_components.Popover, (0, _extends2.default)({
|
|
48
48
|
className: "block-editor-url-popover",
|
|
49
49
|
focusOnMount: focusOnMount,
|
|
50
|
-
position: position
|
|
50
|
+
position: position,
|
|
51
|
+
__unstableShift: true
|
|
51
52
|
}, popoverProps), (0, _element.createElement)("div", {
|
|
52
53
|
className: "block-editor-url-popover__input-container"
|
|
53
54
|
}, (0, _element.createElement)("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/url-popover/index.js"],"names":["URLPopover","additionalControls","children","renderSettings","position","focusOnMount","popoverProps","isSettingsExpanded","setIsSettingsExpanded","showSettings","toggleSettingsVisibility","chevronDown","LinkEditor","LinkViewer"],"mappings":";;;;;;;;;AAIA;;;;AADA;;AAEA;;AACA;;AAKA;;AACA;;AAZA;AACA;AACA;;AAMA;AACA;AACA;AAIA,SAASA,UAAT,OAOI;AAAA,MAPiB;AACpBC,IAAAA,kBADoB;AAEpBC,IAAAA,QAFoB;AAGpBC,IAAAA,cAHoB;AAIpBC,IAAAA,QAAQ,GAAG,eAJS;AAKpBC,IAAAA,YAAY,GAAG,cALK;AAMpB,OAAGC;AANiB,GAOjB;AACH,QAAM,CAAEC,kBAAF,EAAsBC,qBAAtB,IAAgD,uBAAU,KAAV,CAAtD;AAEA,QAAMC,YAAY,GAAG,CAAC,CAAEN,cAAH,IAAqBI,kBAA1C;;AAEA,QAAMG,wBAAwB,GAAG,MAAM;AACtCF,IAAAA,qBAAqB,CAAE,CAAED,kBAAJ,CAArB;AACA,GAFD;;AAIA,SACC,4BAAC,mBAAD;AACC,IAAA,SAAS,EAAC,0BADX;AAEC,IAAA,YAAY,EAAGF,YAFhB;AAGC,IAAA,QAAQ,EAAGD;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/url-popover/index.js"],"names":["URLPopover","additionalControls","children","renderSettings","position","focusOnMount","popoverProps","isSettingsExpanded","setIsSettingsExpanded","showSettings","toggleSettingsVisibility","chevronDown","LinkEditor","LinkViewer"],"mappings":";;;;;;;;;AAIA;;;;AADA;;AAEA;;AACA;;AAKA;;AACA;;AAZA;AACA;AACA;;AAMA;AACA;AACA;AAIA,SAASA,UAAT,OAOI;AAAA,MAPiB;AACpBC,IAAAA,kBADoB;AAEpBC,IAAAA,QAFoB;AAGpBC,IAAAA,cAHoB;AAIpBC,IAAAA,QAAQ,GAAG,eAJS;AAKpBC,IAAAA,YAAY,GAAG,cALK;AAMpB,OAAGC;AANiB,GAOjB;AACH,QAAM,CAAEC,kBAAF,EAAsBC,qBAAtB,IAAgD,uBAAU,KAAV,CAAtD;AAEA,QAAMC,YAAY,GAAG,CAAC,CAAEN,cAAH,IAAqBI,kBAA1C;;AAEA,QAAMG,wBAAwB,GAAG,MAAM;AACtCF,IAAAA,qBAAqB,CAAE,CAAED,kBAAJ,CAArB;AACA,GAFD;;AAIA,SACC,4BAAC,mBAAD;AACC,IAAA,SAAS,EAAC,0BADX;AAEC,IAAA,YAAY,EAAGF,YAFhB;AAGC,IAAA,QAAQ,EAAGD,QAHZ;AAIC,IAAA,eAAe;AAJhB,KAKME,YALN,GAOC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGJ,QADH,EAEG,CAAC,CAAEC,cAAH,IACD,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,2CADX;AAEC,IAAA,IAAI,EAAGQ,kBAFR;AAGC,IAAA,KAAK,EAAG,cAAI,eAAJ,CAHT;AAIC,IAAA,OAAO,EAAGD,wBAJX;AAKC,qBAAgBH;AALjB,IAHF,CADD,EAaGE,YAAY,IACb;AAAK,IAAA,SAAS,EAAC;AAAf,KACGN,cAAc,EADjB,CAdF,CAPD,EA0BGF,kBAAkB,IAAI,CAAEQ,YAAxB,IACD;AAAK,IAAA,SAAS,EAAC;AAAf,KACGR,kBADH,CA3BF,CADD;AAkCA;;AAEDD,UAAU,CAACY,UAAX,GAAwBA,mBAAxB;AAEAZ,UAAU,CAACa,UAAX,GAAwBA,mBAAxB;AAEA;AACA;AACA;;eACeb,U","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { Button, Popover } from '@wordpress/components';\nimport { chevronDown } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport LinkViewer from './link-viewer';\nimport LinkEditor from './link-editor';\n\nfunction URLPopover( {\n\tadditionalControls,\n\tchildren,\n\trenderSettings,\n\tposition = 'bottom center',\n\tfocusOnMount = 'firstElement',\n\t...popoverProps\n} ) {\n\tconst [ isSettingsExpanded, setIsSettingsExpanded ] = useState( false );\n\n\tconst showSettings = !! renderSettings && isSettingsExpanded;\n\n\tconst toggleSettingsVisibility = () => {\n\t\tsetIsSettingsExpanded( ! isSettingsExpanded );\n\t};\n\n\treturn (\n\t\t<Popover\n\t\t\tclassName=\"block-editor-url-popover\"\n\t\t\tfocusOnMount={ focusOnMount }\n\t\t\tposition={ position }\n\t\t\t__unstableShift\n\t\t\t{ ...popoverProps }\n\t\t>\n\t\t\t<div className=\"block-editor-url-popover__input-container\">\n\t\t\t\t<div className=\"block-editor-url-popover__row\">\n\t\t\t\t\t{ children }\n\t\t\t\t\t{ !! renderSettings && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"block-editor-url-popover__settings-toggle\"\n\t\t\t\t\t\t\ticon={ chevronDown }\n\t\t\t\t\t\t\tlabel={ __( 'Link settings' ) }\n\t\t\t\t\t\t\tonClick={ toggleSettingsVisibility }\n\t\t\t\t\t\t\taria-expanded={ isSettingsExpanded }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t{ showSettings && (\n\t\t\t\t\t<div className=\"block-editor-url-popover__row block-editor-url-popover__settings\">\n\t\t\t\t\t\t{ renderSettings() }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t{ additionalControls && ! showSettings && (\n\t\t\t\t<div className=\"block-editor-url-popover__additional-controls\">\n\t\t\t\t\t{ additionalControls }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</Popover>\n\t);\n}\n\nURLPopover.LinkEditor = LinkEditor;\n\nURLPopover.LinkViewer = LinkViewer;\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-popover/README.md\n */\nexport default URLPopover;\n"]}
|
|
@@ -118,13 +118,15 @@ function getClosestTabbable(target, isReverse, containerElement, onlyVertical) {
|
|
|
118
118
|
|
|
119
119
|
function useArrowNav() {
|
|
120
120
|
const {
|
|
121
|
-
|
|
121
|
+
getMultiSelectedBlocksStartClientId,
|
|
122
122
|
getMultiSelectedBlocksEndClientId,
|
|
123
|
-
getPreviousBlockClientId,
|
|
124
|
-
getNextBlockClientId,
|
|
125
123
|
getSettings,
|
|
126
|
-
hasMultiSelection
|
|
124
|
+
hasMultiSelection,
|
|
125
|
+
__unstableIsFullySelected
|
|
127
126
|
} = (0, _data.useSelect)(_store.store);
|
|
127
|
+
const {
|
|
128
|
+
selectBlock
|
|
129
|
+
} = (0, _data.useDispatch)(_store.store);
|
|
128
130
|
return (0, _compose.useRefEffect)(node => {
|
|
129
131
|
// Here a DOMRect is stored while moving the caret vertically so
|
|
130
132
|
// vertical position of the start position can be restored. This is to
|
|
@@ -134,22 +136,10 @@ function useArrowNav() {
|
|
|
134
136
|
function onMouseDown() {
|
|
135
137
|
verticalRect = null;
|
|
136
138
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
* can be considered for tab transition. For example, in a block with
|
|
140
|
-
* two text fields, this would return true when reversing from the first
|
|
141
|
-
* of the two fields, but false when reversing from the second.
|
|
142
|
-
*
|
|
143
|
-
* @param {Element} target Currently focused text field.
|
|
144
|
-
* @param {boolean} isReverse True if considering as the first field.
|
|
145
|
-
*
|
|
146
|
-
* @return {boolean} Whether field is at edge for tab transition.
|
|
147
|
-
*/
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
function isTabbableEdge(target, isReverse) {
|
|
139
|
+
|
|
140
|
+
function isClosestTabbableABlock(target, isReverse) {
|
|
151
141
|
const closestTabbable = getClosestTabbable(target, isReverse, node);
|
|
152
|
-
return
|
|
142
|
+
return closestTabbable && (0, _dom2.getBlockClientId)(closestTabbable);
|
|
153
143
|
}
|
|
154
144
|
|
|
155
145
|
function onKeyDown(event) {
|
|
@@ -173,9 +163,36 @@ function useArrowNav() {
|
|
|
173
163
|
} = node;
|
|
174
164
|
const {
|
|
175
165
|
defaultView
|
|
176
|
-
} = ownerDocument;
|
|
166
|
+
} = ownerDocument; // If there is a multi-selection, the arrow keys should collapse the
|
|
167
|
+
// selection to the start or end of the selection.
|
|
177
168
|
|
|
178
169
|
if (hasMultiSelection()) {
|
|
170
|
+
// Only handle if we have a full selection (not a native partial
|
|
171
|
+
// selection).
|
|
172
|
+
if (!__unstableIsFullySelected()) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (event.defaultPrevented) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (!isNav) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (isShift) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
event.preventDefault();
|
|
189
|
+
|
|
190
|
+
if (isReverse) {
|
|
191
|
+
selectBlock(getMultiSelectedBlocksStartClientId());
|
|
192
|
+
} else {
|
|
193
|
+
selectBlock(getMultiSelectedBlocksEndClientId(), -1);
|
|
194
|
+
}
|
|
195
|
+
|
|
179
196
|
return;
|
|
180
197
|
} // When presing any key other than up or down, the initial vertical
|
|
181
198
|
// position must ALWAYS be reset. The vertical position is saved so
|
|
@@ -214,15 +231,9 @@ function useArrowNav() {
|
|
|
214
231
|
const {
|
|
215
232
|
keepCaretInsideBlock
|
|
216
233
|
} = getSettings();
|
|
217
|
-
const selectedBlockClientId = getSelectedBlockClientId();
|
|
218
234
|
|
|
219
235
|
if (isShift) {
|
|
220
|
-
|
|
221
|
-
const selectionBeforeEndClientId = getPreviousBlockClientId(selectionEndClientId || selectedBlockClientId);
|
|
222
|
-
const selectionAfterEndClientId = getNextBlockClientId(selectionEndClientId || selectedBlockClientId);
|
|
223
|
-
|
|
224
|
-
if ( // Ensure that there is a target block.
|
|
225
|
-
(isReverse && selectionBeforeEndClientId || !isReverse && selectionAfterEndClientId) && isTabbableEdge(target, isReverse) && isNavEdge(target, isReverse)) {
|
|
236
|
+
if (isClosestTabbableABlock(target, isReverse) && isNavEdge(target, isReverse)) {
|
|
226
237
|
node.contentEditable = true; // Firefox doesn't automatically move focus.
|
|
227
238
|
|
|
228
239
|
node.focus();
|