@wordpress/block-editor 7.0.2 → 8.0.1
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 +11 -0
- package/README.md +45 -1
- package/build/components/autocomplete/index.js +1 -1
- package/build/components/autocomplete/index.js.map +1 -1
- package/build/components/block-actions/index.js +8 -4
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-alignment-control/ui.js +61 -14
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/use-available-alignments.js +25 -3
- package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build/components/block-controls/fill.js +2 -2
- package/build/components/block-controls/fill.js.map +1 -1
- package/build/components/block-controls/hook.js +3 -3
- package/build/components/block-controls/hook.js.map +1 -1
- package/build/components/block-icon/index.js +5 -1
- package/build/components/block-icon/index.js.map +1 -1
- package/build/components/block-icon/index.native.js +9 -11
- package/build/components/block-icon/index.native.js.map +1 -1
- package/build/components/block-inspector/index.js +8 -0
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-html.js +5 -0
- package/build/components/block-list/block-html.js.map +1 -1
- package/build/components/block-list/block.js +12 -5
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +4 -3
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +1 -1
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-block-props/use-multi-selection.js +21 -8
- package/build/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build/components/block-list-appender/index.js +9 -1
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-mover/index.js +4 -4
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-mover/index.native.js +4 -4
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-navigation/dropdown.js +0 -1
- package/build/components/block-navigation/dropdown.js.map +1 -1
- package/build/components/block-patterns-list/index.js +1 -8
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-preview/auto.js +1 -1
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-settings/container.native.js +5 -2
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +26 -5
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +10 -3
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-styles/preview.native.js +2 -2
- package/build/components/block-styles/preview.native.js.map +1 -1
- package/build/components/block-switcher/block-styles-menu.js +1 -1
- package/build/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build/components/block-switcher/index.js +10 -3
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-title/index.js +3 -2
- package/build/components/block-title/index.js.map +1 -1
- package/build/components/block-tools/block-popover.js +2 -4
- package/build/components/block-tools/block-popover.js.map +1 -1
- package/build/components/block-tools/index.js +4 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +96 -7
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/utils.js +17 -8
- package/build/components/border-radius-control/utils.js.map +1 -1
- package/build/components/colors/utils.js +11 -3
- package/build/components/colors/utils.js.map +1 -1
- package/build/components/colors-gradients/control.js +22 -57
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +83 -7
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/contrast-checker/index.js +18 -12
- package/build/components/contrast-checker/index.js.map +1 -1
- package/build/components/copy-handler/index.js +9 -3
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/default-block-appender/index.js +2 -2
- package/build/components/default-block-appender/index.js.map +1 -1
- package/build/components/duotone-control/index.js +41 -39
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/editor-styles/index.js +9 -3
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +32 -21
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/iframe/index.js +6 -4
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js +126 -0
- package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -0
- package/build/components/image-editor/constants.js +16 -0
- package/build/components/image-editor/constants.js.map +1 -0
- package/build/components/image-editor/context.js +59 -0
- package/build/components/image-editor/context.js.map +1 -0
- package/build/components/image-editor/cropper.js +83 -0
- package/build/components/image-editor/cropper.js.map +1 -0
- package/build/components/image-editor/form-controls.js +36 -0
- package/build/components/image-editor/form-controls.js.map +1 -0
- package/build/components/image-editor/index.js +60 -0
- package/build/components/image-editor/index.js.map +1 -0
- package/build/components/image-editor/rotation-button.js +37 -0
- package/build/components/image-editor/rotation-button.js.map +1 -0
- package/build/components/image-editor/use-save-image.js +84 -0
- package/build/components/image-editor/use-save-image.js.map +1 -0
- package/build/components/image-editor/use-transform-image.js +135 -0
- package/build/components/image-editor/use-transform-image.js.map +1 -0
- package/build/components/image-editor/zoom-dropdown.js +55 -0
- package/build/components/image-editor/zoom-dropdown.js.map +1 -0
- package/build/components/image-size-control/use-dimension-handler.js +14 -3
- package/build/components/image-size-control/use-dimension-handler.js.map +1 -1
- package/build/components/index.js +36 -20
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +2 -2
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/button-block-appender.js +11 -1
- package/build/components/inner-blocks/button-block-appender.js.map +1 -1
- package/build/components/inner-blocks/index.js +8 -5
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +4 -3
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +24 -13
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/explorer.js +62 -0
- package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/patterns-list.js +111 -0
- package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js +78 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
- package/build/components/inserter/block-patterns-tab.js +74 -35
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.native.js +3 -11
- package/build/components/inserter/block-types-tab.native.js.map +1 -1
- package/build/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
- package/build/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build/components/inserter/hooks/use-clipboard-block.native.js +5 -4
- package/build/components/inserter/hooks/use-clipboard-block.native.js.map +1 -1
- package/build/components/inserter/index.js +12 -4
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +1 -7
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/library.js +2 -0
- package/build/components/inserter/library.js.map +1 -1
- package/build/components/inserter/menu.js +2 -1
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/menu.native.js +11 -15
- package/build/components/inserter/menu.native.js.map +1 -1
- package/build/components/inserter/pattern-panel.js +19 -10
- package/build/components/inserter/pattern-panel.js.map +1 -1
- package/build/components/inserter/preview-panel.js +1 -1
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +2 -1
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js +5 -6
- package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build/components/inserter/search-results.native.js +6 -11
- package/build/components/inserter/search-results.native.js.map +1 -1
- package/build/components/inserter/utils.native.js +44 -0
- package/build/components/inserter/utils.native.js.map +1 -0
- package/build/components/inspector-controls/block-support-slot-container.js +28 -0
- package/build/components/inspector-controls/block-support-slot-container.js.map +1 -0
- package/build/components/inspector-controls/block-support-tools-panel.js +78 -0
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -0
- package/build/components/inspector-controls/fill.js +16 -1
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/inspector-controls/groups.js +5 -1
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls/slot.js +15 -0
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +9 -6
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/link-control/index.js +93 -34
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/link-preview.js +45 -15
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-input.js +25 -7
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/list-view/block-contents.js +1 -20
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block.js +54 -69
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +102 -76
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +45 -20
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +2 -2
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/list-item.js +3 -2
- package/build/components/list-view/list-item.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +13 -54
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/media-placeholder/index.js +29 -20
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +5 -3
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +1 -4
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/observe-typing/index.js +1 -1
- package/build/components/observe-typing/index.js.map +1 -1
- package/build/components/plain-text/index.native.js +30 -1
- package/build/components/plain-text/index.native.js.map +1 -1
- package/build/components/rich-text/embed-handler-picker.native.js +66 -0
- package/build/components/rich-text/embed-handler-picker.native.js.map +1 -0
- package/build/components/rich-text/format-edit.js +28 -2
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/rich-text/format-toolbar/index.js +32 -11
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/index.js +5 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +41 -2
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +28 -9
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/rich-text/utils.js +22 -0
- package/build/components/rich-text/utils.js.map +1 -1
- package/build/components/typewriter/index.js +1 -1
- package/build/components/typewriter/index.js.map +1 -1
- package/build/components/url-input/index.js +25 -11
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-moving-animation/index.js +13 -10
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +2 -1
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-setting/index.js +48 -9
- package/build/components/use-setting/index.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +6 -0
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +10 -1
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/align.js +13 -10
- 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 +5 -5
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +5 -2
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/dimensions.js +23 -27
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +60 -16
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/font-appearance.js +49 -6
- package/build/hooks/font-appearance.js.map +1 -1
- package/build/hooks/font-family.js +123 -32
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +51 -9
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/gap.js +2 -1
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/index.js +10 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +8 -0
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/letter-spacing.js +44 -7
- package/build/hooks/letter-spacing.js.map +1 -1
- package/build/hooks/line-height.js +45 -8
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/lock.js +43 -0
- package/build/hooks/lock.js.map +1 -0
- package/build/hooks/margin.js +1 -1
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +1 -1
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +7 -4
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/text-decoration.js +42 -6
- package/build/hooks/text-decoration.js.map +1 -1
- package/build/hooks/text-transform.js +42 -6
- package/build/hooks/text-transform.js.map +1 -1
- package/build/hooks/typography.js +108 -8
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/use-cached-truthy.js +29 -0
- package/build/hooks/use-cached-truthy.js.map +1 -0
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/layouts/flex.js +160 -34
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +75 -8
- package/build/layouts/flow.js.map +1 -1
- package/build/store/actions.js +323 -265
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.native.js +13 -1
- package/build/store/defaults.native.js.map +1 -1
- package/build/store/index.js +1 -3
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +33 -22
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +172 -38
- package/build/store/selectors.js.map +1 -1
- package/build/utils/index.js +10 -1
- package/build/utils/index.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +51 -1
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build/utils/transform-styles/transforms/wrap.js +16 -0
- package/build/utils/transform-styles/transforms/wrap.js.map +1 -1
- package/build-module/components/autocomplete/index.js +2 -2
- package/build-module/components/autocomplete/index.js.map +1 -1
- package/build-module/components/block-actions/index.js +8 -4
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.js +64 -17
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +25 -3
- package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build-module/components/block-controls/fill.js +2 -2
- package/build-module/components/block-controls/fill.js.map +1 -1
- package/build-module/components/block-controls/hook.js +3 -3
- package/build-module/components/block-controls/hook.js.map +1 -1
- package/build-module/components/block-icon/index.js +5 -1
- package/build-module/components/block-icon/index.js.map +1 -1
- package/build-module/components/block-icon/index.native.js +10 -11
- package/build-module/components/block-icon/index.native.js.map +1 -1
- package/build-module/components/block-inspector/index.js +8 -0
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-html.js +5 -0
- package/build-module/components/block-list/block-html.js.map +1 -1
- package/build-module/components/block-list/block.js +12 -5
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +4 -3
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +1 -1
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-multi-selection.js +21 -8
- package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +9 -1
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-mover/index.js +4 -4
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-mover/index.native.js +4 -4
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-navigation/dropdown.js +0 -1
- package/build-module/components/block-navigation/dropdown.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +1 -6
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +1 -1
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +6 -3
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +28 -7
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +10 -3
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/preview.native.js +2 -2
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/block-switcher/block-styles-menu.js +1 -1
- package/build-module/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build-module/components/block-switcher/index.js +10 -3
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-title/index.js +3 -2
- package/build-module/components/block-title/index.js.map +1 -1
- package/build-module/components/block-tools/block-popover.js +3 -5
- package/build-module/components/block-tools/block-popover.js.map +1 -1
- package/build-module/components/block-tools/index.js +4 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +96 -8
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/utils.js +16 -9
- package/build-module/components/border-radius-control/utils.js.map +1 -1
- package/build-module/components/colors/utils.js +9 -3
- package/build-module/components/colors/utils.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +26 -63
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +84 -7
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/contrast-checker/index.js +13 -10
- package/build-module/components/contrast-checker/index.js.map +1 -1
- package/build-module/components/copy-handler/index.js +9 -3
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/default-block-appender/index.js +2 -2
- package/build-module/components/default-block-appender/index.js.map +1 -1
- package/build-module/components/duotone-control/index.js +43 -39
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/editor-styles/index.js +7 -3
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +28 -21
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/iframe/index.js +6 -4
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js +115 -0
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -0
- package/build-module/components/image-editor/constants.js +7 -0
- package/build-module/components/image-editor/constants.js.map +1 -0
- package/build-module/components/image-editor/context.js +44 -0
- package/build-module/components/image-editor/context.js.map +1 -0
- package/build-module/components/image-editor/cropper.js +69 -0
- package/build-module/components/image-editor/cropper.js.map +1 -0
- package/build-module/components/image-editor/form-controls.js +26 -0
- package/build-module/components/image-editor/form-controls.js.map +1 -0
- package/build-module/components/image-editor/index.js +37 -0
- package/build-module/components/image-editor/index.js.map +1 -0
- package/build-module/components/image-editor/rotation-button.js +26 -0
- package/build-module/components/image-editor/rotation-button.js.map +1 -0
- package/build-module/components/image-editor/use-save-image.js +70 -0
- package/build-module/components/image-editor/use-save-image.js.map +1 -0
- package/build-module/components/image-editor/use-transform-image.js +127 -0
- package/build-module/components/image-editor/use-transform-image.js.map +1 -0
- package/build-module/components/image-editor/zoom-dropdown.js +43 -0
- package/build-module/components/image-editor/zoom-dropdown.js.map +1 -0
- package/build-module/components/image-size-control/use-dimension-handler.js +13 -2
- package/build-module/components/image-size-control/use-dimension-handler.js.map +1 -1
- package/build-module/components/index.js +4 -3
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/button-block-appender.js +10 -1
- package/build-module/components/inner-blocks/button-block-appender.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +9 -6
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +5 -4
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +24 -13
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/explorer.js +50 -0
- package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +92 -0
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js +69 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab.js +75 -36
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.native.js +2 -10
- package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build-module/components/inserter/hooks/use-clipboard-block.native.js +5 -4
- package/build-module/components/inserter/hooks/use-clipboard-block.native.js.map +1 -1
- package/build-module/components/inserter/index.js +12 -4
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +1 -7
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/library.js +2 -0
- package/build-module/components/inserter/library.js.map +1 -1
- package/build-module/components/inserter/menu.js +2 -1
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/menu.native.js +10 -15
- package/build-module/components/inserter/menu.native.js.map +1 -1
- package/build-module/components/inserter/pattern-panel.js +21 -13
- package/build-module/components/inserter/pattern-panel.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +1 -1
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +2 -1
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js +4 -5
- package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build-module/components/inserter/search-results.native.js +5 -10
- package/build-module/components/inserter/search-results.native.js.map +1 -1
- package/build-module/components/inserter/utils.native.js +35 -0
- package/build-module/components/inserter/utils.native.js.map +1 -0
- package/build-module/components/inspector-controls/block-support-slot-container.js +18 -0
- package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -0
- package/build-module/components/inspector-controls/block-support-tools-panel.js +67 -0
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -0
- package/build-module/components/inspector-controls/fill.js +16 -2
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +5 -1
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +13 -0
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +9 -6
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +93 -35
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +46 -17
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-input.js +24 -7
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +1 -18
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block.js +56 -71
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +102 -78
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +48 -23
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +2 -2
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/list-item.js +3 -2
- package/build-module/components/list-view/list-item.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +13 -54
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +29 -20
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +5 -3
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +1 -4
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/observe-typing/index.js +1 -1
- package/build-module/components/observe-typing/index.js.map +1 -1
- package/build-module/components/plain-text/index.native.js +29 -2
- package/build-module/components/plain-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/embed-handler-picker.native.js +54 -0
- package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -0
- package/build-module/components/rich-text/format-edit.js +28 -3
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js +29 -11
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +4 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +41 -3
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +28 -9
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/rich-text/utils.js +20 -0
- package/build-module/components/rich-text/utils.js.map +1 -1
- package/build-module/components/typewriter/index.js +1 -1
- package/build-module/components/typewriter/index.js.map +1 -1
- package/build-module/components/url-input/index.js +25 -11
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +13 -10
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +3 -2
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +48 -9
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +6 -0
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +10 -1
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/align.js +13 -10
- 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 +5 -5
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +6 -3
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/dimensions.js +24 -27
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +59 -16
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/font-appearance.js +45 -6
- package/build-module/hooks/font-appearance.js.map +1 -1
- package/build-module/hooks/font-family.js +117 -33
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +47 -9
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/gap.js +2 -1
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/index.js +2 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/index.native.js +1 -0
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/letter-spacing.js +40 -7
- package/build-module/hooks/letter-spacing.js.map +1 -1
- package/build-module/hooks/line-height.js +41 -8
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/lock.js +33 -0
- package/build-module/hooks/lock.js.map +1 -0
- package/build-module/hooks/margin.js +1 -1
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +1 -1
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +7 -4
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/text-decoration.js +38 -6
- package/build-module/hooks/text-decoration.js.map +1 -1
- package/build-module/hooks/text-transform.js +38 -6
- package/build-module/hooks/text-transform.js.map +1 -1
- package/build-module/hooks/typography.js +117 -17
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/use-cached-truthy.js +21 -0
- package/build-module/hooks/use-cached-truthy.js.map +1 -0
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/flex.js +163 -38
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +74 -8
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/store/actions.js +286 -241
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.native.js +12 -1
- package/build-module/store/defaults.native.js.map +1 -1
- package/build-module/store/index.js +1 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +33 -22
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +160 -34
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/index.js +1 -0
- package/build-module/utils/index.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +48 -1
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/utils/transform-styles/transforms/wrap.js +16 -0
- package/build-module/utils/transform-styles/transforms/wrap.js.map +1 -1
- package/build-style/style-rtl.css +267 -144
- package/build-style/style.css +267 -144
- package/package.json +28 -27
- package/src/components/autocomplete/index.js +5 -2
- package/src/components/block-actions/index.js +9 -5
- package/src/components/block-alignment-control/style.scss +5 -0
- package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +15 -1
- package/src/components/block-alignment-control/test/index.native.js +37 -0
- package/src/components/block-alignment-control/ui.js +98 -27
- package/src/components/block-alignment-control/use-available-alignments.js +31 -10
- package/src/components/block-controls/fill.js +5 -2
- package/src/components/block-controls/hook.js +3 -3
- package/src/components/block-draggable/style.scss +19 -4
- package/src/components/block-icon/index.js +4 -1
- package/src/components/block-icon/index.native.js +10 -16
- package/src/components/block-inspector/index.js +10 -0
- package/src/components/block-list/block-html.js +5 -0
- package/src/components/block-list/block.js +11 -3
- package/src/components/block-list/block.native.js +5 -3
- package/src/components/block-list/index.native.js +1 -1
- package/src/components/block-list/style.scss +15 -0
- package/src/components/block-list/use-block-props/use-multi-selection.js +27 -7
- package/src/components/block-list-appender/index.js +8 -0
- package/src/components/block-mover/index.js +4 -4
- package/src/components/block-mover/index.native.js +4 -4
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +10 -6
- package/src/components/block-mover/test/index.native.js +26 -28
- package/src/components/block-navigation/dropdown.js +0 -1
- package/src/components/block-patterns-list/index.js +1 -8
- package/src/components/block-patterns-list/style.scss +22 -12
- package/src/components/block-preview/README.md +1 -1
- package/src/components/block-preview/auto.js +1 -1
- package/src/components/block-preview/style.scss +0 -17
- package/src/components/block-settings/container.native.js +7 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +26 -13
- package/src/components/block-settings-menu-controls/index.js +9 -6
- package/src/components/block-styles/preview.native.js +2 -2
- package/src/components/block-switcher/block-styles-menu.js +1 -1
- package/src/components/block-switcher/index.js +7 -3
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +1 -1
- package/src/components/block-switcher/test/index.js +3 -0
- package/src/components/block-title/index.js +5 -2
- package/src/components/block-tools/block-popover.js +3 -5
- package/src/components/block-tools/index.js +5 -2
- package/src/components/block-tools/insertion-point.js +97 -9
- package/src/components/block-tools/style.scss +4 -35
- package/src/components/block-types-list/style.scss +0 -3
- package/src/components/border-radius-control/index.js +1 -0
- package/src/components/border-radius-control/test/utils.js +216 -0
- package/src/components/border-radius-control/utils.js +18 -10
- package/src/components/color-palette/test/__snapshots__/control.js.snap +128 -71
- package/src/components/colors/test/utils.js +41 -0
- package/src/components/colors/utils.js +9 -5
- package/src/components/colors-gradients/control.js +70 -110
- package/src/components/colors-gradients/panel-color-gradient-settings.js +79 -7
- package/src/components/colors-gradients/style.scss +10 -18
- package/src/components/colors-gradients/test/control.js +41 -66
- package/src/components/contrast-checker/index.js +14 -10
- package/src/components/copy-handler/index.js +6 -1
- package/src/components/default-block-appender/index.js +2 -2
- package/src/components/default-block-appender/test/__snapshots__/index.js.snap +3 -3
- package/src/components/duotone-control/index.js +49 -41
- package/src/components/duotone-control/style.scss +27 -12
- package/src/components/editor-styles/index.js +7 -4
- package/src/components/font-appearance-control/index.js +41 -33
- package/src/components/font-appearance-control/style.scss +1 -1
- package/src/components/iframe/index.js +4 -4
- package/src/components/image-editor/aspect-ratio-dropdown.js +129 -0
- package/src/components/image-editor/constants.js +6 -0
- package/src/components/image-editor/context.js +56 -0
- package/src/components/image-editor/cropper.js +74 -0
- package/src/components/image-editor/form-controls.js +22 -0
- package/src/components/image-editor/index.js +52 -0
- package/src/components/image-editor/rotation-button.js +24 -0
- package/src/components/image-editor/use-save-image.js +97 -0
- package/src/components/image-editor/use-transform-image.js +162 -0
- package/src/components/image-editor/zoom-dropdown.js +40 -0
- package/src/components/image-size-control/use-dimension-handler.js +18 -1
- package/src/components/index.js +7 -6
- package/src/components/index.native.js +1 -4
- package/src/components/inner-blocks/button-block-appender.js +9 -0
- package/src/components/inner-blocks/index.js +8 -4
- package/src/components/inner-blocks/index.native.js +7 -4
- package/src/components/inner-blocks/use-nested-settings-update.js +26 -11
- package/src/components/inserter/block-patterns-explorer/explorer.js +50 -0
- package/src/components/inserter/block-patterns-explorer/patterns-list.js +122 -0
- package/src/components/inserter/block-patterns-explorer/sidebar.js +73 -0
- package/src/components/inserter/block-patterns-tab.js +107 -73
- package/src/components/inserter/block-types-tab.native.js +3 -15
- package/src/components/inserter/hooks/use-block-type-impressions.native.js +14 -21
- package/src/components/inserter/hooks/use-clipboard-block.native.js +3 -2
- package/src/components/inserter/index.js +15 -3
- package/src/components/inserter/index.native.js +2 -19
- package/src/components/inserter/library.js +2 -0
- package/src/components/inserter/menu.js +4 -1
- package/src/components/inserter/menu.native.js +9 -14
- package/src/components/inserter/pattern-panel.js +33 -16
- package/src/components/inserter/preview-panel.js +1 -1
- package/src/components/inserter/quick-inserter.js +1 -1
- package/src/components/inserter/reusable-blocks-tab.native.js +4 -6
- package/src/components/inserter/search-results.native.js +5 -15
- package/src/components/inserter/style.scss +80 -16
- package/src/components/inserter/test/block-types-tab.native.js +1 -1
- package/src/components/inserter/test/fixtures/index.native.js +12 -0
- package/src/components/inserter/utils.native.js +35 -0
- package/src/components/inserter-list-item/style.scss +4 -2
- package/src/components/inspector-controls/block-support-slot-container.js +10 -0
- package/src/components/inspector-controls/block-support-tools-panel.js +60 -0
- package/src/components/inspector-controls/fill.js +23 -2
- package/src/components/inspector-controls/groups.js +8 -0
- package/src/components/inspector-controls/slot.js +15 -0
- package/src/components/letter-spacing-control/index.js +12 -6
- package/src/components/link-control/README.md +47 -14
- package/src/components/link-control/index.js +102 -31
- package/src/components/link-control/link-preview.js +53 -20
- package/src/components/link-control/search-input.js +21 -7
- package/src/components/link-control/style.scss +66 -19
- package/src/components/link-control/test/index.js +311 -4
- package/src/components/list-view/block-contents.js +17 -38
- package/src/components/list-view/block.js +73 -84
- package/src/components/list-view/branch.js +123 -94
- package/src/components/list-view/index.js +82 -30
- package/src/components/list-view/leaf.js +2 -2
- package/src/components/list-view/list-item.js +5 -4
- package/src/components/list-view/style.scss +70 -33
- package/src/components/list-view/use-list-view-client-ids.js +9 -68
- package/src/components/media-placeholder/index.js +26 -19
- package/src/components/media-replace-flow/README.md +7 -0
- package/src/components/media-replace-flow/index.js +4 -1
- package/src/components/media-upload/README.md +1 -1
- package/src/components/navigable-toolbar/index.js +1 -4
- package/src/components/observe-typing/index.js +3 -2
- package/src/components/plain-text/index.native.js +26 -4
- package/src/components/rich-text/embed-handler-picker.native.js +68 -0
- package/src/components/rich-text/format-edit.js +36 -2
- package/src/components/rich-text/format-toolbar/index.js +25 -6
- package/src/components/rich-text/index.js +12 -8
- package/src/components/rich-text/index.native.js +35 -1
- package/src/components/rich-text/use-paste-handler.js +30 -12
- package/src/components/rich-text/utils.js +16 -0
- package/src/components/skip-to-selected-block/README.md +39 -0
- package/src/components/typewriter/index.js +3 -2
- package/src/components/url-input/index.js +26 -10
- package/src/components/use-moving-animation/index.js +9 -8
- package/src/components/use-on-block-drop/index.js +5 -1
- package/src/components/use-setting/index.js +49 -11
- package/src/components/writing-flow/use-multi-selection.js +6 -0
- package/src/components/writing-flow/use-tab-nav.js +17 -3
- package/src/hooks/align.js +19 -10
- package/src/hooks/anchor.js +2 -2
- package/src/hooks/border.js +8 -11
- package/src/hooks/color-panel.js +4 -1
- package/src/hooks/color.js +7 -4
- package/src/hooks/dimensions.js +48 -59
- package/src/hooks/duotone.js +68 -19
- package/src/hooks/font-appearance.js +38 -7
- package/src/hooks/font-family.js +129 -33
- package/src/hooks/font-size.js +42 -6
- package/src/hooks/gap.js +2 -1
- package/src/hooks/index.js +2 -0
- package/src/hooks/index.native.js +1 -0
- package/src/hooks/layout.scss +8 -0
- package/src/hooks/letter-spacing.js +35 -7
- package/src/hooks/line-height.js +37 -9
- package/src/hooks/lock.js +34 -0
- package/src/hooks/margin.js +1 -1
- package/src/hooks/padding.js +1 -1
- package/src/hooks/style.js +15 -11
- package/src/hooks/text-decoration.js +34 -6
- package/src/hooks/text-transform.js +34 -6
- package/src/hooks/typography.js +165 -15
- package/src/hooks/typography.scss +16 -0
- package/src/hooks/use-cached-truthy.js +20 -0
- package/src/index.js +1 -0
- package/src/layouts/flex.js +179 -50
- package/src/layouts/flow.js +54 -8
- package/src/store/actions.js +239 -377
- package/src/store/defaults.native.js +12 -0
- package/src/store/index.js +1 -2
- package/src/store/reducer.js +54 -18
- package/src/store/selectors.js +173 -47
- package/src/store/test/actions.js +407 -705
- package/src/store/test/reducer.js +22 -54
- package/src/store/test/selectors.js +79 -21
- package/src/style.scss +2 -1
- package/src/utils/index.js +1 -0
- package/src/utils/parse-css-unit-to-px.js +43 -1
- package/src/utils/test/parse-css-unit-to-px.js +148 -165
- package/src/utils/transform-styles/transforms/test/wrap.js +1 -1
- package/src/utils/transform-styles/transforms/wrap.js +16 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/duotone-control/duotone-picker-popover.js +0 -44
- package/build/components/duotone-control/duotone-picker-popover.js.map +0 -1
- package/build/components/list-view/block-slot.js +0 -121
- package/build/components/list-view/block-slot.js.map +0 -1
- package/build/components/list-view/editor.js +0 -35
- package/build/components/list-view/editor.js.map +0 -1
- package/build/components/text-decoration-and-transform/index.js +0 -39
- package/build/components/text-decoration-and-transform/index.js.map +0 -1
- package/build/store/controls.js +0 -44
- package/build/store/controls.js.map +0 -1
- package/build-module/components/duotone-control/duotone-picker-popover.js +0 -35
- package/build-module/components/duotone-control/duotone-picker-popover.js.map +0 -1
- package/build-module/components/list-view/block-slot.js +0 -96
- package/build-module/components/list-view/block-slot.js.map +0 -1
- package/build-module/components/list-view/editor.js +0 -25
- package/build-module/components/list-view/editor.js.map +0 -1
- package/build-module/components/text-decoration-and-transform/index.js +0 -30
- package/build-module/components/text-decoration-and-transform/index.js.map +0 -1
- package/build-module/store/controls.js +0 -32
- package/build-module/store/controls.js.map +0 -1
- package/src/components/duotone-control/duotone-picker-popover.js +0 -36
- package/src/components/list-view/block-slot.js +0 -120
- package/src/components/list-view/editor.js +0 -29
- package/src/components/text-decoration-and-transform/index.js +0 -36
- package/src/components/text-decoration-and-transform/style.scss +0 -3
- package/src/store/controls.js +0 -39
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/dimensions.js"],"names":["SPACING_SUPPORT_KEY","ALL_SIDES","AXIAL_SIDES","DimensionsPanel","props","isGapDisabled","isPaddingDisabled","isMarginDisabled","isDisabled","useIsDimensionsDisabled","isSupported","hasDimensionsSupport","name","defaultSpacingControls","resetAll","style","attributes","setAttributes","spacing","blockGap","undefined","margin","padding","blockName","Platform","OS","gapDisabled","paddingDisabled","marginDisabled","useCustomSides","feature","support","useIsDimensionsSupportValid","sides","some","side","includes","console","warn"],"mappings":";;;;;;;;;;;;;AAOA;;AAJA;;AAKA;;AACA;;AAKA;;AACA;;AAOA;;AAOA;;AAOA;;AApCA;AACA;AACA;;AASA;AACA;AACA;AAyBO,MAAMA,mBAAmB,GAAG,SAA5B;;AACA,MAAMC,SAAS,GAAG,CAAE,KAAF,EAAS,OAAT,EAAkB,QAAlB,EAA4B,MAA5B,CAAlB;;AACA,MAAMC,WAAW,G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AAMd,uBAAuB,GAAG,CAAEL,KAAK,GAAG,EAAV,KAAkB;AACjD,QAAMsB,WAAW,GAAG,2BAAkBtB,KAAlB,CAApB;AACA,QAAMuB,eAAe,GAAG,mCAAsBvB,KAAtB,CAAxB;AACA,QAAMwB,cAAc,GAAG,iCAAqBxB,KAArB,CAAvB;AAEA,SAAOsB,WAAW,IAAIC,eAAf,IAAkCC,cAAzC;AACA,CAND;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,cAAT,CAAyBN,SAAzB,EAAoCO,OAApC,EAA8C;AACpD,QAAMC,OAAO,GAAG,6BAAiBR,SAAjB,EAA4BvB,mBAA5B,CAAhB,CADoD,CAGpD;;AACA,MAAK,CAAE+B,OAAF,IAAa,OAAOA,OAAO,CAAED,OAAF,CAAd,KAA8B,SAAhD,EAA4D;AAC3D;AACA;;AAED,SAAOC,OAAO,CAAED,OAAF,CAAd;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,2BAAT,CAAsCT,SAAtC,EAAiDO,OAAjD,EAA2D;AACjE,QAAMG,KAAK,GAAGJ,cAAc,CAAEN,SAAF,EAAaO,OAAb,CAA5B;;AAEA,MACCG,KAAK,IACLA,KAAK,CAACC,IAAN,CAAcC,IAAF,IAAYlC,SAAS,CAACmC,QAAV,CAAoBD,IAApB,CAAxB,CADA,IAEAF,KAAK,CAACC,IAAN,CAAcC,IAAF,IAAYjC,WAAW,CAACkC,QAAZ,CAAsBD,IAAtB,CAAxB,CAHD,EAIE;AACD;AACAE,IAAAA,OAAO,CAACC,IAAR,CACE,OAAOR,OAAS,qBAAqBP,SAAW,0EADlD;AAGA,WAAO,KAAP;AACA;;AAED,SAAO,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { Platform } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { getBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport {\n\tGapEdit,\n\thasGapSupport,\n\thasGapValue,\n\tresetGap,\n\tuseIsGapDisabled,\n} from './gap';\nimport {\n\tMarginEdit,\n\thasMarginSupport,\n\thasMarginValue,\n\tresetMargin,\n\tuseIsMarginDisabled,\n} from './margin';\nimport {\n\tPaddingEdit,\n\thasPaddingSupport,\n\thasPaddingValue,\n\tresetPadding,\n\tuseIsPaddingDisabled,\n} from './padding';\nimport { cleanEmptyObject } from './utils';\n\nexport const SPACING_SUPPORT_KEY = 'spacing';\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nexport const AXIAL_SIDES = [ 'vertical', 'horizontal' ];\n\n/**\n * Inspector controls for dimensions support.\n *\n * @param {Object} props Block props.\n *\n * @return {WPElement} Inspector controls for spacing support features.\n */\nexport function DimensionsPanel( props ) {\n\tconst isGapDisabled = useIsGapDisabled( props );\n\tconst isPaddingDisabled = useIsPaddingDisabled( props );\n\tconst isMarginDisabled = useIsMarginDisabled( props );\n\tconst isDisabled = useIsDimensionsDisabled( props );\n\tconst isSupported = hasDimensionsSupport( props.name );\n\n\tif ( isDisabled || ! isSupported ) {\n\t\treturn null;\n\t}\n\n\tconst defaultSpacingControls = getBlockSupport( props.name, [\n\t\tSPACING_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\t// Callback to reset all block support attributes controlled via this panel.\n\tconst resetAll = () => {\n\t\tconst { style } = props.attributes;\n\n\t\tprops.setAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\tspacing: {\n\t\t\t\t\t...style?.spacing,\n\t\t\t\t\tblockGap: undefined,\n\t\t\t\t\tmargin: undefined,\n\t\t\t\t\tpadding: undefined,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t};\n\n\treturn (\n\t\t<InspectorControls key=\"dimensions\">\n\t\t\t<ToolsPanel\n\t\t\t\tlabel={ __( 'Dimensions options' ) }\n\t\t\t\theader={ __( 'Dimensions' ) }\n\t\t\t\tresetAll={ resetAll }\n\t\t\t>\n\t\t\t\t{ ! isPaddingDisabled && (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => hasPaddingValue( props ) }\n\t\t\t\t\t\tlabel={ __( 'Padding' ) }\n\t\t\t\t\t\tonDeselect={ () => resetPadding( props ) }\n\t\t\t\t\t\tisShownByDefault={ defaultSpacingControls?.padding }\n\t\t\t\t\t>\n\t\t\t\t\t\t<PaddingEdit { ...props } />\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t) }\n\t\t\t\t{ ! isMarginDisabled && (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => hasMarginValue( props ) }\n\t\t\t\t\t\tlabel={ __( 'Margin' ) }\n\t\t\t\t\t\tonDeselect={ () => resetMargin( props ) }\n\t\t\t\t\t\tisShownByDefault={ defaultSpacingControls?.margin }\n\t\t\t\t\t>\n\t\t\t\t\t\t<MarginEdit { ...props } />\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t) }\n\t\t\t\t{ ! isGapDisabled && (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\t\thasValue={ () => hasGapValue( props ) }\n\t\t\t\t\t\tlabel={ __( 'Block gap' ) }\n\t\t\t\t\t\tonDeselect={ () => resetGap( props ) }\n\t\t\t\t\t\tisShownByDefault={ defaultSpacingControls?.blockGap }\n\t\t\t\t\t>\n\t\t\t\t\t\t<GapEdit { ...props } />\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t) }\n\t\t\t</ToolsPanel>\n\t\t</InspectorControls>\n\t);\n}\n\n/**\n * Determine whether there is dimensions related block support.\n *\n * @param {string} blockName Block name.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasDimensionsSupport( blockName ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\thasGapSupport( blockName ) ||\n\t\thasPaddingSupport( blockName ) ||\n\t\thasMarginSupport( blockName )\n\t);\n}\n\n/**\n * Determines whether dimensions support has been disabled.\n *\n * @param {Object} props Block properties.\n *\n * @return {boolean} If spacing support is completely disabled.\n */\nconst useIsDimensionsDisabled = ( props = {} ) => {\n\tconst gapDisabled = useIsGapDisabled( props );\n\tconst paddingDisabled = useIsPaddingDisabled( props );\n\tconst marginDisabled = useIsMarginDisabled( props );\n\n\treturn gapDisabled && paddingDisabled && marginDisabled;\n};\n\n/**\n * Custom hook to retrieve which padding/margin is supported\n * e.g. top, right, bottom or left.\n *\n * Sides are opted into by default. It is only if a specific side is set to\n * false that it is omitted.\n *\n * @param {string} blockName Block name.\n * @param {string} feature The feature custom sides relate to e.g. padding or margins.\n *\n * @return {Object} Sides supporting custom margin.\n */\nexport function useCustomSides( blockName, feature ) {\n\tconst support = getBlockSupport( blockName, SPACING_SUPPORT_KEY );\n\n\t// Skip when setting is boolean as theme isn't setting arbitrary sides.\n\tif ( ! support || typeof support[ feature ] === 'boolean' ) {\n\t\treturn;\n\t}\n\n\treturn support[ feature ];\n}\n\n/**\n * Custom hook to determine whether the sides configured in the\n * block support are valid. A dimension property cannot declare\n * support for a mix of axial and individual sides.\n *\n * @param {string} blockName Block name.\n * @param {string} feature The feature custom sides relate to e.g. padding or margins.\n *\n * @return {boolean} If the feature has a valid configuration of sides.\n */\nexport function useIsDimensionsSupportValid( blockName, feature ) {\n\tconst sides = useCustomSides( blockName, feature );\n\n\tif (\n\t\tsides &&\n\t\tsides.some( ( side ) => ALL_SIDES.includes( side ) ) &&\n\t\tsides.some( ( side ) => AXIAL_SIDES.includes( side ) )\n\t) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t`The ${ feature } support for the \"${ blockName }\" block can not be configured to support both axial and arbitrary sides.`\n\t\t);\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/dimensions.js"],"names":["SPACING_SUPPORT_KEY","ALL_SIDES","AXIAL_SIDES","DimensionsPanel","props","isGapDisabled","isPaddingDisabled","isMarginDisabled","isDisabled","useIsDimensionsDisabled","isSupported","hasDimensionsSupport","name","defaultSpacingControls","createResetAllFilter","attribute","newAttributes","style","spacing","undefined","padding","clientId","margin","blockGap","blockName","Platform","OS","gapDisabled","paddingDisabled","marginDisabled","useCustomSides","feature","support","useIsDimensionsSupportValid","sides","some","side","includes","console","warn"],"mappings":";;;;;;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AAKA;;AACA;;AAOA;;AAOA;;AA1BA;AACA;AACA;;AAMA;AACA;AACA;AAwBO,MAAMA,mBAAmB,GAAG,SAA5B;;AACA,MAAMC,SAAS,GAAG,CAAE,KAAF,EAAS,OAAT,EAAkB,QAAlB,EAA4B,MAA5B,CAAlB;;AACA,MAAMC,WAAW,GAAG,CAAE,UAAF,EAAc,YAAd,CAApB;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASC,eAAT,CAA0BC,KAA1B,EAAkC;AACxC,QAAMC,aAAa,GAAG,2BAAkBD,KAAlB,CAAtB;AACA,QAAME,iBAAiB,GAAG,mCAAsBF,KAAtB,CAA1B;AACA,QAAMG,gBAAgB,GAAG,iCAAqBH,KAArB,CAAzB;AACA,QAAMI,UAAU,GAAGC,uBAAuB,CAAEL,KAAF,CAA1C;AACA,QAAMM,WAAW,GAAGC,oBAAoB,CAAEP,KAAK,CAACQ,IAAR,CAAxC;;AAEA,MAAKJ,UAAU,IAAI,CAAEE,WAArB,EAAmC;AAClC,WAAO,IAAP;AACA;;AAED,QAAMG,sBAAsB,GAAG,6BAAiBT,KAAK,CAACQ,IAAvB,EAA6B,CAC3DZ,mBAD2D,EAE3D,+BAF2D,CAA7B,CAA/B;;AAKA,QAAMc,oBAA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ACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,2BAAT,CAAsCT,SAAtC,EAAiDO,OAAjD,EAA2D;AACjE,QAAMG,KAAK,GAAGJ,cAAc,CAAEN,SAAF,EAAaO,OAAb,CAA5B;;AAEA,MACCG,KAAK,IACLA,KAAK,CAACC,IAAN,CAAcC,IAAF,IAAYnC,SAAS,CAACoC,QAAV,CAAoBD,IAApB,CAAxB,CADA,IAEAF,KAAK,CAACC,IAAN,CAAcC,IAAF,IAAYlC,WAAW,CAACmC,QAAZ,CAAsBD,IAAtB,CAAxB,CAHD,EAIE;AACD;AACAE,IAAAA,OAAO,CAACC,IAAR,CACE,OAAOR,OAAS,qBAAqBP,SAAW,0EADlD;AAGA,WAAO,KAAP;AACA;;AAED,SAAO,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';\nimport { Platform } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { getBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport {\n\tGapEdit,\n\thasGapSupport,\n\thasGapValue,\n\tresetGap,\n\tuseIsGapDisabled,\n} from './gap';\nimport {\n\tMarginEdit,\n\thasMarginSupport,\n\thasMarginValue,\n\tresetMargin,\n\tuseIsMarginDisabled,\n} from './margin';\nimport {\n\tPaddingEdit,\n\thasPaddingSupport,\n\thasPaddingValue,\n\tresetPadding,\n\tuseIsPaddingDisabled,\n} from './padding';\n\nexport const SPACING_SUPPORT_KEY = 'spacing';\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nexport const AXIAL_SIDES = [ 'vertical', 'horizontal' ];\n\n/**\n * Inspector controls for dimensions support.\n *\n * @param {Object} props Block props.\n *\n * @return {WPElement} Inspector controls for spacing support features.\n */\nexport function DimensionsPanel( props ) {\n\tconst isGapDisabled = useIsGapDisabled( props );\n\tconst isPaddingDisabled = useIsPaddingDisabled( props );\n\tconst isMarginDisabled = useIsMarginDisabled( props );\n\tconst isDisabled = useIsDimensionsDisabled( props );\n\tconst isSupported = hasDimensionsSupport( props.name );\n\n\tif ( isDisabled || ! isSupported ) {\n\t\treturn null;\n\t}\n\n\tconst defaultSpacingControls = getBlockSupport( props.name, [\n\t\tSPACING_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\tconst createResetAllFilter = ( attribute ) => ( newAttributes ) => ( {\n\t\t...newAttributes,\n\t\tstyle: {\n\t\t\t...newAttributes.style,\n\t\t\tspacing: {\n\t\t\t\t...newAttributes.style?.spacing,\n\t\t\t\t[ attribute ]: undefined,\n\t\t\t},\n\t\t},\n\t} );\n\n\treturn (\n\t\t<InspectorControls __experimentalGroup=\"dimensions\">\n\t\t\t{ ! isPaddingDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasPaddingValue( props ) }\n\t\t\t\t\tlabel={ __( 'Padding' ) }\n\t\t\t\t\tonDeselect={ () => resetPadding( props ) }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'padding' ) }\n\t\t\t\t\tisShownByDefault={ defaultSpacingControls?.padding }\n\t\t\t\t\tpanelId={ props.clientId }\n\t\t\t\t>\n\t\t\t\t\t<PaddingEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isMarginDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasMarginValue( props ) }\n\t\t\t\t\tlabel={ __( 'Margin' ) }\n\t\t\t\t\tonDeselect={ () => resetMargin( props ) }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'margin' ) }\n\t\t\t\t\tisShownByDefault={ defaultSpacingControls?.margin }\n\t\t\t\t\tpanelId={ props.clientId }\n\t\t\t\t>\n\t\t\t\t\t<MarginEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isGapDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasGapValue( props ) }\n\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\tonDeselect={ () => resetGap( props ) }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'blockGap' ) }\n\t\t\t\t\tisShownByDefault={ defaultSpacingControls?.blockGap }\n\t\t\t\t\tpanelId={ props.clientId }\n\t\t\t\t>\n\t\t\t\t\t<GapEdit { ...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 dimensions related block support.\n *\n * @param {string} blockName Block name.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasDimensionsSupport( blockName ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\thasGapSupport( blockName ) ||\n\t\thasPaddingSupport( blockName ) ||\n\t\thasMarginSupport( blockName )\n\t);\n}\n\n/**\n * Determines whether dimensions support has been disabled.\n *\n * @param {Object} props Block properties.\n *\n * @return {boolean} If spacing support is completely disabled.\n */\nconst useIsDimensionsDisabled = ( props = {} ) => {\n\tconst gapDisabled = useIsGapDisabled( props );\n\tconst paddingDisabled = useIsPaddingDisabled( props );\n\tconst marginDisabled = useIsMarginDisabled( props );\n\n\treturn gapDisabled && paddingDisabled && marginDisabled;\n};\n\n/**\n * Custom hook to retrieve which padding/margin is supported\n * e.g. top, right, bottom or left.\n *\n * Sides are opted into by default. It is only if a specific side is set to\n * false that it is omitted.\n *\n * @param {string} blockName Block name.\n * @param {string} feature The feature custom sides relate to e.g. padding or margins.\n *\n * @return {Object} Sides supporting custom margin.\n */\nexport function useCustomSides( blockName, feature ) {\n\tconst support = getBlockSupport( blockName, SPACING_SUPPORT_KEY );\n\n\t// Skip when setting is boolean as theme isn't setting arbitrary sides.\n\tif ( ! support || typeof support[ feature ] === 'boolean' ) {\n\t\treturn;\n\t}\n\n\treturn support[ feature ];\n}\n\n/**\n * Custom hook to determine whether the sides configured in the\n * block support are valid. A dimension property cannot declare\n * support for a mix of axial and individual sides.\n *\n * @param {string} blockName Block name.\n * @param {string} feature The feature custom sides relate to e.g. padding or margins.\n *\n * @return {boolean} If the feature has a valid configuration of sides.\n */\nexport function useIsDimensionsSupportValid( blockName, feature ) {\n\tconst sides = useCustomSides( blockName, feature );\n\n\tif (\n\t\tsides &&\n\t\tsides.some( ( side ) => ALL_SIDES.includes( side ) ) &&\n\t\tsides.some( ( side ) => AXIAL_SIDES.includes( side ) )\n\t) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t`The ${ feature } support for the \"${ blockName }\" block can not be configured to support both axial and arbitrary sides.`\n\t\t);\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n"]}
|
package/build/hooks/duotone.js
CHANGED
|
@@ -13,7 +13,9 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
13
13
|
|
|
14
14
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _colord = require("colord");
|
|
17
|
+
|
|
18
|
+
var _names = _interopRequireDefault(require("colord/plugins/names"));
|
|
17
19
|
|
|
18
20
|
var _blocks = require("@wordpress/blocks");
|
|
19
21
|
|
|
@@ -39,6 +41,7 @@ var _blockList = _interopRequireDefault(require("../components/block-list"));
|
|
|
39
41
|
* Internal dependencies
|
|
40
42
|
*/
|
|
41
43
|
const EMPTY_ARRAY = [];
|
|
44
|
+
(0, _colord.extend)([_names.default]);
|
|
42
45
|
/**
|
|
43
46
|
* Convert a list of colors to an object of R, G, and B values.
|
|
44
47
|
*
|
|
@@ -51,14 +54,15 @@ function getValuesFromColors(colors = []) {
|
|
|
51
54
|
const values = {
|
|
52
55
|
r: [],
|
|
53
56
|
g: [],
|
|
54
|
-
b: []
|
|
57
|
+
b: [],
|
|
58
|
+
a: []
|
|
55
59
|
};
|
|
56
60
|
colors.forEach(color => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
values.
|
|
60
|
-
values.
|
|
61
|
-
values.
|
|
61
|
+
const rgbColor = (0, _colord.colord)(color).toRgb();
|
|
62
|
+
values.r.push(rgbColor.r / 255);
|
|
63
|
+
values.g.push(rgbColor.g / 255);
|
|
64
|
+
values.b.push(rgbColor.b / 255);
|
|
65
|
+
values.a.push(rgbColor.a);
|
|
62
66
|
});
|
|
63
67
|
return values;
|
|
64
68
|
}
|
|
@@ -69,6 +73,7 @@ function getValuesFromColors(colors = []) {
|
|
|
69
73
|
* @property {number[]} r Red values.
|
|
70
74
|
* @property {number[]} g Green values.
|
|
71
75
|
* @property {number[]} b Blue values.
|
|
76
|
+
* @property {number[]} a Alpha values.
|
|
72
77
|
*/
|
|
73
78
|
|
|
74
79
|
/**
|
|
@@ -77,7 +82,7 @@ function getValuesFromColors(colors = []) {
|
|
|
77
82
|
* @param {Object} props Duotone props.
|
|
78
83
|
* @param {string} props.selector Selector to apply the filter to.
|
|
79
84
|
* @param {string} props.id Unique id for this duotone filter.
|
|
80
|
-
* @param {Values} props.values R, G, and
|
|
85
|
+
* @param {Values} props.values R, G, B, and A values to filter with.
|
|
81
86
|
*
|
|
82
87
|
* @return {WPElement} Duotone element.
|
|
83
88
|
*/
|
|
@@ -109,10 +114,11 @@ ${selector} {
|
|
|
109
114
|
}, (0, _element.createElement)("defs", null, (0, _element.createElement)("filter", {
|
|
110
115
|
id: id
|
|
111
116
|
}, (0, _element.createElement)("feColorMatrix", {
|
|
117
|
+
// Use sRGB instead of linearRGB so transparency looks correct.
|
|
118
|
+
colorInterpolationFilters: "sRGB",
|
|
112
119
|
type: "matrix" // Use perceptual brightness to convert to grayscale.
|
|
113
|
-
// prettier-ignore
|
|
114
120
|
,
|
|
115
|
-
values: ".299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0
|
|
121
|
+
values: " .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 "
|
|
116
122
|
}), (0, _element.createElement)("feComponentTransfer", {
|
|
117
123
|
// Use sRGB instead of linearRGB to be consistent with how CSS gradients work.
|
|
118
124
|
colorInterpolationFilters: "sRGB"
|
|
@@ -125,7 +131,14 @@ ${selector} {
|
|
|
125
131
|
}), (0, _element.createElement)("feFuncB", {
|
|
126
132
|
type: "table",
|
|
127
133
|
tableValues: values.b.join(' ')
|
|
128
|
-
})
|
|
134
|
+
}), (0, _element.createElement)("feFuncA", {
|
|
135
|
+
type: "table",
|
|
136
|
+
tableValues: values.a.join(' ')
|
|
137
|
+
})), (0, _element.createElement)("feComposite", {
|
|
138
|
+
// Re-mask the image with the original transparency since the feColorMatrix above loses that information.
|
|
139
|
+
in2: "SourceGraphic",
|
|
140
|
+
operator: "in"
|
|
141
|
+
})))), (0, _element.createElement)("style", {
|
|
129
142
|
dangerouslySetInnerHTML: {
|
|
130
143
|
__html: stylesheet
|
|
131
144
|
}
|
|
@@ -151,7 +164,7 @@ function DuotonePanel({
|
|
|
151
164
|
|
|
152
165
|
return (0, _element.createElement)(_components2.BlockControls, {
|
|
153
166
|
group: "block",
|
|
154
|
-
|
|
167
|
+
__experimentalShareWithChildBlocks: true
|
|
155
168
|
}, (0, _element.createElement)(_components2.__experimentalDuotoneControl, {
|
|
156
169
|
duotonePalette: duotonePalette,
|
|
157
170
|
colorPalette: colorPalette,
|
|
@@ -211,6 +224,35 @@ const withDuotoneControls = (0, _compose.createHigherOrderComponent)(BlockEdit =
|
|
|
211
224
|
const hasDuotoneSupport = (0, _blocks.hasBlockSupport)(props.name, 'color.__experimentalDuotone');
|
|
212
225
|
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(BlockEdit, props), hasDuotoneSupport && (0, _element.createElement)(DuotonePanel, props));
|
|
213
226
|
}, 'withDuotoneControls');
|
|
227
|
+
/**
|
|
228
|
+
* Function that scopes a selector with another one. This works a bit like
|
|
229
|
+
* SCSS nesting except the `&` operator isn't supported.
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```js
|
|
233
|
+
* const scope = '.a, .b .c';
|
|
234
|
+
* const selector = '> .x, .y';
|
|
235
|
+
* const merged = scopeSelector( scope, selector );
|
|
236
|
+
* // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'
|
|
237
|
+
* ```
|
|
238
|
+
*
|
|
239
|
+
* @param {string} scope Selector to scope to.
|
|
240
|
+
* @param {string} selector Original selector.
|
|
241
|
+
*
|
|
242
|
+
* @return {string} Scoped selector.
|
|
243
|
+
*/
|
|
244
|
+
|
|
245
|
+
function scopeSelector(scope, selector) {
|
|
246
|
+
const scopes = scope.split(',');
|
|
247
|
+
const selectors = selector.split(',');
|
|
248
|
+
const selectorsScoped = [];
|
|
249
|
+
scopes.forEach(outer => {
|
|
250
|
+
selectors.forEach(inner => {
|
|
251
|
+
selectorsScoped.push(`${outer.trim()} ${inner.trim()}`);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
return selectorsScoped.join(', ');
|
|
255
|
+
}
|
|
214
256
|
/**
|
|
215
257
|
* Override the default block element to include duotone styles.
|
|
216
258
|
*
|
|
@@ -219,6 +261,7 @@ const withDuotoneControls = (0, _compose.createHigherOrderComponent)(BlockEdit =
|
|
|
219
261
|
* @return {Function} Wrapped component.
|
|
220
262
|
*/
|
|
221
263
|
|
|
264
|
+
|
|
222
265
|
const withDuotoneStyles = (0, _compose.createHigherOrderComponent)(BlockListBlock => props => {
|
|
223
266
|
var _props$attributes, _props$attributes$sty, _props$attributes$sty2;
|
|
224
267
|
|
|
@@ -229,10 +272,11 @@ const withDuotoneStyles = (0, _compose.createHigherOrderComponent)(BlockListBloc
|
|
|
229
272
|
return (0, _element.createElement)(BlockListBlock, props);
|
|
230
273
|
}
|
|
231
274
|
|
|
232
|
-
const id = `wp-duotone
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
275
|
+
const id = `wp-duotone-${(0, _compose.useInstanceId)(BlockListBlock)}`; // Extra .editor-styles-wrapper specificity is needed in the editor
|
|
276
|
+
// since we're not using inline styles to apply the filter. We need to
|
|
277
|
+
// override duotone applied by global styles and theme.json.
|
|
278
|
+
|
|
279
|
+
const selectorsGroup = scopeSelector(`.editor-styles-wrapper .${id}`, duotoneSupport);
|
|
236
280
|
const className = (0, _classnames.default)(props === null || props === void 0 ? void 0 : props.className, id);
|
|
237
281
|
const element = (0, _element.useContext)(_blockList.default.__unstableElementContext);
|
|
238
282
|
return (0, _element.createElement)(_element.Fragment, null, element && (0, _element.createPortal)((0, _element.createElement)(DuotoneFilter, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/duotone.js"],"names":["EMPTY_ARRAY","getValuesFromColors","colors","values","r","g","b","forEach","color","tcolor","push","_r","_g","_b","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","withDuotoneStyles","BlockListBlock","duotoneSupport","selectors","split","selectorsScoped","map","trim","selectorsGroup","className","element","BlockList","__unstableElementContext"],"mappings":";;;;;;;;;AAaA;;;;AAVA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAMA;;AAKA;;AAvBA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;AAQA,MAAMA,WAAW,GAAG,EAApB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,mBAAT,CAA8BC,MAAM,GAAG,EAAvC,EAA4C;AAClD,QAAMC,MAAM,GAAG;AAAEC,IAAAA,CAAC,EAAE,EAAL;AAASC,IAAAA,CAAC,EAAE,EAAZ;AAAgBC,IAAAA,CAAC,EAAE;AAAnB,GAAf;AAEAJ,EAAAA,MAAM,CAACK,OAAP,CAAkBC,KAAF,IAAa;AAC5B;AACA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0BADD,EAEC,oCAFD,EAGCnB,oBAHD;AAKA,sBACC,kBADD,EAEC,0CAFD,EAGCK,mBAHD;AAKA,sBACC,uBADD,EAEC,iCAFD,EAGCK,iBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport tinycolor from 'tinycolor2';\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\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: [] };\n\n\tcolors.forEach( ( color ) => {\n\t\t// Access values directly to skip extra rounding that tinycolor.toRgb() does.\n\t\tconst tcolor = tinycolor( color );\n\t\tvalues.r.push( tcolor._r / 255 );\n\t\tvalues.g.push( tcolor._g / 255 );\n\t\tvalues.b.push( tcolor._b / 255 );\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 */\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, and B 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\ttype=\"matrix\"\n\t\t\t\t\t\t\t// Use perceptual brightness to convert to grayscale.\n\t\t\t\t\t\t\t// prettier-ignore\n\t\t\t\t\t\t\tvalues=\".299 .587 .114 0 0\n\t\t\t\t\t\t\t .299 .587 .114 0 0\n\t\t\t\t\t\t\t .299 .587 .114 0 0\n\t\t\t\t\t\t\t 0 0 0 1 0\"\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</feComponentTransfer>\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\" __experimentalExposeToChildren>\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 * 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-filter-${ useInstanceId( BlockListBlock ) }`;\n\n\t\tconst selectors = duotoneSupport.split( ',' );\n\t\tconst selectorsScoped = selectors.map(\n\t\t\t( selector ) => `.${ id } ${ selector.trim() }`\n\t\t);\n\t\tconst selectorsGroup = selectorsScoped.join( ', ' );\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","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,CAA8BC,MAAM,GAAG,EAAvC,EAA4C;AAClD,QAAMC,MAAM,GAAG;AAAEC,IAAAA,CAAC,EAAE,EAAL;AAASC,IAAAA,CAAC,EAAE,EAAZ;AAAgBC,IAAAA,CAAC,EAAE,EAAnB;AAAuBC,IAAAA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CAAGA,KAAK,CAAElB,UAAV,+EAAG,kBAAmBE,KAAtB,oFAAG,sBAA0BjB,KAA7B,2DAAG,uBAAiCkB,OAAhD;;AAEA,MAAK,CAAE6B,cAAF,IAAoB,CAAErD,MAA3B,EAAoC;AACnC,WAAO,4BAAC,cAAD,EAAqBuC,KAArB,CAAP;AACA;;AAED,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"]}
|
|
@@ -9,6 +9,8 @@ exports.FontAppearanceEdit = FontAppearanceEdit;
|
|
|
9
9
|
exports.useIsFontStyleDisabled = useIsFontStyleDisabled;
|
|
10
10
|
exports.useIsFontWeightDisabled = useIsFontWeightDisabled;
|
|
11
11
|
exports.useIsFontAppearanceDisabled = useIsFontAppearanceDisabled;
|
|
12
|
+
exports.hasFontAppearanceValue = hasFontAppearanceValue;
|
|
13
|
+
exports.resetFontAppearance = resetFontAppearance;
|
|
12
14
|
exports.FONT_WEIGHT_SUPPORT_KEY = exports.FONT_STYLE_SUPPORT_KEY = void 0;
|
|
13
15
|
|
|
14
16
|
var _element = require("@wordpress/element");
|
|
@@ -61,10 +63,6 @@ function FontAppearanceEdit(props) {
|
|
|
61
63
|
const hasFontStyles = !useIsFontStyleDisabled(props);
|
|
62
64
|
const hasFontWeights = !useIsFontWeightDisabled(props);
|
|
63
65
|
|
|
64
|
-
if (!hasFontStyles && !hasFontWeights) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
66
|
const onChange = newStyles => {
|
|
69
67
|
setAttributes({
|
|
70
68
|
style: (0, _utils.cleanEmptyObject)({ ...style,
|
|
@@ -103,7 +101,7 @@ function useIsFontStyleDisabled({
|
|
|
103
101
|
name: blockName
|
|
104
102
|
} = {}) {
|
|
105
103
|
const styleSupport = (0, _blocks.hasBlockSupport)(blockName, FONT_STYLE_SUPPORT_KEY);
|
|
106
|
-
const hasFontStyles = (0, _useSetting.default)('typography.
|
|
104
|
+
const hasFontStyles = (0, _useSetting.default)('typography.fontStyle');
|
|
107
105
|
return !styleSupport || !hasFontStyles;
|
|
108
106
|
}
|
|
109
107
|
/**
|
|
@@ -121,7 +119,7 @@ function useIsFontWeightDisabled({
|
|
|
121
119
|
name: blockName
|
|
122
120
|
} = {}) {
|
|
123
121
|
const weightSupport = (0, _blocks.hasBlockSupport)(blockName, FONT_WEIGHT_SUPPORT_KEY);
|
|
124
|
-
const hasFontWeights = (0, _useSetting.default)('typography.
|
|
122
|
+
const hasFontWeights = (0, _useSetting.default)('typography.fontWeight');
|
|
125
123
|
return !weightSupport || !hasFontWeights;
|
|
126
124
|
}
|
|
127
125
|
/**
|
|
@@ -138,4 +136,49 @@ function useIsFontAppearanceDisabled(props) {
|
|
|
138
136
|
const weightsDisabled = useIsFontWeightDisabled(props);
|
|
139
137
|
return stylesDisabled && weightsDisabled;
|
|
140
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Checks if there is either a font style or weight value set within the
|
|
141
|
+
* typography styles.
|
|
142
|
+
*
|
|
143
|
+
* @param {Object} props Block props.
|
|
144
|
+
* @return {boolean} Whether or not the block has a font style or weight.
|
|
145
|
+
*/
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
function hasFontAppearanceValue(props) {
|
|
149
|
+
var _props$attributes$sty;
|
|
150
|
+
|
|
151
|
+
const {
|
|
152
|
+
fontStyle,
|
|
153
|
+
fontWeight
|
|
154
|
+
} = ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : _props$attributes$sty.typography) || {};
|
|
155
|
+
return !!fontStyle || !!fontWeight;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Resets the font style and weight block support attributes. This can be used
|
|
159
|
+
* when disabling the font appearance support controls for a block via a
|
|
160
|
+
* progressive discovery panel.
|
|
161
|
+
*
|
|
162
|
+
* @param {Object} props Block props.
|
|
163
|
+
* @param {Object} props.attributes Block's attributes.
|
|
164
|
+
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
165
|
+
*/
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
function resetFontAppearance({
|
|
169
|
+
attributes = {},
|
|
170
|
+
setAttributes
|
|
171
|
+
}) {
|
|
172
|
+
const {
|
|
173
|
+
style
|
|
174
|
+
} = attributes;
|
|
175
|
+
setAttributes({
|
|
176
|
+
style: (0, _utils.cleanEmptyObject)({ ...style,
|
|
177
|
+
typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
|
|
178
|
+
fontStyle: undefined,
|
|
179
|
+
fontWeight: undefined
|
|
180
|
+
}
|
|
181
|
+
})
|
|
182
|
+
});
|
|
183
|
+
}
|
|
141
184
|
//# sourceMappingURL=font-appearance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/font-appearance.js"],"names":["FONT_STYLE_SUPPORT_KEY","FONT_WEIGHT_SUPPORT_KEY","FontAppearanceEdit","props","attributes","style","setAttributes","hasFontStyles","useIsFontStyleDisabled","hasFontWeights","useIsFontWeightDisabled","onChange","newStyles","typography","fontStyle","fontWeight","name","blockName","styleSupport","weightSupport","useIsFontAppearanceDisabled","stylesDisabled","weightsDisabled"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/font-appearance.js"],"names":["FONT_STYLE_SUPPORT_KEY","FONT_WEIGHT_SUPPORT_KEY","FontAppearanceEdit","props","attributes","style","setAttributes","hasFontStyles","useIsFontStyleDisabled","hasFontWeights","useIsFontWeightDisabled","onChange","newStyles","typography","fontStyle","fontWeight","name","blockName","styleSupport","weightSupport","useIsFontAppearanceDisabled","stylesDisabled","weightsDisabled","hasFontAppearanceValue","resetFontAppearance","undefined"],"mappings":";;;;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AACO,MAAMA,sBAAsB,GAAG,oCAA/B;AAEP;AACA;AACA;;;AACO,MAAMC,uBAAuB,GAAG,qCAAhC;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASC,kBAAT,CAA6BC,KAA7B,EAAqC;AAAA;;AAC3C,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELC,IAAAA;AAFK,MAGFH,KAHJ;AAKA,QAAMI,aAAa,GAAG,CAAEC,sBAAsB,CAAEL,KAAF,CAA9C;AACA,QAAMM,cAAc,GAAG,CAAEC,uBAAuB,CAAEP,KAAF,CAAhD;;AAEA,QAAMQ,QAAQ,GAAKC,SAAF,IAAiB;AACjCN,IAAAA,aAAa,CAAE;AACdD,MAAAA,KAAK,EAAE,6BAAkB,EACxB,GAAGA,KADqB;AAExBQ,QAAAA,UAAU,EAAE,EACX,IAAGR,KAAH,aAAGA,KAAH,uBAA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,QAAMkB,cAAc,GAAGb,sBAAsB,CAAEL,KAAF,CAA7C;AACA,QAAMmB,eAAe,GAAGZ,uBAAuB,CAAEP,KAAF,CAA/C;AAEA,SAAOkB,cAAc,IAAIC,eAAzB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,sBAAT,CAAiCpB,KAAjC,EAAyC;AAAA;;AAC/C,QAAM;AAAEW,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA4B,0BAAAZ,KAAK,CAACC,UAAN,CAAiBC,KAAjB,gFAAwBQ,UAAxB,KAAsC,EAAxE;AACA,SAAO,CAAC,CAAEC,SAAH,IAAgB,CAAC,CAAEC,UAA1B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASS,mBAAT,CAA8B;AAAEpB,EAAAA,UAAU,GAAG,EAAf;AAAmBE,EAAAA;AAAnB,CAA9B,EAAmE;AACzE,QAAM;AAAED,IAAAA;AAAF,MAAYD,UAAlB;AAEAE,EAAAA,aAAa,CAAE;AACdD,IAAAA,KAAK,EAAE,6BAAkB,EACxB,GAAGA,KADqB;AAExBQ,MAAAA,UAAU,EAAE,EACX,IAAGR,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEQ,UAAV,CADW;AAEXC,QAAAA,SAAS,EAAEW,SAFA;AAGXV,QAAAA,UAAU,EAAEU;AAHD;AAFY,KAAlB;AADO,GAAF,CAAb;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport FontAppearanceControl from '../components/font-appearance-control';\nimport useSetting from '../components/use-setting';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Key within block settings' support array indicating support for font style.\n */\nexport const FONT_STYLE_SUPPORT_KEY = 'typography.__experimentalFontStyle';\n\n/**\n * Key within block settings' support array indicating support for font weight.\n */\nexport const FONT_WEIGHT_SUPPORT_KEY = 'typography.__experimentalFontWeight';\n\n/**\n * Inspector control panel containing the font appearance options.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Font appearance edit element.\n */\nexport function FontAppearanceEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tconst hasFontStyles = ! useIsFontStyleDisabled( props );\n\tconst hasFontWeights = ! useIsFontWeightDisabled( props );\n\n\tconst onChange = ( newStyles ) => {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\ttypography: {\n\t\t\t\t\t...style?.typography,\n\t\t\t\t\tfontStyle: newStyles.fontStyle,\n\t\t\t\t\tfontWeight: newStyles.fontWeight,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t};\n\n\tconst fontStyle = style?.typography?.fontStyle;\n\tconst fontWeight = style?.typography?.fontWeight;\n\n\treturn (\n\t\t<FontAppearanceControl\n\t\t\tonChange={ onChange }\n\t\t\thasFontStyles={ hasFontStyles }\n\t\t\thasFontWeights={ hasFontWeights }\n\t\t\tvalue={ { fontStyle, fontWeight } }\n\t\t/>\n\t);\n}\n\n/**\n * Checks if font style support has been disabled either by not opting in for\n * support or by failing to provide preset styles.\n *\n * @param {Object} props Block properties.\n * @param {string} props.name Name for the block type.\n *\n * @return {boolean} Whether font style support has been disabled.\n */\nexport function useIsFontStyleDisabled( { name: blockName } = {} ) {\n\tconst styleSupport = hasBlockSupport( blockName, FONT_STYLE_SUPPORT_KEY );\n\tconst hasFontStyles = useSetting( 'typography.fontStyle' );\n\n\treturn ! styleSupport || ! hasFontStyles;\n}\n\n/**\n * Checks if font weight support has been disabled either by not opting in for\n * support or by failing to provide preset weights.\n *\n * @param {Object} props Block properties.\n * @param {string} props.name Name for the block type.\n *\n * @return {boolean} Whether font weight support has been disabled.\n */\nexport function useIsFontWeightDisabled( { name: blockName } = {} ) {\n\tconst weightSupport = hasBlockSupport( blockName, FONT_WEIGHT_SUPPORT_KEY );\n\tconst hasFontWeights = useSetting( 'typography.fontWeight' );\n\n\treturn ! weightSupport || ! hasFontWeights;\n}\n\n/**\n * Checks if font appearance support has been disabled.\n *\n * @param {Object} props Block properties.\n *\n * @return {boolean} Whether font appearance support has been disabled.\n */\nexport function useIsFontAppearanceDisabled( props ) {\n\tconst stylesDisabled = useIsFontStyleDisabled( props );\n\tconst weightsDisabled = useIsFontWeightDisabled( props );\n\n\treturn stylesDisabled && weightsDisabled;\n}\n\n/**\n * Checks if there is either a font style or weight value set within the\n * typography styles.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a font style or weight.\n */\nexport function hasFontAppearanceValue( props ) {\n\tconst { fontStyle, fontWeight } = props.attributes.style?.typography || {};\n\treturn !! fontStyle || !! fontWeight;\n}\n\n/**\n * Resets the font style and weight block support attributes. This can be used\n * when disabling the font appearance support controls for a block via a\n * progressive discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetFontAppearance( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\ttypography: {\n\t\t\t\t...style?.typography,\n\t\t\t\tfontStyle: undefined,\n\t\t\t\tfontWeight: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n"]}
|
|
@@ -7,15 +7,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.FontFamilyEdit = FontFamilyEdit;
|
|
9
9
|
exports.useIsFontFamilyDisabled = useIsFontFamilyDisabled;
|
|
10
|
+
exports.hasFontFamilyValue = hasFontFamilyValue;
|
|
11
|
+
exports.resetFontFamily = resetFontFamily;
|
|
10
12
|
exports.FONT_FAMILY_SUPPORT_KEY = void 0;
|
|
11
13
|
|
|
12
14
|
var _element = require("@wordpress/element");
|
|
13
15
|
|
|
14
16
|
var _lodash = require("lodash");
|
|
15
17
|
|
|
18
|
+
var _hooks = require("@wordpress/hooks");
|
|
19
|
+
|
|
16
20
|
var _blocks = require("@wordpress/blocks");
|
|
17
21
|
|
|
18
|
-
var
|
|
22
|
+
var _tokenList = _interopRequireDefault(require("@wordpress/token-list"));
|
|
19
23
|
|
|
20
24
|
var _useSetting = _interopRequireDefault(require("../components/use-setting"));
|
|
21
25
|
|
|
@@ -33,56 +37,111 @@ var _fontFamily = _interopRequireDefault(require("../components/font-family"));
|
|
|
33
37
|
* Internal dependencies
|
|
34
38
|
*/
|
|
35
39
|
const FONT_FAMILY_SUPPORT_KEY = 'typography.__experimentalFontFamily';
|
|
40
|
+
/**
|
|
41
|
+
* Filters registered block settings, extending attributes to include
|
|
42
|
+
* the `fontFamily` attribute.
|
|
43
|
+
*
|
|
44
|
+
* @param {Object} settings Original block settings
|
|
45
|
+
* @return {Object} Filtered block settings
|
|
46
|
+
*/
|
|
47
|
+
|
|
36
48
|
exports.FONT_FAMILY_SUPPORT_KEY = FONT_FAMILY_SUPPORT_KEY;
|
|
37
49
|
|
|
38
|
-
|
|
39
|
-
|
|
50
|
+
function addAttributes(settings) {
|
|
51
|
+
if (!(0, _blocks.hasBlockSupport)(settings, FONT_FAMILY_SUPPORT_KEY)) {
|
|
52
|
+
return settings;
|
|
53
|
+
} // Allow blocks to specify a default value if needed.
|
|
54
|
+
|
|
40
55
|
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
56
|
+
if (!settings.attributes.fontFamily) {
|
|
57
|
+
Object.assign(settings.attributes, {
|
|
58
|
+
fontFamily: {
|
|
59
|
+
type: 'string'
|
|
60
|
+
}
|
|
46
61
|
});
|
|
62
|
+
}
|
|
47
63
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
64
|
+
return settings;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Override props assigned to save component to inject font family.
|
|
68
|
+
*
|
|
69
|
+
* @param {Object} props Additional props applied to save element
|
|
70
|
+
* @param {Object} blockType Block type
|
|
71
|
+
* @param {Object} attributes Block attributes
|
|
72
|
+
* @return {Object} Filtered props applied to save element
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
function addSaveProps(props, blockType, attributes) {
|
|
77
|
+
if (!(0, _blocks.hasBlockSupport)(blockType, FONT_FAMILY_SUPPORT_KEY)) {
|
|
78
|
+
return props;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if ((0, _blocks.hasBlockSupport)(blockType, 'typography.__experimentalSkipSerialization')) {
|
|
82
|
+
return props;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (!(attributes !== null && attributes !== void 0 && attributes.fontFamily)) {
|
|
86
|
+
return props;
|
|
87
|
+
} // Use TokenList to dedupe classes.
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
const classes = new _tokenList.default(props.className);
|
|
91
|
+
classes.add(`has-${(0, _lodash.kebabCase)(attributes === null || attributes === void 0 ? void 0 : attributes.fontFamily)}-font-family`);
|
|
92
|
+
const newClassName = classes.value;
|
|
93
|
+
props.className = newClassName ? newClassName : undefined;
|
|
94
|
+
return props;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Filters registered block settings to expand the block edit wrapper
|
|
98
|
+
* by applying the desired styles and classnames.
|
|
99
|
+
*
|
|
100
|
+
* @param {Object} settings Original block settings.
|
|
101
|
+
*
|
|
102
|
+
* @return {Object} Filtered block settings.
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
function addEditProps(settings) {
|
|
107
|
+
if (!(0, _blocks.hasBlockSupport)(settings, FONT_FAMILY_SUPPORT_KEY)) {
|
|
108
|
+
return settings;
|
|
51
109
|
}
|
|
52
110
|
|
|
53
|
-
|
|
54
|
-
|
|
111
|
+
const existingGetEditWrapperProps = settings.getEditWrapperProps;
|
|
112
|
+
|
|
113
|
+
settings.getEditWrapperProps = attributes => {
|
|
114
|
+
let props = {};
|
|
115
|
+
|
|
116
|
+
if (existingGetEditWrapperProps) {
|
|
117
|
+
props = existingGetEditWrapperProps(attributes);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return addSaveProps(props, settings, attributes);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
return settings;
|
|
124
|
+
}
|
|
55
125
|
|
|
56
126
|
function FontFamilyEdit({
|
|
57
|
-
name,
|
|
58
127
|
setAttributes,
|
|
59
128
|
attributes: {
|
|
60
|
-
|
|
129
|
+
fontFamily
|
|
61
130
|
}
|
|
62
131
|
}) {
|
|
63
|
-
var
|
|
132
|
+
var _find;
|
|
64
133
|
|
|
65
134
|
const fontFamilies = (0, _useSetting.default)('typography.fontFamilies');
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
if (isDisable) {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const value = getFontFamilyFromAttributeValue(fontFamilies, (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.fontFamily);
|
|
135
|
+
const value = (_find = (0, _lodash.find)(fontFamilies, ({
|
|
136
|
+
slug
|
|
137
|
+
}) => fontFamily === slug)) === null || _find === void 0 ? void 0 : _find.fontFamily;
|
|
75
138
|
|
|
76
139
|
function onChange(newValue) {
|
|
77
140
|
const predefinedFontFamily = (0, _lodash.find)(fontFamilies, ({
|
|
78
|
-
fontFamily
|
|
79
|
-
}) =>
|
|
141
|
+
fontFamily: f
|
|
142
|
+
}) => f === newValue);
|
|
80
143
|
setAttributes({
|
|
81
|
-
|
|
82
|
-
typography: { ...(style.typography || {}),
|
|
83
|
-
fontFamily: predefinedFontFamily ? `var:preset|font-family|${predefinedFontFamily.slug}` : newValue || undefined
|
|
84
|
-
}
|
|
85
|
-
})
|
|
144
|
+
fontFamily: predefinedFontFamily === null || predefinedFontFamily === void 0 ? void 0 : predefinedFontFamily.slug
|
|
86
145
|
});
|
|
87
146
|
}
|
|
88
147
|
|
|
@@ -107,4 +166,36 @@ function useIsFontFamilyDisabled({
|
|
|
107
166
|
const fontFamilies = (0, _useSetting.default)('typography.fontFamilies');
|
|
108
167
|
return !fontFamilies || fontFamilies.length === 0 || !(0, _blocks.hasBlockSupport)(name, FONT_FAMILY_SUPPORT_KEY);
|
|
109
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Checks if there is a current value set for the font family block support.
|
|
171
|
+
*
|
|
172
|
+
* @param {Object} props Block props.
|
|
173
|
+
* @return {boolean} Whether or not the block has a font family value set.
|
|
174
|
+
*/
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
function hasFontFamilyValue(props) {
|
|
178
|
+
return !!props.attributes.fontFamily;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Resets the font family block support attribute. This can be used when
|
|
182
|
+
* disabling the font family support controls for a block via a progressive
|
|
183
|
+
* discovery panel.
|
|
184
|
+
*
|
|
185
|
+
* @param {Object} props Block props.
|
|
186
|
+
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
187
|
+
*/
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
function resetFontFamily({
|
|
191
|
+
setAttributes
|
|
192
|
+
}) {
|
|
193
|
+
setAttributes({
|
|
194
|
+
fontFamily: undefined
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
(0, _hooks.addFilter)('blocks.registerBlockType', 'core/fontFamily/addAttribute', addAttributes);
|
|
199
|
+
(0, _hooks.addFilter)('blocks.getSaveContent.extraProps', 'core/fontFamily/addSaveProps', addSaveProps);
|
|
200
|
+
(0, _hooks.addFilter)('blocks.registerBlockType', 'core/fontFamily/addEditProps', addEditProps);
|
|
110
201
|
//# sourceMappingURL=font-family.js.map
|