@wordpress/block-editor 8.2.0 → 8.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +6 -2
- package/build/autocompleters/link.js +78 -0
- package/build/autocompleters/link.js.map +1 -0
- package/build/components/autocomplete/index.js +3 -1
- package/build/components/autocomplete/index.js.map +1 -1
- package/build/components/block-actions/index.js +1 -1
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-breadcrumb/index.js +4 -2
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-compare/index.js +2 -2
- package/build/components/block-compare/index.js.map +1 -1
- package/build/components/block-controls/index.js +1 -1
- package/build/components/block-controls/index.js.map +1 -1
- package/build/components/block-draggable/index.js +1 -1
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-edit/edit.js +1 -1
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-list/block-html.js +1 -1
- package/build/components/block-list/block-html.js.map +1 -1
- package/build/components/block-list/block-invalid-warning.js +1 -1
- package/build/components/block-list/block-invalid-warning.js.map +1 -1
- package/build/components/block-list/block-list-item.native.js +4 -4
- package/build/components/block-list/block-list-item.native.js.map +1 -1
- package/build/components/block-list/block-selection-button.native.js +4 -3
- package/build/components/block-list/block-selection-button.native.js.map +1 -1
- package/build/components/block-list/block.js +1 -1
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +5 -5
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +5 -5
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-class-names.js +1 -1
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build/components/block-media-update-progress/index.native.js +4 -4
- package/build/components/block-media-update-progress/index.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +3 -3
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/index.native.js +1 -1
- package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build/components/block-mover/mover-description.js +4 -4
- package/build/components/block-mover/mover-description.js.map +1 -1
- package/build/components/block-mover/mover-description.native.js +5 -5
- package/build/components/block-mover/mover-description.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +7 -12
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/preview.native.js +1 -1
- package/build/components/block-styles/preview.native.js.map +1 -1
- package/build/components/block-switcher/index.js +2 -1
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/use-transformed-patterns.js +0 -1
- package/build/components/block-switcher/use-transformed-patterns.js.map +1 -1
- package/build/components/block-title/index.js +7 -62
- package/build/components/block-title/index.js.map +1 -1
- package/build/components/block-title/use-block-display-title.js +94 -0
- package/build/components/block-title/use-block-display-title.js.map +1 -0
- package/build/components/block-toolbar/utils.js +9 -1
- package/build/components/block-toolbar/utils.js.map +1 -1
- package/build/components/block-tools/block-popover.js +1 -1
- package/build/components/block-tools/block-popover.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +2 -1
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-types-list/index.native.js +1 -1
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/border-radius-control/index.js +2 -2
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/utils.js +10 -6
- package/build/components/border-radius-control/utils.js.map +1 -1
- package/build/components/contrast-checker/index.js +3 -3
- package/build/components/contrast-checker/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/index.js +1 -1
- package/build/components/convert-to-group-buttons/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +1 -3
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build/components/copy-handler/index.js +3 -3
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +3 -3
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/index.native.js +29 -1
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +1 -1
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +1 -1
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-block-type-impressions.native.js +2 -2
- package/build/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build/components/inserter/index.js +3 -3
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +7 -7
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/menu.native.js +3 -3
- package/build/components/inserter/menu.native.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +1 -1
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-items.js +1 -1
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inserter/search-results.js +1 -1
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -1
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +3 -3
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/line-height-control/index.js +4 -4
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/line-height-control/index.native.js +3 -1
- package/build/components/line-height-control/index.native.js.map +1 -1
- package/build/components/link-control/index.js +2 -2
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/search-results.js +2 -2
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/link-control/use-rich-url-data.js +1 -1
- package/build/components/link-control/use-rich-url-data.js.map +1 -1
- package/build/components/link-control/use-search-handler.js +2 -2
- package/build/components/link-control/use-search-handler.js.map +1 -1
- package/build/components/list-view/block-select-button.js +2 -1
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +1 -1
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/media-placeholder/index.native.js +7 -5
- package/build/components/media-placeholder/index.native.js.map +1 -1
- package/build/components/media-replace-flow/index.js +20 -24
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/media-upload/index.native.js +4 -3
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/media-upload-progress/index.native.js +2 -2
- package/build/components/media-upload-progress/index.native.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +3 -3
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/plain-text/index.native.js +3 -3
- package/build/components/plain-text/index.native.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +2 -2
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.native.js +1 -1
- package/build/components/rich-text/format-toolbar-container.native.js.map +1 -1
- package/build/components/rich-text/index.native.js +3 -3
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +7 -11
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/url-input/index.js +11 -11
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-moving-animation/index.js +1 -1
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +2 -2
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +4 -3
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/align.js +1 -1
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/anchor.js +1 -1
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/border.js +2 -14
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +2 -2
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/duotone.js +22 -4
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/generated-class-name.js +3 -3
- package/build/hooks/generated-class-name.js.map +1 -1
- package/build/hooks/lock.js +1 -1
- package/build/hooks/lock.js.map +1 -1
- package/build/hooks/style.js +5 -2
- package/build/hooks/style.js.map +1 -1
- package/build/store/actions.js +4 -4
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +1 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +11 -11
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +6 -6
- package/build/store/selectors.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +3 -3
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build/utils/pasting.js +91 -0
- package/build/utils/pasting.js.map +1 -0
- package/build/utils/transform-styles/ast/parse.js +5 -5
- package/build/utils/transform-styles/ast/parse.js.map +1 -1
- package/build/utils/transform-styles/transforms/url-rewrite.js +2 -2
- package/build/utils/transform-styles/transforms/url-rewrite.js.map +1 -1
- package/build-module/autocompleters/link.js +64 -0
- package/build-module/autocompleters/link.js.map +1 -0
- package/build-module/components/autocomplete/index.js +2 -1
- package/build-module/components/autocomplete/index.js.map +1 -1
- package/build-module/components/block-actions/index.js +1 -1
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js +4 -2
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-compare/index.js +2 -2
- package/build-module/components/block-compare/index.js.map +1 -1
- package/build-module/components/block-controls/index.js +1 -1
- package/build-module/components/block-controls/index.js.map +1 -1
- package/build-module/components/block-draggable/index.js +1 -1
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-edit/edit.js +1 -1
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-list/block-html.js +1 -1
- package/build-module/components/block-list/block-html.js.map +1 -1
- package/build-module/components/block-list/block-invalid-warning.js +1 -1
- package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
- package/build-module/components/block-list/block-list-item.native.js +4 -4
- package/build-module/components/block-list/block-list-item.native.js.map +1 -1
- package/build-module/components/block-list/block-selection-button.native.js +4 -3
- package/build-module/components/block-list/block-selection-button.native.js.map +1 -1
- package/build-module/components/block-list/block.js +1 -1
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +5 -5
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +5 -5
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +1 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build-module/components/block-media-update-progress/index.native.js +4 -4
- package/build-module/components/block-media-update-progress/index.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +3 -3
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-mover/mover-description.js +4 -4
- package/build-module/components/block-mover/mover-description.js.map +1 -1
- package/build-module/components/block-mover/mover-description.native.js +5 -5
- package/build-module/components/block-mover/mover-description.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +7 -13
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/preview.native.js +1 -1
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/block-switcher/index.js +2 -1
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/use-transformed-patterns.js +0 -1
- package/build-module/components/block-switcher/use-transformed-patterns.js.map +1 -1
- package/build-module/components/block-title/index.js +7 -58
- package/build-module/components/block-title/index.js.map +1 -1
- package/build-module/components/block-title/use-block-display-title.js +80 -0
- package/build-module/components/block-title/use-block-display-title.js.map +1 -0
- package/build-module/components/block-toolbar/utils.js +9 -1
- package/build-module/components/block-toolbar/utils.js.map +1 -1
- package/build-module/components/block-tools/block-popover.js +1 -1
- package/build-module/components/block-tools/block-popover.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +2 -1
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +1 -1
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +3 -3
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/utils.js +11 -7
- package/build-module/components/border-radius-control/utils.js.map +1 -1
- package/build-module/components/contrast-checker/index.js +3 -3
- package/build-module/components/contrast-checker/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/index.js +1 -1
- package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +1 -3
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build-module/components/copy-handler/index.js +2 -2
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +3 -3
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/index.native.js +4 -4
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +1 -1
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +1 -1
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js +2 -2
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build-module/components/inserter/index.js +3 -3
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +7 -7
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/menu.native.js +3 -3
- package/build-module/components/inserter/menu.native.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +1 -1
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-items.js +1 -1
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter/search-results.js +1 -1
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -1
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +3 -3
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/line-height-control/index.js +4 -4
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/line-height-control/index.native.js +3 -1
- package/build-module/components/line-height-control/index.native.js.map +1 -1
- package/build-module/components/link-control/index.js +2 -2
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/search-results.js +2 -2
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/link-control/use-rich-url-data.js +1 -1
- package/build-module/components/link-control/use-rich-url-data.js.map +1 -1
- package/build-module/components/link-control/use-search-handler.js +2 -2
- package/build-module/components/link-control/use-search-handler.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +2 -1
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +1 -1
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/media-placeholder/index.native.js +7 -5
- package/build-module/components/media-placeholder/index.native.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +22 -27
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +4 -3
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/media-upload-progress/index.native.js +2 -2
- package/build-module/components/media-upload-progress/index.native.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +3 -3
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/plain-text/index.native.js +3 -3
- package/build-module/components/plain-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +2 -2
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.native.js +1 -1
- package/build-module/components/rich-text/format-toolbar-container.native.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +3 -3
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +6 -11
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/url-input/index.js +11 -11
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +1 -1
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +2 -2
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +4 -3
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/align.js +1 -1
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/anchor.js +1 -1
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/border.js +2 -14
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +2 -2
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/duotone.js +23 -5
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/generated-class-name.js +3 -3
- package/build-module/hooks/generated-class-name.js.map +1 -1
- package/build-module/hooks/lock.js +1 -1
- package/build-module/hooks/lock.js.map +1 -1
- package/build-module/hooks/style.js +5 -2
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/store/actions.js +4 -4
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +1 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +11 -11
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +6 -6
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +3 -3
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/utils/pasting.js +80 -0
- package/build-module/utils/pasting.js.map +1 -0
- package/build-module/utils/transform-styles/ast/parse.js +5 -5
- package/build-module/utils/transform-styles/ast/parse.js.map +1 -1
- package/build-module/utils/transform-styles/transforms/url-rewrite.js +2 -2
- package/build-module/utils/transform-styles/transforms/url-rewrite.js.map +1 -1
- package/build-style/style-rtl.css +7 -0
- package/build-style/style.css +7 -0
- package/package.json +27 -27
- package/src/autocompleters/link.js +62 -0
- package/src/autocompleters/style.scss +8 -0
- package/src/components/alignment-control/test/index.js +2 -2
- package/src/components/autocomplete/index.js +2 -0
- package/src/components/block-actions/index.js +1 -1
- package/src/components/block-alignment-control/test/index.js +1 -1
- package/src/components/block-breadcrumb/index.js +5 -2
- package/src/components/block-compare/index.js +2 -2
- package/src/components/block-controls/index.js +1 -1
- package/src/components/block-draggable/index.js +1 -1
- package/src/components/block-draggable/stories/index.js +1 -1
- package/src/components/block-edit/edit.js +1 -1
- package/src/components/block-list/block-html.js +1 -1
- package/src/components/block-list/block-invalid-warning.js +1 -1
- package/src/components/block-list/block-list-item.native.js +4 -4
- package/src/components/block-list/block-selection-button.native.js +3 -3
- package/src/components/block-list/block.js +1 -1
- package/src/components/block-list/block.native.js +5 -5
- package/src/components/block-list/index.native.js +5 -5
- package/src/components/block-list/use-block-props/use-block-class-names.js +1 -1
- package/src/components/block-media-update-progress/index.native.js +4 -4
- package/src/components/block-media-update-progress/test/index.native.js +2 -2
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +3 -3
- package/src/components/block-mobile-toolbar/index.native.js +2 -2
- package/src/components/block-mover/mover-description.js +4 -4
- package/src/components/block-mover/mover-description.native.js +5 -5
- package/src/components/block-settings-menu/block-settings-dropdown.js +7 -8
- package/src/components/block-styles/preview.native.js +1 -1
- package/src/components/block-switcher/index.js +4 -1
- package/src/components/block-switcher/use-transformed-patterns.js +0 -1
- package/src/components/block-title/README.md +17 -1
- package/src/components/block-title/index.js +7 -62
- package/src/components/block-title/test/index.js +21 -3
- package/src/components/block-title/use-block-display-title.js +83 -0
- package/src/components/block-toolbar/utils.js +12 -2
- package/src/components/block-tools/block-popover.js +1 -1
- package/src/components/block-tools/block-selection-button.js +4 -1
- package/src/components/block-types-list/index.native.js +1 -1
- package/src/components/border-radius-control/index.js +5 -3
- package/src/components/border-radius-control/test/utils.js +10 -10
- package/src/components/border-radius-control/utils.js +10 -8
- package/src/components/contrast-checker/index.js +3 -3
- package/src/components/convert-to-group-buttons/index.js +1 -1
- package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +1 -6
- package/src/components/copy-handler/index.js +2 -2
- package/src/components/font-sizes/with-font-sizes.js +3 -3
- package/src/components/image-size-control/test/index.js +1 -1
- package/src/components/index.native.js +10 -4
- package/src/components/inserter/block-patterns-tab.js +1 -1
- package/src/components/inserter/block-types-tab.js +1 -1
- package/src/components/inserter/hooks/use-block-type-impressions.native.js +2 -2
- package/src/components/inserter/index.js +3 -3
- package/src/components/inserter/index.native.js +7 -7
- package/src/components/inserter/menu.js +1 -1
- package/src/components/inserter/menu.native.js +3 -3
- package/src/components/inserter/quick-inserter.js +1 -1
- package/src/components/inserter/search-items.js +1 -1
- package/src/components/inserter/search-results.js +1 -1
- package/src/components/inserter/test/fixtures/index.native.js +1 -1
- package/src/components/inserter/test/reusable-blocks-tab.js +2 -2
- package/src/components/justify-content-control/README.md +1 -1
- package/src/components/keyboard-shortcuts/index.js +1 -1
- package/src/components/letter-spacing-control/index.js +1 -1
- package/src/components/line-height-control/index.js +4 -4
- package/src/components/line-height-control/index.native.js +2 -0
- package/src/components/link-control/index.js +2 -2
- package/src/components/link-control/search-input.js +1 -1
- package/src/components/link-control/search-results.js +2 -2
- package/src/components/link-control/test/index.js +142 -144
- package/src/components/link-control/use-rich-url-data.js +1 -1
- package/src/components/link-control/use-search-handler.js +2 -2
- package/src/components/list-view/block-select-button.js +1 -1
- package/src/components/list-view/block.js +1 -1
- package/src/components/media-placeholder/index.native.js +11 -9
- package/src/components/media-replace-flow/README.md +7 -0
- package/src/components/media-replace-flow/index.js +20 -26
- package/src/components/media-replace-flow/test/index.js +100 -0
- package/src/components/media-upload/index.native.js +3 -2
- package/src/components/media-upload-progress/index.native.js +2 -2
- package/src/components/navigable-toolbar/index.js +3 -3
- package/src/components/plain-text/index.native.js +3 -3
- package/src/components/responsive-block-control/test/index.js +6 -6
- package/src/components/rich-text/format-toolbar-container.js +2 -2
- package/src/components/rich-text/format-toolbar-container.native.js +1 -1
- package/src/components/rich-text/index.native.js +3 -3
- package/src/components/rich-text/use-paste-handler.js +7 -13
- package/src/components/url-input/index.js +11 -11
- package/src/components/use-block-drop-zone/test/index.js +1 -1
- package/src/components/use-moving-animation/index.js +1 -1
- package/src/components/use-on-block-drop/index.js +2 -2
- package/src/components/writing-flow/use-tab-nav.js +6 -3
- package/src/hooks/align.js +1 -1
- package/src/hooks/anchor.js +1 -1
- package/src/hooks/border.js +8 -19
- package/src/hooks/color.js +2 -2
- package/src/hooks/duotone.js +27 -3
- package/src/hooks/generated-class-name.js +3 -3
- package/src/hooks/lock.js +1 -1
- package/src/hooks/style.js +5 -2
- package/src/hooks/test/align.js +1 -1
- package/src/store/actions.js +4 -4
- package/src/store/defaults.js +1 -2
- package/src/store/reducer.js +11 -11
- package/src/store/selectors.js +6 -6
- package/src/store/test/actions.js +1 -1
- package/src/store/test/reducer.js +1 -1
- package/src/store/test/selectors.js +1 -1
- package/src/utils/parse-css-unit-to-px.js +3 -3
- package/src/utils/pasting.js +77 -0
- package/src/utils/test/parse-css-unit-to-px.js +5 -5
- package/src/utils/test/pasting.js +84 -0
- package/src/utils/transform-styles/ast/parse.js +5 -5
- package/src/utils/transform-styles/transforms/url-rewrite.js +2 -2
- package/build/utils/get-paste-event-data.js +0 -56
- package/build/utils/get-paste-event-data.js.map +0 -1
- package/build-module/utils/get-paste-event-data.js +0 -47
- package/build-module/utils/get-paste-event-data.js.map +0 -1
- package/src/utils/get-paste-event-data.js +0 -42
|
@@ -79,7 +79,7 @@ export function getValidAlignments(blockAlign) {
|
|
|
79
79
|
*/
|
|
80
80
|
|
|
81
81
|
export function addAttribute(settings) {
|
|
82
|
-
//
|
|
82
|
+
// Allow blocks to specify their own attribute definition with default values if needed.
|
|
83
83
|
if (has(settings.attributes, ['align', 'type'])) {
|
|
84
84
|
return settings;
|
|
85
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/align.js"],"names":["classnames","has","without","createHigherOrderComponent","addFilter","getBlockSupport","getBlockType","hasBlockSupport","BlockControls","BlockAlignmentControl","useAvailableAlignments","ALL_ALIGNMENTS","WIDE_ALIGNMENTS","getValidAlignments","blockAlign","hasWideBlockSupport","hasWideEnabled","validAlignments","Array","isArray","filter","value","includes","addAttribute","settings","attributes","align","type","enum","withToolbarControls","BlockEdit","props","name","blockName","blockAllowedAlignments","map","updateAlignment","nextAlign","blockType","blockDefaultAlign","default","setAttributes","length","withDataAlign","BlockListBlock","undefined","wrapperProps","some","alignment","addAssignedAlign","isAlignValid","className"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,GAAT,EAAcC,OAAd,QAA6B,QAA7B;AAEA;AACA;AACA;;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SACCC,eADD,EAECC,YAFD,EAGCC,eAHD,QAIO,mBAJP;AAMA;AACA;AACA;;AACA,SAASC,aAAT,EAAwBC,qBAAxB,QAAqD,eAArD;AACA,OAAOC,sBAAP,MAAmC,gEAAnC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,cAAc,GAAG,CAAE,MAAF,EAAU,QAAV,EAAoB,OAApB,EAA6B,MAA7B,EAAqC,MAArC,CAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,eAAe,GAAG,CAAE,MAAF,EAAU,MAAV,CAAxB;AAEA;AACA;AACA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Aa,WAAb,EAA0B,IAA1B,CAA3C,CAHgE,CAKhE;AACA;AACA;;AACA,QAAMY,YAAY,GAAGrC,kBAAkB,CACtCC,UADsC,EAEtCC,mBAFsC,CAAlB,CAGnBO,QAHmB,CAGTI,KAHS,CAArB;;AAIA,MAAKwB,YAAL,EAAoB;AACnBnB,IAAAA,KAAK,CAACoB,SAAN,GAAkBnD,UAAU,CAAG,QAAQ0B,KAAO,EAAlB,EAAqBK,KAAK,CAACoB,SAA3B,CAA5B;AACA;;AAED,SAAOpB,KAAP;AACA;AAED3B,SAAS,CACR,0BADQ,EAER,yBAFQ,EAGRmB,YAHQ,CAAT;AAKAnB,SAAS,CACR,uBADQ,EAER,mCAFQ,EAGRuC,aAHQ,CAAT;AAKAvC,SAAS,CACR,kBADQ,EAER,yCAFQ,EAGRyB,mBAHQ,CAAT;AAKAzB,SAAS,CACR,kCADQ,EAER,6BAFQ,EAGR6C,gBAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { has, without } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport {\n\tgetBlockSupport,\n\tgetBlockType,\n\thasBlockSupport,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { BlockControls, BlockAlignmentControl } from '../components';\nimport useAvailableAlignments from '../components/block-alignment-control/use-available-alignments';\n\n/**\n * An array which includes all possible valid alignments,\n * used to validate if an alignment is valid or not.\n *\n * @constant\n * @type {string[]}\n */\nconst ALL_ALIGNMENTS = [ 'left', 'center', 'right', 'wide', 'full' ];\n\n/**\n * An array which includes all wide alignments.\n * In order for this alignments to be valid they need to be supported by the block,\n * and by the theme.\n *\n * @constant\n * @type {string[]}\n */\nconst WIDE_ALIGNMENTS = [ 'wide', 'full' ];\n\n/**\n * Returns the valid alignments.\n * Takes into consideration the aligns supported by a block, if the block supports wide controls or not and if theme supports wide controls or not.\n * Exported just for testing purposes, not exported outside the module.\n *\n * @param {?boolean|string[]} blockAlign Aligns supported by the block.\n * @param {?boolean} hasWideBlockSupport True if block supports wide alignments. And False otherwise.\n * @param {?boolean} hasWideEnabled True if theme supports wide alignments. And False otherwise.\n *\n * @return {string[]} Valid alignments.\n */\nexport function getValidAlignments(\n\tblockAlign,\n\thasWideBlockSupport = true,\n\thasWideEnabled = true\n) {\n\tlet validAlignments;\n\tif ( Array.isArray( blockAlign ) ) {\n\t\tvalidAlignments = ALL_ALIGNMENTS.filter( ( value ) =>\n\t\t\tblockAlign.includes( value )\n\t\t);\n\t} else if ( blockAlign === true ) {\n\t\t// `true` includes all alignments...\n\t\tvalidAlignments = [ ...ALL_ALIGNMENTS ];\n\t} else {\n\t\tvalidAlignments = [];\n\t}\n\n\tif (\n\t\t! hasWideEnabled ||\n\t\t( blockAlign === true && ! hasWideBlockSupport )\n\t) {\n\t\treturn without( validAlignments, ...WIDE_ALIGNMENTS );\n\t}\n\n\treturn validAlignments;\n}\n\n/**\n * Filters registered block settings, extending attributes to include `align`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// allow blocks to specify their own attribute definition with default values if needed.\n\tif ( has( settings.attributes, [ 'align', 'type' ] ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'align' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\talign: {\n\t\t\t\ttype: 'string',\n\t\t\t\t// Allow for '' since it is used by updateAlignment function\n\t\t\t\t// in withToolbarControls for special cases with defined default values.\n\t\t\t\tenum: [ ...ALL_ALIGNMENTS, '' ],\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include new toolbar controls for block\n * alignment, if block defines support.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withToolbarControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name: blockName } = props;\n\t\t// Compute the block valid alignments by taking into account,\n\t\t// if the theme supports wide alignments or not and the layout's\n\t\t// availble alignments. We do that for conditionally rendering\n\t\t// Slot.\n\t\tconst blockAllowedAlignments = getValidAlignments(\n\t\t\tgetBlockSupport( blockName, 'align' ),\n\t\t\thasBlockSupport( blockName, 'alignWide', true )\n\t\t);\n\n\t\tconst validAlignments = useAvailableAlignments(\n\t\t\tblockAllowedAlignments\n\t\t).map( ( { name } ) => name );\n\n\t\tconst updateAlignment = ( nextAlign ) => {\n\t\t\tif ( ! nextAlign ) {\n\t\t\t\tconst blockType = getBlockType( props.name );\n\t\t\t\tconst blockDefaultAlign = blockType?.attributes?.align?.default;\n\t\t\t\tif ( blockDefaultAlign ) {\n\t\t\t\t\tnextAlign = '';\n\t\t\t\t}\n\t\t\t}\n\t\t\tprops.setAttributes( { align: nextAlign } );\n\t\t};\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ !! validAlignments.length && (\n\t\t\t\t\t<BlockControls\n\t\t\t\t\t\tgroup=\"block\"\n\t\t\t\t\t\t__experimentalShareWithChildBlocks\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockAlignmentControl\n\t\t\t\t\t\t\tvalue={ props.attributes.align }\n\t\t\t\t\t\t\tonChange={ updateAlignment }\n\t\t\t\t\t\t\tcontrols={ validAlignments }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t) }\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withToolbarControls'\n);\n\n/**\n * Override the default block element to add alignment wrapper props.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withDataAlign = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { align } = attributes;\n\t\tconst blockAllowedAlignments = getValidAlignments(\n\t\t\tgetBlockSupport( name, 'align' ),\n\t\t\thasBlockSupport( name, 'alignWide', true )\n\t\t);\n\t\tconst validAlignments = useAvailableAlignments(\n\t\t\tblockAllowedAlignments\n\t\t);\n\n\t\t// If an alignment is not assigned, there's no need to go through the\n\t\t// effort to validate or assign its value.\n\t\tif ( align === undefined ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\tif (\n\t\t\tvalidAlignments.some( ( alignment ) => alignment.name === align )\n\t\t) {\n\t\t\twrapperProps = { ...wrapperProps, 'data-align': align };\n\t\t}\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\n/**\n * Override props assigned to save component to inject alignment class name if\n * block supports it.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addAssignedAlign( props, blockType, attributes ) {\n\tconst { align } = attributes;\n\tconst blockAlign = getBlockSupport( blockType, 'align' );\n\tconst hasWideBlockSupport = hasBlockSupport( blockType, 'alignWide', true );\n\n\t// Compute valid alignments without taking into account if\n\t// the theme supports wide alignments or not.\n\t// This way changing themes does not impact the block save.\n\tconst isAlignValid = getValidAlignments(\n\t\tblockAlign,\n\t\thasWideBlockSupport\n\t).includes( align );\n\tif ( isAlignValid ) {\n\t\tprops.className = classnames( `align${ align }`, props.className );\n\t}\n\n\treturn props;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/align/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/align/with-data-align',\n\twithDataAlign\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/align/with-toolbar-controls',\n\twithToolbarControls\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/align/addAssignedAlign',\n\taddAssignedAlign\n);\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/align.js"],"names":["classnames","has","without","createHigherOrderComponent","addFilter","getBlockSupport","getBlockType","hasBlockSupport","BlockControls","BlockAlignmentControl","useAvailableAlignments","ALL_ALIGNMENTS","WIDE_ALIGNMENTS","getValidAlignments","blockAlign","hasWideBlockSupport","hasWideEnabled","validAlignments","Array","isArray","filter","value","includes","addAttribute","settings","attributes","align","type","enum","withToolbarControls","BlockEdit","props","name","blockName","blockAllowedAlignments","map","updateAlignment","nextAlign","blockType","blockDefaultAlign","default","setAttributes","length","withDataAlign","BlockListBlock","undefined","wrapperProps","some","alignment","addAssignedAlign","isAlignValid","className"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,GAAT,EAAcC,OAAd,QAA6B,QAA7B;AAEA;AACA;AACA;;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SACCC,eADD,EAECC,YAFD,EAGCC,eAHD,QAIO,mBAJP;AAMA;AACA;AACA;;AACA,SAASC,aAAT,EAAwBC,qBAAxB,QAAqD,eAArD;AACA,OAAOC,sBAAP,MAAmC,gEAAnC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,cAAc,GAAG,CAAE,MAAF,EAAU,QAAV,EAAoB,OAApB,EAA6B,MAA7B,EAAqC,MAArC,CAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,eAAe,GAAG,CAAE,MAAF,EAAU,MAAV,CAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,kBAAT,CACNC,UADM,EAIL;AAAA,MAFDC,mBAEC,uEAFqB,IAErB;AAAA,MADDC,cACC,uEADgB,IAChB;AACD,MAAIC,eAAJ;;AACA,MAAKC,KAAK,CAACC,OAAN,CAAeL,UAAf,CAAL,EAAmC;AAClCG,IAAAA,eAAe,GAAGN,cAAc,CAACS,MAAf,C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,EAAqBK,KAAK,CAACoB,SAA3B,CAA5B;AACA;;AAED,SAAOpB,KAAP;AACA;AAED3B,SAAS,CACR,0BADQ,EAER,yBAFQ,EAGRmB,YAHQ,CAAT;AAKAnB,SAAS,CACR,uBADQ,EAER,mCAFQ,EAGRuC,aAHQ,CAAT;AAKAvC,SAAS,CACR,kBADQ,EAER,yCAFQ,EAGRyB,mBAHQ,CAAT;AAKAzB,SAAS,CACR,kCADQ,EAER,6BAFQ,EAGR6C,gBAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { has, without } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport {\n\tgetBlockSupport,\n\tgetBlockType,\n\thasBlockSupport,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { BlockControls, BlockAlignmentControl } from '../components';\nimport useAvailableAlignments from '../components/block-alignment-control/use-available-alignments';\n\n/**\n * An array which includes all possible valid alignments,\n * used to validate if an alignment is valid or not.\n *\n * @constant\n * @type {string[]}\n */\nconst ALL_ALIGNMENTS = [ 'left', 'center', 'right', 'wide', 'full' ];\n\n/**\n * An array which includes all wide alignments.\n * In order for this alignments to be valid they need to be supported by the block,\n * and by the theme.\n *\n * @constant\n * @type {string[]}\n */\nconst WIDE_ALIGNMENTS = [ 'wide', 'full' ];\n\n/**\n * Returns the valid alignments.\n * Takes into consideration the aligns supported by a block, if the block supports wide controls or not and if theme supports wide controls or not.\n * Exported just for testing purposes, not exported outside the module.\n *\n * @param {?boolean|string[]} blockAlign Aligns supported by the block.\n * @param {?boolean} hasWideBlockSupport True if block supports wide alignments. And False otherwise.\n * @param {?boolean} hasWideEnabled True if theme supports wide alignments. And False otherwise.\n *\n * @return {string[]} Valid alignments.\n */\nexport function getValidAlignments(\n\tblockAlign,\n\thasWideBlockSupport = true,\n\thasWideEnabled = true\n) {\n\tlet validAlignments;\n\tif ( Array.isArray( blockAlign ) ) {\n\t\tvalidAlignments = ALL_ALIGNMENTS.filter( ( value ) =>\n\t\t\tblockAlign.includes( value )\n\t\t);\n\t} else if ( blockAlign === true ) {\n\t\t// `true` includes all alignments...\n\t\tvalidAlignments = [ ...ALL_ALIGNMENTS ];\n\t} else {\n\t\tvalidAlignments = [];\n\t}\n\n\tif (\n\t\t! hasWideEnabled ||\n\t\t( blockAlign === true && ! hasWideBlockSupport )\n\t) {\n\t\treturn without( validAlignments, ...WIDE_ALIGNMENTS );\n\t}\n\n\treturn validAlignments;\n}\n\n/**\n * Filters registered block settings, extending attributes to include `align`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( has( settings.attributes, [ 'align', 'type' ] ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'align' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\talign: {\n\t\t\t\ttype: 'string',\n\t\t\t\t// Allow for '' since it is used by updateAlignment function\n\t\t\t\t// in withToolbarControls for special cases with defined default values.\n\t\t\t\tenum: [ ...ALL_ALIGNMENTS, '' ],\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include new toolbar controls for block\n * alignment, if block defines support.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withToolbarControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name: blockName } = props;\n\t\t// Compute the block valid alignments by taking into account,\n\t\t// if the theme supports wide alignments or not and the layout's\n\t\t// availble alignments. We do that for conditionally rendering\n\t\t// Slot.\n\t\tconst blockAllowedAlignments = getValidAlignments(\n\t\t\tgetBlockSupport( blockName, 'align' ),\n\t\t\thasBlockSupport( blockName, 'alignWide', true )\n\t\t);\n\n\t\tconst validAlignments = useAvailableAlignments(\n\t\t\tblockAllowedAlignments\n\t\t).map( ( { name } ) => name );\n\n\t\tconst updateAlignment = ( nextAlign ) => {\n\t\t\tif ( ! nextAlign ) {\n\t\t\t\tconst blockType = getBlockType( props.name );\n\t\t\t\tconst blockDefaultAlign = blockType?.attributes?.align?.default;\n\t\t\t\tif ( blockDefaultAlign ) {\n\t\t\t\t\tnextAlign = '';\n\t\t\t\t}\n\t\t\t}\n\t\t\tprops.setAttributes( { align: nextAlign } );\n\t\t};\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ !! validAlignments.length && (\n\t\t\t\t\t<BlockControls\n\t\t\t\t\t\tgroup=\"block\"\n\t\t\t\t\t\t__experimentalShareWithChildBlocks\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockAlignmentControl\n\t\t\t\t\t\t\tvalue={ props.attributes.align }\n\t\t\t\t\t\t\tonChange={ updateAlignment }\n\t\t\t\t\t\t\tcontrols={ validAlignments }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t) }\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withToolbarControls'\n);\n\n/**\n * Override the default block element to add alignment wrapper props.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withDataAlign = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { align } = attributes;\n\t\tconst blockAllowedAlignments = getValidAlignments(\n\t\t\tgetBlockSupport( name, 'align' ),\n\t\t\thasBlockSupport( name, 'alignWide', true )\n\t\t);\n\t\tconst validAlignments = useAvailableAlignments(\n\t\t\tblockAllowedAlignments\n\t\t);\n\n\t\t// If an alignment is not assigned, there's no need to go through the\n\t\t// effort to validate or assign its value.\n\t\tif ( align === undefined ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\tif (\n\t\t\tvalidAlignments.some( ( alignment ) => alignment.name === align )\n\t\t) {\n\t\t\twrapperProps = { ...wrapperProps, 'data-align': align };\n\t\t}\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\n/**\n * Override props assigned to save component to inject alignment class name if\n * block supports it.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addAssignedAlign( props, blockType, attributes ) {\n\tconst { align } = attributes;\n\tconst blockAlign = getBlockSupport( blockType, 'align' );\n\tconst hasWideBlockSupport = hasBlockSupport( blockType, 'alignWide', true );\n\n\t// Compute valid alignments without taking into account if\n\t// the theme supports wide alignments or not.\n\t// This way changing themes does not impact the block save.\n\tconst isAlignValid = getValidAlignments(\n\t\tblockAlign,\n\t\thasWideBlockSupport\n\t).includes( align );\n\tif ( isAlignValid ) {\n\t\tprops.className = classnames( `align${ align }`, props.className );\n\t}\n\n\treturn props;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/align/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/align/with-data-align',\n\twithDataAlign\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/align/with-toolbar-controls',\n\twithToolbarControls\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/align/addAssignedAlign',\n\taddAssignedAlign\n);\n"]}
|
|
@@ -36,7 +36,7 @@ const ANCHOR_REGEX = /[\s#]/g;
|
|
|
36
36
|
*/
|
|
37
37
|
|
|
38
38
|
export function addAttribute(settings) {
|
|
39
|
-
//
|
|
39
|
+
// Allow blocks to specify their own attribute definition with default values if needed.
|
|
40
40
|
if (has(settings.attributes, ['anchor', 'type'])) {
|
|
41
41
|
return settings;
|
|
42
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"names":["has","addFilter","PanelBody","TextControl","ExternalLink","__","hasBlockSupport","createHigherOrderComponent","Platform","InspectorControls","ANCHOR_REGEX","addAttribute","settings","attributes","anchor","type","source","attribute","selector","withInspectorControl","BlockEdit","props","hasAnchor","name","isSelected","isWeb","OS","textControl","nextValue","replace","setAttributes","addSaveProps","extraProps","blockType","id"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,SAAT,EAAoBC,WAApB,EAAiCC,YAAjC,QAAqD,uBAArD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,SAASC,iBAAT,QAAkC,eAAlC;AAEA;AACA;AACA;AACA;AACA;;AACA,MAAMC,YAAY,GAAG,QAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,YAAT,CAAuBC,QAAvB,EAAkC;AACxC;AACA,MAAKZ,GAAG,CAAEY,QAAQ,CAACC,UAAX,EAAuB,CAAE,QAAF,EAAY,MAAZ,CAAvB,CAAR,EAAwD;AACvD,WAAOD,QAAP;AACA;;AACD,MAAKN,eAAe,CAAEM,QAAF,EAAY,QAAZ,CAApB,EAA6C;AAC5C;AACAA,IAAAA,QAAQ,CAACC,UAAT,GAAsB,EACrB,GAAGD,QAAQ,CAACC,UADS;AAErBC,MAAAA,MAAM,EAAE;AACPC,QAAAA,IAAI,EAAE,QADC;AAEPC,QAAAA,MAAM,EAAE,WAFD;AAGPC,QAAAA,SAAS,EAAE,IAHJ;AAIPC,QAAAA,QAAQ,EAAE;AAJH;AAFa,KAAtB;AASA;;AAED,SAAON,QAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMO,o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;AAAW,QAAA,KAAK,EAAGlB,EAAE,CAAE,kBAAF;AAArB,SACGsB,WADH,CADD,CAdF,CADD;AAuBA;;AAED,WAAO,cAAC,SAAD,EAAgBN,KAAhB,CAAP;AACA,GAjED;AAkEA,CApE4D,EAqE7D,sBArE6D,CAAvD;AAwEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASU,YAAT,CAAuBC,UAAvB,EAAmCC,SAAnC,EAA8CpB,UAA9C,EAA2D;AACjE,MAAKP,eAAe,CAAE2B,SAAF,EAAa,QAAb,CAApB,EAA8C;AAC7CD,IAAAA,UAAU,CAACE,EAAX,GAAgBrB,UAAU,CAACC,MAAX,KAAsB,EAAtB,GAA2B,IAA3B,GAAkCD,UAAU,CAACC,MAA7D;AACA;;AAED,SAAOkB,UAAP;AACA;AAED/B,SAAS,CAAE,0BAAF,EAA8B,uBAA9B,EAAuDU,YAAvD,CAAT;AACAV,SAAS,CACR,kBADQ,EAER,2CAFQ,EAGRkB,oBAHQ,CAAT;AAKAlB,SAAS,CACR,kCADQ,EAER,wBAFQ,EAGR8B,YAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport { has } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t//
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"names":["has","addFilter","PanelBody","TextControl","ExternalLink","__","hasBlockSupport","createHigherOrderComponent","Platform","InspectorControls","ANCHOR_REGEX","addAttribute","settings","attributes","anchor","type","source","attribute","selector","withInspectorControl","BlockEdit","props","hasAnchor","name","isSelected","isWeb","OS","textControl","nextValue","replace","setAttributes","addSaveProps","extraProps","blockType","id"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,SAAT,EAAoBC,WAApB,EAAiCC,YAAjC,QAAqD,uBAArD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,SAASC,iBAAT,QAAkC,eAAlC;AAEA;AACA;AACA;AACA;AACA;;AACA,MAAMC,YAAY,GAAG,QAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,YAAT,CAAuBC,QAAvB,EAAkC;AACxC;AACA,MAAKZ,GAAG,CAAEY,QAAQ,CAACC,UAAX,EAAuB,CAAE,QAAF,EAAY,MAAZ,CAAvB,CAAR,EAAwD;AACvD,WAAOD,QAAP;AACA;;AACD,MAAKN,eAAe,CAAEM,QAAF,EAAY,QAAZ,CAApB,EAA6C;AAC5C;AACAA,IAAAA,QAAQ,CAACC,UAAT,GAAsB,EACrB,GAAGD,QAAQ,CAACC,UADS;AAErBC,MAAAA,MAAM,EAAE;AACPC,QAAAA,IAAI,EAAE,QADC;AAEPC,QAAAA,MAAM,EAAE,WAFD;AAGPC,QAAAA,SAAS,EAAE,IAHJ;AAIPC,QAAAA,QAAQ,EAAE;AAJH;AAFa,KAAtB;AASA;;AAED,SAAON,QAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA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BAAD,QACC,cAAC,SAAD;AAAW,QAAA,KAAK,EAAGlB,EAAE,CAAE,kBAAF;AAArB,SACGsB,WADH,CADD,CAdF,CADD;AAuBA;;AAED,WAAO,cAAC,SAAD,EAAgBN,KAAhB,CAAP;AACA,GAjED;AAkEA,CApE4D,EAqE7D,sBArE6D,CAAvD;AAwEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASU,YAAT,CAAuBC,UAAvB,EAAmCC,SAAnC,EAA8CpB,UAA9C,EAA2D;AACjE,MAAKP,eAAe,CAAE2B,SAAF,EAAa,QAAb,CAApB,EAA8C;AAC7CD,IAAAA,UAAU,CAACE,EAAX,GAAgBrB,UAAU,CAACC,MAAX,KAAsB,EAAtB,GAA2B,IAA3B,GAAkCD,UAAU,CAACC,MAA7D;AACA;;AAED,SAAOkB,UAAP;AACA;AAED/B,SAAS,CAAE,0BAAF,EAA8B,uBAA9B,EAAuDU,YAAvD,CAAT;AACAV,SAAS,CACR,kBADQ,EAER,2CAFQ,EAGRkB,oBAHQ,CAAT;AAKAlB,SAAS,CACR,kCADQ,EAER,wBAFQ,EAGR8B,YAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport { has } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( has( settings.attributes, [ 'anchor', 'type' ] ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: {\n\t\t\t\ttype: 'string',\n\t\t\t\tsource: 'attribute',\n\t\t\t\tattribute: 'id',\n\t\t\t\tselector: '*',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning the anchor ID, if block supports anchor.\n *\n * @param {WPComponent} BlockEdit Original component.\n *\n * @return {WPComponent} Wrapped component.\n */\nexport const withInspectorControl = createHigherOrderComponent(\n\t( BlockEdit ) => {\n\t\treturn ( props ) => {\n\t\t\tconst hasAnchor = hasBlockSupport( props.name, 'anchor' );\n\n\t\t\tif ( hasAnchor && props.isSelected ) {\n\t\t\t\tconst isWeb = Platform.OS === 'web';\n\t\t\t\tconst textControl = (\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tclassName=\"html-anchor-control\"\n\t\t\t\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/support/article/page-jumps/'\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{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t\t\t\t</ExternalLink>\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\tvalue={ props.attributes.anchor || '' }\n\t\t\t\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\tanchor: nextValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t);\n\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ /*\n\t\t\t\t\t\t * We plan to remove scoping anchors to 'core/heading' to support\n\t\t\t\t\t\t * anchors for all eligble blocks. Additionally we plan to explore\n\t\t\t\t\t\t * leveraging InspectorAdvancedControls instead of a custom\n\t\t\t\t\t\t * PanelBody title. https://git.io/Jtcov\n\t\t\t\t\t\t */ }\n\t\t\t\t\t\t{ ! isWeb && props.name === 'core/heading' && (\n\t\t\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t\t\t<PanelBody title={ __( 'Heading settings' ) }>\n\t\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t};\n\t},\n\t'withInspectorControl'\n);\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/anchor/with-inspector-control',\n\twithInspectorControl\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/anchor/save-props',\n\taddSaveProps\n);\n"]}
|
|
@@ -23,14 +23,13 @@ export function BorderPanel(props) {
|
|
|
23
23
|
const {
|
|
24
24
|
clientId
|
|
25
25
|
} = props;
|
|
26
|
-
const isDisabled = useIsBorderDisabled(props);
|
|
27
|
-
const isSupported = hasBorderSupport(props.name);
|
|
28
26
|
const isColorSupported = useSetting('border.color') && hasBorderSupport(props.name, 'color');
|
|
29
27
|
const isRadiusSupported = useSetting('border.radius') && hasBorderSupport(props.name, 'radius');
|
|
30
28
|
const isStyleSupported = useSetting('border.style') && hasBorderSupport(props.name, 'style');
|
|
31
29
|
const isWidthSupported = useSetting('border.width') && hasBorderSupport(props.name, 'width');
|
|
30
|
+
const isDisabled = [!isColorSupported, !isRadiusSupported, !isStyleSupported, !isWidthSupported].every(Boolean);
|
|
32
31
|
|
|
33
|
-
if (isDisabled
|
|
32
|
+
if (isDisabled) {
|
|
34
33
|
return null;
|
|
35
34
|
}
|
|
36
35
|
|
|
@@ -128,16 +127,6 @@ export function shouldSkipSerialization(blockType) {
|
|
|
128
127
|
const support = getBlockSupport(blockType, BORDER_SUPPORT_KEY);
|
|
129
128
|
return support === null || support === void 0 ? void 0 : support.__experimentalSkipSerialization;
|
|
130
129
|
}
|
|
131
|
-
/**
|
|
132
|
-
* Determines if all border support features have been disabled.
|
|
133
|
-
*
|
|
134
|
-
* @return {boolean} If border support is completely disabled.
|
|
135
|
-
*/
|
|
136
|
-
|
|
137
|
-
const useIsBorderDisabled = () => {
|
|
138
|
-
const configs = [!useSetting('border.color'), !useSetting('border.radius'), !useSetting('border.style'), !useSetting('border.width')];
|
|
139
|
-
return configs.every(Boolean);
|
|
140
|
-
};
|
|
141
130
|
/**
|
|
142
131
|
* Returns a new style object where the specified border attribute has been
|
|
143
132
|
* removed.
|
|
@@ -148,7 +137,6 @@ const useIsBorderDisabled = () => {
|
|
|
148
137
|
* @return {Object} Style object with the specified attribute removed.
|
|
149
138
|
*/
|
|
150
139
|
|
|
151
|
-
|
|
152
140
|
export function removeBorderAttribute(style, attribute) {
|
|
153
141
|
return cleanEmptyObject({ ...style,
|
|
154
142
|
border: { ...(style === null || style === void 0 ? void 0 : style.border),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/border.js"],"names":["getBlockSupport","__experimentalToolsPanelItem","ToolsPanelItem","Platform","__","BorderColorEdit","hasBorderColorValue","resetBorderColor","BorderRadiusEdit","hasBorderRadiusValue","resetBorderRadius","BorderStyleEdit","hasBorderStyleValue","resetBorderStyle","BorderWidthEdit","hasBorderWidthValue","resetBorderWidth","InspectorControls","useSetting","cleanEmptyObject","BORDER_SUPPORT_KEY","BorderPanel","props","clientId","isDisabled","useIsBorderDisabled","isSupported","hasBorderSupport","name","isColorSupported","isRadiusSupported","isStyleSupported","isWidthSupported","defaultBorderControls","createResetAllFilter","borderAttribute","topLevelAttributes","newAttributes","style","border","undefined","width","color","borderColor","radius","blockName","feature","OS","support","shouldSkipSerialization","blockType","__experimentalSkipSerialization","configs","every","Boolean","removeBorderAttribute","attribute"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,mBAAhC;AACA,SAASC,4BAA4B,IAAIC,cAAzC,QAA+D,uBAA/D;AACA,SAASC,QAAT,QA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AAM,EAAE,EACP,IAAGD,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEC,MAAV,CADO;AAEP,OAAEiB,SAAF,GAAehB;AAFR;AAFgB,GAAF,CAAvB;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';\nimport { Platform } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBorderColorEdit,\n\thasBorderColorValue,\n\tresetBorderColor,\n} from './border-color';\nimport {\n\tBorderRadiusEdit,\n\thasBorderRadiusValue,\n\tresetBorderRadius,\n} from './border-radius';\nimport {\n\tBorderStyleEdit,\n\thasBorderStyleValue,\n\tresetBorderStyle,\n} from './border-style';\nimport {\n\tBorderWidthEdit,\n\thasBorderWidthValue,\n\tresetBorderWidth,\n} from './border-width';\nimport InspectorControls from '../components/inspector-controls';\nimport useSetting from '../components/use-setting';\nimport { cleanEmptyObject } from './utils';\n\nexport const BORDER_SUPPORT_KEY = '__experimentalBorder';\n\nexport function BorderPanel( props ) {\n\tconst { clientId } = props;\n\tconst isDisabled = useIsBorderDisabled( props );\n\tconst isSupported = hasBorderSupport( props.name );\n\n\tconst isColorSupported =\n\t\tuseSetting( 'border.color' ) && hasBorderSupport( props.name, 'color' );\n\n\tconst isRadiusSupported =\n\t\tuseSetting( 'border.radius' ) &&\n\t\thasBorderSupport( props.name, 'radius' );\n\n\tconst isStyleSupported =\n\t\tuseSetting( 'border.style' ) && hasBorderSupport( props.name, 'style' );\n\n\tconst isWidthSupported =\n\t\tuseSetting( 'border.width' ) && hasBorderSupport( props.name, 'width' );\n\n\tif ( isDisabled || ! isSupported ) {\n\t\treturn null;\n\t}\n\n\tconst defaultBorderControls = getBlockSupport( props.name, [\n\t\tBORDER_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\tconst createResetAllFilter = (\n\t\tborderAttribute,\n\t\ttopLevelAttributes = {}\n\t) => ( newAttributes ) => ( {\n\t\t...newAttributes,\n\t\t...topLevelAttributes,\n\t\tstyle: {\n\t\t\t...newAttributes.style,\n\t\t\tborder: {\n\t\t\t\t...newAttributes.style?.border,\n\t\t\t\t[ borderAttribute ]: undefined,\n\t\t\t},\n\t\t},\n\t} );\n\n\treturn (\n\t\t<InspectorControls __experimentalGroup=\"border\">\n\t\t\t{ isWidthSupported && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\thasValue={ () => hasBorderWidthValue( props ) }\n\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\tonDeselect={ () => resetBorderWidth( props ) }\n\t\t\t\t\tisShownByDefault={ defaultBorderControls?.width }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'width' ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<BorderWidthEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ isStyleSupported && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\thasValue={ () => hasBorderStyleValue( props ) }\n\t\t\t\t\tlabel={ __( 'Style' ) }\n\t\t\t\t\tonDeselect={ () => resetBorderStyle( props ) }\n\t\t\t\t\tisShownByDefault={ defaultBorderControls?.style }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'style' ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<BorderStyleEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ isColorSupported && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasBorderColorValue( props ) }\n\t\t\t\t\tlabel={ __( 'Color' ) }\n\t\t\t\t\tonDeselect={ () => resetBorderColor( props ) }\n\t\t\t\t\tisShownByDefault={ defaultBorderControls?.color }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'color', {\n\t\t\t\t\t\tborderColor: undefined,\n\t\t\t\t\t} ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<BorderColorEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ isRadiusSupported && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasBorderRadiusValue( props ) }\n\t\t\t\t\tlabel={ __( 'Radius' ) }\n\t\t\t\t\tonDeselect={ () => resetBorderRadius( props ) }\n\t\t\t\t\tisShownByDefault={ defaultBorderControls?.radius }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'radius' ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<BorderRadiusEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n}\n\n/**\n * Determine whether there is block support for border properties.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Border feature to check support for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBorderSupport( blockName, feature = 'any' ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst support = getBlockSupport( blockName, BORDER_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn !! (\n\t\t\tsupport?.color ||\n\t\t\tsupport?.radius ||\n\t\t\tsupport?.width ||\n\t\t\tsupport?.style\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\n/**\n * Check whether serialization of border classes and styles should be skipped.\n *\n * @param {string|Object} blockType Block name or block type object.\n *\n * @return {boolean} Whether serialization of border properties should occur.\n */\nexport function shouldSkipSerialization( blockType ) {\n\tconst support = getBlockSupport( blockType, BORDER_SUPPORT_KEY );\n\n\treturn support?.__experimentalSkipSerialization;\n}\n\n/**\n * Determines if all border support features have been disabled.\n *\n * @return {boolean} If border support is completely disabled.\n */\nconst useIsBorderDisabled = () => {\n\tconst configs = [\n\t\t! useSetting( 'border.color' ),\n\t\t! useSetting( 'border.radius' ),\n\t\t! useSetting( 'border.style' ),\n\t\t! useSetting( 'border.width' ),\n\t];\n\n\treturn configs.every( Boolean );\n};\n\n/**\n * Returns a new style object where the specified border attribute has been\n * removed.\n *\n * @param {Object} style Styles from block attributes.\n * @param {string} attribute The border style attribute to clear.\n *\n * @return {Object} Style object with the specified attribute removed.\n */\nexport function removeBorderAttribute( style, attribute ) {\n\treturn cleanEmptyObject( {\n\t\t...style,\n\t\tborder: {\n\t\t\t...style?.border,\n\t\t\t[ attribute ]: undefined,\n\t\t},\n\t} );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/border.js"],"names":["getBlockSupport","__experimentalToolsPanelItem","ToolsPanelItem","Platform","__","BorderColorEdit","hasBorderColorValue","resetBorderColor","BorderRadiusEdit","hasBorderRadiusValue","resetBorderRadius","BorderStyleEdit","hasBorderStyleValue","resetBorderStyle","BorderWidthEdit","hasBorderWidthValue","resetBorderWidth","InspectorControls","useSetting","cleanEmptyObject","BORDER_SUPPORT_KEY","BorderPanel","props","clientId","isColorSupported","hasBorderSupport","name","isRadiusSupported","isStyleSupported","isWidthSupported","isDisabled","every","Boolean","defaultBorderControls","createResetAllFilter","borderAttribute","topLevelAttributes","newAttributes","style","border","undefined","width","color","borderColor","radius","blockName","feature","OS","support","shouldSkipSerialization","blockType","__experimentalSkipSerialization","removeBorderAttribute","attribute"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,mBAAhC;AACA,SAASC,4BAA4B,IAAIC,cAAzC,QAA+D,uBAA/D;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SACCC,eADD,EAECC,mBAFD,EAGCC,gBAHD,QAIO,gBAJP;AAKA,SACCC,gBADD,EAECC,oBAF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O,IAAP;AACA;;AAED,MAAKF,OAAO,KAAK,KAAjB,EAAyB;AACxB,WAAO,CAAC,EACPE,OAAO,SAAP,IAAAA,OAAO,WAAP,IAAAA,OAAO,CAAEN,KAAT,IACAM,OADA,aACAA,OADA,eACAA,OAAO,CAAEJ,MADT,IAEAI,OAFA,aAEAA,OAFA,eAEAA,OAAO,CAAEP,KAFT,IAGAO,OAHA,aAGAA,OAHA,eAGAA,OAAO,CAAEV,KAJF,CAAR;AAMA;;AAED,SAAO,CAAC,EAAEU,OAAF,aAAEA,OAAF,eAAEA,OAAO,CAAIF,OAAJ,CAAT,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,uBAAT,CAAkCC,SAAlC,EAA8C;AACpD,QAAMF,OAAO,GAAGhD,eAAe,CAAEkD,SAAF,EAAa9B,kBAAb,CAA/B;AAEA,SAAO4B,OAAP,aAAOA,OAAP,uBAAOA,OAAO,CAAEG,+BAAhB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,qBAAT,CAAgCd,KAAhC,EAAuCe,SAAvC,EAAmD;AACzD,SAAOlC,gBAAgB,CAAE,EACxB,GAAGmB,KADqB;AAExBC,IAAAA,MAAM,EAAE,EACP,IAAGD,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEC,MAAV,CADO;AAEP,OAAEc,SAAF,GAAeb;AAFR;AAFgB,GAAF,CAAvB;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';\nimport { Platform } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBorderColorEdit,\n\thasBorderColorValue,\n\tresetBorderColor,\n} from './border-color';\nimport {\n\tBorderRadiusEdit,\n\thasBorderRadiusValue,\n\tresetBorderRadius,\n} from './border-radius';\nimport {\n\tBorderStyleEdit,\n\thasBorderStyleValue,\n\tresetBorderStyle,\n} from './border-style';\nimport {\n\tBorderWidthEdit,\n\thasBorderWidthValue,\n\tresetBorderWidth,\n} from './border-width';\nimport InspectorControls from '../components/inspector-controls';\nimport useSetting from '../components/use-setting';\nimport { cleanEmptyObject } from './utils';\n\nexport const BORDER_SUPPORT_KEY = '__experimentalBorder';\n\nexport function BorderPanel( props ) {\n\tconst { clientId } = props;\n\n\tconst isColorSupported =\n\t\tuseSetting( 'border.color' ) && hasBorderSupport( props.name, 'color' );\n\n\tconst isRadiusSupported =\n\t\tuseSetting( 'border.radius' ) &&\n\t\thasBorderSupport( props.name, 'radius' );\n\n\tconst isStyleSupported =\n\t\tuseSetting( 'border.style' ) && hasBorderSupport( props.name, 'style' );\n\n\tconst isWidthSupported =\n\t\tuseSetting( 'border.width' ) && hasBorderSupport( props.name, 'width' );\n\n\tconst isDisabled = [\n\t\t! isColorSupported,\n\t\t! isRadiusSupported,\n\t\t! isStyleSupported,\n\t\t! isWidthSupported,\n\t].every( Boolean );\n\n\tif ( isDisabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultBorderControls = getBlockSupport( props.name, [\n\t\tBORDER_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\tconst createResetAllFilter = (\n\t\tborderAttribute,\n\t\ttopLevelAttributes = {}\n\t) => ( newAttributes ) => ( {\n\t\t...newAttributes,\n\t\t...topLevelAttributes,\n\t\tstyle: {\n\t\t\t...newAttributes.style,\n\t\t\tborder: {\n\t\t\t\t...newAttributes.style?.border,\n\t\t\t\t[ borderAttribute ]: undefined,\n\t\t\t},\n\t\t},\n\t} );\n\n\treturn (\n\t\t<InspectorControls __experimentalGroup=\"border\">\n\t\t\t{ isWidthSupported && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\thasValue={ () => hasBorderWidthValue( props ) }\n\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\tonDeselect={ () => resetBorderWidth( props ) }\n\t\t\t\t\tisShownByDefault={ defaultBorderControls?.width }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'width' ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<BorderWidthEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ isStyleSupported && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\thasValue={ () => hasBorderStyleValue( props ) }\n\t\t\t\t\tlabel={ __( 'Style' ) }\n\t\t\t\t\tonDeselect={ () => resetBorderStyle( props ) }\n\t\t\t\t\tisShownByDefault={ defaultBorderControls?.style }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'style' ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<BorderStyleEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ isColorSupported && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasBorderColorValue( props ) }\n\t\t\t\t\tlabel={ __( 'Color' ) }\n\t\t\t\t\tonDeselect={ () => resetBorderColor( props ) }\n\t\t\t\t\tisShownByDefault={ defaultBorderControls?.color }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'color', {\n\t\t\t\t\t\tborderColor: undefined,\n\t\t\t\t\t} ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<BorderColorEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ isRadiusSupported && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasBorderRadiusValue( props ) }\n\t\t\t\t\tlabel={ __( 'Radius' ) }\n\t\t\t\t\tonDeselect={ () => resetBorderRadius( props ) }\n\t\t\t\t\tisShownByDefault={ defaultBorderControls?.radius }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'radius' ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<BorderRadiusEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n}\n\n/**\n * Determine whether there is block support for border properties.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Border feature to check support for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBorderSupport( blockName, feature = 'any' ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst support = getBlockSupport( blockName, BORDER_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn !! (\n\t\t\tsupport?.color ||\n\t\t\tsupport?.radius ||\n\t\t\tsupport?.width ||\n\t\t\tsupport?.style\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\n/**\n * Check whether serialization of border classes and styles should be skipped.\n *\n * @param {string|Object} blockType Block name or block type object.\n *\n * @return {boolean} Whether serialization of border properties should occur.\n */\nexport function shouldSkipSerialization( blockType ) {\n\tconst support = getBlockSupport( blockType, BORDER_SUPPORT_KEY );\n\n\treturn support?.__experimentalSkipSerialization;\n}\n\n/**\n * Returns a new style object where the specified border attribute has been\n * removed.\n *\n * @param {Object} style Styles from block attributes.\n * @param {string} attribute The border style attribute to clear.\n *\n * @return {Object} Style object with the specified attribute removed.\n */\nexport function removeBorderAttribute( style, attribute ) {\n\treturn cleanEmptyObject( {\n\t\t...style,\n\t\tborder: {\n\t\t\t...style?.border,\n\t\t\t[ attribute ]: undefined,\n\t\t},\n\t} );\n}\n"]}
|
|
@@ -209,7 +209,7 @@ const resetBackgroundAndGradient = _ref3 => {
|
|
|
209
209
|
function addAttributes(settings) {
|
|
210
210
|
if (!hasColorSupport(settings)) {
|
|
211
211
|
return settings;
|
|
212
|
-
} //
|
|
212
|
+
} // Allow blocks to specify their own attribute definition with default values if needed.
|
|
213
213
|
|
|
214
214
|
|
|
215
215
|
if (!settings.attributes.backgroundColor) {
|
|
@@ -270,7 +270,7 @@ export function addSaveProps(props, blockType, attributes) {
|
|
|
270
270
|
|
|
271
271
|
const textClass = getColorClassName('color', textColor);
|
|
272
272
|
const newClassName = classnames(props.className, textClass, gradientClass, {
|
|
273
|
-
// Don't apply the background class if there's a custom gradient
|
|
273
|
+
// Don't apply the background class if there's a custom gradient.
|
|
274
274
|
[backgroundClass]: (!hasGradient || !(style !== null && style !== void 0 && (_style$color = style.color) !== null && _style$color !== void 0 && _style$color.gradient)) && !!backgroundClass,
|
|
275
275
|
'has-text-color': textColor || (style === null || style === void 0 ? void 0 : (_style$color2 = style.color) === null || _style$color2 === void 0 ? void 0 : _style$color2.text),
|
|
276
276
|
'has-background': backgroundColor || (style === null || style === void 0 ? void 0 : (_style$color3 = style.color) === null || _style$color3 === void 0 ? void 0 : _style$color3.background) || hasGradient && (gradient || (style === null || style === void 0 ? void 0 : (_style$color4 = style.color) === null || _style$color4 === void 0 ? void 0 : _style$color4.gradient)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/color.js"],"names":["classnames","isObject","addFilter","getBlockSupport","__","useRef","useEffect","useMemo","Platform","createHigherOrderComponent","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","__experimentalGetGradientClass","getGradientValueBySlug","getGradientSlugByValue","cleanEmptyObject","transformStyles","immutableSet","ColorPanel","useSetting","COLOR_SUPPORT_KEY","hasColorSupport","blockType","colorSupport","link","gradient","background","text","shouldSkipSerialization","__experimentalSkipSerialization","hasLinkColorSupport","OS","hasGradientSupport","gradients","hasBackgroundColorSupport","hasTextColorSupport","hasColor","name","props","attributes","backgroundColor","style","color","elements","clearColorFromStyles","path","undefined","resetTextColor","setAttributes","textColor","resetAllTextFilter","resetLinkColor","resetAllLinkFilter","clearBackgroundAndGradient","resetBackgroundAndGradient","addAttributes","settings","Object","assign","type","addSaveProps","hasGradient","backgroundClass","gradientClass","textClass","newClassName","className","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","getLinkColorFromAttributeValue","colors","value","attributeParsed","exec","ColorEdit","blockName","userPalette","themePalette","defaultPalette","allSolids","userGradientPalette","themeGradientPalette","defaultGradientPalette","allGradients","areCustomSolidsEnabled","areCustomGradientsEnabled","isBackgroundEnabled","isLinkEnabled","isTextEnabled","solidsEnabled","length","gradientsEnabled","localAttributes","current","hasLinkColor","hasTextColor","hasBackgroundColor","hasGradientColor","gradientValue","onChangeColor","colorObject","attributeName","newStyle","slug","newNamedColor","newAttributes","onChangeGradient","onChangeLinkColor","newLinkColorValue","enableContrastChecking","defaultColorControls","clientId","label","onColorChange","colorValue","isShownByDefault","hasValue","onDeselect","resetAllFilter","onGradientChange","clearable","withColorPaletteStyles","BlockListBlock","extraStyles","wrapperProps","MIGRATION_PATHS","linkColor","addTransforms","result","source","index","results","destinationBlockType","activeSupports"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,QAAT,QAAyB,QAAzB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,SAAjB,EAA4BC,OAA5B,EAAqCC,QAArC,QAAqD,oBAArD;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AAEA;AACA;AACA;;AACA,SACCC,iBADD,EAECC,0BAFD,EAGCC,+BAHD,QAIO,sBAJP;AAKA,SACCC,8BADD,EAECC,sBAFD,EAGCC,sBAHD,QAIO,yBAJP;AAKA,SAASC,gBAAT,EAA2BC,eAA3B,EAA4CC,YAA5C,QAAgE,SAAhE;AACA,OAAOC,UAAP,MAAuB,eAAvB;AACA,OAAOC,UAAP,MAAuB,2BAAvB;AAEA,OAAO,MAAMC,iBAAiB,GAAG,OAA1B;;AAEP,MAAMC,eAAe,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CC,MAAhC,EAAwCC,KAAxC,EAA+CC,OAA/C,EAAyD;AAC/D,QAAMC,oBAAoB,GAAGJ,MAAM,CAAC5F,IAApC;AACA,QAAMiG,cAAc,GAAG;AACtBP,IAAAA,SAAS,EAAEjG,mBAAmB,CAAEuG,oBAAF,CADR;AAEtBpF,IAAAA,SAAS,EAAEd,mBAAmB,CAAEkG,oBAAF,CAFR;AAGtB7F,IAAAA,eAAe,EAAEN,yBAAyB,CAAEmG,oBAAF,CAHpB;AAItB5G,IAAAA,QAAQ,EAAEO,kBAAkB,CAAEqG,oBAAF;AAJN,GAAvB;AAMA,SAAOrH,eAAe,CACrBsH,cADqB,EAErBR,eAFqB,EAGrBG,MAHqB,EAIrBC,MAJqB,EAKrBC,KALqB,EAMrBC,OANqB,CAAtB;AAQA;AAEDnI,SAAS,CACR,0BADQ,EAER,yBAFQ,EAGRsD,aAHQ,CAAT;AAMAtD,SAAS,CACR,kCADQ,EAER,yBAFQ,EAGR2D,YAHQ,CAAT;AAMA3D,SAAS,CACR,0BADQ,EAER,yBAFQ,EAGRkE,YAHQ,CAAT;AAMAlE,SAAS,CACR,uBADQ,EAER,sCAFQ,EAGRyH,sBAHQ,CAAT;AAMAzH,SAAS,CACR,2CADQ,EAER,0BAFQ,EAGR+H,aAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { isObject } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useEffect, useMemo, Platform } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n} from '../components/colors';\nimport {\n\t__experimentalGetGradientClass,\n\tgetGradientValueBySlug,\n\tgetGradientSlugByValue,\n} from '../components/gradients';\nimport { cleanEmptyObject, transformStyles, immutableSet } from './utils';\nimport ColorPanel from './color-panel';\nimport useSetting from '../components/use-setting';\n\nexport const COLOR_SUPPORT_KEY = 'color';\n\nconst hasColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\treturn (\n\t\tcolorSupport &&\n\t\t( colorSupport.link === true ||\n\t\t\tcolorSupport.gradient === true ||\n\t\t\tcolorSupport.background !== false ||\n\t\t\tcolorSupport.text !== false )\n\t);\n};\n\nconst shouldSkipSerialization = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport?.__experimentalSkipSerialization;\n};\n\nconst hasLinkColorSupport = ( blockType ) => {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn isObject( colorSupport ) && !! colorSupport.link;\n};\n\nconst hasGradientSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn isObject( colorSupport ) && !! colorSupport.gradients;\n};\n\nconst hasBackgroundColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport && colorSupport.background !== false;\n};\n\nconst hasTextColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport && colorSupport.text !== false;\n};\n\n/**\n * Checks whether a color has been set either with a named preset color in\n * a top level block attribute or as a custom value within the style attribute\n * object.\n *\n * @param {string} name Name of the color to check.\n * @return {boolean} Whether or not a color has a value.\n */\nconst hasColor = ( name ) => ( props ) => {\n\tif ( name === 'background' ) {\n\t\treturn (\n\t\t\t!! props.attributes.backgroundColor ||\n\t\t\t!! props.attributes.style?.color?.background ||\n\t\t\t!! props.attributes.gradient ||\n\t\t\t!! props.attributes.style?.color?.gradient\n\t\t);\n\t}\n\n\tif ( name === 'link' ) {\n\t\treturn !! props.attributes.style?.elements?.link?.color?.text;\n\t}\n\n\treturn (\n\t\t!! props.attributes[ `${ name }Color` ] ||\n\t\t!! props.attributes.style?.color?.[ name ]\n\t);\n};\n\n/**\n * Clears a single color property from a style object.\n *\n * @param {Array} path Path to color property to clear within styles object.\n * @param {Object} style Block attributes style object.\n * @return {Object} Styles with the color property omitted.\n */\nconst clearColorFromStyles = ( path, style ) =>\n\tcleanEmptyObject( immutableSet( style, path, undefined ) );\n\n/**\n * Resets the block attributes for text color.\n *\n * @param {Object} props Current block props.\n * @param {Object} props.attributes Block attributes.\n * @param {Function} props.setAttributes Block's setAttributes prop used to apply reset.\n */\nconst resetTextColor = ( { attributes, setAttributes } ) => {\n\tsetAttributes( {\n\t\ttextColor: undefined,\n\t\tstyle: clearColorFromStyles( [ 'color', 'text' ], attributes.style ),\n\t} );\n};\n\n/**\n * Clears text color related properties from supplied attributes.\n *\n * @param {Object} attributes Block attributes.\n * @return {Object} Update block attributes with text color properties omitted.\n */\nconst resetAllTextFilter = ( attributes ) => ( {\n\ttextColor: undefined,\n\tstyle: clearColorFromStyles( [ 'color', 'text' ], attributes.style ),\n} );\n\n/**\n * Resets the block attributes for link color.\n *\n * @param {Object} props Current block props.\n * @param {Object} props.attributes Block attributes.\n * @param {Function} props.setAttributes Block's setAttributes prop used to apply reset.\n */\nconst resetLinkColor = ( { attributes, setAttributes } ) => {\n\tconst path = [ 'elements', 'link', 'color', 'text' ];\n\tsetAttributes( { style: clearColorFromStyles( path, attributes.style ) } );\n};\n\n/**\n * Clears link color related properties from supplied attributes.\n *\n * @param {Object} attributes Block attributes.\n * @return {Object} Update block attributes with link color properties omitted.\n */\nconst resetAllLinkFilter = ( attributes ) => ( {\n\tstyle: clearColorFromStyles(\n\t\t[ 'elements', 'link', 'color', 'text' ],\n\t\tattributes.style\n\t),\n} );\n\n/**\n * Clears all background color related properties including gradients from\n * supplied block attributes.\n *\n * @param {Object} attributes Block attributes.\n * @return {Object} Block attributes with background and gradient omitted.\n */\nconst clearBackgroundAndGradient = ( attributes ) => ( {\n\tbackgroundColor: undefined,\n\tgradient: undefined,\n\tstyle: {\n\t\t...attributes.style,\n\t\tcolor: {\n\t\t\t...attributes.style?.color,\n\t\t\tbackground: undefined,\n\t\t\tgradient: undefined,\n\t\t},\n\t},\n} );\n\n/**\n * Resets the block attributes for both background color and gradient.\n *\n * @param {Object} props Current block props.\n * @param {Object} props.attributes Block attributes.\n * @param {Function} props.setAttributes Block's setAttributes prop used to apply reset.\n */\nconst resetBackgroundAndGradient = ( { attributes, setAttributes } ) => {\n\tsetAttributes( clearBackgroundAndGradient( attributes ) );\n};\n\n/**\n * Filters registered block settings, extending attributes to include\n * `backgroundColor` and `textColor` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasColorSupport( settings ) ) {\n\t\treturn settings;\n\t}\n\n\t// allow blocks to specify their own attribute definition with default values if needed.\n\tif ( ! settings.attributes.backgroundColor ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tbackgroundColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\tif ( ! settings.attributes.textColor ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\ttextColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\n\tif ( hasGradientSupport( settings ) && ! settings.attributes.gradient ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tgradient: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override props assigned to save component to inject colors classnames.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasColorSupport( blockType ) ||\n\t\tshouldSkipSerialization( blockType )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst hasGradient = hasGradientSupport( blockType );\n\n\t// I'd have preferred to avoid the \"style\" attribute usage here\n\tconst { backgroundColor, textColor, gradient, style } = attributes;\n\n\tconst backgroundClass = getColorClassName(\n\t\t'background-color',\n\t\tbackgroundColor\n\t);\n\tconst gradientClass = __experimentalGetGradientClass( gradient );\n\tconst textClass = getColorClassName( 'color', textColor );\n\tconst newClassName = classnames(\n\t\tprops.className,\n\t\ttextClass,\n\t\tgradientClass,\n\t\t{\n\t\t\t// Don't apply the background class if there's a custom gradient\n\t\t\t[ backgroundClass ]:\n\t\t\t\t( ! hasGradient || ! style?.color?.gradient ) &&\n\t\t\t\t!! backgroundClass,\n\t\t\t'has-text-color': textColor || style?.color?.text,\n\t\t\t'has-background':\n\t\t\t\tbackgroundColor ||\n\t\t\t\tstyle?.color?.background ||\n\t\t\t\t( hasGradient && ( gradient || style?.color?.gradient ) ),\n\t\t\t'has-link-color': style?.elements?.link?.color,\n\t\t}\n\t);\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Filters registered block settings to extend the block edit wrapper\n * to apply the desired styles and classnames properly.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addEditProps( settings ) {\n\tif (\n\t\t! hasColorSupport( settings ) ||\n\t\tshouldSkipSerialization( settings )\n\t) {\n\t\treturn settings;\n\t}\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\nconst getLinkColorFromAttributeValue = ( colors, value ) => {\n\tconst attributeParsed = /var:preset\\|color\\|(.+)/.exec( value );\n\tif ( attributeParsed && attributeParsed[ 1 ] ) {\n\t\treturn getColorObjectByAttributeValues( colors, attributeParsed[ 1 ] )\n\t\t\t.color;\n\t}\n\treturn value;\n};\n\n/**\n * Inspector control panel containing the color related configuration\n *\n * @param {Object} props\n *\n * @return {WPElement} Color edit element.\n */\nexport function ColorEdit( props ) {\n\tconst { name: blockName, attributes } = props;\n\t// Some color settings have a special handling for deprecated flags in `useSetting`,\n\t// so we can't unwrap them by doing const { ... } = useSetting('color')\n\t// until https://github.com/WordPress/gutenberg/issues/37094 is fixed.\n\tconst userPalette = useSetting( 'color.palette.custom' );\n\tconst themePalette = useSetting( 'color.palette.theme' );\n\tconst defaultPalette = useSetting( 'color.palette.default' );\n\tconst allSolids = useMemo(\n\t\t() => [\n\t\t\t...( userPalette || [] ),\n\t\t\t...( themePalette || [] ),\n\t\t\t...( defaultPalette || [] ),\n\t\t],\n\t\t[ userPalette, themePalette, defaultPalette ]\n\t);\n\tconst userGradientPalette = useSetting( 'color.gradients.custom' );\n\tconst themeGradientPalette = useSetting( 'color.gradients.theme' );\n\tconst defaultGradientPalette = useSetting( 'color.gradients.default' );\n\tconst allGradients = useMemo(\n\t\t() => [\n\t\t\t...( userGradientPalette || [] ),\n\t\t\t...( themeGradientPalette || [] ),\n\t\t\t...( defaultGradientPalette || [] ),\n\t\t],\n\t\t[ userGradientPalette, themeGradientPalette, defaultGradientPalette ]\n\t);\n\tconst areCustomSolidsEnabled = useSetting( 'color.custom' );\n\tconst areCustomGradientsEnabled = useSetting( 'color.customGradient' );\n\tconst isBackgroundEnabled = useSetting( 'color.background' );\n\tconst isLinkEnabled = useSetting( 'color.link' );\n\tconst isTextEnabled = useSetting( 'color.text' );\n\n\tconst solidsEnabled =\n\t\tareCustomSolidsEnabled || ! themePalette || themePalette?.length > 0;\n\n\tconst gradientsEnabled =\n\t\tareCustomGradientsEnabled ||\n\t\t! themeGradientPalette ||\n\t\tthemeGradientPalette?.length > 0;\n\n\t// Shouldn't be needed but right now the ColorGradientsPanel\n\t// can trigger both onChangeColor and onChangeBackground\n\t// synchronously causing our two callbacks to override changes\n\t// from each other.\n\tconst localAttributes = useRef( attributes );\n\tuseEffect( () => {\n\t\tlocalAttributes.current = attributes;\n\t}, [ attributes ] );\n\n\tif ( ! hasColorSupport( blockName ) ) {\n\t\treturn null;\n\t}\n\n\tconst hasLinkColor =\n\t\thasLinkColorSupport( blockName ) && isLinkEnabled && solidsEnabled;\n\tconst hasTextColor =\n\t\thasTextColorSupport( blockName ) && isTextEnabled && solidsEnabled;\n\tconst hasBackgroundColor =\n\t\thasBackgroundColorSupport( blockName ) &&\n\t\tisBackgroundEnabled &&\n\t\tsolidsEnabled;\n\tconst hasGradientColor =\n\t\thasGradientSupport( blockName ) && gradientsEnabled;\n\n\tif (\n\t\t! hasLinkColor &&\n\t\t! hasTextColor &&\n\t\t! hasBackgroundColor &&\n\t\t! hasGradientColor\n\t) {\n\t\treturn null;\n\t}\n\n\tconst { style, textColor, backgroundColor, gradient } = attributes;\n\tlet gradientValue;\n\tif ( hasGradientColor && gradient ) {\n\t\tgradientValue = getGradientValueBySlug( allGradients, gradient );\n\t} else if ( hasGradientColor ) {\n\t\tgradientValue = style?.color?.gradient;\n\t}\n\n\tconst onChangeColor = ( name ) => ( value ) => {\n\t\tconst colorObject = getColorObjectByColorValue( allSolids, value );\n\t\tconst attributeName = name + 'Color';\n\t\tconst newStyle = {\n\t\t\t...localAttributes.current.style,\n\t\t\tcolor: {\n\t\t\t\t...localAttributes.current?.style?.color,\n\t\t\t\t[ name ]: colorObject?.slug ? undefined : value,\n\t\t\t},\n\t\t};\n\n\t\tconst newNamedColor = colorObject?.slug ? colorObject.slug : undefined;\n\t\tconst newAttributes = {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t[ attributeName ]: newNamedColor,\n\t\t};\n\n\t\tprops.setAttributes( newAttributes );\n\t\tlocalAttributes.current = {\n\t\t\t...localAttributes.current,\n\t\t\t...newAttributes,\n\t\t};\n\t};\n\n\tconst onChangeGradient = ( value ) => {\n\t\tconst slug = getGradientSlugByValue( allGradients, value );\n\t\tlet newAttributes;\n\t\tif ( slug ) {\n\t\t\tconst newStyle = {\n\t\t\t\t...localAttributes.current?.style,\n\t\t\t\tcolor: {\n\t\t\t\t\t...localAttributes.current?.style?.color,\n\t\t\t\t\tgradient: undefined,\n\t\t\t\t},\n\t\t\t};\n\t\t\tnewAttributes = {\n\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t\tgradient: slug,\n\t\t\t};\n\t\t} else {\n\t\t\tconst newStyle = {\n\t\t\t\t...localAttributes.current?.style,\n\t\t\t\tcolor: {\n\t\t\t\t\t...localAttributes.current?.style?.color,\n\t\t\t\t\tgradient: value,\n\t\t\t\t},\n\t\t\t};\n\t\t\tnewAttributes = {\n\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t\tgradient: undefined,\n\t\t\t};\n\t\t}\n\t\tprops.setAttributes( newAttributes );\n\t\tlocalAttributes.current = {\n\t\t\t...localAttributes.current,\n\t\t\t...newAttributes,\n\t\t};\n\t};\n\n\tconst onChangeLinkColor = ( value ) => {\n\t\tconst colorObject = getColorObjectByColorValue( allSolids, value );\n\t\tconst newLinkColorValue = colorObject?.slug\n\t\t\t? `var:preset|color|${ colorObject.slug }`\n\t\t\t: value;\n\n\t\tconst newStyle = cleanEmptyObject(\n\t\t\timmutableSet(\n\t\t\t\tstyle,\n\t\t\t\t[ 'elements', 'link', 'color', 'text' ],\n\t\t\t\tnewLinkColorValue\n\t\t\t)\n\t\t);\n\t\tprops.setAttributes( { style: newStyle } );\n\t};\n\n\tconst enableContrastChecking =\n\t\tPlatform.OS === 'web' && ! gradient && ! style?.color?.gradient;\n\n\tconst defaultColorControls = getBlockSupport( props.name, [\n\t\tCOLOR_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\treturn (\n\t\t<ColorPanel\n\t\t\tenableContrastChecking={ enableContrastChecking }\n\t\t\tclientId={ props.clientId }\n\t\t\tenableAlpha={ true }\n\t\t\tsettings={ [\n\t\t\t\t...( hasTextColor\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Text' ),\n\t\t\t\t\t\t\t\tonColorChange: onChangeColor( 'text' ),\n\t\t\t\t\t\t\t\tcolorValue: getColorObjectByAttributeValues(\n\t\t\t\t\t\t\t\t\tallSolids,\n\t\t\t\t\t\t\t\t\ttextColor,\n\t\t\t\t\t\t\t\t\tstyle?.color?.text\n\t\t\t\t\t\t\t\t).color,\n\t\t\t\t\t\t\t\tisShownByDefault: defaultColorControls?.text,\n\t\t\t\t\t\t\t\thasValue: () => hasColor( 'text' )( props ),\n\t\t\t\t\t\t\t\tonDeselect: () => resetTextColor( props ),\n\t\t\t\t\t\t\t\tresetAllFilter: resetAllTextFilter,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [] ),\n\t\t\t\t...( hasBackgroundColor || hasGradientColor\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Background' ),\n\t\t\t\t\t\t\t\tonColorChange: hasBackgroundColor\n\t\t\t\t\t\t\t\t\t? onChangeColor( 'background' )\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\tcolorValue: getColorObjectByAttributeValues(\n\t\t\t\t\t\t\t\t\tallSolids,\n\t\t\t\t\t\t\t\t\tbackgroundColor,\n\t\t\t\t\t\t\t\t\tstyle?.color?.background\n\t\t\t\t\t\t\t\t).color,\n\t\t\t\t\t\t\t\tgradientValue,\n\t\t\t\t\t\t\t\tonGradientChange: hasGradientColor\n\t\t\t\t\t\t\t\t\t? onChangeGradient\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\tisShownByDefault:\n\t\t\t\t\t\t\t\t\tdefaultColorControls?.background,\n\t\t\t\t\t\t\t\thasValue: () =>\n\t\t\t\t\t\t\t\t\thasColor( 'background' )( props ),\n\t\t\t\t\t\t\t\tonDeselect: () =>\n\t\t\t\t\t\t\t\t\tresetBackgroundAndGradient( props ),\n\t\t\t\t\t\t\t\tresetAllFilter: clearBackgroundAndGradient,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [] ),\n\t\t\t\t...( hasLinkColor\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Link' ),\n\t\t\t\t\t\t\t\tonColorChange: onChangeLinkColor,\n\t\t\t\t\t\t\t\tcolorValue: getLinkColorFromAttributeValue(\n\t\t\t\t\t\t\t\t\tallSolids,\n\t\t\t\t\t\t\t\t\tstyle?.elements?.link?.color?.text\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tclearable: !! style?.elements?.link?.color\n\t\t\t\t\t\t\t\t\t?.text,\n\t\t\t\t\t\t\t\tisShownByDefault: defaultColorControls?.link,\n\t\t\t\t\t\t\t\thasValue: () => hasColor( 'link' )( props ),\n\t\t\t\t\t\t\t\tonDeselect: () => resetLinkColor( props ),\n\t\t\t\t\t\t\t\tresetAllFilter: resetAllLinkFilter,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [] ),\n\t\t\t] }\n\t\t/>\n\t);\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { backgroundColor, textColor } = attributes;\n\t\tconst userPalette = useSetting( 'color.palette.custom' ) || [];\n\t\tconst themePalette = useSetting( 'color.palette.theme' ) || [];\n\t\tconst defaultPalette = useSetting( 'color.palette.default' ) || [];\n\t\tconst colors = useMemo(\n\t\t\t() => [\n\t\t\t\t...( userPalette || [] ),\n\t\t\t\t...( themePalette || [] ),\n\t\t\t\t...( defaultPalette || [] ),\n\t\t\t],\n\t\t\t[ userPalette, themePalette, defaultPalette ]\n\t\t);\n\t\tif ( ! hasColorSupport( name ) || shouldSkipSerialization( name ) ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\t\tconst extraStyles = {};\n\n\t\tif ( textColor ) {\n\t\t\textraStyles.color = getColorObjectByAttributeValues(\n\t\t\t\tcolors,\n\t\t\t\ttextColor\n\t\t\t)?.color;\n\t\t}\n\t\tif ( backgroundColor ) {\n\t\t\textraStyles.backgroundColor = getColorObjectByAttributeValues(\n\t\t\t\tcolors,\n\t\t\t\tbackgroundColor\n\t\t\t)?.color;\n\t\t}\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...extraStyles,\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\nconst MIGRATION_PATHS = {\n\tlinkColor: [ [ 'style', 'elements', 'link', 'color', 'text' ] ],\n\ttextColor: [ [ 'textColor' ], [ 'style', 'color', 'text' ] ],\n\tbackgroundColor: [\n\t\t[ 'backgroundColor' ],\n\t\t[ 'style', 'color', 'background' ],\n\t],\n\tgradient: [ [ 'gradient' ], [ 'style', 'color', 'gradient' ] ],\n};\n\nexport function addTransforms( result, source, index, results ) {\n\tconst destinationBlockType = result.name;\n\tconst activeSupports = {\n\t\tlinkColor: hasLinkColorSupport( destinationBlockType ),\n\t\ttextColor: hasTextColorSupport( destinationBlockType ),\n\t\tbackgroundColor: hasBackgroundColorSupport( destinationBlockType ),\n\t\tgradient: hasGradientSupport( destinationBlockType ),\n\t};\n\treturn transformStyles(\n\t\tactiveSupports,\n\t\tMIGRATION_PATHS,\n\t\tresult,\n\t\tsource,\n\t\tindex,\n\t\tresults\n\t);\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/color/addAttribute',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/color/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/color/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/color/with-color-palette-styles',\n\twithColorPaletteStyles\n);\n\naddFilter(\n\t'blocks.switchToBlockType.transformedBlock',\n\t'core/color/addTransforms',\n\taddTransforms\n);\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/color.js"],"names":["classnames","isObject","addFilter","getBlockSupport","__","useRef","useEffect","useMemo","Platform","createHigherOrderComponent","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","__experimentalGetGradientClass","getGradientValueBySlug","getGradientSlugByValue","cleanEmptyObject","transformStyles","immutableSet","ColorPanel","useSetting","COLOR_SUPPORT_KEY","hasColorSupport","blockType","colorSupport","link","gradient","background","text","shouldSkipSerialization","__experimentalSkipSerialization","hasLinkColorSupport","OS","hasGradientSupport","gradients","hasBackgroundColorSupport","hasTextColorSupport","hasColor","name","props","attributes","backgroundColor","style","color","elements","clearColorFromStyles","path","undefined","resetTextColor","setAttributes","textColor","resetAllTextFilter","resetLinkColor","resetAllLinkFilter","clearBackgroundAndGradient","resetBackgroundAndGradient","addAttributes","settings","Object","assign","type","addSaveProps","hasGradient","backgroundClass","gradientClass","textClass","newClassName","className","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","getLinkColorFromAttributeValue","colors","value","attributeParsed","exec","ColorEdit","blockName","userPalette","themePalette","defaultPalette","allSolids","userGradientPalette","themeGradientPalette","defaultGradientPalette","allGradients","areCustomSolidsEnabled","areCustomGradientsEnabled","isBackgroundEnabled","isLinkEnabled","isTextEnabled","solidsEnabled","length","gradientsEnabled","localAttributes","current","hasLinkColor","hasTextColor","hasBackgroundColor","hasGradientColor","gradientValue","onChangeColor","colorObject","attributeName","newStyle","slug","newNamedColor","newAttributes","onChangeGradient","onChangeLinkColor","newLinkColorValue","enableContrastChecking","defaultColorControls","clientId","label","onColorChange","colorValue","isShownByDefault","hasValue","onDeselect","resetAllFilter","onGradientChange","clearable","withColorPaletteStyles","BlockListBlock","extraStyles","wrapperProps","MIGRATION_PATHS","linkColor","addTransforms","result","source","index","results","destinationBlockType","activeSupports"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,QAAT,QAAyB,QAAzB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,SAAjB,EAA4BC,OAA5B,EAAqCC,QAArC,QAAqD,oBAArD;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AAEA;AACA;AACA;;AACA,SACCC,iBADD,EAECC,0BAFD,EAGCC,+BAHD,QAIO,sBAJP;AAKA,SACCC,8BADD,EAECC,sBAFD,EAGCC,sBAHD,QAIO,yBAJP;AAKA,SAASC,gBAAT,EAA2BC,eAA3B,EAA4CC,YAA5C,QAAgE,SAAhE;AACA,OAAOC,UAAP,MAAuB,eAAvB;AACA,OAAOC,UAAP,MAAuB,2BAAvB;AAEA,OAAO,MAAMC,iBAAiB,GAAG,OAA1B;;AAEP,MAAMC,eAAe,GAAKC,SAAF,IAAiB;AACxC,QAAMC,YAAY,GAAGrB,eAAe,CAAEoB,SAAF,EAAaF,iBAAb,CAApC;AACA,SACCG,YAAY,KACVA,YAAY,CAACC,IAAb,KAAsB,IAAtB,IACDD,YAAY,CAACE,QAAb,KAA0B,IADzB,IAEDF,YAAY,CAACG,UAAb,KAA4B,KAF3B,IAGDH,YAAY,CAACI,IAAb,KAAsB,KAJX,CADb;AAOA,CATD;;AAWA,MAAMC,uBAAuB,GAAKN,SAAF,IAAiB;AAChD,QAAMC,YAAY,GAAGrB,eAAe,CAAEoB,SAAF,EAAaF,iBAAb,CAApC;AAEA,SAAOG,YAAP,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,EAErBR,eAFqB,EAGrBG,MAHqB,EAIrBC,MAJqB,EAKrBC,KALqB,EAMrBC,OANqB,CAAtB;AAQA;AAEDnI,SAAS,CACR,0BADQ,EAER,yBAFQ,EAGRsD,aAHQ,CAAT;AAMAtD,SAAS,CACR,kCADQ,EAER,yBAFQ,EAGR2D,YAHQ,CAAT;AAMA3D,SAAS,CACR,0BADQ,EAER,yBAFQ,EAGRkE,YAHQ,CAAT;AAMAlE,SAAS,CACR,uBADQ,EAER,sCAFQ,EAGRyH,sBAHQ,CAAT;AAMAzH,SAAS,CACR,2CADQ,EAER,0BAFQ,EAGR+H,aAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { isObject } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useEffect, useMemo, Platform } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n} from '../components/colors';\nimport {\n\t__experimentalGetGradientClass,\n\tgetGradientValueBySlug,\n\tgetGradientSlugByValue,\n} from '../components/gradients';\nimport { cleanEmptyObject, transformStyles, immutableSet } from './utils';\nimport ColorPanel from './color-panel';\nimport useSetting from '../components/use-setting';\n\nexport const COLOR_SUPPORT_KEY = 'color';\n\nconst hasColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\treturn (\n\t\tcolorSupport &&\n\t\t( colorSupport.link === true ||\n\t\t\tcolorSupport.gradient === true ||\n\t\t\tcolorSupport.background !== false ||\n\t\t\tcolorSupport.text !== false )\n\t);\n};\n\nconst shouldSkipSerialization = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport?.__experimentalSkipSerialization;\n};\n\nconst hasLinkColorSupport = ( blockType ) => {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn isObject( colorSupport ) && !! colorSupport.link;\n};\n\nconst hasGradientSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn isObject( colorSupport ) && !! colorSupport.gradients;\n};\n\nconst hasBackgroundColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport && colorSupport.background !== false;\n};\n\nconst hasTextColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport && colorSupport.text !== false;\n};\n\n/**\n * Checks whether a color has been set either with a named preset color in\n * a top level block attribute or as a custom value within the style attribute\n * object.\n *\n * @param {string} name Name of the color to check.\n * @return {boolean} Whether or not a color has a value.\n */\nconst hasColor = ( name ) => ( props ) => {\n\tif ( name === 'background' ) {\n\t\treturn (\n\t\t\t!! props.attributes.backgroundColor ||\n\t\t\t!! props.attributes.style?.color?.background ||\n\t\t\t!! props.attributes.gradient ||\n\t\t\t!! props.attributes.style?.color?.gradient\n\t\t);\n\t}\n\n\tif ( name === 'link' ) {\n\t\treturn !! props.attributes.style?.elements?.link?.color?.text;\n\t}\n\n\treturn (\n\t\t!! props.attributes[ `${ name }Color` ] ||\n\t\t!! props.attributes.style?.color?.[ name ]\n\t);\n};\n\n/**\n * Clears a single color property from a style object.\n *\n * @param {Array} path Path to color property to clear within styles object.\n * @param {Object} style Block attributes style object.\n * @return {Object} Styles with the color property omitted.\n */\nconst clearColorFromStyles = ( path, style ) =>\n\tcleanEmptyObject( immutableSet( style, path, undefined ) );\n\n/**\n * Resets the block attributes for text color.\n *\n * @param {Object} props Current block props.\n * @param {Object} props.attributes Block attributes.\n * @param {Function} props.setAttributes Block's setAttributes prop used to apply reset.\n */\nconst resetTextColor = ( { attributes, setAttributes } ) => {\n\tsetAttributes( {\n\t\ttextColor: undefined,\n\t\tstyle: clearColorFromStyles( [ 'color', 'text' ], attributes.style ),\n\t} );\n};\n\n/**\n * Clears text color related properties from supplied attributes.\n *\n * @param {Object} attributes Block attributes.\n * @return {Object} Update block attributes with text color properties omitted.\n */\nconst resetAllTextFilter = ( attributes ) => ( {\n\ttextColor: undefined,\n\tstyle: clearColorFromStyles( [ 'color', 'text' ], attributes.style ),\n} );\n\n/**\n * Resets the block attributes for link color.\n *\n * @param {Object} props Current block props.\n * @param {Object} props.attributes Block attributes.\n * @param {Function} props.setAttributes Block's setAttributes prop used to apply reset.\n */\nconst resetLinkColor = ( { attributes, setAttributes } ) => {\n\tconst path = [ 'elements', 'link', 'color', 'text' ];\n\tsetAttributes( { style: clearColorFromStyles( path, attributes.style ) } );\n};\n\n/**\n * Clears link color related properties from supplied attributes.\n *\n * @param {Object} attributes Block attributes.\n * @return {Object} Update block attributes with link color properties omitted.\n */\nconst resetAllLinkFilter = ( attributes ) => ( {\n\tstyle: clearColorFromStyles(\n\t\t[ 'elements', 'link', 'color', 'text' ],\n\t\tattributes.style\n\t),\n} );\n\n/**\n * Clears all background color related properties including gradients from\n * supplied block attributes.\n *\n * @param {Object} attributes Block attributes.\n * @return {Object} Block attributes with background and gradient omitted.\n */\nconst clearBackgroundAndGradient = ( attributes ) => ( {\n\tbackgroundColor: undefined,\n\tgradient: undefined,\n\tstyle: {\n\t\t...attributes.style,\n\t\tcolor: {\n\t\t\t...attributes.style?.color,\n\t\t\tbackground: undefined,\n\t\t\tgradient: undefined,\n\t\t},\n\t},\n} );\n\n/**\n * Resets the block attributes for both background color and gradient.\n *\n * @param {Object} props Current block props.\n * @param {Object} props.attributes Block attributes.\n * @param {Function} props.setAttributes Block's setAttributes prop used to apply reset.\n */\nconst resetBackgroundAndGradient = ( { attributes, setAttributes } ) => {\n\tsetAttributes( clearBackgroundAndGradient( attributes ) );\n};\n\n/**\n * Filters registered block settings, extending attributes to include\n * `backgroundColor` and `textColor` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasColorSupport( settings ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( ! settings.attributes.backgroundColor ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tbackgroundColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\tif ( ! settings.attributes.textColor ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\ttextColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\n\tif ( hasGradientSupport( settings ) && ! settings.attributes.gradient ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tgradient: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override props assigned to save component to inject colors classnames.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasColorSupport( blockType ) ||\n\t\tshouldSkipSerialization( blockType )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst hasGradient = hasGradientSupport( blockType );\n\n\t// I'd have preferred to avoid the \"style\" attribute usage here\n\tconst { backgroundColor, textColor, gradient, style } = attributes;\n\n\tconst backgroundClass = getColorClassName(\n\t\t'background-color',\n\t\tbackgroundColor\n\t);\n\tconst gradientClass = __experimentalGetGradientClass( gradient );\n\tconst textClass = getColorClassName( 'color', textColor );\n\tconst newClassName = classnames(\n\t\tprops.className,\n\t\ttextClass,\n\t\tgradientClass,\n\t\t{\n\t\t\t// Don't apply the background class if there's a custom gradient.\n\t\t\t[ backgroundClass ]:\n\t\t\t\t( ! hasGradient || ! style?.color?.gradient ) &&\n\t\t\t\t!! backgroundClass,\n\t\t\t'has-text-color': textColor || style?.color?.text,\n\t\t\t'has-background':\n\t\t\t\tbackgroundColor ||\n\t\t\t\tstyle?.color?.background ||\n\t\t\t\t( hasGradient && ( gradient || style?.color?.gradient ) ),\n\t\t\t'has-link-color': style?.elements?.link?.color,\n\t\t}\n\t);\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Filters registered block settings to extend the block edit wrapper\n * to apply the desired styles and classnames properly.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addEditProps( settings ) {\n\tif (\n\t\t! hasColorSupport( settings ) ||\n\t\tshouldSkipSerialization( settings )\n\t) {\n\t\treturn settings;\n\t}\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\nconst getLinkColorFromAttributeValue = ( colors, value ) => {\n\tconst attributeParsed = /var:preset\\|color\\|(.+)/.exec( value );\n\tif ( attributeParsed && attributeParsed[ 1 ] ) {\n\t\treturn getColorObjectByAttributeValues( colors, attributeParsed[ 1 ] )\n\t\t\t.color;\n\t}\n\treturn value;\n};\n\n/**\n * Inspector control panel containing the color related configuration\n *\n * @param {Object} props\n *\n * @return {WPElement} Color edit element.\n */\nexport function ColorEdit( props ) {\n\tconst { name: blockName, attributes } = props;\n\t// Some color settings have a special handling for deprecated flags in `useSetting`,\n\t// so we can't unwrap them by doing const { ... } = useSetting('color')\n\t// until https://github.com/WordPress/gutenberg/issues/37094 is fixed.\n\tconst userPalette = useSetting( 'color.palette.custom' );\n\tconst themePalette = useSetting( 'color.palette.theme' );\n\tconst defaultPalette = useSetting( 'color.palette.default' );\n\tconst allSolids = useMemo(\n\t\t() => [\n\t\t\t...( userPalette || [] ),\n\t\t\t...( themePalette || [] ),\n\t\t\t...( defaultPalette || [] ),\n\t\t],\n\t\t[ userPalette, themePalette, defaultPalette ]\n\t);\n\tconst userGradientPalette = useSetting( 'color.gradients.custom' );\n\tconst themeGradientPalette = useSetting( 'color.gradients.theme' );\n\tconst defaultGradientPalette = useSetting( 'color.gradients.default' );\n\tconst allGradients = useMemo(\n\t\t() => [\n\t\t\t...( userGradientPalette || [] ),\n\t\t\t...( themeGradientPalette || [] ),\n\t\t\t...( defaultGradientPalette || [] ),\n\t\t],\n\t\t[ userGradientPalette, themeGradientPalette, defaultGradientPalette ]\n\t);\n\tconst areCustomSolidsEnabled = useSetting( 'color.custom' );\n\tconst areCustomGradientsEnabled = useSetting( 'color.customGradient' );\n\tconst isBackgroundEnabled = useSetting( 'color.background' );\n\tconst isLinkEnabled = useSetting( 'color.link' );\n\tconst isTextEnabled = useSetting( 'color.text' );\n\n\tconst solidsEnabled =\n\t\tareCustomSolidsEnabled || ! themePalette || themePalette?.length > 0;\n\n\tconst gradientsEnabled =\n\t\tareCustomGradientsEnabled ||\n\t\t! themeGradientPalette ||\n\t\tthemeGradientPalette?.length > 0;\n\n\t// Shouldn't be needed but right now the ColorGradientsPanel\n\t// can trigger both onChangeColor and onChangeBackground\n\t// synchronously causing our two callbacks to override changes\n\t// from each other.\n\tconst localAttributes = useRef( attributes );\n\tuseEffect( () => {\n\t\tlocalAttributes.current = attributes;\n\t}, [ attributes ] );\n\n\tif ( ! hasColorSupport( blockName ) ) {\n\t\treturn null;\n\t}\n\n\tconst hasLinkColor =\n\t\thasLinkColorSupport( blockName ) && isLinkEnabled && solidsEnabled;\n\tconst hasTextColor =\n\t\thasTextColorSupport( blockName ) && isTextEnabled && solidsEnabled;\n\tconst hasBackgroundColor =\n\t\thasBackgroundColorSupport( blockName ) &&\n\t\tisBackgroundEnabled &&\n\t\tsolidsEnabled;\n\tconst hasGradientColor =\n\t\thasGradientSupport( blockName ) && gradientsEnabled;\n\n\tif (\n\t\t! hasLinkColor &&\n\t\t! hasTextColor &&\n\t\t! hasBackgroundColor &&\n\t\t! hasGradientColor\n\t) {\n\t\treturn null;\n\t}\n\n\tconst { style, textColor, backgroundColor, gradient } = attributes;\n\tlet gradientValue;\n\tif ( hasGradientColor && gradient ) {\n\t\tgradientValue = getGradientValueBySlug( allGradients, gradient );\n\t} else if ( hasGradientColor ) {\n\t\tgradientValue = style?.color?.gradient;\n\t}\n\n\tconst onChangeColor = ( name ) => ( value ) => {\n\t\tconst colorObject = getColorObjectByColorValue( allSolids, value );\n\t\tconst attributeName = name + 'Color';\n\t\tconst newStyle = {\n\t\t\t...localAttributes.current.style,\n\t\t\tcolor: {\n\t\t\t\t...localAttributes.current?.style?.color,\n\t\t\t\t[ name ]: colorObject?.slug ? undefined : value,\n\t\t\t},\n\t\t};\n\n\t\tconst newNamedColor = colorObject?.slug ? colorObject.slug : undefined;\n\t\tconst newAttributes = {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t[ attributeName ]: newNamedColor,\n\t\t};\n\n\t\tprops.setAttributes( newAttributes );\n\t\tlocalAttributes.current = {\n\t\t\t...localAttributes.current,\n\t\t\t...newAttributes,\n\t\t};\n\t};\n\n\tconst onChangeGradient = ( value ) => {\n\t\tconst slug = getGradientSlugByValue( allGradients, value );\n\t\tlet newAttributes;\n\t\tif ( slug ) {\n\t\t\tconst newStyle = {\n\t\t\t\t...localAttributes.current?.style,\n\t\t\t\tcolor: {\n\t\t\t\t\t...localAttributes.current?.style?.color,\n\t\t\t\t\tgradient: undefined,\n\t\t\t\t},\n\t\t\t};\n\t\t\tnewAttributes = {\n\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t\tgradient: slug,\n\t\t\t};\n\t\t} else {\n\t\t\tconst newStyle = {\n\t\t\t\t...localAttributes.current?.style,\n\t\t\t\tcolor: {\n\t\t\t\t\t...localAttributes.current?.style?.color,\n\t\t\t\t\tgradient: value,\n\t\t\t\t},\n\t\t\t};\n\t\t\tnewAttributes = {\n\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t\tgradient: undefined,\n\t\t\t};\n\t\t}\n\t\tprops.setAttributes( newAttributes );\n\t\tlocalAttributes.current = {\n\t\t\t...localAttributes.current,\n\t\t\t...newAttributes,\n\t\t};\n\t};\n\n\tconst onChangeLinkColor = ( value ) => {\n\t\tconst colorObject = getColorObjectByColorValue( allSolids, value );\n\t\tconst newLinkColorValue = colorObject?.slug\n\t\t\t? `var:preset|color|${ colorObject.slug }`\n\t\t\t: value;\n\n\t\tconst newStyle = cleanEmptyObject(\n\t\t\timmutableSet(\n\t\t\t\tstyle,\n\t\t\t\t[ 'elements', 'link', 'color', 'text' ],\n\t\t\t\tnewLinkColorValue\n\t\t\t)\n\t\t);\n\t\tprops.setAttributes( { style: newStyle } );\n\t};\n\n\tconst enableContrastChecking =\n\t\tPlatform.OS === 'web' && ! gradient && ! style?.color?.gradient;\n\n\tconst defaultColorControls = getBlockSupport( props.name, [\n\t\tCOLOR_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\treturn (\n\t\t<ColorPanel\n\t\t\tenableContrastChecking={ enableContrastChecking }\n\t\t\tclientId={ props.clientId }\n\t\t\tenableAlpha={ true }\n\t\t\tsettings={ [\n\t\t\t\t...( hasTextColor\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Text' ),\n\t\t\t\t\t\t\t\tonColorChange: onChangeColor( 'text' ),\n\t\t\t\t\t\t\t\tcolorValue: getColorObjectByAttributeValues(\n\t\t\t\t\t\t\t\t\tallSolids,\n\t\t\t\t\t\t\t\t\ttextColor,\n\t\t\t\t\t\t\t\t\tstyle?.color?.text\n\t\t\t\t\t\t\t\t).color,\n\t\t\t\t\t\t\t\tisShownByDefault: defaultColorControls?.text,\n\t\t\t\t\t\t\t\thasValue: () => hasColor( 'text' )( props ),\n\t\t\t\t\t\t\t\tonDeselect: () => resetTextColor( props ),\n\t\t\t\t\t\t\t\tresetAllFilter: resetAllTextFilter,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [] ),\n\t\t\t\t...( hasBackgroundColor || hasGradientColor\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Background' ),\n\t\t\t\t\t\t\t\tonColorChange: hasBackgroundColor\n\t\t\t\t\t\t\t\t\t? onChangeColor( 'background' )\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\tcolorValue: getColorObjectByAttributeValues(\n\t\t\t\t\t\t\t\t\tallSolids,\n\t\t\t\t\t\t\t\t\tbackgroundColor,\n\t\t\t\t\t\t\t\t\tstyle?.color?.background\n\t\t\t\t\t\t\t\t).color,\n\t\t\t\t\t\t\t\tgradientValue,\n\t\t\t\t\t\t\t\tonGradientChange: hasGradientColor\n\t\t\t\t\t\t\t\t\t? onChangeGradient\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\tisShownByDefault:\n\t\t\t\t\t\t\t\t\tdefaultColorControls?.background,\n\t\t\t\t\t\t\t\thasValue: () =>\n\t\t\t\t\t\t\t\t\thasColor( 'background' )( props ),\n\t\t\t\t\t\t\t\tonDeselect: () =>\n\t\t\t\t\t\t\t\t\tresetBackgroundAndGradient( props ),\n\t\t\t\t\t\t\t\tresetAllFilter: clearBackgroundAndGradient,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [] ),\n\t\t\t\t...( hasLinkColor\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Link' ),\n\t\t\t\t\t\t\t\tonColorChange: onChangeLinkColor,\n\t\t\t\t\t\t\t\tcolorValue: getLinkColorFromAttributeValue(\n\t\t\t\t\t\t\t\t\tallSolids,\n\t\t\t\t\t\t\t\t\tstyle?.elements?.link?.color?.text\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tclearable: !! style?.elements?.link?.color\n\t\t\t\t\t\t\t\t\t?.text,\n\t\t\t\t\t\t\t\tisShownByDefault: defaultColorControls?.link,\n\t\t\t\t\t\t\t\thasValue: () => hasColor( 'link' )( props ),\n\t\t\t\t\t\t\t\tonDeselect: () => resetLinkColor( props ),\n\t\t\t\t\t\t\t\tresetAllFilter: resetAllLinkFilter,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [] ),\n\t\t\t] }\n\t\t/>\n\t);\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { backgroundColor, textColor } = attributes;\n\t\tconst userPalette = useSetting( 'color.palette.custom' ) || [];\n\t\tconst themePalette = useSetting( 'color.palette.theme' ) || [];\n\t\tconst defaultPalette = useSetting( 'color.palette.default' ) || [];\n\t\tconst colors = useMemo(\n\t\t\t() => [\n\t\t\t\t...( userPalette || [] ),\n\t\t\t\t...( themePalette || [] ),\n\t\t\t\t...( defaultPalette || [] ),\n\t\t\t],\n\t\t\t[ userPalette, themePalette, defaultPalette ]\n\t\t);\n\t\tif ( ! hasColorSupport( name ) || shouldSkipSerialization( name ) ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\t\tconst extraStyles = {};\n\n\t\tif ( textColor ) {\n\t\t\textraStyles.color = getColorObjectByAttributeValues(\n\t\t\t\tcolors,\n\t\t\t\ttextColor\n\t\t\t)?.color;\n\t\t}\n\t\tif ( backgroundColor ) {\n\t\t\textraStyles.backgroundColor = getColorObjectByAttributeValues(\n\t\t\t\tcolors,\n\t\t\t\tbackgroundColor\n\t\t\t)?.color;\n\t\t}\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...extraStyles,\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\nconst MIGRATION_PATHS = {\n\tlinkColor: [ [ 'style', 'elements', 'link', 'color', 'text' ] ],\n\ttextColor: [ [ 'textColor' ], [ 'style', 'color', 'text' ] ],\n\tbackgroundColor: [\n\t\t[ 'backgroundColor' ],\n\t\t[ 'style', 'color', 'background' ],\n\t],\n\tgradient: [ [ 'gradient' ], [ 'style', 'color', 'gradient' ] ],\n};\n\nexport function addTransforms( result, source, index, results ) {\n\tconst destinationBlockType = result.name;\n\tconst activeSupports = {\n\t\tlinkColor: hasLinkColorSupport( destinationBlockType ),\n\t\ttextColor: hasTextColorSupport( destinationBlockType ),\n\t\tbackgroundColor: hasBackgroundColorSupport( destinationBlockType ),\n\t\tgradient: hasGradientSupport( destinationBlockType ),\n\t};\n\treturn transformStyles(\n\t\tactiveSupports,\n\t\tMIGRATION_PATHS,\n\t\tresult,\n\t\tsource,\n\t\tindex,\n\t\tresults\n\t);\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/color/addAttribute',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/color/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/color/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/color/with-color-palette-styles',\n\twithColorPaletteStyles\n);\n\naddFilter(\n\t'blocks.switchToBlockType.transformedBlock',\n\t'core/color/addTransforms',\n\taddTransforms\n);\n"]}
|
|
@@ -15,7 +15,7 @@ import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';
|
|
|
15
15
|
import { SVG } from '@wordpress/components';
|
|
16
16
|
import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
|
|
17
17
|
import { addFilter } from '@wordpress/hooks';
|
|
18
|
-
import { useContext, createPortal } from '@wordpress/element';
|
|
18
|
+
import { useMemo, useContext, createPortal } from '@wordpress/element';
|
|
19
19
|
/**
|
|
20
20
|
* Internal dependencies
|
|
21
21
|
*/
|
|
@@ -128,17 +128,35 @@ ${selector} {
|
|
|
128
128
|
}));
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
function
|
|
131
|
+
function useMultiOriginPresets(_ref2) {
|
|
132
|
+
let {
|
|
133
|
+
presetSetting,
|
|
134
|
+
defaultSetting
|
|
135
|
+
} = _ref2;
|
|
136
|
+
const disableDefault = !useSetting(defaultSetting);
|
|
137
|
+
const userPresets = useSetting(`${presetSetting}.custom`) || EMPTY_ARRAY;
|
|
138
|
+
const themePresets = useSetting(`${presetSetting}.theme`) || EMPTY_ARRAY;
|
|
139
|
+
const defaultPresets = useSetting(`${presetSetting}.default`) || EMPTY_ARRAY;
|
|
140
|
+
return useMemo(() => [...userPresets, ...themePresets, ...(disableDefault ? EMPTY_ARRAY : defaultPresets)], [disableDefault, userPresets, themePresets, defaultPresets]);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function DuotonePanel(_ref3) {
|
|
132
144
|
var _style$color;
|
|
133
145
|
|
|
134
146
|
let {
|
|
135
147
|
attributes,
|
|
136
148
|
setAttributes
|
|
137
|
-
} =
|
|
149
|
+
} = _ref3;
|
|
138
150
|
const style = attributes === null || attributes === void 0 ? void 0 : attributes.style;
|
|
139
151
|
const duotone = style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.duotone;
|
|
140
|
-
const duotonePalette =
|
|
141
|
-
|
|
152
|
+
const duotonePalette = useMultiOriginPresets({
|
|
153
|
+
presetSetting: 'color.duotone',
|
|
154
|
+
defaultSetting: 'color.defaultDuotone'
|
|
155
|
+
});
|
|
156
|
+
const colorPalette = useMultiOriginPresets({
|
|
157
|
+
presetSetting: 'color.palette',
|
|
158
|
+
defaultSetting: 'color.defaultPalette'
|
|
159
|
+
});
|
|
142
160
|
const disableCustomColors = !useSetting('color.custom');
|
|
143
161
|
const disableCustomDuotone = !useSetting('color.customDuotone') || (colorPalette === null || colorPalette === void 0 ? void 0 : colorPalette.length) === 0 && disableCustomColors;
|
|
144
162
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/duotone.js"],"names":["classnames","colord","extend","namesPlugin","getBlockSupport","hasBlockSupport","SVG","createHigherOrderComponent","useInstanceId","addFilter","useContext","createPortal","BlockControls","__experimentalDuotoneControl","DuotoneControl","useSetting","BlockList","EMPTY_ARRAY","getValuesFromColors","colors","values","r","g","b","a","forEach","color","rgbColor","toRgb","push","DuotoneFilter","selector","id","stylesheet","visibility","position","left","overflow","join","__html","DuotonePanel","attributes","setAttributes","style","duotone","duotonePalette","colorPalette","disableCustomColors","disableCustomDuotone","length","newDuotone","newStyle","addDuotoneAttributes","settings","Object","assign","type","withDuotoneControls","BlockEdit","props","hasDuotoneSupport","name","scopeSelector","scope","scopes","split","selectors","selectorsScoped","outer","inner","trim","withDuotoneStyles","BlockListBlock","duotoneSupport","selectorsGroup","className","element","__unstableElementContext"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,MAAT,EAAiBC,MAAjB,QAA+B,QAA/B;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AAEA;AACA;AACA;;AACA,SAASC,eAAT,EAA0BC,eAA1B,QAAiD,mBAAjD;AACA,SAASC,GAAT,QAAoB,uBAApB;AACA,SAASC,0BAAT,EAAqCC,aAArC,QAA0D,oBAA1D;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,oBAAzC;AAEA;AACA;AACA;;AACA,SACCC,aADD,EAECC,4BAA4B,IAAIC,cAFjC,EAGCC,UAHD,QAIO,eAJP;AA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BjB,KAArB;AAA6B,IAAA,SAAS,EAAGgB;AAAzC,KAVD,CADD;AAcA,CAxCkD,EAyCnD,mBAzCmD,CAApD;AA4CAlE,SAAS,CACR,0BADQ,EAER,oCAFQ,EAGR2C,oBAHQ,CAAT;AAKA3C,SAAS,CACR,kBADQ,EAER,0CAFQ,EAGRgD,mBAHQ,CAAT;AAKAhD,SAAS,CACR,uBADQ,EAER,iCAFQ,EAGR8D,iBAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { SVG } from '@wordpress/components';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useContext, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockControls,\n\t__experimentalDuotoneControl as DuotoneControl,\n\tuseSetting,\n} from '../components';\nimport BlockList from '../components/block-list';\n\nconst EMPTY_ARRAY = [];\n\nextend( [ namesPlugin ] );\n\n/**\n * Convert a list of colors to an object of R, G, and B values.\n *\n * @param {string[]} colors Array of RBG color strings.\n *\n * @return {Object} R, G, and B values.\n */\nexport function getValuesFromColors( colors = [] ) {\n\tconst values = { r: [], g: [], b: [], a: [] };\n\n\tcolors.forEach( ( color ) => {\n\t\tconst rgbColor = colord( color ).toRgb();\n\t\tvalues.r.push( rgbColor.r / 255 );\n\t\tvalues.g.push( rgbColor.g / 255 );\n\t\tvalues.b.push( rgbColor.b / 255 );\n\t\tvalues.a.push( rgbColor.a );\n\t} );\n\n\treturn values;\n}\n\n/**\n * Values for the SVG `feComponentTransfer`.\n *\n * @typedef Values {Object}\n * @property {number[]} r Red values.\n * @property {number[]} g Green values.\n * @property {number[]} b Blue values.\n * @property {number[]} a Alpha values.\n */\n\n/**\n * SVG and stylesheet needed for rendering the duotone filter.\n *\n * @param {Object} props Duotone props.\n * @param {string} props.selector Selector to apply the filter to.\n * @param {string} props.id Unique id for this duotone filter.\n * @param {Values} props.values R, G, B, and A values to filter with.\n *\n * @return {WPElement} Duotone element.\n */\nfunction DuotoneFilter( { selector, id, values } ) {\n\tconst stylesheet = `\n${ selector } {\n\tfilter: url( #${ id } );\n}\n`;\n\n\treturn (\n\t\t<>\n\t\t\t<SVG\n\t\t\t\txmlnsXlink=\"http://www.w3.org/1999/xlink\"\n\t\t\t\tviewBox=\"0 0 0 0\"\n\t\t\t\twidth=\"0\"\n\t\t\t\theight=\"0\"\n\t\t\t\tfocusable=\"false\"\n\t\t\t\trole=\"none\"\n\t\t\t\tstyle={ {\n\t\t\t\t\tvisibility: 'hidden',\n\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\tleft: '-9999px',\n\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<defs>\n\t\t\t\t\t<filter id={ id }>\n\t\t\t\t\t\t<feColorMatrix\n\t\t\t\t\t\t\t// Use sRGB instead of linearRGB so transparency looks correct.\n\t\t\t\t\t\t\tcolorInterpolationFilters=\"sRGB\"\n\t\t\t\t\t\t\ttype=\"matrix\"\n\t\t\t\t\t\t\t// Use perceptual brightness to convert to grayscale.\n\t\t\t\t\t\t\tvalues=\"\n\t\t\t\t\t\t\t\t.299 .587 .114 0 0\n\t\t\t\t\t\t\t\t.299 .587 .114 0 0\n\t\t\t\t\t\t\t\t.299 .587 .114 0 0\n\t\t\t\t\t\t\t\t.299 .587 .114 0 0\n\t\t\t\t\t\t\t\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<feComponentTransfer\n\t\t\t\t\t\t\t// Use sRGB instead of linearRGB to be consistent with how CSS gradients work.\n\t\t\t\t\t\t\tcolorInterpolationFilters=\"sRGB\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<feFuncR\n\t\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\t\ttableValues={ values.r.join( ' ' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<feFuncG\n\t\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\t\ttableValues={ values.g.join( ' ' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<feFuncB\n\t\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\t\ttableValues={ values.b.join( ' ' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<feFuncA\n\t\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\t\ttableValues={ values.a.join( ' ' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</feComponentTransfer>\n\t\t\t\t\t\t<feComposite\n\t\t\t\t\t\t\t// Re-mask the image with the original transparency since the feColorMatrix above loses that information.\n\t\t\t\t\t\t\tin2=\"SourceGraphic\"\n\t\t\t\t\t\t\toperator=\"in\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</filter>\n\t\t\t\t</defs>\n\t\t\t</SVG>\n\t\t\t<style dangerouslySetInnerHTML={ { __html: stylesheet } } />\n\t\t</>\n\t);\n}\n\nfunction DuotonePanel( { attributes, setAttributes } ) {\n\tconst style = attributes?.style;\n\tconst duotone = style?.color?.duotone;\n\n\tconst duotonePalette = useSetting( 'color.duotone' ) || EMPTY_ARRAY;\n\tconst colorPalette = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\tconst disableCustomColors = ! useSetting( 'color.custom' );\n\tconst disableCustomDuotone =\n\t\t! useSetting( 'color.customDuotone' ) ||\n\t\t( colorPalette?.length === 0 && disableCustomColors );\n\n\tif ( duotonePalette?.length === 0 && disableCustomDuotone ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t<DuotoneControl\n\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\tvalue={ duotone }\n\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t...style,\n\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t...style?.color,\n\t\t\t\t\t\t\tduotone: newDuotone,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tsetAttributes( { style: newStyle } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `duotone` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addDuotoneAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, 'color.__experimentalDuotone' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default\n\t// values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include toolbar controls for duotone if the\n * block supports duotone.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst hasDuotoneSupport = hasBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ hasDuotoneSupport && <DuotonePanel { ...props } /> }\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneControls'\n);\n\n/**\n * Function that scopes a selector with another one. This works a bit like\n * SCSS nesting except the `&` operator isn't supported.\n *\n * @example\n * ```js\n * const scope = '.a, .b .c';\n * const selector = '> .x, .y';\n * const merged = scopeSelector( scope, selector );\n * // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'\n * ```\n *\n * @param {string} scope Selector to scope to.\n * @param {string} selector Original selector.\n *\n * @return {string} Scoped selector.\n */\nfunction scopeSelector( scope, selector ) {\n\tconst scopes = scope.split( ',' );\n\tconst selectors = selector.split( ',' );\n\n\tconst selectorsScoped = [];\n\tscopes.forEach( ( outer ) => {\n\t\tselectors.forEach( ( inner ) => {\n\t\t\tselectorsScoped.push( `${ outer.trim() } ${ inner.trim() }` );\n\t\t} );\n\t} );\n\n\treturn selectorsScoped.join( ', ' );\n}\n\n/**\n * Override the default block element to include duotone styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst duotoneSupport = getBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\t\tconst values = props?.attributes?.style?.color?.duotone;\n\n\t\tif ( ! duotoneSupport || ! values ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst id = `wp-duotone-${ useInstanceId( BlockListBlock ) }`;\n\n\t\t// Extra .editor-styles-wrapper specificity is needed in the editor\n\t\t// since we're not using inline styles to apply the filter. We need to\n\t\t// override duotone applied by global styles and theme.json.\n\t\tconst selectorsGroup = scopeSelector(\n\t\t\t`.editor-styles-wrapper .${ id }`,\n\t\t\tduotoneSupport\n\t\t);\n\n\t\tconst className = classnames( props?.className, id );\n\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ element &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<DuotoneFilter\n\t\t\t\t\t\t\tselector={ selectorsGroup }\n\t\t\t\t\t\t\tid={ id }\n\t\t\t\t\t\t\tvalues={ getValuesFromColors( values ) }\n\t\t\t\t\t\t/>,\n\t\t\t\t\t\telement\n\t\t\t\t\t) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/duotone/add-attributes',\n\taddDuotoneAttributes\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/duotone/with-editor-controls',\n\twithDuotoneControls\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/duotone/with-styles',\n\twithDuotoneStyles\n);\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/duotone.js"],"names":["classnames","colord","extend","namesPlugin","getBlockSupport","hasBlockSupport","SVG","createHigherOrderComponent","useInstanceId","addFilter","useMemo","useContext","createPortal","BlockControls","__experimentalDuotoneControl","DuotoneControl","useSetting","BlockList","EMPTY_ARRAY","getValuesFromColors","colors","values","r","g","b","a","forEach","color","rgbColor","toRgb","push","DuotoneFilter","selector","id","stylesheet","visibility","position","left","overflow","join","__html","useMultiOriginPresets","presetSetting","defaultSetting","disableDefault","userPresets","themePresets","defaultPresets","DuotonePanel","attributes","setAttributes","style","duotone","duotonePalette","colorPalette","disableCustomColors","disableCustomDuotone","length","newDuotone","newStyle","addDuotoneAttributes","settings","Object","assign","type","withDuotoneControls","BlockEdit","props","hasDuotoneSupport","name","scopeSelector","scope","scopes","split","selectors","selectorsScoped","outer","inner","trim","withDuotoneStyles","BlockListBlock","duotoneSupport","selectorsGroup","className","element","__unstableElementContext"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,MAAT,EAAiBC,MAAjB,QAA+B,QAA/B;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AAEA;AACA;AACA;;AACA,SAASC,eAAT,EAA0BC,eAA1B,QAAiD,mBAAjD;AACA,SAASC,GAAT,QAAoB,uBAApB;AACA,SAASC,0BAAT,EAAqCC,aAArC,QAA0D,oBAA1D;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC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,IAD+B,EAErC,6BAFqC,CAAtC;AAIA,QAAMhD,MAAM,GAAG8C,KAAH,aAAGA,KAAH,4CAAGA,KAAK,CAAElB,UAAV,+EAAG,kBAAmBE,KAAtB,oFAAG,sBAA0BxB,KAA7B,2DAAG,uBAAiCyB,OAAhD;;AAEA,MAAK,CAAE6B,cAAF,IAAoB,CAAE5D,MAA3B,EAAoC;AACnC,WAAO,cAAC,cAAD,EAAqB8C,KAArB,CAAP;AACA;;AAED,QAAMlC,EAAE,GAAI,cAAczB,aAAa,CAAEwE,cAAF,CAAoB,EAA3D,CAXkC,CAalC;AACA;AACA;;AACA,QAAME,cAAc,GAAGZ,aAAa,CAClC,2BAA2BrC,EAAI,EADG,EAEnCgD,cAFmC,CAApC;AAKA,QAAME,SAAS,GAAGnF,UAAU,CAAEmE,KAAF,aAAEA,KAAF,uBAAEA,KAAK,CAAEgB,SAAT,EAAoBlD,EAApB,CAA5B;AAEA,QAAMmD,OAAO,GAAGzE,UAAU,CAAEM,SAAS,CAACoE,wBAAZ,CAA1B;AAEA,SACC,8BACGD,OAAO,IACRxE,YAAY,CACX,cAAC,aAAD;AACC,IAAA,QAAQ,EAAGsE,cADZ;AAEC,IAAA,EAAE,EAAGjD,EAFN;AAGC,IAAA,MAAM,EAAGd,mBAAmB,CAAEE,MAAF;AAH7B,IADW,EAMX+D,OANW,CAFd,EAUC,cAAC,cAAD,eAAqBjB,KAArB;AAA6B,IAAA,SAAS,EAAGgB;AAAzC,KAVD,CADD;AAcA,CAxCkD,EAyCnD,mBAzCmD,CAApD;AA4CA1E,SAAS,CACR,0BADQ,EAER,oCAFQ,EAGRmD,oBAHQ,CAAT;AAKAnD,SAAS,CACR,kBADQ,EAER,0CAFQ,EAGRwD,mBAHQ,CAAT;AAKAxD,SAAS,CACR,uBADQ,EAER,iCAFQ,EAGRsE,iBAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { SVG } from '@wordpress/components';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useMemo, useContext, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockControls,\n\t__experimentalDuotoneControl as DuotoneControl,\n\tuseSetting,\n} from '../components';\nimport BlockList from '../components/block-list';\n\nconst EMPTY_ARRAY = [];\n\nextend( [ namesPlugin ] );\n\n/**\n * Convert a list of colors to an object of R, G, and B values.\n *\n * @param {string[]} colors Array of RBG color strings.\n *\n * @return {Object} R, G, and B values.\n */\nexport function getValuesFromColors( colors = [] ) {\n\tconst values = { r: [], g: [], b: [], a: [] };\n\n\tcolors.forEach( ( color ) => {\n\t\tconst rgbColor = colord( color ).toRgb();\n\t\tvalues.r.push( rgbColor.r / 255 );\n\t\tvalues.g.push( rgbColor.g / 255 );\n\t\tvalues.b.push( rgbColor.b / 255 );\n\t\tvalues.a.push( rgbColor.a );\n\t} );\n\n\treturn values;\n}\n\n/**\n * Values for the SVG `feComponentTransfer`.\n *\n * @typedef Values {Object}\n * @property {number[]} r Red values.\n * @property {number[]} g Green values.\n * @property {number[]} b Blue values.\n * @property {number[]} a Alpha values.\n */\n\n/**\n * SVG and stylesheet needed for rendering the duotone filter.\n *\n * @param {Object} props Duotone props.\n * @param {string} props.selector Selector to apply the filter to.\n * @param {string} props.id Unique id for this duotone filter.\n * @param {Values} props.values R, G, B, and A values to filter with.\n *\n * @return {WPElement} Duotone element.\n */\nfunction DuotoneFilter( { selector, id, values } ) {\n\tconst stylesheet = `\n${ selector } {\n\tfilter: url( #${ id } );\n}\n`;\n\n\treturn (\n\t\t<>\n\t\t\t<SVG\n\t\t\t\txmlnsXlink=\"http://www.w3.org/1999/xlink\"\n\t\t\t\tviewBox=\"0 0 0 0\"\n\t\t\t\twidth=\"0\"\n\t\t\t\theight=\"0\"\n\t\t\t\tfocusable=\"false\"\n\t\t\t\trole=\"none\"\n\t\t\t\tstyle={ {\n\t\t\t\t\tvisibility: 'hidden',\n\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\tleft: '-9999px',\n\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<defs>\n\t\t\t\t\t<filter id={ id }>\n\t\t\t\t\t\t<feColorMatrix\n\t\t\t\t\t\t\t// Use sRGB instead of linearRGB so transparency looks correct.\n\t\t\t\t\t\t\tcolorInterpolationFilters=\"sRGB\"\n\t\t\t\t\t\t\ttype=\"matrix\"\n\t\t\t\t\t\t\t// Use perceptual brightness to convert to grayscale.\n\t\t\t\t\t\t\tvalues=\"\n\t\t\t\t\t\t\t\t.299 .587 .114 0 0\n\t\t\t\t\t\t\t\t.299 .587 .114 0 0\n\t\t\t\t\t\t\t\t.299 .587 .114 0 0\n\t\t\t\t\t\t\t\t.299 .587 .114 0 0\n\t\t\t\t\t\t\t\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<feComponentTransfer\n\t\t\t\t\t\t\t// Use sRGB instead of linearRGB to be consistent with how CSS gradients work.\n\t\t\t\t\t\t\tcolorInterpolationFilters=\"sRGB\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<feFuncR\n\t\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\t\ttableValues={ values.r.join( ' ' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<feFuncG\n\t\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\t\ttableValues={ values.g.join( ' ' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<feFuncB\n\t\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\t\ttableValues={ values.b.join( ' ' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<feFuncA\n\t\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\t\ttableValues={ values.a.join( ' ' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</feComponentTransfer>\n\t\t\t\t\t\t<feComposite\n\t\t\t\t\t\t\t// Re-mask the image with the original transparency since the feColorMatrix above loses that information.\n\t\t\t\t\t\t\tin2=\"SourceGraphic\"\n\t\t\t\t\t\t\toperator=\"in\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</filter>\n\t\t\t\t</defs>\n\t\t\t</SVG>\n\t\t\t<style dangerouslySetInnerHTML={ { __html: stylesheet } } />\n\t\t</>\n\t);\n}\n\nfunction useMultiOriginPresets( { presetSetting, defaultSetting } ) {\n\tconst disableDefault = ! useSetting( defaultSetting );\n\tconst userPresets =\n\t\tuseSetting( `${ presetSetting }.custom` ) || EMPTY_ARRAY;\n\tconst themePresets =\n\t\tuseSetting( `${ presetSetting }.theme` ) || EMPTY_ARRAY;\n\tconst defaultPresets =\n\t\tuseSetting( `${ presetSetting }.default` ) || EMPTY_ARRAY;\n\treturn useMemo(\n\t\t() => [\n\t\t\t...userPresets,\n\t\t\t...themePresets,\n\t\t\t...( disableDefault ? EMPTY_ARRAY : defaultPresets ),\n\t\t],\n\t\t[ disableDefault, userPresets, themePresets, defaultPresets ]\n\t);\n}\n\nfunction DuotonePanel( { attributes, setAttributes } ) {\n\tconst style = attributes?.style;\n\tconst duotone = style?.color?.duotone;\n\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\tconst colorPalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.palette',\n\t\tdefaultSetting: 'color.defaultPalette',\n\t} );\n\tconst disableCustomColors = ! useSetting( 'color.custom' );\n\tconst disableCustomDuotone =\n\t\t! useSetting( 'color.customDuotone' ) ||\n\t\t( colorPalette?.length === 0 && disableCustomColors );\n\n\tif ( duotonePalette?.length === 0 && disableCustomDuotone ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t<DuotoneControl\n\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\tvalue={ duotone }\n\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t...style,\n\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t...style?.color,\n\t\t\t\t\t\t\tduotone: newDuotone,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tsetAttributes( { style: newStyle } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `duotone` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addDuotoneAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, 'color.__experimentalDuotone' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default\n\t// values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include toolbar controls for duotone if the\n * block supports duotone.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst hasDuotoneSupport = hasBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ hasDuotoneSupport && <DuotonePanel { ...props } /> }\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneControls'\n);\n\n/**\n * Function that scopes a selector with another one. This works a bit like\n * SCSS nesting except the `&` operator isn't supported.\n *\n * @example\n * ```js\n * const scope = '.a, .b .c';\n * const selector = '> .x, .y';\n * const merged = scopeSelector( scope, selector );\n * // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'\n * ```\n *\n * @param {string} scope Selector to scope to.\n * @param {string} selector Original selector.\n *\n * @return {string} Scoped selector.\n */\nfunction scopeSelector( scope, selector ) {\n\tconst scopes = scope.split( ',' );\n\tconst selectors = selector.split( ',' );\n\n\tconst selectorsScoped = [];\n\tscopes.forEach( ( outer ) => {\n\t\tselectors.forEach( ( inner ) => {\n\t\t\tselectorsScoped.push( `${ outer.trim() } ${ inner.trim() }` );\n\t\t} );\n\t} );\n\n\treturn selectorsScoped.join( ', ' );\n}\n\n/**\n * Override the default block element to include duotone styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst duotoneSupport = getBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\t\tconst values = props?.attributes?.style?.color?.duotone;\n\n\t\tif ( ! duotoneSupport || ! values ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst id = `wp-duotone-${ useInstanceId( BlockListBlock ) }`;\n\n\t\t// Extra .editor-styles-wrapper specificity is needed in the editor\n\t\t// since we're not using inline styles to apply the filter. We need to\n\t\t// override duotone applied by global styles and theme.json.\n\t\tconst selectorsGroup = scopeSelector(\n\t\t\t`.editor-styles-wrapper .${ id }`,\n\t\t\tduotoneSupport\n\t\t);\n\n\t\tconst className = classnames( props?.className, id );\n\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ element &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<DuotoneFilter\n\t\t\t\t\t\t\tselector={ selectorsGroup }\n\t\t\t\t\t\t\tid={ id }\n\t\t\t\t\t\t\tvalues={ getValuesFromColors( values ) }\n\t\t\t\t\t\t/>,\n\t\t\t\t\t\telement\n\t\t\t\t\t) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/duotone/add-attributes',\n\taddDuotoneAttributes\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/duotone/with-editor-controls',\n\twithDuotoneControls\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/duotone/with-styles',\n\twithDuotoneStyles\n);\n"]}
|