mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
This commit is contained in:
parent
15fadeda2d
commit
de285c712a
3 changed files with 23 additions and 11 deletions
|
@ -98,8 +98,8 @@
|
|||
"babel-plugin-transform-define": "1.3.0",
|
||||
"babel-plugin-transform-object-rest-spread": "6.23.0",
|
||||
"babel-polyfill": "6.20.0",
|
||||
"babel-preset-env": "1.4.0",
|
||||
"babel-preset-react": "6.22.0",
|
||||
"babel-preset-env": "1.6.1",
|
||||
"babel-preset-react": "6.24.1",
|
||||
"babel-register": "6.18.0",
|
||||
"bluebird": "2.9.34",
|
||||
"body-parser": "1.12.0",
|
||||
|
@ -177,7 +177,7 @@
|
|||
"react-input-range": "1.2.1",
|
||||
"react-markdown": "3.1.0",
|
||||
"react-redux": "5.0.5",
|
||||
"react-router": "2.0.0",
|
||||
"react-router": "3.2.0",
|
||||
"react-router-dom": "4.2.2",
|
||||
"react-router-redux": "4.0.4",
|
||||
"react-select": "1.0.0-rc.5",
|
||||
|
|
|
@ -2,16 +2,27 @@ import React from 'react';
|
|||
|
||||
import {
|
||||
render,
|
||||
configure
|
||||
} from 'enzyme';
|
||||
|
||||
import EnzymeAdapter from 'enzyme-adapter-react-16';
|
||||
|
||||
import html from 'html';
|
||||
|
||||
configure({ adapter: new EnzymeAdapter() });
|
||||
|
||||
export function renderToHtml(componentReference, props = {}) {
|
||||
// Create the React element, render it and get its HTML, then format it prettily.
|
||||
const element = React.createElement(componentReference, props);
|
||||
const htmlString = render(element).html();
|
||||
return html.prettyPrint(htmlString, {
|
||||
indent_size: 2,
|
||||
unformatted: [], // Expand all tags, including spans
|
||||
});
|
||||
// If there's a failure, just return an empty string. The actual component itself should
|
||||
// trip an error boundary in the UI when it fails.
|
||||
try {
|
||||
// Create the React element, render it and get its HTML, then format it prettily.
|
||||
const element = React.createElement(componentReference, props);
|
||||
const htmlString = render(element).html();
|
||||
return html.prettyPrint(htmlString, {
|
||||
indent_size: 2,
|
||||
unformatted: [], // Expand all tags, including spans
|
||||
});
|
||||
} catch(e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import React, { PropTypes } from 'react';
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import {
|
||||
KuiExpression,
|
||||
KuiExpressionButton,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue