@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,732 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @wordpress/no-unused-vars-before-return */
|
|
2
|
-
|
|
3
|
-
// Adapted from https://github.com/reworkcss/css
|
|
4
|
-
// because we needed to remove source map support.
|
|
5
|
-
|
|
6
|
-
// http://www.w3.org/TR/CSS21/grammar.htm
|
|
7
|
-
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
|
|
8
|
-
const commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
|
|
9
|
-
|
|
10
|
-
export default function ( css, options ) {
|
|
11
|
-
options = options || {};
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Positional.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
let lineno = 1;
|
|
18
|
-
let column = 1;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Update lineno and column based on `str`.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
function updatePosition( str ) {
|
|
25
|
-
const lines = str.match( /\n/g );
|
|
26
|
-
if ( lines ) {
|
|
27
|
-
lineno += lines.length;
|
|
28
|
-
}
|
|
29
|
-
const i = str.lastIndexOf( '\n' );
|
|
30
|
-
// eslint-disable-next-line no-bitwise
|
|
31
|
-
column = ~i ? str.length - i : column + str.length;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Mark position and patch `node.position`.
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
function position() {
|
|
39
|
-
const start = { line: lineno, column };
|
|
40
|
-
return function ( node ) {
|
|
41
|
-
node.position = new Position( start );
|
|
42
|
-
whitespace();
|
|
43
|
-
return node;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Store position information for a node
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
function Position( start ) {
|
|
52
|
-
this.start = start;
|
|
53
|
-
this.end = { line: lineno, column };
|
|
54
|
-
this.source = options.source;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Non-enumerable source string
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
Position.prototype.content = css;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Error `msg`.
|
|
65
|
-
*/
|
|
66
|
-
|
|
67
|
-
const errorsList = [];
|
|
68
|
-
|
|
69
|
-
function error( msg ) {
|
|
70
|
-
const err = new Error(
|
|
71
|
-
options.source + ':' + lineno + ':' + column + ': ' + msg
|
|
72
|
-
);
|
|
73
|
-
err.reason = msg;
|
|
74
|
-
err.filename = options.source;
|
|
75
|
-
err.line = lineno;
|
|
76
|
-
err.column = column;
|
|
77
|
-
err.source = css;
|
|
78
|
-
|
|
79
|
-
if ( options.silent ) {
|
|
80
|
-
errorsList.push( err );
|
|
81
|
-
} else {
|
|
82
|
-
throw err;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Parse stylesheet.
|
|
88
|
-
*/
|
|
89
|
-
|
|
90
|
-
function stylesheet() {
|
|
91
|
-
const rulesList = rules();
|
|
92
|
-
|
|
93
|
-
return {
|
|
94
|
-
type: 'stylesheet',
|
|
95
|
-
stylesheet: {
|
|
96
|
-
source: options.source,
|
|
97
|
-
rules: rulesList,
|
|
98
|
-
parsingErrors: errorsList,
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Opening brace.
|
|
105
|
-
*/
|
|
106
|
-
|
|
107
|
-
function open() {
|
|
108
|
-
return match( /^{\s*/ );
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Closing brace.
|
|
113
|
-
*/
|
|
114
|
-
|
|
115
|
-
function close() {
|
|
116
|
-
return match( /^}/ );
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Parse ruleset.
|
|
121
|
-
*/
|
|
122
|
-
|
|
123
|
-
function rules() {
|
|
124
|
-
let node;
|
|
125
|
-
const accumulator = [];
|
|
126
|
-
whitespace();
|
|
127
|
-
comments( accumulator );
|
|
128
|
-
while (
|
|
129
|
-
css.length &&
|
|
130
|
-
css.charAt( 0 ) !== '}' &&
|
|
131
|
-
( node = atrule() || rule() )
|
|
132
|
-
) {
|
|
133
|
-
if ( node !== false ) {
|
|
134
|
-
accumulator.push( node );
|
|
135
|
-
comments( accumulator );
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return accumulator;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Match `re` and return captures.
|
|
143
|
-
*/
|
|
144
|
-
|
|
145
|
-
function match( re ) {
|
|
146
|
-
const m = re.exec( css );
|
|
147
|
-
if ( ! m ) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
const str = m[ 0 ];
|
|
151
|
-
updatePosition( str );
|
|
152
|
-
css = css.slice( str.length );
|
|
153
|
-
return m;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Parse whitespace.
|
|
158
|
-
*/
|
|
159
|
-
|
|
160
|
-
function whitespace() {
|
|
161
|
-
match( /^\s*/ );
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Parse comments;
|
|
166
|
-
*/
|
|
167
|
-
|
|
168
|
-
function comments( accumulator ) {
|
|
169
|
-
let c;
|
|
170
|
-
accumulator = accumulator || [];
|
|
171
|
-
// eslint-disable-next-line no-cond-assign
|
|
172
|
-
while ( ( c = comment() ) ) {
|
|
173
|
-
if ( c !== false ) {
|
|
174
|
-
accumulator.push( c );
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return accumulator;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Parse comment.
|
|
182
|
-
*/
|
|
183
|
-
|
|
184
|
-
function comment() {
|
|
185
|
-
const pos = position();
|
|
186
|
-
if ( '/' !== css.charAt( 0 ) || '*' !== css.charAt( 1 ) ) {
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
let i = 2;
|
|
191
|
-
while (
|
|
192
|
-
'' !== css.charAt( i ) &&
|
|
193
|
-
( '*' !== css.charAt( i ) || '/' !== css.charAt( i + 1 ) )
|
|
194
|
-
) {
|
|
195
|
-
++i;
|
|
196
|
-
}
|
|
197
|
-
i += 2;
|
|
198
|
-
|
|
199
|
-
if ( '' === css.charAt( i - 1 ) ) {
|
|
200
|
-
return error( 'End of comment missing' );
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
const str = css.slice( 2, i - 2 );
|
|
204
|
-
column += 2;
|
|
205
|
-
updatePosition( str );
|
|
206
|
-
css = css.slice( i );
|
|
207
|
-
column += 2;
|
|
208
|
-
|
|
209
|
-
return pos( {
|
|
210
|
-
type: 'comment',
|
|
211
|
-
comment: str,
|
|
212
|
-
} );
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Parse selector.
|
|
217
|
-
*/
|
|
218
|
-
|
|
219
|
-
function selector() {
|
|
220
|
-
const m = match( /^([^{]+)/ );
|
|
221
|
-
if ( ! m ) {
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
// FIXME: Remove all comments from selectors http://ostermiller.org/findcomment.html
|
|
225
|
-
return trim( m[ 0 ] )
|
|
226
|
-
.replace( /\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '' )
|
|
227
|
-
.replace( /"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function ( matched ) {
|
|
228
|
-
return matched.replace( /,/g, '\u200C' );
|
|
229
|
-
} )
|
|
230
|
-
.split( /\s*(?![^(]*\)),\s*/ )
|
|
231
|
-
.map( function ( s ) {
|
|
232
|
-
return s.replace( /\u200C/g, ',' );
|
|
233
|
-
} );
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Parse declaration.
|
|
238
|
-
*/
|
|
239
|
-
|
|
240
|
-
function declaration() {
|
|
241
|
-
const pos = position();
|
|
242
|
-
|
|
243
|
-
// prop.
|
|
244
|
-
let prop = match( /^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/ );
|
|
245
|
-
if ( ! prop ) {
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
prop = trim( prop[ 0 ] );
|
|
249
|
-
|
|
250
|
-
// :
|
|
251
|
-
if ( ! match( /^:\s*/ ) ) {
|
|
252
|
-
return error( "property missing ':'" );
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// val.
|
|
256
|
-
const val = match(
|
|
257
|
-
/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/
|
|
258
|
-
);
|
|
259
|
-
|
|
260
|
-
const ret = pos( {
|
|
261
|
-
type: 'declaration',
|
|
262
|
-
property: prop.replace( commentre, '' ),
|
|
263
|
-
value: val ? trim( val[ 0 ] ).replace( commentre, '' ) : '',
|
|
264
|
-
} );
|
|
265
|
-
|
|
266
|
-
// ;
|
|
267
|
-
match( /^[;\s]*/ );
|
|
268
|
-
|
|
269
|
-
return ret;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
* Parse declarations.
|
|
274
|
-
*/
|
|
275
|
-
|
|
276
|
-
function declarations() {
|
|
277
|
-
const decls = [];
|
|
278
|
-
|
|
279
|
-
if ( ! open() ) {
|
|
280
|
-
return error( "missing '{'" );
|
|
281
|
-
}
|
|
282
|
-
comments( decls );
|
|
283
|
-
|
|
284
|
-
// declarations.
|
|
285
|
-
let decl;
|
|
286
|
-
// eslint-disable-next-line no-cond-assign
|
|
287
|
-
while ( ( decl = declaration() ) ) {
|
|
288
|
-
if ( decl !== false ) {
|
|
289
|
-
decls.push( decl );
|
|
290
|
-
comments( decls );
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
if ( ! close() ) {
|
|
295
|
-
return error( "missing '}'" );
|
|
296
|
-
}
|
|
297
|
-
return decls;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* Parse keyframe.
|
|
302
|
-
*/
|
|
303
|
-
|
|
304
|
-
function keyframe() {
|
|
305
|
-
let m;
|
|
306
|
-
const vals = [];
|
|
307
|
-
const pos = position();
|
|
308
|
-
|
|
309
|
-
// eslint-disable-next-line no-cond-assign
|
|
310
|
-
while ( ( m = match( /^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/ ) ) ) {
|
|
311
|
-
vals.push( m[ 1 ] );
|
|
312
|
-
match( /^,\s*/ );
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
if ( ! vals.length ) {
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
return pos( {
|
|
320
|
-
type: 'keyframe',
|
|
321
|
-
values: vals,
|
|
322
|
-
declarations: declarations(),
|
|
323
|
-
} );
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Parse keyframes.
|
|
328
|
-
*/
|
|
329
|
-
|
|
330
|
-
function atkeyframes() {
|
|
331
|
-
const pos = position();
|
|
332
|
-
let m = match( /^@([-\w]+)?keyframes\s*/ );
|
|
333
|
-
|
|
334
|
-
if ( ! m ) {
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
const vendor = m[ 1 ];
|
|
338
|
-
|
|
339
|
-
// identifier
|
|
340
|
-
m = match( /^([-\w]+)\s*/ );
|
|
341
|
-
if ( ! m ) {
|
|
342
|
-
return error( '@keyframes missing name' );
|
|
343
|
-
}
|
|
344
|
-
const name = m[ 1 ];
|
|
345
|
-
|
|
346
|
-
if ( ! open() ) {
|
|
347
|
-
return error( "@keyframes missing '{'" );
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
let frame;
|
|
351
|
-
let frames = comments();
|
|
352
|
-
// eslint-disable-next-line no-cond-assign
|
|
353
|
-
while ( ( frame = keyframe() ) ) {
|
|
354
|
-
frames.push( frame );
|
|
355
|
-
frames = frames.concat( comments() );
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
if ( ! close() ) {
|
|
359
|
-
return error( "@keyframes missing '}'" );
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
return pos( {
|
|
363
|
-
type: 'keyframes',
|
|
364
|
-
name,
|
|
365
|
-
vendor,
|
|
366
|
-
keyframes: frames,
|
|
367
|
-
} );
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Parse supports.
|
|
372
|
-
*/
|
|
373
|
-
|
|
374
|
-
function atsupports() {
|
|
375
|
-
const pos = position();
|
|
376
|
-
const m = match( /^@supports *([^{]+)/ );
|
|
377
|
-
|
|
378
|
-
if ( ! m ) {
|
|
379
|
-
return;
|
|
380
|
-
}
|
|
381
|
-
const supports = trim( m[ 1 ] );
|
|
382
|
-
|
|
383
|
-
if ( ! open() ) {
|
|
384
|
-
return error( "@supports missing '{'" );
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
const style = comments().concat( rules() );
|
|
388
|
-
|
|
389
|
-
if ( ! close() ) {
|
|
390
|
-
return error( "@supports missing '}'" );
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
return pos( {
|
|
394
|
-
type: 'supports',
|
|
395
|
-
supports,
|
|
396
|
-
rules: style,
|
|
397
|
-
} );
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
* Parse host.
|
|
402
|
-
*/
|
|
403
|
-
|
|
404
|
-
function athost() {
|
|
405
|
-
const pos = position();
|
|
406
|
-
const m = match( /^@host\s*/ );
|
|
407
|
-
|
|
408
|
-
if ( ! m ) {
|
|
409
|
-
return;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
if ( ! open() ) {
|
|
413
|
-
return error( "@host missing '{'" );
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
const style = comments().concat( rules() );
|
|
417
|
-
|
|
418
|
-
if ( ! close() ) {
|
|
419
|
-
return error( "@host missing '}'" );
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
return pos( {
|
|
423
|
-
type: 'host',
|
|
424
|
-
rules: style,
|
|
425
|
-
} );
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* Parse media.
|
|
430
|
-
*/
|
|
431
|
-
|
|
432
|
-
function atmedia() {
|
|
433
|
-
const pos = position();
|
|
434
|
-
const m = match( /^@media *([^{]+)/ );
|
|
435
|
-
|
|
436
|
-
if ( ! m ) {
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
const media = trim( m[ 1 ] );
|
|
440
|
-
|
|
441
|
-
if ( ! open() ) {
|
|
442
|
-
return error( "@media missing '{'" );
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
const style = comments().concat( rules() );
|
|
446
|
-
|
|
447
|
-
if ( ! close() ) {
|
|
448
|
-
return error( "@media missing '}'" );
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
return pos( {
|
|
452
|
-
type: 'media',
|
|
453
|
-
media,
|
|
454
|
-
rules: style,
|
|
455
|
-
} );
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* Parse container.
|
|
460
|
-
*/
|
|
461
|
-
|
|
462
|
-
function atcontainer() {
|
|
463
|
-
const pos = position();
|
|
464
|
-
const m = match( /^@container *([^{]+)/ );
|
|
465
|
-
|
|
466
|
-
if ( ! m ) {
|
|
467
|
-
return;
|
|
468
|
-
}
|
|
469
|
-
const container = trim( m[ 1 ] );
|
|
470
|
-
|
|
471
|
-
if ( ! open() ) {
|
|
472
|
-
return error( "@container missing '{'" );
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
const style = comments().concat( rules() );
|
|
476
|
-
|
|
477
|
-
if ( ! close() ) {
|
|
478
|
-
return error( "@container missing '}'" );
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
return pos( {
|
|
482
|
-
type: 'container',
|
|
483
|
-
container,
|
|
484
|
-
rules: style,
|
|
485
|
-
} );
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* Parse custom-media.
|
|
490
|
-
*/
|
|
491
|
-
|
|
492
|
-
function atcustommedia() {
|
|
493
|
-
const pos = position();
|
|
494
|
-
const m = match( /^@custom-media\s+(--[^\s]+)\s*([^{;]+);/ );
|
|
495
|
-
if ( ! m ) {
|
|
496
|
-
return;
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
return pos( {
|
|
500
|
-
type: 'custom-media',
|
|
501
|
-
name: trim( m[ 1 ] ),
|
|
502
|
-
media: trim( m[ 2 ] ),
|
|
503
|
-
} );
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* Parse paged media.
|
|
508
|
-
*/
|
|
509
|
-
|
|
510
|
-
function atpage() {
|
|
511
|
-
const pos = position();
|
|
512
|
-
const m = match( /^@page */ );
|
|
513
|
-
if ( ! m ) {
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
const sel = selector() || [];
|
|
518
|
-
|
|
519
|
-
if ( ! open() ) {
|
|
520
|
-
return error( "@page missing '{'" );
|
|
521
|
-
}
|
|
522
|
-
let decls = comments();
|
|
523
|
-
|
|
524
|
-
// declarations.
|
|
525
|
-
let decl;
|
|
526
|
-
// eslint-disable-next-line no-cond-assign
|
|
527
|
-
while ( ( decl = declaration() ) ) {
|
|
528
|
-
decls.push( decl );
|
|
529
|
-
decls = decls.concat( comments() );
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
if ( ! close() ) {
|
|
533
|
-
return error( "@page missing '}'" );
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
return pos( {
|
|
537
|
-
type: 'page',
|
|
538
|
-
selectors: sel,
|
|
539
|
-
declarations: decls,
|
|
540
|
-
} );
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
/**
|
|
544
|
-
* Parse document.
|
|
545
|
-
*/
|
|
546
|
-
|
|
547
|
-
function atdocument() {
|
|
548
|
-
const pos = position();
|
|
549
|
-
const m = match( /^@([-\w]+)?document *([^{]+)/ );
|
|
550
|
-
if ( ! m ) {
|
|
551
|
-
return;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
const vendor = trim( m[ 1 ] );
|
|
555
|
-
const doc = trim( m[ 2 ] );
|
|
556
|
-
|
|
557
|
-
if ( ! open() ) {
|
|
558
|
-
return error( "@document missing '{'" );
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
const style = comments().concat( rules() );
|
|
562
|
-
|
|
563
|
-
if ( ! close() ) {
|
|
564
|
-
return error( "@document missing '}'" );
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
return pos( {
|
|
568
|
-
type: 'document',
|
|
569
|
-
document: doc,
|
|
570
|
-
vendor,
|
|
571
|
-
rules: style,
|
|
572
|
-
} );
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
/**
|
|
576
|
-
* Parse font-face.
|
|
577
|
-
*/
|
|
578
|
-
|
|
579
|
-
function atfontface() {
|
|
580
|
-
const pos = position();
|
|
581
|
-
const m = match( /^@font-face\s*/ );
|
|
582
|
-
if ( ! m ) {
|
|
583
|
-
return;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
if ( ! open() ) {
|
|
587
|
-
return error( "@font-face missing '{'" );
|
|
588
|
-
}
|
|
589
|
-
let decls = comments();
|
|
590
|
-
|
|
591
|
-
// declarations.
|
|
592
|
-
let decl;
|
|
593
|
-
// eslint-disable-next-line no-cond-assign
|
|
594
|
-
while ( ( decl = declaration() ) ) {
|
|
595
|
-
decls.push( decl );
|
|
596
|
-
decls = decls.concat( comments() );
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
if ( ! close() ) {
|
|
600
|
-
return error( "@font-face missing '}'" );
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
return pos( {
|
|
604
|
-
type: 'font-face',
|
|
605
|
-
declarations: decls,
|
|
606
|
-
} );
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
/**
|
|
610
|
-
* Parse import
|
|
611
|
-
*/
|
|
612
|
-
|
|
613
|
-
const atimport = _compileAtrule( 'import' );
|
|
614
|
-
|
|
615
|
-
/**
|
|
616
|
-
* Parse charset
|
|
617
|
-
*/
|
|
618
|
-
|
|
619
|
-
const atcharset = _compileAtrule( 'charset' );
|
|
620
|
-
|
|
621
|
-
/**
|
|
622
|
-
* Parse namespace
|
|
623
|
-
*/
|
|
624
|
-
|
|
625
|
-
const atnamespace = _compileAtrule( 'namespace' );
|
|
626
|
-
|
|
627
|
-
/**
|
|
628
|
-
* Parse non-block at-rules
|
|
629
|
-
*/
|
|
630
|
-
|
|
631
|
-
function _compileAtrule( name ) {
|
|
632
|
-
const re = new RegExp( '^@' + name + '\\s*([^;]+);' );
|
|
633
|
-
return function () {
|
|
634
|
-
const pos = position();
|
|
635
|
-
const m = match( re );
|
|
636
|
-
if ( ! m ) {
|
|
637
|
-
return;
|
|
638
|
-
}
|
|
639
|
-
const ret = { type: name };
|
|
640
|
-
ret[ name ] = m[ 1 ].trim();
|
|
641
|
-
return pos( ret );
|
|
642
|
-
};
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
/**
|
|
646
|
-
* Parse at rule.
|
|
647
|
-
*/
|
|
648
|
-
|
|
649
|
-
function atrule() {
|
|
650
|
-
if ( css[ 0 ] !== '@' ) {
|
|
651
|
-
return;
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
return (
|
|
655
|
-
atkeyframes() ||
|
|
656
|
-
atmedia() ||
|
|
657
|
-
atcontainer() ||
|
|
658
|
-
atcustommedia() ||
|
|
659
|
-
atsupports() ||
|
|
660
|
-
atimport() ||
|
|
661
|
-
atcharset() ||
|
|
662
|
-
atnamespace() ||
|
|
663
|
-
atdocument() ||
|
|
664
|
-
atpage() ||
|
|
665
|
-
athost() ||
|
|
666
|
-
atfontface()
|
|
667
|
-
);
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
/**
|
|
671
|
-
* Parse rule.
|
|
672
|
-
*/
|
|
673
|
-
|
|
674
|
-
function rule() {
|
|
675
|
-
const pos = position();
|
|
676
|
-
const sel = selector();
|
|
677
|
-
|
|
678
|
-
if ( ! sel ) {
|
|
679
|
-
return error( 'selector missing' );
|
|
680
|
-
}
|
|
681
|
-
comments();
|
|
682
|
-
|
|
683
|
-
return pos( {
|
|
684
|
-
type: 'rule',
|
|
685
|
-
selectors: sel,
|
|
686
|
-
declarations: declarations(),
|
|
687
|
-
} );
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
return addParent( stylesheet() );
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
/**
|
|
694
|
-
* Trim `str`.
|
|
695
|
-
*/
|
|
696
|
-
|
|
697
|
-
function trim( str ) {
|
|
698
|
-
return str ? str.replace( /^\s+|\s+$/g, '' ) : '';
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
* Adds non-enumerable parent node reference to each node.
|
|
703
|
-
*/
|
|
704
|
-
|
|
705
|
-
function addParent( obj, parent ) {
|
|
706
|
-
const isNode = obj && typeof obj.type === 'string';
|
|
707
|
-
const childParent = isNode ? obj : parent;
|
|
708
|
-
|
|
709
|
-
for ( const k in obj ) {
|
|
710
|
-
const value = obj[ k ];
|
|
711
|
-
if ( Array.isArray( value ) ) {
|
|
712
|
-
value.forEach( function ( v ) {
|
|
713
|
-
addParent( v, childParent );
|
|
714
|
-
} );
|
|
715
|
-
} else if ( value && typeof value === 'object' ) {
|
|
716
|
-
addParent( value, childParent );
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
if ( isNode ) {
|
|
721
|
-
Object.defineProperty( obj, 'parent', {
|
|
722
|
-
configurable: true,
|
|
723
|
-
writable: true,
|
|
724
|
-
enumerable: false,
|
|
725
|
-
value: parent || null,
|
|
726
|
-
} );
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
return obj;
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
/* eslint-enable @wordpress/no-unused-vars-before-return */
|