@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
package/build/hooks/align.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/align.js"],"names":["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":";;;;;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AASA;;AACA;;AArBA;AACA;AACA;;AAIA;AACA;AACA;;AASA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,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;;AACO,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,CAAyBC,KAAF,IACxCP,UAAU,CAACQ,QAAX,CAAqBD,KAArB,CADiB,CAAlB;AAGA,GAJD,MAIO,IAAKP,UAAU,KAAK,IAApB,EAA2B;AACjC;AACAG,IAAAA,eAAe,GAAG,CAAE,GAAGN,cAAL,CAAlB;AACA,GAHM,MAGA;AACNM,IAAAA,eAAe,GAAG,EAAlB;AACA;;AAED,MACC,CAAED,cAAF,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AY,GAAGf,KAAK,CAACe,YAAzB;;AACA,MACC7B,eAAe,CAAC8B,IAAhB,CAAwBC,SAAF,IAAiBA,SAAS,CAAChB,IAAV,KAAmBN,KAA1D,CADD,EAEE;AACDoB,IAAAA,YAAY,GAAG,EAAE,GAAGA,YAAL;AAAmB,oBAAcpB;AAAjC,KAAf;AACA;;AAED,SAAO,4BAAC,cAAD,6BAAqBK,KAArB;AAA6B,IAAA,YAAY,EAAGe;AAA5C,KAAP;AACA,CA1B2B,CAAtB;AA6BP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASG,gBAAT,CAA2BlB,KAA3B,EAAkCO,SAAlC,EAA6Cb,UAA7C,EAA0D;AAChE,QAAM;AAAEC,IAAAA;AAAF,MAAYD,UAAlB;AACA,QAAMX,UAAU,GAAG,6BAAiBwB,SAAjB,EAA4B,OAA5B,CAAnB;AACA,QAAMvB,mBAAmB,GAAG,6BAAiBuB,SAAjB,EAA4B,WAA5B,EAAyC,IAAzC,CAA5B,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,GAAkB,yBAAa,QAAQzB,KAAO,EAA5B,EAA+BK,KAAK,CAACoB,SAArC,CAAlB;AACA;;AAED,SAAOpB,KAAP;AACA;;AAED,sBACC,0BADD,EAEC,yBAFD,EAGCR,YAHD;AAKA,sBACC,uBADD,EAEC,mCAFD,EAGCoB,aAHD;AAKA,sBACC,kBADD,EAEC,yCAFD,EAGCd,mBAHD;AAKA,sBACC,kCADD,EAEC,6BAFD,EAGCoB,gBAHD","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":["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":";;;;;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AASA;;AACA;;AArBA;AACA;AACA;;AAIA;AACA;AACA;;AASA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,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;;AACO,SA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CAArB;;AAIA,MAAKwB,YAAL,EAAoB;AACnBnB,IAAAA,KAAK,CAACoB,SAAN,GAAkB,yBAAa,QAAQzB,KAAO,EAA5B,EAA+BK,KAAK,CAACoB,SAArC,CAAlB;AACA;;AAED,SAAOpB,KAAP;AACA;;AAED,sBACC,0BADD,EAEC,yBAFD,EAGCR,YAHD;AAKA,sBACC,uBADD,EAEC,mCAFD,EAGCoB,aAHD;AAKA,sBACC,kBADD,EAEC,yCAFD,EAGCd,mBAHD;AAKA,sBACC,kCADD,EAEC,6BAFD,EAGCoB,gBAHD","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"]}
|
package/build/hooks/anchor.js
CHANGED
|
@@ -51,7 +51,7 @@ const ANCHOR_REGEX = /[\s#]/g;
|
|
|
51
51
|
*/
|
|
52
52
|
|
|
53
53
|
function addAttribute(settings) {
|
|
54
|
-
//
|
|
54
|
+
// Allow blocks to specify their own attribute definition with default values if needed.
|
|
55
55
|
if ((0, _lodash.has)(settings.attributes, ['anchor', 'type'])) {
|
|
56
56
|
return settings;
|
|
57
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"names":["ANCHOR_REGEX","addAttribute","settings","attributes","anchor","type","source","attribute","selector","withInspectorControl","BlockEdit","props","hasAnchor","name","isSelected","isWeb","Platform","OS","textControl","nextValue","replace","setAttributes","addSaveProps","extraProps","blockType","id"],"mappings":";;;;;;;;;AAaA;;AAVA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA,MAAMA,YAAY,GAAG,QAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,YAAT,CAAuBC,QAAvB,EAAkC;AACxC;AACA,MAAK,iBAAKA,QAAQ,CAACC,UAAd,EAA0B,CAAE,QAAF,EAAY,MAAZ,CAA1B,CAAL,EAAwD;AACvD,WAAOD,QAAP;AACA;;AACD,MAAK,6BAAiBA,QAAjB,EAA2B,QAA3B,CAAL,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;;;AACO,MAAMO,oBAAoB,GAAG,yCACjCC,SAAF,IAAiB;AAChB,SAASC,KAAF,IAAa;AACnB,UAAMC,SAAS,GAAG,6BAAiBD,KAAK,CAACE,IAAvB,EAA6B,QAA7B,CAAlB;;AAEA,QAAKD,SAAS,IAAID,KAAK,CAACG,UAAxB,EAAqC;AACpC,YAAMC,KAAK,GAAGC,kBAASC,EAAT,KAAgB,KA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CrB,UAA9C,EAA2D;AACjE,MAAK,6BAAiBqB,SAAjB,EAA4B,QAA5B,CAAL,EAA8C;AAC7CD,IAAAA,UAAU,CAACE,EAAX,GAAgBtB,UAAU,CAACC,MAAX,KAAsB,EAAtB,GAA2B,IAA3B,GAAkCD,UAAU,CAACC,MAA7D;AACA;;AAED,SAAOmB,UAAP;AACA;;AAED,sBAAW,0BAAX,EAAuC,uBAAvC,EAAgEtB,YAAhE;AACA,sBACC,kBADD,EAEC,2CAFD,EAGCQ,oBAHD;AAKA,sBACC,kCADD,EAEC,wBAFD,EAGCa,YAHD","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":["ANCHOR_REGEX","addAttribute","settings","attributes","anchor","type","source","attribute","selector","withInspectorControl","BlockEdit","props","hasAnchor","name","isSelected","isWeb","Platform","OS","textControl","nextValue","replace","setAttributes","addSaveProps","extraProps","blockType","id"],"mappings":";;;;;;;;;AAaA;;AAVA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA,MAAMA,YAAY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\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"]}
|
package/build/hooks/border.js
CHANGED
|
@@ -47,14 +47,13 @@ function BorderPanel(props) {
|
|
|
47
47
|
const {
|
|
48
48
|
clientId
|
|
49
49
|
} = props;
|
|
50
|
-
const isDisabled = useIsBorderDisabled(props);
|
|
51
|
-
const isSupported = hasBorderSupport(props.name);
|
|
52
50
|
const isColorSupported = (0, _useSetting.default)('border.color') && hasBorderSupport(props.name, 'color');
|
|
53
51
|
const isRadiusSupported = (0, _useSetting.default)('border.radius') && hasBorderSupport(props.name, 'radius');
|
|
54
52
|
const isStyleSupported = (0, _useSetting.default)('border.style') && hasBorderSupport(props.name, 'style');
|
|
55
53
|
const isWidthSupported = (0, _useSetting.default)('border.width') && hasBorderSupport(props.name, 'width');
|
|
54
|
+
const isDisabled = [!isColorSupported, !isRadiusSupported, !isStyleSupported, !isWidthSupported].every(Boolean);
|
|
56
55
|
|
|
57
|
-
if (isDisabled
|
|
56
|
+
if (isDisabled) {
|
|
58
57
|
return null;
|
|
59
58
|
}
|
|
60
59
|
|
|
@@ -154,17 +153,6 @@ function shouldSkipSerialization(blockType) {
|
|
|
154
153
|
const support = (0, _blocks.getBlockSupport)(blockType, BORDER_SUPPORT_KEY);
|
|
155
154
|
return support === null || support === void 0 ? void 0 : support.__experimentalSkipSerialization;
|
|
156
155
|
}
|
|
157
|
-
/**
|
|
158
|
-
* Determines if all border support features have been disabled.
|
|
159
|
-
*
|
|
160
|
-
* @return {boolean} If border support is completely disabled.
|
|
161
|
-
*/
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const useIsBorderDisabled = () => {
|
|
165
|
-
const configs = [!(0, _useSetting.default)('border.color'), !(0, _useSetting.default)('border.radius'), !(0, _useSetting.default)('border.style'), !(0, _useSetting.default)('border.width')];
|
|
166
|
-
return configs.every(Boolean);
|
|
167
|
-
};
|
|
168
156
|
/**
|
|
169
157
|
* Returns a new style object where the specified border attribute has been
|
|
170
158
|
* removed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/border.js"],"names":["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","Platform","OS","support","shouldSkipSerialization","blockType","__experimentalSkipSerialization","configs","every","Boolean","removeBorder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,aAGAA,OAHA,eAGAA,OAAO,CAAEX,KAJF,CAAR;AAMA;;AAED,SAAO,CAAC,EAAEW,OAAF,aAAEA,OAAF,eAAEA,OAAO,CAAIH,OAAJ,CAAT,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,uBAAT,CAAkCC,SAAlC,EAA8C;AACpD,QAAMF,OAAO,GAAG,6BAAiBE,SAAjB,EAA4B/B,kBAA5B,CAAhB;AAEA,SAAO6B,OAAP,aAAOA,OAAP,uBAAOA,OAAO,CAAEG,+BAAhB;AACA;AAED;AACA;AACA;AACA;AACA;;;AACA,MAAM3B,mBAAmB,GAAG,MAAM;AACjC,QAAM4B,OAAO,GAAG,CACf,CAAE,yBAAY,cAAZ,CADa,EAEf,CAAE,yBAAY,eAAZ,CAFa,EAGf,CAAE,yBAAY,cAAZ,CAHa,EAIf,CAAE,yBAAY,cAAZ,CAJa,CAAhB;AAOA,SAAOA,OAAO,CAACC,KAAR,CAAeC,OAAf,CAAP;AACA,CATD;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,qBAAT,CAAgClB,KAAhC,EAAuCmB,SAAvC,EAAmD;AACzD,SAAO,6BAAkB,EACxB,GAAGnB,KADqB;AAExBC,IAAAA,MAAM,EAAE,EACP,IAAGD,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEC,MAAV,CADO;AAEP,OAAEkB,SAAF,GAAejB;AAFR;AAFgB,GAAlB,CAAP;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":["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","Platform","OS","support","shouldSkipSerialization","blockType","__experimentalSkipSerialization","removeBorderAttribute","attribute"],"mappings":";;;;;;;;;;;;;AAKA;;AAFA;;AACA;;AAEA;;AAKA;;AAKA;;AAKA;;AAKA;;AAKA;;AACA;;AACA;;AAjCA;AACA;AACA;;AAMA;AACA;AACA;AAyBO,MAAMA,kBAAkB,GAAG,sBAA3B;;;AAEA,SAASC,WAAT,CAAsBC,KAAtB,EAA8B;AACpC,QAAM;AAAEC,IAAAA;AAAF,MAAeD,KAArB;AAEA,QAAME,gBAAgB,GACrB,yBAAY,cAAZ,KAAgCC,gBAAgB,CAAEH,KAAK,CAACI,IAAR,EAAc,OAAd,CADjD;AAGA,QAAMC,iBAAiB,GACtB,yBAAY,eAAZ,KACAF,gBAAgB,CAAEH,KAAK,CAACI,IAAR,EAAc,QAAd,CAFjB;AAIA,QAAME,gBAAgB,GACrB,yBAAY,cAAZ,KAAgCH,gBAAgB,CAAEH,KAAK,CAACI,IAAR,EAAc,OAAd,CADjD;AAGA,QAAMG,gBAAgB,GACrB,yBAAY,cAAZ,KAAgCJ,gBAAgB,CAAEH,KAAK,CAACI,IAAR,EAAc,OAAd,CADjD;AAGA,QAAMI,UAAU,GAAG,CAClB,CAAEN,gBADgB,EAElB,CAAEG,iBAFgB,EAGlB,CAAEC,gBAHgB,EAIlB,CAAEC,gBAJgB,EAKjBE,KALiB,CAKVC,OALU,CAAnB;;AAOA,MAAKF,UAAL,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,QAAMG,qBAAqB,GAAG,6BAAiBX,KAAK,CAACI,IAAvB,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5B,CAAhB;;AAEA,MAAK6B,OAAO,KAAK,IAAjB,EAAwB;AACvB,WAAO,IAAP;AACA;;AAED,MAAKH,OAAO,KAAK,KAAjB,EAAyB;AACxB,WAAO,CAAC,EACPG,OAAO,SAAP,IAAAA,OAAO,WAAP,IAAAA,OAAO,CAAEP,KAAT,IACAO,OADA,aACAA,OADA,eACAA,OAAO,CAAEL,MADT,IAEAK,OAFA,aAEAA,OAFA,eAEAA,OAAO,CAAER,KAFT,IAGAQ,OAHA,aAGAA,OAHA,eAGAA,OAAO,CAAEX,KAJF,CAAR;AAMA;;AAED,SAAO,CAAC,EAAEW,OAAF,aAAEA,OAAF,eAAEA,OAAO,CAAIH,OAAJ,CAAT,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,uBAAT,CAAkCC,SAAlC,EAA8C;AACpD,QAAMF,OAAO,GAAG,6BAAiBE,SAAjB,EAA4B/B,kBAA5B,CAAhB;AAEA,SAAO6B,OAAP,aAAOA,OAAP,uBAAOA,OAAO,CAAEG,+BAAhB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,qBAAT,CAAgCf,KAAhC,EAAuCgB,SAAvC,EAAmD;AACzD,SAAO,6BAAkB,EACxB,GAAGhB,KADqB;AAExBC,IAAAA,MAAM,EAAE,EACP,IAAGD,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEC,MAAV,CADO;AAEP,OAAEe,SAAF,GAAed;AAFR;AAFgB,GAAlB,CAAP;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"]}
|
package/build/hooks/color.js
CHANGED
|
@@ -235,7 +235,7 @@ const resetBackgroundAndGradient = _ref3 => {
|
|
|
235
235
|
function addAttributes(settings) {
|
|
236
236
|
if (!hasColorSupport(settings)) {
|
|
237
237
|
return settings;
|
|
238
|
-
} //
|
|
238
|
+
} // Allow blocks to specify their own attribute definition with default values if needed.
|
|
239
239
|
|
|
240
240
|
|
|
241
241
|
if (!settings.attributes.backgroundColor) {
|
|
@@ -294,7 +294,7 @@ function addSaveProps(props, blockType, attributes) {
|
|
|
294
294
|
const gradientClass = (0, _gradients.__experimentalGetGradientClass)(gradient);
|
|
295
295
|
const textClass = (0, _colors.getColorClassName)('color', textColor);
|
|
296
296
|
const newClassName = (0, _classnames.default)(props.className, textClass, gradientClass, {
|
|
297
|
-
// Don't apply the background class if there's a custom gradient
|
|
297
|
+
// Don't apply the background class if there's a custom gradient.
|
|
298
298
|
[backgroundClass]: (!hasGradient || !(style !== null && style !== void 0 && (_style$color = style.color) !== null && _style$color !== void 0 && _style$color.gradient)) && !!backgroundClass,
|
|
299
299
|
'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),
|
|
300
300
|
'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)),
|
package/build/hooks/color.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/color.js"],"names":["COLOR_SUPPORT_KEY","hasColorSupport","blockType","colorSupport","link","gradient","background","text","shouldSkipSerialization","__experimentalSkipSerialization","hasLinkColorSupport","Platform","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":";;;;;;;;;;;;;;AAYA;;;;AATA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AAKA;;AAKA;;AAKA;;AACA;;AACA;;AA9BA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;AAeO,MAAMA,iBAAiB,GAAG,OAA1B;;;AAEP,MAAMC,eAAe,GAAKC,SAAF,IAAiB;AACxC,QAAMC,YAAY,GAAG,6BAAiBD,SAAjB,EAA4BF,iBAA5B,CAArB;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,GAAG,6BAAiBD,SAAjB,EAA4BF,iBAA5B,CAArB;AAEA,SAAOG,YAAP,aAAOA,YAAP,uBAAOA,YAAY,CAAEM,+BAArB;AACA,CAJD;;AAMA,MAAMC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E,CAChB,CAAE,iBAAF,CADgB,EAEhB,CAAE,OAAF,EAAW,OAAX,EAAoB,YAApB,CAFgB,CAHM;AAOvBhB,EAAAA,QAAQ,EAAE,CAAE,CAAE,UAAF,CAAF,EAAkB,CAAE,OAAF,EAAW,OAAX,EAAoB,UAApB,CAAlB;AAPa,CAAxB;;AAUO,SAASwG,aAAT,CAAwBC,MAAxB,EAAgCC,MAAhC,EAAwCC,KAAxC,EAA+CC,OAA/C,EAAyD;AAC/D,QAAMC,oBAAoB,GAAGJ,MAAM,CAAC5F,IAApC;AACA,QAAMiG,cAAc,GAAG;AACtBP,IAAAA,SAAS,EAAElG,mBAAmB,CAAEwG,oBAAF,CADR;AAEtBpF,IAAAA,SAAS,EAAEd,mBAAmB,CAAEkG,oBAAF,CAFR;AAGtB7F,IAAAA,eAAe,EAAEN,yBAAyB,CAAEmG,oBAAF,CAHpB;AAItB7G,IAAAA,QAAQ,EAAEQ,kBAAkB,CAAEqG,oBAAF;AAJN,GAAvB;AAMA,SAAO,4BACNC,cADM,EAENR,eAFM,EAGNG,MAHM,EAINC,MAJM,EAKNC,KALM,EAMNC,OANM,CAAP;AAQA;;AAED,sBACC,0BADD,EAEC,yBAFD,EAGC7E,aAHD;AAMA,sBACC,kCADD,EAEC,yBAFD,EAGCK,YAHD;AAMA,sBACC,0BADD,EAEC,yBAFD,EAGCO,YAHD;AAMA,sBACC,uBADD,EAEC,sCAFD,EAGCuD,sBAHD;AAMA,sBACC,2CADD,EAEC,0BAFD,EAGCM,aAHD","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":["COLOR_SUPPORT_KEY","hasColorSupport","blockType","colorSupport","link","gradient","background","text","shouldSkipSerialization","__experimentalSkipSerialization","hasLinkColorSupport","Platform","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":";;;;;;;;;;;;;;AAYA;;;;AATA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AAKA;;AAKA;;AAKA;;AACA;;AACA;;AA9BA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;AAeO,MAAMA,iBAAiB,GAAG,OAA1B;;;AAEP,MAAMC,eAAe,GAAKC,SAAF,IAAiB;AACxC,QAAMC,YAAY,GAAG,6BAAiBD,SAAjB,EAA4BF,iBAA5B,CAArB;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,GAAG,6BAAiBD,SAAjB,EAA4BF,iBAA5B,CAArB;AAEA,SAAOG,YAAP,aAAOA,YAAP,uBAAOA,YAAY,CAAEM,+BAArB;AACA,CAJD;;AAMA,MAAMC,mBAAmB,GAAKR,SAAF,IAAiB;AAC5C,MAAKS,kBAASC,EAAT,KAAgB,KAArB,EAA6B;AAC5B,WAAO,KAAP;AACA;;AAED,QAAMT,YAAY,GAAG,6BAAiBD,SAAjB,EAA4BF,iBAA5B,CAArB;AAEA,SAAO,sBAAUG,YAAV,KAA4B,CAAC,CAAEA,YAAY,CAACC,IAAnD;AACA,CARD;;AAUA,MAAMS,kBAAkB,GAAKX,SAAF,IAAiB;AAC3C,QAAMC,YAAY,GAAG,6BAAiBD,SAAjB,EAA4BF,iBAA5B,CAArB;AAEA,SAAO,sBAAUG,YAAV,KAA4B,CAAC,CAAEA,YAAY,CAACW,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EwG,oBAAF,CADR;AAEtBpF,IAAAA,SAAS,EAAEd,mBAAmB,CAAEkG,oBAAF,CAFR;AAGtB7F,IAAAA,eAAe,EAAEN,yBAAyB,CAAEmG,oBAAF,CAHpB;AAItB7G,IAAAA,QAAQ,EAAEQ,kBAAkB,CAAEqG,oBAAF;AAJN,GAAvB;AAMA,SAAO,4BACNC,cADM,EAENR,eAFM,EAGNG,MAHM,EAINC,MAJM,EAKNC,KALM,EAMNC,OANM,CAAP;AAQA;;AAED,sBACC,0BADD,EAEC,yBAFD,EAGC7E,aAHD;AAMA,sBACC,kCADD,EAEC,yBAFD,EAGCK,YAHD;AAMA,sBACC,0BADD,EAEC,yBAFD,EAGCO,YAHD;AAMA,sBACC,uBADD,EAEC,sCAFD,EAGCuD,sBAHD;AAMA,sBACC,2CADD,EAEC,0BAFD,EAGCM,aAHD","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"]}
|
package/build/hooks/duotone.js
CHANGED
|
@@ -147,17 +147,35 @@ ${selector} {
|
|
|
147
147
|
}));
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
function
|
|
150
|
+
function useMultiOriginPresets(_ref2) {
|
|
151
|
+
let {
|
|
152
|
+
presetSetting,
|
|
153
|
+
defaultSetting
|
|
154
|
+
} = _ref2;
|
|
155
|
+
const disableDefault = !(0, _components2.useSetting)(defaultSetting);
|
|
156
|
+
const userPresets = (0, _components2.useSetting)(`${presetSetting}.custom`) || EMPTY_ARRAY;
|
|
157
|
+
const themePresets = (0, _components2.useSetting)(`${presetSetting}.theme`) || EMPTY_ARRAY;
|
|
158
|
+
const defaultPresets = (0, _components2.useSetting)(`${presetSetting}.default`) || EMPTY_ARRAY;
|
|
159
|
+
return (0, _element.useMemo)(() => [...userPresets, ...themePresets, ...(disableDefault ? EMPTY_ARRAY : defaultPresets)], [disableDefault, userPresets, themePresets, defaultPresets]);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function DuotonePanel(_ref3) {
|
|
151
163
|
var _style$color;
|
|
152
164
|
|
|
153
165
|
let {
|
|
154
166
|
attributes,
|
|
155
167
|
setAttributes
|
|
156
|
-
} =
|
|
168
|
+
} = _ref3;
|
|
157
169
|
const style = attributes === null || attributes === void 0 ? void 0 : attributes.style;
|
|
158
170
|
const duotone = style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.duotone;
|
|
159
|
-
const duotonePalette = (
|
|
160
|
-
|
|
171
|
+
const duotonePalette = useMultiOriginPresets({
|
|
172
|
+
presetSetting: 'color.duotone',
|
|
173
|
+
defaultSetting: 'color.defaultDuotone'
|
|
174
|
+
});
|
|
175
|
+
const colorPalette = useMultiOriginPresets({
|
|
176
|
+
presetSetting: 'color.palette',
|
|
177
|
+
defaultSetting: 'color.defaultPalette'
|
|
178
|
+
});
|
|
161
179
|
const disableCustomColors = !(0, _components2.useSetting)('color.custom');
|
|
162
180
|
const disableCustomDuotone = !(0, _components2.useSetting)('color.customDuotone') || (colorPalette === null || colorPalette === void 0 ? void 0 : colorPalette.length) === 0 && disableCustomColors;
|
|
163
181
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/duotone.js"],"names":["EMPTY_ARRAY","namesPlugin","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","BlockList","__unstableElementContext"],"mappings":";;;;;;;;;AAcA;;;;AAXA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAMA;;AAKA;;AAxBA;AACA;AACA;;AAKA;AACA;AACA;;AAOA;AACA;AACA;AAQA,MAAMA,WAAW,GAAG,EAApB;AAEA,oBAAQ,CAAEC,cAAF,CAAR;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,mBAAT,GAA4C;AAAA,MAAdC,MAAc,uEAAL,EAAK;AAClD,QAAMC,MAAM,GAAG;AAAEC,IAAAA,CAAC,EAAE,EAAL;AAASC,IAAAA,CAAC,EAAE,EAAZ;AAAgBC,IAAAA,CAAC,EAAE,EAAnB;AAAuBC,IAAAA,CAAC,EAAE;AAA1B,GAAf;AAEAL,EAAAA,MAAM,CAACM,OAAP,CAAkBC,KAAF,IAAa;AAC5B,UAAMC,QAAQ,GAAG,oBAAQD,KAAR,EAAgBE,KAAhB,EAAjB;AACAR,IAAAA,MAAM,CAACC,CAAP,CAASQ,IAAT,CAAeF,QAAQ,CAACN,CAAT,GAAa,GAA5B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QAAM3B,EAAE,GAAI,cAAc,4BAAewC,cAAf,CAAiC,EAA3D,CAXkC,CAalC;AACA;AACA;;AACA,QAAME,cAAc,GAAGZ,aAAa,CAClC,2BAA2B9B,EAAI,EADG,EAEnCyC,cAFmC,CAApC;AAKA,QAAME,SAAS,GAAG,yBAAYhB,KAAZ,aAAYA,KAAZ,uBAAYA,KAAK,CAAEgB,SAAnB,EAA8B3C,EAA9B,CAAlB;AAEA,QAAM4C,OAAO,GAAG,yBAAYC,mBAAUC,wBAAtB,CAAhB;AAEA,SACC,qDACGF,OAAO,IACR,2BACC,4BAAC,aAAD;AACC,IAAA,QAAQ,EAAGF,cADZ;AAEC,IAAA,EAAE,EAAG1C,EAFN;AAGC,IAAA,MAAM,EAAGd,mBAAmB,CAAEE,MAAF;AAH7B,IADD,EAMCwD,OAND,CAFF,EAUC,4BAAC,cAAD,6BAAqBjB,KAArB;AAA6B,IAAA,SAAS,EAAGgB;AAAzC,KAVD,CADD;AAcA,CAxCwB,EAyCzB,mBAzCyB,CAA1B;AA4CA,sBACC,0BADD,EAEC,oCAFD,EAGCvB,oBAHD;AAKA,sBACC,kBADD,EAEC,0CAFD,EAGCK,mBAHD;AAKA,sBACC,uBADD,EAEC,iCAFD,EAGCc,iBAHD","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":["EMPTY_ARRAY","namesPlugin","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","BlockList","__unstableElementContext"],"mappings":";;;;;;;;;AAcA;;;;AAXA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAMA;;AAKA;;AAxBA;AACA;AACA;;AAKA;AACA;AACA;;AAOA;AACA;AACA;AAQA,MAAMA,WAAW,GAAG,EAApB;AAEA,oBAAQ,CAAEC,cAAF,CAAR;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,mBAAT,GAA4C;AAAA,MAAdC,MAAc,uEAAL,EAAK;AAClD,QAAMC,MAAM,GAAG;AAAEC,IAAAA,CAAC,EAAE,EAAL;AAASC,IAAAA,CAAC,EAAE,EAAZ;AAAgBC,IAAAA,CAAC,EAAE,EAAnB;AAAuBC,IAAAA,CAAC,EAAE;AAA1B,GAAf;AAEAL,EAAAA,MAAM,CAACM,OAAP,CAAkBC,KAAF,IAAa;AAC5B,UAAMC,QAAQ,GAAG,oBAAQD,KAAR,EAAgBE,KAAhB,EAAjB;AACAR,IAAAA,MAAM,CAACC,CAAP,CAASQ,IAAT,CAAeF,QAAQ,CAACN,CAAT,GAAa,GAA5B;AACAD,IAAAA,MAAM,CAACE,CAAP,CAASO,IAAT,CAAeF,QAAQ,CAACL,CAAT,GAAa,GAA5B;AACAF,IAAAA,MAAM,CAACG,CAAP,CAASM,IAAT,CAAeF,QAAQ,CAACJ,CAAT,GAAa,GAA5B;AACAH,IAAAA,MAAM,CAACI,CAAP,CAASK,IAAT,CAAeF,QAAQ,CAACH,CAAxB;AACA,GAND;AAQA,SAAOJ,MAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASU,aAAT,OAAmD;AAAA,MAA3B;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,EAAZ;AAAgBZ,IAAAA;AAAhB,GAA2B;AAClD,QAAMa,UAAU,GAAI;AACrB,EAAGF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BE,KAAtB,oFAAG,sBAA0BxB,KAA7B,2DAAG,uBAAiCyB,OAAhD;;AAEA,MAAK,CAAE6B,cAAF,IAAoB,CAAE5D,MAA3B,EAAoC;AACnC,WAAO,4BAAC,cAAD,EAAqB8C,KAArB,CAAP;AACA;;AAED,QAAMlC,EAAE,GAAI,cAAc,4BAAe+C,cAAf,CAAiC,EAA3D,CAXkC,CAalC;AACA;AACA;;AACA,QAAME,cAAc,GAAGZ,aAAa,CAClC,2BAA2BrC,EAAI,EADG,EAEnCgD,cAFmC,CAApC;AAKA,QAAME,SAAS,GAAG,yBAAYhB,KAAZ,aAAYA,KAAZ,uBAAYA,KAAK,CAAEgB,SAAnB,EAA8BlD,EAA9B,CAAlB;AAEA,QAAMmD,OAAO,GAAG,yBAAYC,mBAAUC,wBAAtB,CAAhB;AAEA,SACC,qDACGF,OAAO,IACR,2BACC,4BAAC,aAAD;AACC,IAAA,QAAQ,EAAGF,cADZ;AAEC,IAAA,EAAE,EAAGjD,EAFN;AAGC,IAAA,MAAM,EAAGd,mBAAmB,CAAEE,MAAF;AAH7B,IADD,EAMC+D,OAND,CAFF,EAUC,4BAAC,cAAD,6BAAqBjB,KAArB;AAA6B,IAAA,SAAS,EAAGgB;AAAzC,KAVD,CADD;AAcA,CAxCwB,EAyCzB,mBAzCyB,CAA1B;AA4CA,sBACC,0BADD,EAEC,oCAFD,EAGCvB,oBAHD;AAKA,sBACC,kBADD,EAEC,0CAFD,EAGCK,mBAHD;AAKA,sBACC,uBADD,EAEC,iCAFD,EAGCc,iBAHD","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"]}
|
|
@@ -30,15 +30,15 @@ var _blocks = require("@wordpress/blocks");
|
|
|
30
30
|
* @return {Object} Filtered props applied to save element.
|
|
31
31
|
*/
|
|
32
32
|
function addGeneratedClassName(extraProps, blockType) {
|
|
33
|
-
// Adding the generated className
|
|
33
|
+
// Adding the generated className.
|
|
34
34
|
if ((0, _blocks.hasBlockSupport)(blockType, 'className', true)) {
|
|
35
35
|
if (typeof extraProps.className === 'string') {
|
|
36
36
|
// We have some extra classes and want to add the default classname
|
|
37
|
-
// We use uniq to prevent duplicate classnames
|
|
37
|
+
// We use uniq to prevent duplicate classnames.
|
|
38
38
|
extraProps.className = (0, _lodash.uniq)([(0, _blocks.getBlockDefaultClassName)(blockType.name), ...extraProps.className.split(' ')]).join(' ').trim();
|
|
39
39
|
} else {
|
|
40
40
|
// There is no string in the className variable,
|
|
41
|
-
// so we just dump the default name in there
|
|
41
|
+
// so we just dump the default name in there.
|
|
42
42
|
extraProps.className = (0, _blocks.getBlockDefaultClassName)(blockType.name);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/generated-class-name.js"],"names":["addGeneratedClassName","extraProps","blockType","className","name","split","join","trim"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,qBAAT,CAAgCC,UAAhC,EAA4CC,SAA5C,EAAwD;AAC9D;AACA,MAAK,6BAAiBA,SAAjB,EAA4B,WAA5B,EAAyC,IAAzC,CAAL,EAAuD;AACtD,QAAK,OAAOD,UAAU,CAACE,SAAlB,KAAgC,QAArC,EAAgD;AAC/C;AACA;AAEAF,MAAAA,UAAU,CAACE,SAAX,GAAuB,kBAAM,CAC5B,sCAA0BD,SAAS,CAACE,IAApC,CAD4B,EAE5B,GAAGH,UAAU,CAACE,SAAX,CAAqBE,KAArB,CAA4B,GAA5B,CAFyB,CAAN,EAIrBC,IAJqB,CAIf,GAJe,EAKrBC,IALqB,EAAvB;AAMA,KAVD,MAUO;AACN;AACA;AACAN,MAAAA,UAAU,CAACE,SAAX,GAAuB,sCAA0BD,SAAS,CAACE,IAApC,CAAvB;AACA;AACD;;AACD,SAAOH,UAAP;AACA;;AAED,sBACC,kCADD,EAEC,sCAFD,EAGCD,qBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport { uniq } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport, getBlockDefaultClassName } from '@wordpress/blocks';\n\n/**\n * Override props assigned to save component to inject generated className if\n * block supports it. 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 *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addGeneratedClassName( extraProps, blockType ) {\n\t// Adding the generated className
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/generated-class-name.js"],"names":["addGeneratedClassName","extraProps","blockType","className","name","split","join","trim"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,qBAAT,CAAgCC,UAAhC,EAA4CC,SAA5C,EAAwD;AAC9D;AACA,MAAK,6BAAiBA,SAAjB,EAA4B,WAA5B,EAAyC,IAAzC,CAAL,EAAuD;AACtD,QAAK,OAAOD,UAAU,CAACE,SAAlB,KAAgC,QAArC,EAAgD;AAC/C;AACA;AAEAF,MAAAA,UAAU,CAACE,SAAX,GAAuB,kBAAM,CAC5B,sCAA0BD,SAAS,CAACE,IAApC,CAD4B,EAE5B,GAAGH,UAAU,CAACE,SAAX,CAAqBE,KAArB,CAA4B,GAA5B,CAFyB,CAAN,EAIrBC,IAJqB,CAIf,GAJe,EAKrBC,IALqB,EAAvB;AAMA,KAVD,MAUO;AACN;AACA;AACAN,MAAAA,UAAU,CAACE,SAAX,GAAuB,sCAA0BD,SAAS,CAACE,IAApC,CAAvB;AACA;AACD;;AACD,SAAOH,UAAP;AACA;;AAED,sBACC,kCADD,EAEC,sCAFD,EAGCD,qBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport { uniq } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport, getBlockDefaultClassName } from '@wordpress/blocks';\n\n/**\n * Override props assigned to save component to inject generated className if\n * block supports it. 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 *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addGeneratedClassName( extraProps, blockType ) {\n\t// Adding the generated className.\n\tif ( hasBlockSupport( blockType, 'className', true ) ) {\n\t\tif ( typeof extraProps.className === 'string' ) {\n\t\t\t// We have some extra classes and want to add the default classname\n\t\t\t// We use uniq to prevent duplicate classnames.\n\n\t\t\textraProps.className = uniq( [\n\t\t\t\tgetBlockDefaultClassName( blockType.name ),\n\t\t\t\t...extraProps.className.split( ' ' ),\n\t\t\t] )\n\t\t\t\t.join( ' ' )\n\t\t\t\t.trim();\n\t\t} else {\n\t\t\t// There is no string in the className variable,\n\t\t\t// so we just dump the default name in there.\n\t\t\textraProps.className = getBlockDefaultClassName( blockType.name );\n\t\t}\n\t}\n\treturn extraProps;\n}\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/generated-class-name/save-props',\n\taddGeneratedClassName\n);\n"]}
|
package/build/hooks/lock.js
CHANGED
|
@@ -25,7 +25,7 @@ var _hooks = require("@wordpress/hooks");
|
|
|
25
25
|
* @return {Object} Filtered block settings.
|
|
26
26
|
*/
|
|
27
27
|
function addAttribute(settings) {
|
|
28
|
-
//
|
|
28
|
+
// Allow blocks to specify their own attribute definition with default values if needed.
|
|
29
29
|
if ((0, _lodash.has)(settings.attributes, ['lock', 'type'])) {
|
|
30
30
|
return settings;
|
|
31
31
|
} // Gracefully handle if settings.attributes is undefined.
|