@wordpress/block-editor 12.11.1 → 12.12.2-next.f8d8eceb.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -10
- package/README.md +35 -3
- package/build/components/block-alignment-control/use-available-alignments.js +30 -28
- package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build/components/block-controls/hook.js +4 -1
- package/build/components/block-controls/hook.js.map +1 -1
- package/build/components/block-list/block-outline.native.js +1 -1
- package/build/components/block-list/block-outline.native.js.map +1 -1
- package/build/components/block-list/block.js +2 -0
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +4 -4
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/layout.js +2 -3
- package/build/components/block-list/layout.js.map +1 -1
- package/build/components/block-preview/index.js +4 -1
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-styles/index.js +1 -2
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/pattern-transformations-menu.js +2 -4
- package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +1 -0
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/border-radius-control/index.js +3 -2
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/color-palette/with-color-context.js +6 -6
- package/build/components/color-palette/with-color-context.js.map +1 -1
- package/build/components/colors/with-colors.js +2 -8
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/colors-gradients/control.js +6 -7
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +5 -13
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build/components/dimensions-tool/index.js +22 -22
- package/build/components/dimensions-tool/index.js.map +1 -1
- package/build/components/dimensions-tool/scale-tool.js +1 -1
- package/build/components/dimensions-tool/scale-tool.js.map +1 -1
- package/build/components/font-family/index.js +2 -3
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/font-sizes/font-size-picker.js +3 -5
- package/build/components/font-sizes/font-size-picker.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +3 -4
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +7 -8
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js +2 -2
- package/build/components/global-styles/image-settings-panel.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +1 -1
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/gradients/use-gradient.js +2 -5
- package/build/components/gradients/use-gradient.js.map +1 -1
- package/build/components/height-control/index.js +93 -5
- package/build/components/height-control/index.js.map +1 -1
- package/build/components/iframe/index.js +9 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js +0 -6
- package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build/components/index.js +9 -2
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +17 -2
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/index.js +2 -2
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +3 -3
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/link-control/link-preview.js +5 -2
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-item.js +11 -0
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/link-control/search-results.js +2 -1
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/link-control/use-internal-value.js +14 -8
- package/build/components/link-control/use-internal-value.js.map +1 -1
- package/build/components/link-control/use-search-handler.js +10 -5
- package/build/components/link-control/use-search-handler.js.map +1 -1
- package/build/components/list-view/index.js +6 -5
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +2 -4
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/provider/use-block-sync.js +2 -2
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/rich-text/index.js +1 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +14 -3
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-delete.js +1 -1
- package/build/components/rich-text/use-delete.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +25 -22
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +6 -3
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +91 -3
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/tool-selector/index.js +1 -2
- package/build/components/tool-selector/index.js.map +1 -1
- package/build/components/unit-control/index.js +3 -3
- package/build/components/unit-control/index.js.map +1 -1
- package/build/components/use-block-commands/index.js +96 -47
- package/build/components/use-block-commands/index.js.map +1 -1
- package/build/components/use-settings/index.js +212 -0
- package/build/components/use-settings/index.js.map +1 -0
- package/build/components/writing-flow/use-arrow-nav.js +4 -0
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/hooks/align.js +51 -35
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/anchor.js +37 -32
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/background.js +4 -4
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-rename-ui.js +5 -5
- package/build/hooks/block-rename-ui.js.map +1 -1
- package/build/hooks/{metadata-name.js → block-renaming.js} +3 -7
- package/build/hooks/block-renaming.js.map +1 -0
- package/build/hooks/color.js +2 -4
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/custom-class-name.js +28 -21
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/duotone.js +33 -8
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/font-size.js +4 -4
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/index.js +1 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +16 -17
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/line-height.js +3 -3
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/metadata.js +6 -27
- package/build/hooks/metadata.js.map +1 -1
- package/build/hooks/position.js +2 -3
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/use-color-props.js +3 -11
- package/build/hooks/use-color-props.js.map +1 -1
- package/build/hooks/utils.js +2 -43
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +3 -3
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/grid.js +25 -3
- package/build/layouts/grid.js.map +1 -1
- package/build/layouts/utils.js +1 -1
- package/build/layouts/utils.js.map +1 -1
- package/build/lock-unlock.js +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/store/actions.js +13 -5
- package/build/store/actions.js.map +1 -1
- package/build/utils/object.js +4 -1
- package/build/utils/object.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +20 -0
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build/utils/pasting.js +1 -1
- package/build/utils/pasting.js.map +1 -1
- package/build/utils/transform-styles/index.js +19 -24
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +30 -28
- package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build-module/components/block-controls/hook.js +4 -1
- package/build-module/components/block-controls/hook.js.map +1 -1
- package/build-module/components/block-list/block-outline.native.js +1 -1
- package/build-module/components/block-list/block-outline.native.js.map +1 -1
- package/build-module/components/block-list/block.js +2 -0
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +4 -4
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/layout.js +2 -2
- package/build-module/components/block-list/layout.js.map +1 -1
- package/build-module/components/block-preview/index.js +4 -1
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +1 -2
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-switcher/pattern-transformations-menu.js +2 -4
- package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +1 -0
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +3 -2
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/color-palette/with-color-context.js +6 -5
- package/build-module/components/color-palette/with-color-context.js.map +1 -1
- package/build-module/components/colors/with-colors.js +2 -7
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +6 -7
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +5 -12
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build-module/components/dimensions-tool/index.js +22 -22
- package/build-module/components/dimensions-tool/index.js.map +1 -1
- package/build-module/components/dimensions-tool/scale-tool.js +1 -1
- package/build-module/components/dimensions-tool/scale-tool.js.map +1 -1
- package/build-module/components/font-family/index.js +2 -2
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/font-sizes/font-size-picker.js +3 -4
- package/build-module/components/font-sizes/font-size-picker.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +3 -3
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +7 -8
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js +2 -2
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +1 -1
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/gradients/use-gradient.js +2 -4
- package/build-module/components/gradients/use-gradient.js.map +1 -1
- package/build-module/components/height-control/index.js +93 -4
- package/build-module/components/height-control/index.js.map +1 -1
- package/build-module/components/iframe/index.js +9 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js +0 -6
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build-module/components/index.js +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +2 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +2 -2
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +3 -2
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +6 -3
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-item.js +12 -1
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/link-control/search-results.js +2 -1
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/link-control/use-internal-value.js +14 -9
- package/build-module/components/link-control/use-internal-value.js.map +1 -1
- package/build-module/components/link-control/use-search-handler.js +10 -5
- package/build-module/components/link-control/use-search-handler.js.map +1 -1
- package/build-module/components/list-view/index.js +7 -6
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +3 -5
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +2 -2
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/rich-text/index.js +1 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +15 -4
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-delete.js +1 -1
- package/build-module/components/rich-text/use-delete.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +25 -22
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +6 -2
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +91 -2
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/tool-selector/index.js +1 -2
- package/build-module/components/tool-selector/index.js.map +1 -1
- package/build-module/components/unit-control/index.js +3 -2
- package/build-module/components/unit-control/index.js.map +1 -1
- package/build-module/components/use-block-commands/index.js +95 -47
- package/build-module/components/use-block-commands/index.js.map +1 -1
- package/build-module/components/use-settings/index.js +203 -0
- package/build-module/components/use-settings/index.js.map +1 -0
- package/build-module/components/writing-flow/use-arrow-nav.js +4 -0
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/hooks/align.js +51 -35
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/anchor.js +37 -32
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/background.js +4 -4
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-rename-ui.js +6 -6
- package/build-module/hooks/block-rename-ui.js.map +1 -1
- package/build-module/hooks/{metadata-name.js → block-renaming.js} +3 -6
- package/build-module/hooks/block-renaming.js.map +1 -0
- package/build-module/hooks/color.js +2 -4
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +28 -21
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/duotone.js +34 -9
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/font-size.js +4 -4
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/index.js +1 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +16 -17
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/line-height.js +3 -3
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/metadata.js +6 -25
- package/build-module/hooks/metadata.js.map +1 -1
- package/build-module/hooks/position.js +2 -3
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/use-color-props.js +3 -11
- package/build-module/hooks/use-color-props.js.map +1 -1
- package/build-module/hooks/utils.js +3 -44
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +3 -2
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/grid.js +25 -3
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/layouts/utils.js +1 -1
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/lock-unlock.js +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/store/actions.js +14 -6
- package/build-module/store/actions.js.map +1 -1
- package/build-module/utils/object.js +3 -1
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +20 -0
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/utils/pasting.js +1 -1
- package/build-module/utils/pasting.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +20 -24
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-style/style-rtl.css +24 -12
- package/build-style/style.css +24 -12
- package/package.json +36 -34
- package/src/components/block-alignment-control/use-available-alignments.js +49 -34
- package/src/components/block-controls/hook.js +6 -3
- package/src/components/block-list/block-outline.native.js +1 -1
- package/src/components/block-list/block.js +2 -0
- package/src/components/block-list/block.native.js +4 -4
- package/src/components/block-list/layout.js +2 -2
- package/src/components/block-preview/index.js +7 -1
- package/src/components/block-styles/index.js +1 -4
- package/src/components/block-styles/style.scss +1 -1
- package/src/components/block-switcher/pattern-transformations-menu.js +1 -4
- package/src/components/block-switcher/style.scss +6 -0
- package/src/components/block-tools/block-contextual-toolbar.js +1 -0
- package/src/components/block-tools/style.scss +0 -1
- package/src/components/border-radius-control/index.js +3 -2
- package/src/components/color-palette/test/__snapshots__/control.js.snap +3 -1
- package/src/components/color-palette/with-color-context.js +9 -9
- package/src/components/colors/with-colors.js +6 -7
- package/src/components/colors-gradients/control.js +10 -7
- package/src/components/colors-gradients/style.scss +4 -2
- package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +29 -15
- package/src/components/dimensions-tool/index.js +25 -25
- package/src/components/dimensions-tool/scale-tool.js +1 -1
- package/src/components/font-family/index.js +2 -2
- package/src/components/font-sizes/font-size-picker.js +6 -4
- package/src/components/font-sizes/with-font-sizes.js +3 -5
- package/src/components/global-styles/filters-panel.js +9 -15
- package/src/components/global-styles/image-settings-panel.js +2 -2
- package/src/components/global-styles/typography-panel.js +1 -1
- package/src/components/gradients/use-gradient.js +10 -4
- package/src/components/height-control/index.js +53 -4
- package/src/components/iframe/index.js +8 -1
- package/src/components/image-editor/aspect-ratio-dropdown.js +0 -8
- package/src/components/index.js +1 -1
- package/src/components/index.native.js +2 -1
- package/src/components/inner-blocks/index.js +2 -2
- package/src/components/inserter/style.scss +9 -1
- package/src/components/letter-spacing-control/index.js +3 -2
- package/src/components/link-control/README.md +43 -0
- package/src/components/link-control/link-preview.js +11 -5
- package/src/components/link-control/search-item.js +14 -0
- package/src/components/link-control/search-results.js +1 -0
- package/src/components/link-control/style.scss +3 -3
- package/src/components/link-control/test/index.js +19 -0
- package/src/components/link-control/use-internal-value.js +14 -10
- package/src/components/link-control/use-search-handler.js +22 -15
- package/src/components/list-view/index.js +13 -3
- package/src/components/media-replace-flow/index.js +9 -14
- package/src/components/provider/test/use-block-sync.js +1 -1
- package/src/components/provider/use-block-sync.js +2 -2
- package/src/components/rich-text/index.js +1 -1
- package/src/components/rich-text/index.native.js +19 -3
- package/src/components/rich-text/use-delete.js +1 -1
- package/src/components/rich-text/use-paste-handler.js +27 -24
- package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +7 -5
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +25 -2
- package/src/components/tool-selector/index.js +1 -1
- package/src/components/unit-control/index.js +3 -8
- package/src/components/use-block-commands/index.js +93 -47
- package/src/components/{use-setting → use-settings}/README.md +9 -10
- package/src/components/use-settings/index.js +272 -0
- package/src/components/{use-setting → use-settings}/test/index.js +47 -5
- package/src/components/writing-flow/use-arrow-nav.js +4 -0
- package/src/hooks/align.js +79 -54
- package/src/hooks/anchor.js +75 -65
- package/src/hooks/background.js +7 -9
- package/src/hooks/block-rename-ui.js +5 -14
- package/src/hooks/{metadata-name.js → block-renaming.js} +4 -7
- package/src/hooks/color.js +7 -4
- package/src/hooks/custom-class-name.js +36 -31
- package/src/hooks/duotone.js +51 -14
- package/src/hooks/font-size.js +4 -4
- package/src/hooks/index.js +1 -1
- package/src/hooks/layout.js +17 -17
- package/src/hooks/line-height.js +3 -3
- package/src/hooks/metadata.js +6 -38
- package/src/hooks/position.js +5 -3
- package/src/hooks/use-color-props.js +21 -14
- package/src/hooks/utils.js +90 -43
- package/src/layouts/constrained.js +3 -8
- package/src/layouts/grid.js +50 -2
- package/src/layouts/utils.js +2 -1
- package/src/lock-unlock.js +1 -1
- package/src/store/actions.js +25 -8
- package/src/utils/object.js +4 -1
- package/src/utils/parse-css-unit-to-px.js +20 -0
- package/src/utils/pasting.js +1 -4
- package/src/utils/test/__snapshots__/transform-styles.js.snap +103 -0
- package/src/utils/test/pasting.js +12 -19
- package/src/utils/test/transform-styles.js +217 -0
- package/src/utils/transform-styles/index.js +25 -25
- package/build/components/use-setting/index.js +0 -159
- package/build/components/use-setting/index.js.map +0 -1
- package/build/hooks/metadata-name.js.map +0 -1
- package/build/utils/transform-styles/ast/index.js +0 -21
- package/build/utils/transform-styles/ast/index.js.map +0 -1
- package/build/utils/transform-styles/ast/parse.js +0 -660
- package/build/utils/transform-styles/ast/parse.js.map +0 -1
- package/build/utils/transform-styles/ast/stringify/compiler.js +0 -52
- package/build/utils/transform-styles/ast/stringify/compiler.js.map +0 -1
- package/build/utils/transform-styles/ast/stringify/compress.js +0 -178
- package/build/utils/transform-styles/ast/stringify/compress.js.map +0 -1
- package/build/utils/transform-styles/ast/stringify/identity.js +0 -207
- package/build/utils/transform-styles/ast/stringify/identity.js.map +0 -1
- package/build/utils/transform-styles/ast/stringify/index.js +0 -36
- package/build/utils/transform-styles/ast/stringify/index.js.map +0 -1
- package/build/utils/transform-styles/transforms/url-rewrite.js +0 -130
- package/build/utils/transform-styles/transforms/url-rewrite.js.map +0 -1
- package/build/utils/transform-styles/transforms/wrap.js +0 -59
- package/build/utils/transform-styles/transforms/wrap.js.map +0 -1
- package/build/utils/transform-styles/traverse.js +0 -37
- package/build/utils/transform-styles/traverse.js.map +0 -1
- package/build-module/components/use-setting/index.js +0 -152
- package/build-module/components/use-setting/index.js.map +0 -1
- package/build-module/hooks/metadata-name.js.map +0 -1
- package/build-module/utils/transform-styles/ast/index.js +0 -6
- package/build-module/utils/transform-styles/ast/index.js.map +0 -1
- package/build-module/utils/transform-styles/ast/parse.js +0 -654
- package/build-module/utils/transform-styles/ast/parse.js.map +0 -1
- package/build-module/utils/transform-styles/ast/stringify/compiler.js +0 -49
- package/build-module/utils/transform-styles/ast/stringify/compiler.js.map +0 -1
- package/build-module/utils/transform-styles/ast/stringify/compress.js +0 -176
- package/build-module/utils/transform-styles/ast/stringify/compress.js.map +0 -1
- package/build-module/utils/transform-styles/ast/stringify/identity.js +0 -206
- package/build-module/utils/transform-styles/ast/stringify/identity.js.map +0 -1
- package/build-module/utils/transform-styles/ast/stringify/index.js +0 -29
- package/build-module/utils/transform-styles/ast/stringify/index.js.map +0 -1
- package/build-module/utils/transform-styles/transforms/url-rewrite.js +0 -123
- package/build-module/utils/transform-styles/transforms/url-rewrite.js.map +0 -1
- package/build-module/utils/transform-styles/transforms/wrap.js +0 -52
- package/build-module/utils/transform-styles/transforms/wrap.js.map +0 -1
- package/build-module/utils/transform-styles/traverse.js +0 -28
- package/build-module/utils/transform-styles/traverse.js.map +0 -1
- package/src/components/use-setting/index.js +0 -213
- package/src/utils/transform-styles/ast/index.js +0 -5
- package/src/utils/transform-styles/ast/parse.js +0 -732
- package/src/utils/transform-styles/ast/stringify/compiler.js +0 -50
- package/src/utils/transform-styles/ast/stringify/compress.js +0 -238
- package/src/utils/transform-styles/ast/stringify/identity.js +0 -286
- package/src/utils/transform-styles/ast/stringify/index.js +0 -32
- package/src/utils/transform-styles/test/__snapshots__/traverse.js.snap +0 -7
- package/src/utils/transform-styles/test/traverse.js +0 -24
- package/src/utils/transform-styles/transforms/test/__snapshots__/url-rewrite.js.snap +0 -25
- package/src/utils/transform-styles/transforms/test/__snapshots__/wrap.js.snap +0 -64
- package/src/utils/transform-styles/transforms/test/url-rewrite.js +0 -39
- package/src/utils/transform-styles/transforms/test/wrap.js +0 -95
- package/src/utils/transform-styles/transforms/url-rewrite.js +0 -139
- package/src/utils/transform-styles/transforms/wrap.js +0 -56
- package/src/utils/transform-styles/traverse.js +0 -32
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Return `true` if the given path is http/https.
|
|
3
|
-
*
|
|
4
|
-
* @param {string} filePath path
|
|
5
|
-
*
|
|
6
|
-
* @return {boolean} is remote path.
|
|
7
|
-
*/
|
|
8
|
-
function isRemotePath(filePath) {
|
|
9
|
-
return /^(?:https?:)?\/\//.test(filePath);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Return `true` if the given filePath is an absolute url.
|
|
14
|
-
*
|
|
15
|
-
* @param {string} filePath path
|
|
16
|
-
*
|
|
17
|
-
* @return {boolean} is absolute path.
|
|
18
|
-
*/
|
|
19
|
-
function isAbsolutePath(filePath) {
|
|
20
|
-
return /^\/(?!\/)/.test(filePath);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Whether or not the url should be inluded.
|
|
25
|
-
*
|
|
26
|
-
* @param {Object} meta url meta info
|
|
27
|
-
*
|
|
28
|
-
* @return {boolean} is valid.
|
|
29
|
-
*/
|
|
30
|
-
function isValidURL(meta) {
|
|
31
|
-
// Ignore hashes or data uris.
|
|
32
|
-
if (meta.value.indexOf('data:') === 0 || meta.value.indexOf('#') === 0) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
if (isAbsolutePath(meta.value)) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Do not handle the http/https urls if `includeRemote` is false.
|
|
40
|
-
if (isRemotePath(meta.value)) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Get the absolute path of the url, relative to the basePath
|
|
48
|
-
*
|
|
49
|
-
* @param {string} str the url
|
|
50
|
-
* @param {string} baseURL base URL
|
|
51
|
-
*
|
|
52
|
-
* @return {string} the full path to the file
|
|
53
|
-
*/
|
|
54
|
-
function getResourcePath(str, baseURL) {
|
|
55
|
-
return new URL(str, baseURL).toString();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Process the single `url()` pattern
|
|
60
|
-
*
|
|
61
|
-
* @param {string} baseURL the base URL for relative URLs.
|
|
62
|
-
*
|
|
63
|
-
* @return {Promise} the Promise.
|
|
64
|
-
*/
|
|
65
|
-
function processURL(baseURL) {
|
|
66
|
-
return meta => ({
|
|
67
|
-
...meta,
|
|
68
|
-
newUrl: 'url(' + meta.before + meta.quote + getResourcePath(meta.value, baseURL) + meta.quote + meta.after + ')'
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Get all `url()`s, and return the meta info
|
|
74
|
-
*
|
|
75
|
-
* @param {string} value decl.value.
|
|
76
|
-
*
|
|
77
|
-
* @return {Array} the urls.
|
|
78
|
-
*/
|
|
79
|
-
function getURLs(value) {
|
|
80
|
-
const reg = /url\((\s*)(['"]?)(.+?)\2(\s*)\)/g;
|
|
81
|
-
let match;
|
|
82
|
-
const URLs = [];
|
|
83
|
-
while ((match = reg.exec(value)) !== null) {
|
|
84
|
-
const meta = {
|
|
85
|
-
source: match[0],
|
|
86
|
-
before: match[1],
|
|
87
|
-
quote: match[2],
|
|
88
|
-
value: match[3],
|
|
89
|
-
after: match[4]
|
|
90
|
-
};
|
|
91
|
-
if (isValidURL(meta)) {
|
|
92
|
-
URLs.push(meta);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return URLs;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Replace the raw value's `url()` segment to the new value
|
|
100
|
-
*
|
|
101
|
-
* @param {string} raw the raw value.
|
|
102
|
-
* @param {Array} URLs the URLs to replace.
|
|
103
|
-
*
|
|
104
|
-
* @return {string} the new value.
|
|
105
|
-
*/
|
|
106
|
-
function replaceURLs(raw, URLs) {
|
|
107
|
-
URLs.forEach(item => {
|
|
108
|
-
raw = raw.replace(item.source, item.newUrl);
|
|
109
|
-
});
|
|
110
|
-
return raw;
|
|
111
|
-
}
|
|
112
|
-
const rewrite = rootURL => node => {
|
|
113
|
-
if (node.type === 'declaration') {
|
|
114
|
-
const updatedURLs = getURLs(node.value).map(processURL(rootURL));
|
|
115
|
-
return {
|
|
116
|
-
...node,
|
|
117
|
-
value: replaceURLs(node.value, updatedURLs)
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
return node;
|
|
121
|
-
};
|
|
122
|
-
export default rewrite;
|
|
123
|
-
//# sourceMappingURL=url-rewrite.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["isRemotePath","filePath","test","isAbsolutePath","isValidURL","meta","value","indexOf","getResourcePath","str","baseURL","URL","toString","processURL","newUrl","before","quote","after","getURLs","reg","match","URLs","exec","source","push","replaceURLs","raw","forEach","item","replace","rewrite","rootURL","node","type","updatedURLs","map"],"sources":["@wordpress/block-editor/src/utils/transform-styles/transforms/url-rewrite.js"],"sourcesContent":["/**\n * Return `true` if the given path is http/https.\n *\n * @param {string} filePath path\n *\n * @return {boolean} is remote path.\n */\nfunction isRemotePath( filePath ) {\n\treturn /^(?:https?:)?\\/\\//.test( filePath );\n}\n\n/**\n * Return `true` if the given filePath is an absolute url.\n *\n * @param {string} filePath path\n *\n * @return {boolean} is absolute path.\n */\nfunction isAbsolutePath( filePath ) {\n\treturn /^\\/(?!\\/)/.test( filePath );\n}\n\n/**\n * Whether or not the url should be inluded.\n *\n * @param {Object} meta url meta info\n *\n * @return {boolean} is valid.\n */\nfunction isValidURL( meta ) {\n\t// Ignore hashes or data uris.\n\tif (\n\t\tmeta.value.indexOf( 'data:' ) === 0 ||\n\t\tmeta.value.indexOf( '#' ) === 0\n\t) {\n\t\treturn false;\n\t}\n\n\tif ( isAbsolutePath( meta.value ) ) {\n\t\treturn false;\n\t}\n\n\t// Do not handle the http/https urls if `includeRemote` is false.\n\tif ( isRemotePath( meta.value ) ) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Get the absolute path of the url, relative to the basePath\n *\n * @param {string} str the url\n * @param {string} baseURL base URL\n *\n * @return {string} the full path to the file\n */\nfunction getResourcePath( str, baseURL ) {\n\treturn new URL( str, baseURL ).toString();\n}\n\n/**\n * Process the single `url()` pattern\n *\n * @param {string} baseURL the base URL for relative URLs.\n *\n * @return {Promise} the Promise.\n */\nfunction processURL( baseURL ) {\n\treturn ( meta ) => ( {\n\t\t...meta,\n\t\tnewUrl:\n\t\t\t'url(' +\n\t\t\tmeta.before +\n\t\t\tmeta.quote +\n\t\t\tgetResourcePath( meta.value, baseURL ) +\n\t\t\tmeta.quote +\n\t\t\tmeta.after +\n\t\t\t')',\n\t} );\n}\n\n/**\n * Get all `url()`s, and return the meta info\n *\n * @param {string} value decl.value.\n *\n * @return {Array} the urls.\n */\nfunction getURLs( value ) {\n\tconst reg = /url\\((\\s*)(['\"]?)(.+?)\\2(\\s*)\\)/g;\n\tlet match;\n\tconst URLs = [];\n\n\twhile ( ( match = reg.exec( value ) ) !== null ) {\n\t\tconst meta = {\n\t\t\tsource: match[ 0 ],\n\t\t\tbefore: match[ 1 ],\n\t\t\tquote: match[ 2 ],\n\t\t\tvalue: match[ 3 ],\n\t\t\tafter: match[ 4 ],\n\t\t};\n\t\tif ( isValidURL( meta ) ) {\n\t\t\tURLs.push( meta );\n\t\t}\n\t}\n\treturn URLs;\n}\n\n/**\n * Replace the raw value's `url()` segment to the new value\n *\n * @param {string} raw the raw value.\n * @param {Array} URLs the URLs to replace.\n *\n * @return {string} the new value.\n */\nfunction replaceURLs( raw, URLs ) {\n\tURLs.forEach( ( item ) => {\n\t\traw = raw.replace( item.source, item.newUrl );\n\t} );\n\n\treturn raw;\n}\n\nconst rewrite = ( rootURL ) => ( node ) => {\n\tif ( node.type === 'declaration' ) {\n\t\tconst updatedURLs = getURLs( node.value ).map( processURL( rootURL ) );\n\t\treturn {\n\t\t\t...node,\n\t\t\tvalue: replaceURLs( node.value, updatedURLs ),\n\t\t};\n\t}\n\n\treturn node;\n};\n\nexport default rewrite;\n"],"mappings":"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"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @constant string IS_ROOT_TAG Regex to check if the selector is a root tag selector.
|
|
3
|
-
*/
|
|
4
|
-
const IS_ROOT_TAG = /^(body|html|:root).*$/;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Creates a callback to modify selectors so they only apply within a certain
|
|
8
|
-
* namespace.
|
|
9
|
-
*
|
|
10
|
-
* @param {string} namespace Namespace to prefix selectors with.
|
|
11
|
-
* @param {string[]} ignore Selectors to not prefix.
|
|
12
|
-
*
|
|
13
|
-
* @return {(node: Object) => Object} Callback to wrap selectors.
|
|
14
|
-
*/
|
|
15
|
-
const wrap = (namespace, ignore = []) => node => {
|
|
16
|
-
/**
|
|
17
|
-
* Updates selector if necessary.
|
|
18
|
-
*
|
|
19
|
-
* @param {string} selector Selector to modify.
|
|
20
|
-
*
|
|
21
|
-
* @return {string} Updated selector.
|
|
22
|
-
*/
|
|
23
|
-
const updateSelector = selector => {
|
|
24
|
-
if (ignore.includes(selector.trim())) {
|
|
25
|
-
return selector;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Skip the update when a selector already has a namespace + space (" ").
|
|
29
|
-
if (selector.trim().startsWith(`${namespace} `)) {
|
|
30
|
-
return selector;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Anything other than a root tag is always prefixed.
|
|
34
|
-
{
|
|
35
|
-
if (!selector.match(IS_ROOT_TAG)) {
|
|
36
|
-
return namespace + ' ' + selector;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// HTML and Body elements cannot be contained within our container so lets extract their styles.
|
|
41
|
-
return selector.replace(/^(body|html|:root)/, namespace);
|
|
42
|
-
};
|
|
43
|
-
if (node.type === 'rule') {
|
|
44
|
-
return {
|
|
45
|
-
...node,
|
|
46
|
-
selectors: node.selectors.map(updateSelector)
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
return node;
|
|
50
|
-
};
|
|
51
|
-
export default wrap;
|
|
52
|
-
//# sourceMappingURL=wrap.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["IS_ROOT_TAG","wrap","namespace","ignore","node","updateSelector","selector","includes","trim","startsWith","match","replace","type","selectors","map"],"sources":["@wordpress/block-editor/src/utils/transform-styles/transforms/wrap.js"],"sourcesContent":["/**\n * @constant string IS_ROOT_TAG Regex to check if the selector is a root tag selector.\n */\nconst IS_ROOT_TAG = /^(body|html|:root).*$/;\n\n/**\n * Creates a callback to modify selectors so they only apply within a certain\n * namespace.\n *\n * @param {string} namespace Namespace to prefix selectors with.\n * @param {string[]} ignore Selectors to not prefix.\n *\n * @return {(node: Object) => Object} Callback to wrap selectors.\n */\nconst wrap =\n\t( namespace, ignore = [] ) =>\n\t( node ) => {\n\t\t/**\n\t\t * Updates selector if necessary.\n\t\t *\n\t\t * @param {string} selector Selector to modify.\n\t\t *\n\t\t * @return {string} Updated selector.\n\t\t */\n\t\tconst updateSelector = ( selector ) => {\n\t\t\tif ( ignore.includes( selector.trim() ) ) {\n\t\t\t\treturn selector;\n\t\t\t}\n\n\t\t\t// Skip the update when a selector already has a namespace + space (\" \").\n\t\t\tif ( selector.trim().startsWith( `${ namespace } ` ) ) {\n\t\t\t\treturn selector;\n\t\t\t}\n\n\t\t\t// Anything other than a root tag is always prefixed.\n\t\t\t{\n\t\t\t\tif ( ! selector.match( IS_ROOT_TAG ) ) {\n\t\t\t\t\treturn namespace + ' ' + selector;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// HTML and Body elements cannot be contained within our container so lets extract their styles.\n\t\t\treturn selector.replace( /^(body|html|:root)/, namespace );\n\t\t};\n\n\t\tif ( node.type === 'rule' ) {\n\t\t\treturn {\n\t\t\t\t...node,\n\t\t\t\tselectors: node.selectors.map( updateSelector ),\n\t\t\t};\n\t\t}\n\n\t\treturn node;\n\t};\n\nexport default wrap;\n"],"mappings":"AAAA;AACA;AACA;AACA,MAAMA,WAAW,GAAG,uBAAuB;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,IAAI,GACTA,CAAEC,SAAS,EAAEC,MAAM,GAAG,EAAE,KACtBC,IAAI,IAAM;EACX;AACF;AACA;AACA;AACA;AACA;AACA;EACE,MAAMC,cAAc,GAAKC,QAAQ,IAAM;IACtC,IAAKH,MAAM,CAACI,QAAQ,CAAED,QAAQ,CAACE,IAAI,CAAC,CAAE,CAAC,EAAG;MACzC,OAAOF,QAAQ;IAChB;;IAEA;IACA,IAAKA,QAAQ,CAACE,IAAI,CAAC,CAAC,CAACC,UAAU,CAAG,GAAGP,SAAW,GAAG,CAAC,EAAG;MACtD,OAAOI,QAAQ;IAChB;;IAEA;IACA;MACC,IAAK,CAAEA,QAAQ,CAACI,KAAK,CAAEV,WAAY,CAAC,EAAG;QACtC,OAAOE,SAAS,GAAG,GAAG,GAAGI,QAAQ;MAClC;IACD;;IAEA;IACA,OAAOA,QAAQ,CAACK,OAAO,CAAE,oBAAoB,EAAET,SAAU,CAAC;EAC3D,CAAC;EAED,IAAKE,IAAI,CAACQ,IAAI,KAAK,MAAM,EAAG;IAC3B,OAAO;MACN,GAAGR,IAAI;MACPS,SAAS,EAAET,IAAI,CAACS,SAAS,CAACC,GAAG,CAAET,cAAe;IAC/C,CAAC;EACF;EAEA,OAAOD,IAAI;AACZ,CAAC;AAEF,eAAeH,IAAI"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import traverse from 'traverse';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { parse, stringify } from './ast';
|
|
10
|
-
function traverseCSS(css, callback) {
|
|
11
|
-
try {
|
|
12
|
-
const parsed = parse(css);
|
|
13
|
-
const updated = traverse.map(parsed, function (node) {
|
|
14
|
-
if (!node) {
|
|
15
|
-
return node;
|
|
16
|
-
}
|
|
17
|
-
const updatedNode = callback(node);
|
|
18
|
-
return this.update(updatedNode);
|
|
19
|
-
});
|
|
20
|
-
return stringify(updated);
|
|
21
|
-
} catch (err) {
|
|
22
|
-
// eslint-disable-next-line no-console
|
|
23
|
-
console.warn('Error while traversing the CSS: ' + err);
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export default traverseCSS;
|
|
28
|
-
//# sourceMappingURL=traverse.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["traverse","parse","stringify","traverseCSS","css","callback","parsed","updated","map","node","updatedNode","update","err","console","warn"],"sources":["@wordpress/block-editor/src/utils/transform-styles/traverse.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport traverse from 'traverse';\n\n/**\n * Internal dependencies\n */\nimport { parse, stringify } from './ast';\n\nfunction traverseCSS( css, callback ) {\n\ttry {\n\t\tconst parsed = parse( css );\n\n\t\tconst updated = traverse.map( parsed, function ( node ) {\n\t\t\tif ( ! node ) {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t\tconst updatedNode = callback( node );\n\t\t\treturn this.update( updatedNode );\n\t\t} );\n\n\t\treturn stringify( updated );\n\t} catch ( err ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn( 'Error while traversing the CSS: ' + err );\n\n\t\treturn null;\n\t}\n}\n\nexport default traverseCSS;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,QAAQ,MAAM,UAAU;;AAE/B;AACA;AACA;AACA,SAASC,KAAK,EAAEC,SAAS,QAAQ,OAAO;AAExC,SAASC,WAAWA,CAAEC,GAAG,EAAEC,QAAQ,EAAG;EACrC,IAAI;IACH,MAAMC,MAAM,GAAGL,KAAK,CAAEG,GAAI,CAAC;IAE3B,MAAMG,OAAO,GAAGP,QAAQ,CAACQ,GAAG,CAAEF,MAAM,EAAE,UAAWG,IAAI,EAAG;MACvD,IAAK,CAAEA,IAAI,EAAG;QACb,OAAOA,IAAI;MACZ;MACA,MAAMC,WAAW,GAAGL,QAAQ,CAAEI,IAAK,CAAC;MACpC,OAAO,IAAI,CAACE,MAAM,CAAED,WAAY,CAAC;IAClC,CAAE,CAAC;IAEH,OAAOR,SAAS,CAAEK,OAAQ,CAAC;EAC5B,CAAC,CAAC,OAAQK,GAAG,EAAG;IACf;IACAC,OAAO,CAACC,IAAI,CAAE,kCAAkC,GAAGF,GAAI,CAAC;IAExD,OAAO,IAAI;EACZ;AACD;AAEA,eAAeT,WAAW"}
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useSelect } from '@wordpress/data';
|
|
5
|
-
import {
|
|
6
|
-
__EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE,
|
|
7
|
-
hasBlockSupport,
|
|
8
|
-
} from '@wordpress/blocks';
|
|
9
|
-
import { applyFilters } from '@wordpress/hooks';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import { useBlockEditContext } from '../block-edit';
|
|
15
|
-
import { store as blockEditorStore } from '../../store';
|
|
16
|
-
import { getValueFromObjectPath } from '../../utils/object';
|
|
17
|
-
|
|
18
|
-
const blockedPaths = [
|
|
19
|
-
'color',
|
|
20
|
-
'border',
|
|
21
|
-
'dimensions',
|
|
22
|
-
'typography',
|
|
23
|
-
'spacing',
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
const deprecatedFlags = {
|
|
27
|
-
'color.palette': ( settings ) => settings.colors,
|
|
28
|
-
'color.gradients': ( settings ) => settings.gradients,
|
|
29
|
-
'color.custom': ( settings ) =>
|
|
30
|
-
settings.disableCustomColors === undefined
|
|
31
|
-
? undefined
|
|
32
|
-
: ! settings.disableCustomColors,
|
|
33
|
-
'color.customGradient': ( settings ) =>
|
|
34
|
-
settings.disableCustomGradients === undefined
|
|
35
|
-
? undefined
|
|
36
|
-
: ! settings.disableCustomGradients,
|
|
37
|
-
'typography.fontSizes': ( settings ) => settings.fontSizes,
|
|
38
|
-
'typography.customFontSize': ( settings ) =>
|
|
39
|
-
settings.disableCustomFontSizes === undefined
|
|
40
|
-
? undefined
|
|
41
|
-
: ! settings.disableCustomFontSizes,
|
|
42
|
-
'typography.lineHeight': ( settings ) => settings.enableCustomLineHeight,
|
|
43
|
-
'spacing.units': ( settings ) => {
|
|
44
|
-
if ( settings.enableCustomUnits === undefined ) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if ( settings.enableCustomUnits === true ) {
|
|
49
|
-
return [ 'px', 'em', 'rem', 'vh', 'vw', '%' ];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return settings.enableCustomUnits;
|
|
53
|
-
},
|
|
54
|
-
'spacing.padding': ( settings ) => settings.enableCustomSpacing,
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const prefixedFlags = {
|
|
58
|
-
/*
|
|
59
|
-
* These were only available in the plugin
|
|
60
|
-
* and can be removed when the minimum WordPress version
|
|
61
|
-
* for the plugin is 5.9.
|
|
62
|
-
*/
|
|
63
|
-
'border.customColor': 'border.color',
|
|
64
|
-
'border.customStyle': 'border.style',
|
|
65
|
-
'border.customWidth': 'border.width',
|
|
66
|
-
'typography.customFontStyle': 'typography.fontStyle',
|
|
67
|
-
'typography.customFontWeight': 'typography.fontWeight',
|
|
68
|
-
'typography.customLetterSpacing': 'typography.letterSpacing',
|
|
69
|
-
'typography.customTextDecorations': 'typography.textDecoration',
|
|
70
|
-
'typography.customTextTransforms': 'typography.textTransform',
|
|
71
|
-
/*
|
|
72
|
-
* These were part of WordPress 5.8 and we need to keep them.
|
|
73
|
-
*/
|
|
74
|
-
'border.customRadius': 'border.radius',
|
|
75
|
-
'spacing.customMargin': 'spacing.margin',
|
|
76
|
-
'spacing.customPadding': 'spacing.padding',
|
|
77
|
-
'typography.customLineHeight': 'typography.lineHeight',
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Remove `custom` prefixes for flags that did not land in 5.8.
|
|
82
|
-
*
|
|
83
|
-
* This provides continued support for `custom` prefixed properties. It will
|
|
84
|
-
* be removed once third party devs have had sufficient time to update themes,
|
|
85
|
-
* plugins, etc.
|
|
86
|
-
*
|
|
87
|
-
* @see https://github.com/WordPress/gutenberg/pull/34485
|
|
88
|
-
*
|
|
89
|
-
* @param {string} path Path to desired value in settings.
|
|
90
|
-
* @return {string} The value for defined setting.
|
|
91
|
-
*/
|
|
92
|
-
const removeCustomPrefixes = ( path ) => {
|
|
93
|
-
return prefixedFlags[ path ] || path;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Hook that retrieves the given setting for the block instance in use.
|
|
98
|
-
*
|
|
99
|
-
* It looks up the settings first in the block instance hierarchy.
|
|
100
|
-
* If none is found, it'll look it up in the block editor store.
|
|
101
|
-
*
|
|
102
|
-
* @param {string} path The path to the setting.
|
|
103
|
-
* @return {any} Returns the value defined for the setting.
|
|
104
|
-
* @example
|
|
105
|
-
* ```js
|
|
106
|
-
* const isEnabled = useSetting( 'typography.dropCap' );
|
|
107
|
-
* ```
|
|
108
|
-
*/
|
|
109
|
-
export default function useSetting( path ) {
|
|
110
|
-
const { name: blockName, clientId } = useBlockEditContext();
|
|
111
|
-
|
|
112
|
-
return useSelect(
|
|
113
|
-
( select ) => {
|
|
114
|
-
if ( blockedPaths.includes( path ) ) {
|
|
115
|
-
// eslint-disable-next-line no-console
|
|
116
|
-
console.warn(
|
|
117
|
-
'Top level useSetting paths are disabled. Please use a subpath to query the information needed.'
|
|
118
|
-
);
|
|
119
|
-
return undefined;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// 0. Allow third parties to filter the block's settings at runtime.
|
|
123
|
-
let result = applyFilters(
|
|
124
|
-
'blockEditor.useSetting.before',
|
|
125
|
-
undefined,
|
|
126
|
-
path,
|
|
127
|
-
clientId,
|
|
128
|
-
blockName
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
if ( undefined !== result ) {
|
|
132
|
-
return result;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const normalizedPath = removeCustomPrefixes( path );
|
|
136
|
-
|
|
137
|
-
// 1. Take settings from the block instance or its ancestors.
|
|
138
|
-
// Start from the current block and work our way up the ancestors.
|
|
139
|
-
const candidates = [
|
|
140
|
-
clientId,
|
|
141
|
-
...select( blockEditorStore ).getBlockParents(
|
|
142
|
-
clientId,
|
|
143
|
-
/* ascending */ true
|
|
144
|
-
),
|
|
145
|
-
];
|
|
146
|
-
|
|
147
|
-
for ( const candidateClientId of candidates ) {
|
|
148
|
-
const candidateBlockName =
|
|
149
|
-
select( blockEditorStore ).getBlockName(
|
|
150
|
-
candidateClientId
|
|
151
|
-
);
|
|
152
|
-
if (
|
|
153
|
-
hasBlockSupport(
|
|
154
|
-
candidateBlockName,
|
|
155
|
-
'__experimentalSettings',
|
|
156
|
-
false
|
|
157
|
-
)
|
|
158
|
-
) {
|
|
159
|
-
const candidateAtts =
|
|
160
|
-
select( blockEditorStore ).getBlockAttributes(
|
|
161
|
-
candidateClientId
|
|
162
|
-
);
|
|
163
|
-
result =
|
|
164
|
-
getValueFromObjectPath(
|
|
165
|
-
candidateAtts,
|
|
166
|
-
`settings.blocks.${ blockName }.${ normalizedPath }`
|
|
167
|
-
) ??
|
|
168
|
-
getValueFromObjectPath(
|
|
169
|
-
candidateAtts,
|
|
170
|
-
`settings.${ normalizedPath }`
|
|
171
|
-
);
|
|
172
|
-
if ( result !== undefined ) {
|
|
173
|
-
// Stop the search for more distant ancestors and move on.
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// 2. Fall back to the settings from the block editor store (__experimentalFeatures).
|
|
180
|
-
const settings = select( blockEditorStore ).getSettings();
|
|
181
|
-
if ( result === undefined ) {
|
|
182
|
-
const defaultsPath = `__experimentalFeatures.${ normalizedPath }`;
|
|
183
|
-
const blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;
|
|
184
|
-
result =
|
|
185
|
-
getValueFromObjectPath( settings, blockPath ) ??
|
|
186
|
-
getValueFromObjectPath( settings, defaultsPath );
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// Return if the setting was found in either the block instance or the store.
|
|
190
|
-
if ( result !== undefined ) {
|
|
191
|
-
if ( PATHS_WITH_MERGE[ normalizedPath ] ) {
|
|
192
|
-
return result.custom ?? result.theme ?? result.default;
|
|
193
|
-
}
|
|
194
|
-
return result;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// 3. Otherwise, use deprecated settings.
|
|
198
|
-
const deprecatedSettingsValue = deprecatedFlags[ normalizedPath ]
|
|
199
|
-
? deprecatedFlags[ normalizedPath ]( settings )
|
|
200
|
-
: undefined;
|
|
201
|
-
if ( deprecatedSettingsValue !== undefined ) {
|
|
202
|
-
return deprecatedSettingsValue;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// 4. Fallback for typography.dropCap:
|
|
206
|
-
// This is only necessary to support typography.dropCap.
|
|
207
|
-
// when __experimentalFeatures are not present (core without plugin).
|
|
208
|
-
// To remove when __experimentalFeatures are ported to core.
|
|
209
|
-
return normalizedPath === 'typography.dropCap' ? true : undefined;
|
|
210
|
-
},
|
|
211
|
-
[ blockName, clientId, path ]
|
|
212
|
-
);
|
|
213
|
-
}
|