Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed import of react-syntax-highlighter from esm to cjs #9292

Merged
merged 19 commits into from
Mar 10, 2020
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
9081e1f
Changed imports for react-syntax-highlighter
Rikpat Jan 1, 2020
e362b69
Properly imported prism-light with type
Rikpat Jan 1, 2020
4dbc783
added type declarations for cjs modules and used import instead of re…
Rikpat Jan 1, 2020
4131c6f
added javascript and markdown as registered language
Rikpat Jan 2, 2020
8c3e749
added jsExtras and cssExtras to SyntaxHighlighter
Rikpat Jan 2, 2020
851242c
updated yarn.lock
Rikpat Jan 2, 2020
097cbee
Update @types/react-syntax-highlighter (includes cjs typings)
Hypnosphi Jan 4, 2020
f549e14
FIX css & jsExtra by registering with refractor directly
ndelangen Jan 8, 2020
6ec3feb
Merge commit '0c5c7260bceaf9e9211fb0efd7b9fc819cb77fc1' into pr/Rikpa…
ndelangen Jan 8, 2020
57f71b8
Merge branch 'next' into patch-3
ndelangen Jan 8, 2020
a9f8ed6
Merge branch 'next' into pr/Rikpat/9292
ndelangen Jan 21, 2020
aab4d56
Merge branch 'patch-3' of github.com:Rikpat/storybook into pr/Rikpat/…
ndelangen Jan 21, 2020
47306a4
Merge branch 'next' into pr/Rikpat/9292
ndelangen Feb 14, 2020
806b90b
Merge branch 'next' into patch-3
ndelangen Feb 17, 2020
baffa1f
Merge branch 'next' into pr/Rikpat/9292
ndelangen Feb 18, 2020
19776df
Merge branch 'patch-3' of github.com:Rikpat/storybook into pr/Rikpat/…
ndelangen Feb 18, 2020
2d70f58
Merge branch 'next' into patch-3
ndelangen Feb 20, 2020
9817084
Merge branch 'next' into pr/Rikpat/9292
ndelangen Mar 10, 2020
7e3a902
Merge branch 'patch-3' of github.com:Rikpat/storybook into pr/Rikpat/…
ndelangen Mar 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@ module.exports = {
'babel-runtime/core-js/(.*)': `core-js/es/$1`,
// 'babel-runtime/core-js/object/assign'
'core-js/library/fn/object/assign': 'core-js/es/object/assign',
'react-syntax-highlighter/dist/esm/(.*)': 'react-syntax-highlighter/dist/cjs/$1',
},
projects: [
'<rootDir>',
4 changes: 3 additions & 1 deletion lib/components/package.json
Original file line number Diff line number Diff line change
@@ -30,7 +30,9 @@
"dependencies": {
"@storybook/client-logger": "6.0.0-alpha.22",
"@storybook/theming": "6.0.0-alpha.22",
"@types/react-syntax-highlighter": "11.0.4",
"@types/react-textarea-autosize": "^4.3.3",
"@types/refractor": "^2.8.0",
"core-js": "^3.0.1",
"global": "^4.3.2",
"lodash": "^4.17.15",
@@ -45,11 +47,11 @@
"react-popper-tooltip": "^2.8.3",
"react-syntax-highlighter": "^11.0.2",
"react-textarea-autosize": "^7.1.0",
"refractor": "^2.10.0",
"simplebar-react": "^1.0.0-alpha.6",
"ts-dedent": "^1.1.1"
},
"devDependencies": {
"@types/react-syntax-highlighter": "^11.0.2",
"enzyme": "^3.9.0",
"jest": "^25.1.0",
"jest-enzyme": "^7.0.2"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { storiesOf } from '@storybook/react';
import { ThemeProvider, themes, convert, ensure } from '@storybook/theming';
import { ThemeProvider, themes, ensure } from '@storybook/theming';
import { SyntaxHighlighter } from './syntaxhighlighter';

storiesOf('Basics/SyntaxHighlighter', module)
@@ -9,6 +9,56 @@ storiesOf('Basics/SyntaxHighlighter', module)
npx npm-check-updates '/storybook/' -u && npm install
</SyntaxHighlighter>
))
.add('css', () => (
<SyntaxHighlighter language="css" copyable={false}>
{`
.className {
border: 1px solid hotpink;
}
`}
</SyntaxHighlighter>
))
.add('json', () => (
<SyntaxHighlighter language="json" copyable={false}>
{`
{
"number": 1,
"string": "something",
"object": {
"property": "value",
},
array: [1,2,3],
}
`}
</SyntaxHighlighter>
))
.add('markdown', () => (
<SyntaxHighlighter language="markdown" copyable={false}>
{`
# a big header

some code:

~~~js
const name = "a string";
~~~

> crazy

`}
</SyntaxHighlighter>
))
.add('yaml', () => (
<SyntaxHighlighter language="yaml" copyable={false}>
{`
product:
- sku : BL394D
quantity : 4
description : Basketball
price : 450.00
`}
</SyntaxHighlighter>
))
.add('jsx', () => (
<SyntaxHighlighter language="jsx" copyable={false}>
{`import { Good, Things } from 'life';
@@ -19,6 +69,19 @@ storiesOf('Basics/SyntaxHighlighter', module)
`}
</SyntaxHighlighter>
))
.add('js', () => (
<SyntaxHighlighter language="jsx" copyable={false}>
{`import React, { createElement } from 'react';
import { Good, Things } from 'life';

const result = () => createElement(Good, [createElement(Things, [], { all: true }), []);

console.log(result);

export { result as default };
`}
</SyntaxHighlighter>
))
.add('unsupported', () => (
<SyntaxHighlighter language="C#" bordered copyable>
{`
6 changes: 6 additions & 0 deletions lib/components/src/syntaxhighlighter/syntaxhighlighter.tsx
Original file line number Diff line number Diff line change
@@ -6,7 +6,10 @@ import memoize from 'memoizerific';
import jsx from 'react-syntax-highlighter/dist/cjs/languages/prism/jsx';
import bash from 'react-syntax-highlighter/dist/cjs/languages/prism/bash';
import css from 'react-syntax-highlighter/dist/cjs/languages/prism/css';
import json from 'react-syntax-highlighter/dist/cjs/languages/prism/json';
import html from 'react-syntax-highlighter/dist/cjs/languages/prism/markup';
import md from 'react-syntax-highlighter/dist/cjs/languages/prism/markdown';
import yml from 'react-syntax-highlighter/dist/cjs/languages/prism/yaml';
import tsx from 'react-syntax-highlighter/dist/cjs/languages/prism/tsx';
import typescript from 'react-syntax-highlighter/dist/cjs/languages/prism/typescript';

@@ -21,6 +24,9 @@ import { formatter } from './formatter';
export { createElement as createSyntaxHighlighterElement };

ReactSyntaxHighlighter.registerLanguage('jsx', jsx);
ReactSyntaxHighlighter.registerLanguage('json', json);
ReactSyntaxHighlighter.registerLanguage('yml', yml);
ReactSyntaxHighlighter.registerLanguage('md', md);
ReactSyntaxHighlighter.registerLanguage('bash', bash);
ReactSyntaxHighlighter.registerLanguage('css', css);
ReactSyntaxHighlighter.registerLanguage('html', html);
23 changes: 22 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
@@ -4245,6 +4245,11 @@
resolved "https://registry.yarnpkg.com/@types/pretty-hrtime/-/pretty-hrtime-1.0.0.tgz#c5a2d644a135e988b2932f99737e67b3c62528d0"
integrity sha512-xl+5r2rcrxdLViAYkkiLMYsoUs3qEyrAnHFyEzYysgRxdVp3WbhysxIvJIxZp9FvZ2CYezh0TaHZorivH+voOQ==

"@types/prismjs@*":
version "1.16.0"
resolved "https://registry.yarnpkg.com/@types/prismjs/-/prismjs-1.16.0.tgz#4328c9f65698e59f4feade8f4e5d928c748fd643"
integrity sha512-mEyuziLrfDCQ4juQP1k706BUU/c8OGn/ZFl69AXXY6dStHClKX4P+N8+rhqpul1vRDA2VOygzMRSJJZHyDEOfw==

"@types/prop-types@*", "@types/prop-types@^15.5.9":
version "15.7.3"
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7"
@@ -4325,7 +4330,7 @@
"@types/react-dom" "*"
"@types/react-transition-group" "*"

"@types/react-syntax-highlighter@^11.0.2", "@types/react-syntax-highlighter@^11.0.4":
"@types/react-syntax-highlighter@11.0.4", "@types/react-syntax-highlighter@^11.0.4":
version "11.0.4"
resolved "https://registry.yarnpkg.com/@types/react-syntax-highlighter/-/react-syntax-highlighter-11.0.4.tgz#d86d17697db62f98046874f62fdb3e53a0bbc4cd"
integrity sha512-9GfTo3a0PHwQeTVoqs0g5bS28KkSY48pp5659wA+Dp4MqceDEa8EHBqrllJvvtyusszyJhViUEap0FDvlk/9Zg==
@@ -4362,6 +4367,13 @@
"@types/prop-types" "*"
csstype "^2.2.0"

"@types/refractor@^2.8.0":
version "2.8.0"
resolved "https://registry.yarnpkg.com/@types/refractor/-/refractor-2.8.0.tgz#2e17b69f27e89c1ea076f49b599abe3567c54e01"
integrity sha512-l3wSB96RFZnvB8bnbF8UmYsDD1MQl+u7jtYq+DgI/vo3RD5pdbK3OitGEvMO3DNJhTYmCEhXLVWyyWTddzwNzQ==
dependencies:
"@types/prismjs" "*"

"@types/rfdc@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@types/rfdc/-/rfdc-1.1.0.tgz#1fc5ffdc679575e2ca31399d4ee75f353afdd37b"
@@ -25389,6 +25401,15 @@ reflect.ownkeys@^0.2.0:
resolved "https://registry.yarnpkg.com/reflect.ownkeys/-/reflect.ownkeys-0.2.0.tgz#749aceec7f3fdf8b63f927a04809e90c5c0b3460"
integrity sha1-dJrO7H8/34tj+SegSAnpDFwLNGA=

refractor@^2.10.0:
version "2.10.0"
resolved "https://registry.yarnpkg.com/refractor/-/refractor-2.10.0.tgz#4cc7efc0028a87924a9b31d82d129dec831a287b"
integrity sha512-maW2ClIkm9IYruuFYGTqKzj+m31heq92wlheW4h7bOstP+gf8bocmMec+j7ljLcaB1CAID85LMB3moye31jH1g==
dependencies:
hastscript "^5.0.0"
parse-entities "^1.1.2"
prismjs "~1.17.0"

refractor@^2.4.1:
version "2.10.1"
resolved "https://registry.yarnpkg.com/refractor/-/refractor-2.10.1.tgz#166c32f114ed16fd96190ad21d5193d3afc7d34e"