Skip to content

Commit

Permalink
Fix Prism import order (fixes #526)
Browse files Browse the repository at this point in the history
  • Loading branch information
rainboxx committed Jun 4, 2018
1 parent 0b33f26 commit 3e867c3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/components/__snapshots__/code-pane.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ exports[`<CodePane /> should render correctly. 1`] = `
syntaxStyles={Object {}}
>
<Component
className="language-jsx builtin-prism-theme css-3w3gcf"
className="language-jsx builtin-prism-theme css-1rm1mht"
code="
const myButton = (
<CustomButton
Expand All @@ -71,7 +71,7 @@ exports[`<CodePane /> should render correctly. 1`] = `
syntaxStyles={Object {}}
>
<Editor
className="language-jsx builtin-prism-theme css-3w3gcf"
className="language-jsx builtin-prism-theme css-1rm1mht"
code="
const myButton = (
<CustomButton
Expand All @@ -89,7 +89,7 @@ exports[`<CodePane /> should render correctly. 1`] = `
onKeyUp={[Function]}
>
<pre
className="prism-code language-jsx builtin-prism-theme css-3w3gcf"
className="prism-code language-jsx builtin-prism-theme css-1rm1mht"
contentEditable={false}
dangerouslySetInnerHTML={
Object {
Expand Down
2 changes: 1 addition & 1 deletion src/components/code-pane.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import PropTypes from 'prop-types';
import { getStyles } from '../utils/base';
import styled from 'react-emotion';

import '../utils/prism-import';
import { Editor } from 'react-live';
import '../utils/prism-import';

const StyledWrapper = styled.div(props => props.styles);
const StyledEditor = styled(({ syntaxStyles: _, prismTheme: __, ...rest }) => <Editor {...rest} />)`
Expand Down
13 changes: 13 additions & 0 deletions src/components/code-pane.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,17 @@ describe('<CodePane />', () => {
const wrapper = mount(<CodePane lang="jsx" source={source} />, { context });
expect(wrapper).toMatchSnapshot();
});

test('should handle languages', () => {
const context = {
styles: {
components: { codePane: {}, syntax: {} },
prism: { light: 'light;', dark: 'dark;' }
}
};
const source = `import org.apache.commons.lang3.StringUtils;`;
expect(() => {
mount(<CodePane lang="java" source={source} />, { context });
}).not.toThrow();
});
});
2 changes: 0 additions & 2 deletions src/utils/prism-import.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'prismjs/components/prism-core';

// NOTE: This includes a "slim" list of some components of prism, but not all
// For more, see: https://github.com/PrismJS/prism/blob/1fd690dd8a652dee375acb78b6034c3fc2db687c/components.js
// and: https://github.com/PrismJS/prism/tree/gh-pages/components
Expand Down

0 comments on commit 3e867c3

Please sign in to comment.