@wordpress/block-editor 12.12.0 → 12.13.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 +12 -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-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/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/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 +3 -3
- package/build/components/height-control/index.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 +9 -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/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-search-handler.js +10 -5
- package/build/components/link-control/use-search-handler.js.map +1 -1
- package/build/components/resizable-box-popover/index.js +1 -1
- package/build/components/resizable-box-popover/index.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/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 +3 -3
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.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 +6 -1
- 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/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/color.js +2 -4
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/duotone.js +10 -9
- 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/layout.js +10 -11
- 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/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 +1 -42
- 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/utils/object.js +4 -1
- package/build/utils/object.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-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/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/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 +3 -2
- package/build-module/components/height-control/index.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 +1 -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/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-search-handler.js +10 -5
- package/build-module/components/link-control/use-search-handler.js.map +1 -1
- package/build-module/components/resizable-box-popover/index.js +1 -1
- package/build-module/components/resizable-box-popover/index.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/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 +3 -2
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.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 +5 -1
- 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/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/color.js +2 -4
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/duotone.js +11 -10
- 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/layout.js +10 -11
- 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/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 +2 -43
- 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/utils/object.js +3 -1
- package/build-module/utils/object.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 +13 -6
- package/build-style/style.css +13 -6
- package/package.json +36 -34
- package/src/components/block-alignment-control/use-available-alignments.js +49 -34
- package/src/components/block-list/block.native.js +4 -4
- package/src/components/block-list/layout.js +2 -2
- package/src/components/block-styles/style.scss +1 -1
- package/src/components/border-radius-control/index.js +3 -2
- 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/use-multiple-origin-colors-and-gradients.js +29 -15
- 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 +3 -2
- package/src/components/index.js +1 -1
- package/src/components/index.native.js +1 -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/search-item.js +14 -0
- package/src/components/link-control/search-results.js +1 -0
- package/src/components/link-control/use-search-handler.js +22 -15
- package/src/components/resizable-box-popover/index.js +1 -1
- package/src/components/rich-text/index.js +1 -1
- 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 +3 -2
- package/src/components/unit-control/index.js +3 -8
- package/src/components/use-block-commands/index.js +2 -1
- 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/hooks/align.js +79 -54
- package/src/hooks/anchor.js +75 -65
- package/src/hooks/background.js +7 -9
- package/src/hooks/color.js +7 -4
- package/src/hooks/duotone.js +24 -19
- package/src/hooks/font-size.js +4 -4
- package/src/hooks/layout.js +11 -11
- package/src/hooks/line-height.js +3 -3
- package/src/hooks/position.js +5 -3
- package/src/hooks/use-color-props.js +21 -14
- package/src/hooks/utils.js +88 -43
- package/src/layouts/constrained.js +3 -8
- package/src/utils/object.js +4 -1
- package/src/utils/test/__snapshots__/transform-styles.js.snap +103 -0
- 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 -161
- package/build/components/use-setting/index.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 -154
- package/build-module/components/use-setting/index.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 -218
- 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,50 +0,0 @@
|
|
|
1
|
-
// Adapted from https://github.com/reworkcss/css
|
|
2
|
-
// because we needed to remove source map support.
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Expose `Compiler`.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export default Compiler;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Initialize a compiler.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
function Compiler( opts ) {
|
|
15
|
-
this.options = opts || {};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Emit `str`
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
Compiler.prototype.emit = function ( str ) {
|
|
23
|
-
return str;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Visit `node`.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
Compiler.prototype.visit = function ( node ) {
|
|
31
|
-
return this[ node.type ]( node );
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Map visit over array of `nodes`, optionally using a `delim`
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
Compiler.prototype.mapVisit = function ( nodes, delim ) {
|
|
39
|
-
let buf = '';
|
|
40
|
-
delim = delim || '';
|
|
41
|
-
|
|
42
|
-
for ( let i = 0, length = nodes.length; i < length; i++ ) {
|
|
43
|
-
buf += this.visit( nodes[ i ] );
|
|
44
|
-
if ( delim && i < length - 1 ) {
|
|
45
|
-
buf += this.emit( delim );
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return buf;
|
|
50
|
-
};
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
// Adapted from https://github.com/reworkcss/css
|
|
2
|
-
// because we needed to remove source map support.
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* External dependencies
|
|
6
|
-
*/
|
|
7
|
-
import inherits from 'inherits';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
12
|
-
import Base from './compiler';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Expose compiler.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
export default Compiler;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Initialize a new `Compiler`.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
function Compiler( options ) {
|
|
25
|
-
Base.call( this, options );
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Inherit from `Base.prototype`.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
inherits( Compiler, Base );
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Compile `node`.
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
Compiler.prototype.compile = function ( node ) {
|
|
39
|
-
return node.stylesheet.rules.map( this.visit, this ).join( '' );
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Visit comment node.
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
Compiler.prototype.comment = function ( node ) {
|
|
47
|
-
return this.emit( '', node.position );
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Visit import node.
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
Compiler.prototype.import = function ( node ) {
|
|
55
|
-
return this.emit( '@import ' + node.import + ';', node.position );
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Visit media node.
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
Compiler.prototype.media = function ( node ) {
|
|
63
|
-
return (
|
|
64
|
-
this.emit( '@media ' + node.media, node.position ) +
|
|
65
|
-
this.emit( '{' ) +
|
|
66
|
-
this.mapVisit( node.rules ) +
|
|
67
|
-
this.emit( '}' )
|
|
68
|
-
);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Visit container node.
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
|
-
Compiler.prototype.container = function ( node ) {
|
|
76
|
-
return (
|
|
77
|
-
this.emit( '@container ' + node.container, node.position ) +
|
|
78
|
-
this.emit( '{' ) +
|
|
79
|
-
this.mapVisit( node.rules ) +
|
|
80
|
-
this.emit( '}' )
|
|
81
|
-
);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Visit document node.
|
|
86
|
-
*/
|
|
87
|
-
|
|
88
|
-
Compiler.prototype.document = function ( node ) {
|
|
89
|
-
const doc = '@' + ( node.vendor || '' ) + 'document ' + node.document;
|
|
90
|
-
|
|
91
|
-
return (
|
|
92
|
-
this.emit( doc, node.position ) +
|
|
93
|
-
this.emit( '{' ) +
|
|
94
|
-
this.mapVisit( node.rules ) +
|
|
95
|
-
this.emit( '}' )
|
|
96
|
-
);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Visit charset node.
|
|
101
|
-
*/
|
|
102
|
-
|
|
103
|
-
Compiler.prototype.charset = function ( node ) {
|
|
104
|
-
return this.emit( '@charset ' + node.charset + ';', node.position );
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Visit namespace node.
|
|
109
|
-
*/
|
|
110
|
-
|
|
111
|
-
Compiler.prototype.namespace = function ( node ) {
|
|
112
|
-
return this.emit( '@namespace ' + node.namespace + ';', node.position );
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Visit supports node.
|
|
117
|
-
*/
|
|
118
|
-
|
|
119
|
-
Compiler.prototype.supports = function ( node ) {
|
|
120
|
-
return (
|
|
121
|
-
this.emit( '@supports ' + node.supports, node.position ) +
|
|
122
|
-
this.emit( '{' ) +
|
|
123
|
-
this.mapVisit( node.rules ) +
|
|
124
|
-
this.emit( '}' )
|
|
125
|
-
);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Visit keyframes node.
|
|
130
|
-
*/
|
|
131
|
-
|
|
132
|
-
Compiler.prototype.keyframes = function ( node ) {
|
|
133
|
-
return (
|
|
134
|
-
this.emit(
|
|
135
|
-
'@' + ( node.vendor || '' ) + 'keyframes ' + node.name,
|
|
136
|
-
node.position
|
|
137
|
-
) +
|
|
138
|
-
this.emit( '{' ) +
|
|
139
|
-
this.mapVisit( node.keyframes ) +
|
|
140
|
-
this.emit( '}' )
|
|
141
|
-
);
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Visit keyframe node.
|
|
146
|
-
*/
|
|
147
|
-
|
|
148
|
-
Compiler.prototype.keyframe = function ( node ) {
|
|
149
|
-
const decls = node.declarations;
|
|
150
|
-
|
|
151
|
-
return (
|
|
152
|
-
this.emit( node.values.join( ',' ), node.position ) +
|
|
153
|
-
this.emit( '{' ) +
|
|
154
|
-
this.mapVisit( decls ) +
|
|
155
|
-
this.emit( '}' )
|
|
156
|
-
);
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Visit page node.
|
|
161
|
-
*/
|
|
162
|
-
|
|
163
|
-
Compiler.prototype.page = function ( node ) {
|
|
164
|
-
const sel = node.selectors.length ? node.selectors.join( ', ' ) : '';
|
|
165
|
-
|
|
166
|
-
return (
|
|
167
|
-
this.emit( '@page ' + sel, node.position ) +
|
|
168
|
-
this.emit( '{' ) +
|
|
169
|
-
this.mapVisit( node.declarations ) +
|
|
170
|
-
this.emit( '}' )
|
|
171
|
-
);
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Visit font-face node.
|
|
176
|
-
*/
|
|
177
|
-
|
|
178
|
-
Compiler.prototype[ 'font-face' ] = function ( node ) {
|
|
179
|
-
return (
|
|
180
|
-
this.emit( '@font-face', node.position ) +
|
|
181
|
-
this.emit( '{' ) +
|
|
182
|
-
this.mapVisit( node.declarations ) +
|
|
183
|
-
this.emit( '}' )
|
|
184
|
-
);
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Visit host node.
|
|
189
|
-
*/
|
|
190
|
-
|
|
191
|
-
Compiler.prototype.host = function ( node ) {
|
|
192
|
-
return (
|
|
193
|
-
this.emit( '@host', node.position ) +
|
|
194
|
-
this.emit( '{' ) +
|
|
195
|
-
this.mapVisit( node.rules ) +
|
|
196
|
-
this.emit( '}' )
|
|
197
|
-
);
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Visit custom-media node.
|
|
202
|
-
*/
|
|
203
|
-
|
|
204
|
-
Compiler.prototype[ 'custom-media' ] = function ( node ) {
|
|
205
|
-
return this.emit(
|
|
206
|
-
'@custom-media ' + node.name + ' ' + node.media + ';',
|
|
207
|
-
node.position
|
|
208
|
-
);
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Visit rule node.
|
|
213
|
-
*/
|
|
214
|
-
|
|
215
|
-
Compiler.prototype.rule = function ( node ) {
|
|
216
|
-
const decls = node.declarations;
|
|
217
|
-
if ( ! decls.length ) {
|
|
218
|
-
return '';
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
return (
|
|
222
|
-
this.emit( node.selectors.join( ',' ), node.position ) +
|
|
223
|
-
this.emit( '{' ) +
|
|
224
|
-
this.mapVisit( decls ) +
|
|
225
|
-
this.emit( '}' )
|
|
226
|
-
);
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Visit declaration node.
|
|
231
|
-
*/
|
|
232
|
-
|
|
233
|
-
Compiler.prototype.declaration = function ( node ) {
|
|
234
|
-
return (
|
|
235
|
-
this.emit( node.property + ':' + node.value, node.position ) +
|
|
236
|
-
this.emit( ';' )
|
|
237
|
-
);
|
|
238
|
-
};
|
|
@@ -1,286 +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
|
-
/**
|
|
7
|
-
* External dependencies
|
|
8
|
-
*/
|
|
9
|
-
import inherits from 'inherits';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import Base from './compiler';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Expose compiler.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
export default Compiler;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Initialize a new `Compiler`.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
function Compiler( options ) {
|
|
27
|
-
options = options || {};
|
|
28
|
-
Base.call( this, options );
|
|
29
|
-
this.indentation = options.indent;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Inherit from `Base.prototype`.
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
inherits( Compiler, Base );
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Compile `node`.
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
Compiler.prototype.compile = function ( node ) {
|
|
43
|
-
return this.stylesheet( node );
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Visit stylesheet node.
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
Compiler.prototype.stylesheet = function ( node ) {
|
|
51
|
-
return this.mapVisit( node.stylesheet.rules, '\n\n' );
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Visit comment node.
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
Compiler.prototype.comment = function ( node ) {
|
|
59
|
-
return this.emit(
|
|
60
|
-
this.indent() + '/*' + node.comment + '*/',
|
|
61
|
-
node.position
|
|
62
|
-
);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Visit import node.
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
Compiler.prototype.import = function ( node ) {
|
|
70
|
-
return this.emit( '@import ' + node.import + ';', node.position );
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Visit media node.
|
|
75
|
-
*/
|
|
76
|
-
|
|
77
|
-
Compiler.prototype.media = function ( node ) {
|
|
78
|
-
return (
|
|
79
|
-
this.emit( '@media ' + node.media, node.position ) +
|
|
80
|
-
this.emit( ' {\n' + this.indent( 1 ) ) +
|
|
81
|
-
this.mapVisit( node.rules, '\n\n' ) +
|
|
82
|
-
this.emit( this.indent( -1 ) + '\n}' )
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Visit container node.
|
|
88
|
-
*/
|
|
89
|
-
|
|
90
|
-
Compiler.prototype.container = function ( node ) {
|
|
91
|
-
return (
|
|
92
|
-
this.emit( '@container ' + node.container, node.position ) +
|
|
93
|
-
this.emit( ' {\n' + this.indent( 1 ) ) +
|
|
94
|
-
this.mapVisit( node.rules, '\n\n' ) +
|
|
95
|
-
this.emit( this.indent( -1 ) + '\n}' )
|
|
96
|
-
);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Visit document node.
|
|
101
|
-
*/
|
|
102
|
-
|
|
103
|
-
Compiler.prototype.document = function ( node ) {
|
|
104
|
-
const doc = '@' + ( node.vendor || '' ) + 'document ' + node.document;
|
|
105
|
-
|
|
106
|
-
return (
|
|
107
|
-
this.emit( doc, node.position ) +
|
|
108
|
-
this.emit( ' ' + ' {\n' + this.indent( 1 ) ) +
|
|
109
|
-
this.mapVisit( node.rules, '\n\n' ) +
|
|
110
|
-
this.emit( this.indent( -1 ) + '\n}' )
|
|
111
|
-
);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Visit charset node.
|
|
116
|
-
*/
|
|
117
|
-
|
|
118
|
-
Compiler.prototype.charset = function ( node ) {
|
|
119
|
-
return this.emit( '@charset ' + node.charset + ';', node.position );
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Visit namespace node.
|
|
124
|
-
*/
|
|
125
|
-
|
|
126
|
-
Compiler.prototype.namespace = function ( node ) {
|
|
127
|
-
return this.emit( '@namespace ' + node.namespace + ';', node.position );
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Visit supports node.
|
|
132
|
-
*/
|
|
133
|
-
|
|
134
|
-
Compiler.prototype.supports = function ( node ) {
|
|
135
|
-
return (
|
|
136
|
-
this.emit( '@supports ' + node.supports, node.position ) +
|
|
137
|
-
this.emit( ' {\n' + this.indent( 1 ) ) +
|
|
138
|
-
this.mapVisit( node.rules, '\n\n' ) +
|
|
139
|
-
this.emit( this.indent( -1 ) + '\n}' )
|
|
140
|
-
);
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Visit keyframes node.
|
|
145
|
-
*/
|
|
146
|
-
|
|
147
|
-
Compiler.prototype.keyframes = function ( node ) {
|
|
148
|
-
return (
|
|
149
|
-
this.emit(
|
|
150
|
-
'@' + ( node.vendor || '' ) + 'keyframes ' + node.name,
|
|
151
|
-
node.position
|
|
152
|
-
) +
|
|
153
|
-
this.emit( ' {\n' + this.indent( 1 ) ) +
|
|
154
|
-
this.mapVisit( node.keyframes, '\n' ) +
|
|
155
|
-
this.emit( this.indent( -1 ) + '}' )
|
|
156
|
-
);
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Visit keyframe node.
|
|
161
|
-
*/
|
|
162
|
-
|
|
163
|
-
Compiler.prototype.keyframe = function ( node ) {
|
|
164
|
-
const decls = node.declarations;
|
|
165
|
-
|
|
166
|
-
return (
|
|
167
|
-
this.emit( this.indent() ) +
|
|
168
|
-
this.emit( node.values.join( ', ' ), node.position ) +
|
|
169
|
-
this.emit( ' {\n' + this.indent( 1 ) ) +
|
|
170
|
-
this.mapVisit( decls, '\n' ) +
|
|
171
|
-
this.emit( this.indent( -1 ) + '\n' + this.indent() + '}\n' )
|
|
172
|
-
);
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Visit page node.
|
|
177
|
-
*/
|
|
178
|
-
|
|
179
|
-
Compiler.prototype.page = function ( node ) {
|
|
180
|
-
const sel = node.selectors.length ? node.selectors.join( ', ' ) + ' ' : '';
|
|
181
|
-
|
|
182
|
-
return (
|
|
183
|
-
this.emit( '@page ' + sel, node.position ) +
|
|
184
|
-
this.emit( '{\n' ) +
|
|
185
|
-
this.emit( this.indent( 1 ) ) +
|
|
186
|
-
this.mapVisit( node.declarations, '\n' ) +
|
|
187
|
-
this.emit( this.indent( -1 ) ) +
|
|
188
|
-
this.emit( '\n}' )
|
|
189
|
-
);
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Visit font-face node.
|
|
194
|
-
*/
|
|
195
|
-
|
|
196
|
-
Compiler.prototype[ 'font-face' ] = function ( node ) {
|
|
197
|
-
return (
|
|
198
|
-
this.emit( '@font-face ', node.position ) +
|
|
199
|
-
this.emit( '{\n' ) +
|
|
200
|
-
this.emit( this.indent( 1 ) ) +
|
|
201
|
-
this.mapVisit( node.declarations, '\n' ) +
|
|
202
|
-
this.emit( this.indent( -1 ) ) +
|
|
203
|
-
this.emit( '\n}' )
|
|
204
|
-
);
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Visit host node.
|
|
209
|
-
*/
|
|
210
|
-
|
|
211
|
-
Compiler.prototype.host = function ( node ) {
|
|
212
|
-
return (
|
|
213
|
-
this.emit( '@host', node.position ) +
|
|
214
|
-
this.emit( ' {\n' + this.indent( 1 ) ) +
|
|
215
|
-
this.mapVisit( node.rules, '\n\n' ) +
|
|
216
|
-
this.emit( this.indent( -1 ) + '\n}' )
|
|
217
|
-
);
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Visit custom-media node.
|
|
222
|
-
*/
|
|
223
|
-
|
|
224
|
-
Compiler.prototype[ 'custom-media' ] = function ( node ) {
|
|
225
|
-
return this.emit(
|
|
226
|
-
'@custom-media ' + node.name + ' ' + node.media + ';',
|
|
227
|
-
node.position
|
|
228
|
-
);
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Visit rule node.
|
|
233
|
-
*/
|
|
234
|
-
|
|
235
|
-
Compiler.prototype.rule = function ( node ) {
|
|
236
|
-
const indent = this.indent();
|
|
237
|
-
const decls = node.declarations;
|
|
238
|
-
if ( ! decls.length ) {
|
|
239
|
-
return '';
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
return (
|
|
243
|
-
this.emit(
|
|
244
|
-
node.selectors
|
|
245
|
-
.map( function ( s ) {
|
|
246
|
-
return indent + s;
|
|
247
|
-
} )
|
|
248
|
-
.join( ',\n' ),
|
|
249
|
-
node.position
|
|
250
|
-
) +
|
|
251
|
-
this.emit( ' {\n' ) +
|
|
252
|
-
this.emit( this.indent( 1 ) ) +
|
|
253
|
-
this.mapVisit( decls, '\n' ) +
|
|
254
|
-
this.emit( this.indent( -1 ) ) +
|
|
255
|
-
this.emit( '\n' + this.indent() + '}' )
|
|
256
|
-
);
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Visit declaration node.
|
|
261
|
-
*/
|
|
262
|
-
|
|
263
|
-
Compiler.prototype.declaration = function ( node ) {
|
|
264
|
-
return (
|
|
265
|
-
this.emit( this.indent() ) +
|
|
266
|
-
this.emit( node.property + ': ' + node.value, node.position ) +
|
|
267
|
-
this.emit( ';' )
|
|
268
|
-
);
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Increase, decrease or return current indentation.
|
|
273
|
-
*/
|
|
274
|
-
|
|
275
|
-
Compiler.prototype.indent = function ( level ) {
|
|
276
|
-
this.level = this.level || 1;
|
|
277
|
-
|
|
278
|
-
if ( null !== level ) {
|
|
279
|
-
this.level += level;
|
|
280
|
-
return '';
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
return Array( this.level ).join( this.indentation || ' ' );
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
/* eslint-enable @wordpress/no-unused-vars-before-return */
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// Adapted from https://github.com/reworkcss/css
|
|
2
|
-
// because we needed to remove source map support.
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Internal dependencies
|
|
6
|
-
*/
|
|
7
|
-
import Compressed from './compress';
|
|
8
|
-
import Identity from './identity';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Stringfy the given AST `node`.
|
|
12
|
-
*
|
|
13
|
-
* Options:
|
|
14
|
-
*
|
|
15
|
-
* - `compress` space-optimized output
|
|
16
|
-
* - `sourcemap` return an object with `.code` and `.map`
|
|
17
|
-
*
|
|
18
|
-
* @param {Object} node
|
|
19
|
-
* @param {Object} [options]
|
|
20
|
-
* @return {string}
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
export default function ( node, options ) {
|
|
24
|
-
options = options || {};
|
|
25
|
-
|
|
26
|
-
const compiler = options.compress
|
|
27
|
-
? new Compressed( options )
|
|
28
|
-
: new Identity( options );
|
|
29
|
-
|
|
30
|
-
const code = compiler.compile( node );
|
|
31
|
-
return code;
|
|
32
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal dependencies
|
|
3
|
-
*/
|
|
4
|
-
import traverse from '../traverse';
|
|
5
|
-
|
|
6
|
-
describe( 'CSS traverse', () => {
|
|
7
|
-
it( 'Should traverse the CSS', () => {
|
|
8
|
-
const input = `h1 { color: red; }`;
|
|
9
|
-
const output = traverse( input, ( node ) => {
|
|
10
|
-
if ( node.type === 'rule' ) {
|
|
11
|
-
return {
|
|
12
|
-
...node,
|
|
13
|
-
selectors: node.selectors.map(
|
|
14
|
-
( selector ) => 'namespace ' + selector
|
|
15
|
-
),
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return node;
|
|
20
|
-
} );
|
|
21
|
-
|
|
22
|
-
expect( output ).toMatchSnapshot();
|
|
23
|
-
} );
|
|
24
|
-
} );
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`URL rewrite should not replace absolute paths 1`] = `
|
|
4
|
-
"h1 {
|
|
5
|
-
background: url(/images/test.png);
|
|
6
|
-
}"
|
|
7
|
-
`;
|
|
8
|
-
|
|
9
|
-
exports[`URL rewrite should not replace remote paths 1`] = `
|
|
10
|
-
"h1 {
|
|
11
|
-
background: url(http://wp.org/images/test.png);
|
|
12
|
-
}"
|
|
13
|
-
`;
|
|
14
|
-
|
|
15
|
-
exports[`URL rewrite should replace complex relative paths 1`] = `
|
|
16
|
-
"h1 {
|
|
17
|
-
background: url(http://wp-site.local/themes/gut/images/test.png);
|
|
18
|
-
}"
|
|
19
|
-
`;
|
|
20
|
-
|
|
21
|
-
exports[`URL rewrite should replace relative paths 1`] = `
|
|
22
|
-
"h1 {
|
|
23
|
-
background: url(http://wp-site.local/themes/gut/css/images/test.png);
|
|
24
|
-
}"
|
|
25
|
-
`;
|