@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.
Files changed (287) hide show
  1. package/CHANGELOG.md +12 -10
  2. package/README.md +35 -3
  3. package/build/components/block-alignment-control/use-available-alignments.js +30 -28
  4. package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
  5. package/build/components/block-list/block.native.js +4 -4
  6. package/build/components/block-list/block.native.js.map +1 -1
  7. package/build/components/block-list/layout.js +2 -3
  8. package/build/components/block-list/layout.js.map +1 -1
  9. package/build/components/border-radius-control/index.js +3 -2
  10. package/build/components/border-radius-control/index.js.map +1 -1
  11. package/build/components/color-palette/with-color-context.js +6 -6
  12. package/build/components/color-palette/with-color-context.js.map +1 -1
  13. package/build/components/colors/with-colors.js +2 -8
  14. package/build/components/colors/with-colors.js.map +1 -1
  15. package/build/components/colors-gradients/control.js +6 -7
  16. package/build/components/colors-gradients/control.js.map +1 -1
  17. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +5 -13
  18. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  19. package/build/components/font-family/index.js +2 -3
  20. package/build/components/font-family/index.js.map +1 -1
  21. package/build/components/font-sizes/font-size-picker.js +3 -5
  22. package/build/components/font-sizes/font-size-picker.js.map +1 -1
  23. package/build/components/font-sizes/with-font-sizes.js +3 -4
  24. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  25. package/build/components/global-styles/filters-panel.js +7 -8
  26. package/build/components/global-styles/filters-panel.js.map +1 -1
  27. package/build/components/global-styles/image-settings-panel.js +2 -2
  28. package/build/components/global-styles/image-settings-panel.js.map +1 -1
  29. package/build/components/global-styles/typography-panel.js +1 -1
  30. package/build/components/global-styles/typography-panel.js.map +1 -1
  31. package/build/components/gradients/use-gradient.js +2 -5
  32. package/build/components/gradients/use-gradient.js.map +1 -1
  33. package/build/components/height-control/index.js +3 -3
  34. package/build/components/height-control/index.js.map +1 -1
  35. package/build/components/index.js +9 -2
  36. package/build/components/index.js.map +1 -1
  37. package/build/components/index.native.js +9 -2
  38. package/build/components/index.native.js.map +1 -1
  39. package/build/components/inner-blocks/index.js +2 -2
  40. package/build/components/inner-blocks/index.js.map +1 -1
  41. package/build/components/letter-spacing-control/index.js +3 -3
  42. package/build/components/letter-spacing-control/index.js.map +1 -1
  43. package/build/components/link-control/search-item.js +11 -0
  44. package/build/components/link-control/search-item.js.map +1 -1
  45. package/build/components/link-control/search-results.js +2 -1
  46. package/build/components/link-control/search-results.js.map +1 -1
  47. package/build/components/link-control/use-search-handler.js +10 -5
  48. package/build/components/link-control/use-search-handler.js.map +1 -1
  49. package/build/components/resizable-box-popover/index.js +1 -1
  50. package/build/components/resizable-box-popover/index.js.map +1 -1
  51. package/build/components/rich-text/index.js +1 -1
  52. package/build/components/rich-text/index.js.map +1 -1
  53. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +6 -3
  54. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  55. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +3 -3
  56. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  57. package/build/components/unit-control/index.js +3 -3
  58. package/build/components/unit-control/index.js.map +1 -1
  59. package/build/components/use-block-commands/index.js +6 -1
  60. package/build/components/use-block-commands/index.js.map +1 -1
  61. package/build/components/use-settings/index.js +212 -0
  62. package/build/components/use-settings/index.js.map +1 -0
  63. package/build/hooks/align.js +51 -35
  64. package/build/hooks/align.js.map +1 -1
  65. package/build/hooks/anchor.js +37 -32
  66. package/build/hooks/anchor.js.map +1 -1
  67. package/build/hooks/background.js +4 -4
  68. package/build/hooks/background.js.map +1 -1
  69. package/build/hooks/color.js +2 -4
  70. package/build/hooks/color.js.map +1 -1
  71. package/build/hooks/duotone.js +10 -9
  72. package/build/hooks/duotone.js.map +1 -1
  73. package/build/hooks/font-size.js +4 -4
  74. package/build/hooks/font-size.js.map +1 -1
  75. package/build/hooks/layout.js +10 -11
  76. package/build/hooks/layout.js.map +1 -1
  77. package/build/hooks/line-height.js +3 -3
  78. package/build/hooks/line-height.js.map +1 -1
  79. package/build/hooks/position.js +2 -3
  80. package/build/hooks/position.js.map +1 -1
  81. package/build/hooks/use-color-props.js +3 -11
  82. package/build/hooks/use-color-props.js.map +1 -1
  83. package/build/hooks/utils.js +1 -42
  84. package/build/hooks/utils.js.map +1 -1
  85. package/build/layouts/constrained.js +3 -3
  86. package/build/layouts/constrained.js.map +1 -1
  87. package/build/utils/object.js +4 -1
  88. package/build/utils/object.js.map +1 -1
  89. package/build/utils/transform-styles/index.js +19 -24
  90. package/build/utils/transform-styles/index.js.map +1 -1
  91. package/build-module/components/block-alignment-control/use-available-alignments.js +30 -28
  92. package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
  93. package/build-module/components/block-list/block.native.js +4 -4
  94. package/build-module/components/block-list/block.native.js.map +1 -1
  95. package/build-module/components/block-list/layout.js +2 -2
  96. package/build-module/components/block-list/layout.js.map +1 -1
  97. package/build-module/components/border-radius-control/index.js +3 -2
  98. package/build-module/components/border-radius-control/index.js.map +1 -1
  99. package/build-module/components/color-palette/with-color-context.js +6 -5
  100. package/build-module/components/color-palette/with-color-context.js.map +1 -1
  101. package/build-module/components/colors/with-colors.js +2 -7
  102. package/build-module/components/colors/with-colors.js.map +1 -1
  103. package/build-module/components/colors-gradients/control.js +6 -7
  104. package/build-module/components/colors-gradients/control.js.map +1 -1
  105. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +5 -12
  106. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  107. package/build-module/components/font-family/index.js +2 -2
  108. package/build-module/components/font-family/index.js.map +1 -1
  109. package/build-module/components/font-sizes/font-size-picker.js +3 -4
  110. package/build-module/components/font-sizes/font-size-picker.js.map +1 -1
  111. package/build-module/components/font-sizes/with-font-sizes.js +3 -3
  112. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  113. package/build-module/components/global-styles/filters-panel.js +7 -8
  114. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  115. package/build-module/components/global-styles/image-settings-panel.js +2 -2
  116. package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
  117. package/build-module/components/global-styles/typography-panel.js +1 -1
  118. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  119. package/build-module/components/gradients/use-gradient.js +2 -4
  120. package/build-module/components/gradients/use-gradient.js.map +1 -1
  121. package/build-module/components/height-control/index.js +3 -2
  122. package/build-module/components/height-control/index.js.map +1 -1
  123. package/build-module/components/index.js +1 -1
  124. package/build-module/components/index.js.map +1 -1
  125. package/build-module/components/index.native.js +1 -1
  126. package/build-module/components/index.native.js.map +1 -1
  127. package/build-module/components/inner-blocks/index.js +2 -2
  128. package/build-module/components/inner-blocks/index.js.map +1 -1
  129. package/build-module/components/letter-spacing-control/index.js +3 -2
  130. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  131. package/build-module/components/link-control/search-item.js +12 -1
  132. package/build-module/components/link-control/search-item.js.map +1 -1
  133. package/build-module/components/link-control/search-results.js +2 -1
  134. package/build-module/components/link-control/search-results.js.map +1 -1
  135. package/build-module/components/link-control/use-search-handler.js +10 -5
  136. package/build-module/components/link-control/use-search-handler.js.map +1 -1
  137. package/build-module/components/resizable-box-popover/index.js +1 -1
  138. package/build-module/components/resizable-box-popover/index.js.map +1 -1
  139. package/build-module/components/rich-text/index.js +1 -1
  140. package/build-module/components/rich-text/index.js.map +1 -1
  141. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +6 -2
  142. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  143. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +3 -2
  144. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  145. package/build-module/components/unit-control/index.js +3 -2
  146. package/build-module/components/unit-control/index.js.map +1 -1
  147. package/build-module/components/use-block-commands/index.js +5 -1
  148. package/build-module/components/use-block-commands/index.js.map +1 -1
  149. package/build-module/components/use-settings/index.js +203 -0
  150. package/build-module/components/use-settings/index.js.map +1 -0
  151. package/build-module/hooks/align.js +51 -35
  152. package/build-module/hooks/align.js.map +1 -1
  153. package/build-module/hooks/anchor.js +37 -32
  154. package/build-module/hooks/anchor.js.map +1 -1
  155. package/build-module/hooks/background.js +4 -4
  156. package/build-module/hooks/background.js.map +1 -1
  157. package/build-module/hooks/color.js +2 -4
  158. package/build-module/hooks/color.js.map +1 -1
  159. package/build-module/hooks/duotone.js +11 -10
  160. package/build-module/hooks/duotone.js.map +1 -1
  161. package/build-module/hooks/font-size.js +4 -4
  162. package/build-module/hooks/font-size.js.map +1 -1
  163. package/build-module/hooks/layout.js +10 -11
  164. package/build-module/hooks/layout.js.map +1 -1
  165. package/build-module/hooks/line-height.js +3 -3
  166. package/build-module/hooks/line-height.js.map +1 -1
  167. package/build-module/hooks/position.js +2 -3
  168. package/build-module/hooks/position.js.map +1 -1
  169. package/build-module/hooks/use-color-props.js +3 -11
  170. package/build-module/hooks/use-color-props.js.map +1 -1
  171. package/build-module/hooks/utils.js +2 -43
  172. package/build-module/hooks/utils.js.map +1 -1
  173. package/build-module/layouts/constrained.js +3 -2
  174. package/build-module/layouts/constrained.js.map +1 -1
  175. package/build-module/utils/object.js +3 -1
  176. package/build-module/utils/object.js.map +1 -1
  177. package/build-module/utils/transform-styles/index.js +20 -24
  178. package/build-module/utils/transform-styles/index.js.map +1 -1
  179. package/build-style/style-rtl.css +13 -6
  180. package/build-style/style.css +13 -6
  181. package/package.json +36 -34
  182. package/src/components/block-alignment-control/use-available-alignments.js +49 -34
  183. package/src/components/block-list/block.native.js +4 -4
  184. package/src/components/block-list/layout.js +2 -2
  185. package/src/components/block-styles/style.scss +1 -1
  186. package/src/components/border-radius-control/index.js +3 -2
  187. package/src/components/color-palette/with-color-context.js +9 -9
  188. package/src/components/colors/with-colors.js +6 -7
  189. package/src/components/colors-gradients/control.js +10 -7
  190. package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +29 -15
  191. package/src/components/font-family/index.js +2 -2
  192. package/src/components/font-sizes/font-size-picker.js +6 -4
  193. package/src/components/font-sizes/with-font-sizes.js +3 -5
  194. package/src/components/global-styles/filters-panel.js +9 -15
  195. package/src/components/global-styles/image-settings-panel.js +2 -2
  196. package/src/components/global-styles/typography-panel.js +1 -1
  197. package/src/components/gradients/use-gradient.js +10 -4
  198. package/src/components/height-control/index.js +3 -2
  199. package/src/components/index.js +1 -1
  200. package/src/components/index.native.js +1 -1
  201. package/src/components/inner-blocks/index.js +2 -2
  202. package/src/components/inserter/style.scss +9 -1
  203. package/src/components/letter-spacing-control/index.js +3 -2
  204. package/src/components/link-control/search-item.js +14 -0
  205. package/src/components/link-control/search-results.js +1 -0
  206. package/src/components/link-control/use-search-handler.js +22 -15
  207. package/src/components/resizable-box-popover/index.js +1 -1
  208. package/src/components/rich-text/index.js +1 -1
  209. package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +7 -5
  210. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +3 -2
  211. package/src/components/unit-control/index.js +3 -8
  212. package/src/components/use-block-commands/index.js +2 -1
  213. package/src/components/{use-setting → use-settings}/README.md +9 -10
  214. package/src/components/use-settings/index.js +272 -0
  215. package/src/components/{use-setting → use-settings}/test/index.js +47 -5
  216. package/src/hooks/align.js +79 -54
  217. package/src/hooks/anchor.js +75 -65
  218. package/src/hooks/background.js +7 -9
  219. package/src/hooks/color.js +7 -4
  220. package/src/hooks/duotone.js +24 -19
  221. package/src/hooks/font-size.js +4 -4
  222. package/src/hooks/layout.js +11 -11
  223. package/src/hooks/line-height.js +3 -3
  224. package/src/hooks/position.js +5 -3
  225. package/src/hooks/use-color-props.js +21 -14
  226. package/src/hooks/utils.js +88 -43
  227. package/src/layouts/constrained.js +3 -8
  228. package/src/utils/object.js +4 -1
  229. package/src/utils/test/__snapshots__/transform-styles.js.snap +103 -0
  230. package/src/utils/test/transform-styles.js +217 -0
  231. package/src/utils/transform-styles/index.js +25 -25
  232. package/build/components/use-setting/index.js +0 -161
  233. package/build/components/use-setting/index.js.map +0 -1
  234. package/build/utils/transform-styles/ast/index.js +0 -21
  235. package/build/utils/transform-styles/ast/index.js.map +0 -1
  236. package/build/utils/transform-styles/ast/parse.js +0 -660
  237. package/build/utils/transform-styles/ast/parse.js.map +0 -1
  238. package/build/utils/transform-styles/ast/stringify/compiler.js +0 -52
  239. package/build/utils/transform-styles/ast/stringify/compiler.js.map +0 -1
  240. package/build/utils/transform-styles/ast/stringify/compress.js +0 -178
  241. package/build/utils/transform-styles/ast/stringify/compress.js.map +0 -1
  242. package/build/utils/transform-styles/ast/stringify/identity.js +0 -207
  243. package/build/utils/transform-styles/ast/stringify/identity.js.map +0 -1
  244. package/build/utils/transform-styles/ast/stringify/index.js +0 -36
  245. package/build/utils/transform-styles/ast/stringify/index.js.map +0 -1
  246. package/build/utils/transform-styles/transforms/url-rewrite.js +0 -130
  247. package/build/utils/transform-styles/transforms/url-rewrite.js.map +0 -1
  248. package/build/utils/transform-styles/transforms/wrap.js +0 -59
  249. package/build/utils/transform-styles/transforms/wrap.js.map +0 -1
  250. package/build/utils/transform-styles/traverse.js +0 -37
  251. package/build/utils/transform-styles/traverse.js.map +0 -1
  252. package/build-module/components/use-setting/index.js +0 -154
  253. package/build-module/components/use-setting/index.js.map +0 -1
  254. package/build-module/utils/transform-styles/ast/index.js +0 -6
  255. package/build-module/utils/transform-styles/ast/index.js.map +0 -1
  256. package/build-module/utils/transform-styles/ast/parse.js +0 -654
  257. package/build-module/utils/transform-styles/ast/parse.js.map +0 -1
  258. package/build-module/utils/transform-styles/ast/stringify/compiler.js +0 -49
  259. package/build-module/utils/transform-styles/ast/stringify/compiler.js.map +0 -1
  260. package/build-module/utils/transform-styles/ast/stringify/compress.js +0 -176
  261. package/build-module/utils/transform-styles/ast/stringify/compress.js.map +0 -1
  262. package/build-module/utils/transform-styles/ast/stringify/identity.js +0 -206
  263. package/build-module/utils/transform-styles/ast/stringify/identity.js.map +0 -1
  264. package/build-module/utils/transform-styles/ast/stringify/index.js +0 -29
  265. package/build-module/utils/transform-styles/ast/stringify/index.js.map +0 -1
  266. package/build-module/utils/transform-styles/transforms/url-rewrite.js +0 -123
  267. package/build-module/utils/transform-styles/transforms/url-rewrite.js.map +0 -1
  268. package/build-module/utils/transform-styles/transforms/wrap.js +0 -52
  269. package/build-module/utils/transform-styles/transforms/wrap.js.map +0 -1
  270. package/build-module/utils/transform-styles/traverse.js +0 -28
  271. package/build-module/utils/transform-styles/traverse.js.map +0 -1
  272. package/src/components/use-setting/index.js +0 -218
  273. package/src/utils/transform-styles/ast/index.js +0 -5
  274. package/src/utils/transform-styles/ast/parse.js +0 -732
  275. package/src/utils/transform-styles/ast/stringify/compiler.js +0 -50
  276. package/src/utils/transform-styles/ast/stringify/compress.js +0 -238
  277. package/src/utils/transform-styles/ast/stringify/identity.js +0 -286
  278. package/src/utils/transform-styles/ast/stringify/index.js +0 -32
  279. package/src/utils/transform-styles/test/__snapshots__/traverse.js.snap +0 -7
  280. package/src/utils/transform-styles/test/traverse.js +0 -24
  281. package/src/utils/transform-styles/transforms/test/__snapshots__/url-rewrite.js.snap +0 -25
  282. package/src/utils/transform-styles/transforms/test/__snapshots__/wrap.js.snap +0 -64
  283. package/src/utils/transform-styles/transforms/test/url-rewrite.js +0 -39
  284. package/src/utils/transform-styles/transforms/test/wrap.js +0 -95
  285. package/src/utils/transform-styles/transforms/url-rewrite.js +0 -139
  286. package/src/utils/transform-styles/transforms/wrap.js +0 -56
  287. 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,7 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`CSS traverse Should traverse the CSS 1`] = `
4
- "namespace h1 {
5
- color: red;
6
- }"
7
- `;
@@ -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
- `;