Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* eslint-disable react/no-multi-comp */
import './home.sass'
import { Block } from 'bemboo'
import React from 'react'
import { storiesOf } from '@storybook/react'
import { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter'
import jsx from 'react-syntax-highlighter/dist/esm/languages/prism/jsx'
import sass from 'react-syntax-highlighter/dist/esm/languages/prism/sass'
import prism from 'react-syntax-highlighter/dist/esm/styles/prism/prism'
import Formol, { Conditional, Field, Inliner } from '../src'
import pkg from '../package.json'
SyntaxHighlighter.registerLanguage('jsx', jsx)
SyntaxHighlighter.registerLanguage('sass', sass)
const dedent = (strs, ...values) => {
const str = strs
.reduce((s, part, i) => s + values[i - 1] + part)
.replace(/^\n/, '')
const level = str.length - str.replace(/^ +/, '').length
return str
.split('\n')
.map(line => line.slice(level))
.join('\n')
}
const Exemple1 = () => (
/* eslint-disable react/no-multi-comp */
import './home.sass'
import { Block } from 'bemboo'
import React from 'react'
import { storiesOf } from '@storybook/react'
import { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter'
import jsx from 'react-syntax-highlighter/dist/esm/languages/prism/jsx'
import sass from 'react-syntax-highlighter/dist/esm/languages/prism/sass'
import prism from 'react-syntax-highlighter/dist/esm/styles/prism/prism'
import Formol, { Conditional, Field, Inliner } from '../src'
import pkg from '../package.json'
SyntaxHighlighter.registerLanguage('jsx', jsx)
SyntaxHighlighter.registerLanguage('sass', sass)
const dedent = (strs, ...values) => {
const str = strs
.reduce((s, part, i) => s + values[i - 1] + part)
.replace(/^\n/, '')
const level = str.length - str.replace(/^ +/, '').length
return str
.split('\n')
.map(line => line.slice(level))
.join('\n')
}
const Exemple1 = () => (
// eslint-disable-next-line no-alert
import React from 'react'
import styled from 'styled-components'
import { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter'
import js from 'react-syntax-highlighter/dist/esm/languages/prism/javascript'
import jsx from 'react-syntax-highlighter/dist/esm/languages/prism/jsx'
import ts from 'react-syntax-highlighter/dist/esm/languages/prism/typescript'
import tsx from 'react-syntax-highlighter/dist/esm/languages/prism/tsx'
import prism from 'react-syntax-highlighter/dist/esm/styles/prism/prism'
SyntaxHighlighter.registerLanguage('js', js)
SyntaxHighlighter.registerLanguage('javascript', js)
SyntaxHighlighter.registerLanguage('jsx', jsx)
SyntaxHighlighter.registerLanguage('ts', ts)
SyntaxHighlighter.registerLanguage('typescript', ts)
SyntaxHighlighter.registerLanguage('tsx', tsx)
const CodeBlock: React.FC<{
language: 'js' | 'javascript' | 'jsx' | 'ts' | 'typescript' | 'tsx'
style?: React.CSSProperties
className?: string
}> = ({ language, style, children, className }) => {
let actualLanguage = language
if (!actualLanguage && typeof className === 'string') {
// try to infer language from classname like: 'language-javascript'
for (const classN of className.split(' ')) {
const match = classN.match(/^language-(.*)$/)
if (match) {
actualLanguage = match[1] as any
export const onClientEntry = () => {
SyntaxHighlighter.registerLanguage('scss', scss)
}
const Container = styled.div`
margin: 0;
width: 100%;
max-width: 100%;
@media (min-width: 42rem) {
margin: 0 -16px;
}
span.token {
white-space: pre-wrap !important;
word-break: break-all !important;
}
`;
SyntaxHighlighter.registerLanguage("jsx", jsx);
const Code = ({ children }) => (
{children}
);
export default Code;
import jsx from 'react-syntax-highlighter/dist/esm/languages/prism/jsx';
import bash from 'react-syntax-highlighter/dist/esm/languages/prism/bash';
import css from 'react-syntax-highlighter/dist/esm/languages/prism/css';
import html from 'react-syntax-highlighter/dist/esm/languages/prism/markup';
import { PrismLight as ReactSyntaxHighlighter } from 'react-syntax-highlighter';
import { ActionBar } from '../ActionBar/ActionBar';
import { ScrollArea } from '../ScrollArea/ScrollArea';
import { formatter } from './formatter';
ReactSyntaxHighlighter.registerLanguage('jsx', jsx);
ReactSyntaxHighlighter.registerLanguage('bash', bash);
ReactSyntaxHighlighter.registerLanguage('css', css);
ReactSyntaxHighlighter.registerLanguage('html', html);
const themedSyntax = memoize(2)(theme =>
Object.entries(theme.code || {}).reduce((acc, [key, val]) => ({ ...acc, [`* .${key}`]: val }), {})
);
export interface WrapperProps {
bordered?: boolean;
padded?: boolean;
}
const Wrapper = styled.div(
({ theme }) => ({
position: 'relative',
overflow: 'hidden',
color: theme.color.defaultText,
import { document, window } from 'global';
import memoize from 'memoizerific';
import jsx from 'react-syntax-highlighter/dist/esm/languages/prism/jsx';
import bash from 'react-syntax-highlighter/dist/esm/languages/prism/bash';
import css from 'react-syntax-highlighter/dist/esm/languages/prism/css';
import html from 'react-syntax-highlighter/dist/esm/languages/prism/markup';
import { PrismLight as ReactSyntaxHighlighter } from 'react-syntax-highlighter';
import { ActionBar } from '../ActionBar/ActionBar';
import { ScrollArea } from '../ScrollArea/ScrollArea';
import { formatter } from './formatter';
ReactSyntaxHighlighter.registerLanguage('jsx', jsx);
ReactSyntaxHighlighter.registerLanguage('bash', bash);
ReactSyntaxHighlighter.registerLanguage('css', css);
ReactSyntaxHighlighter.registerLanguage('html', html);
const themedSyntax = memoize(2)(theme =>
Object.entries(theme.code || {}).reduce((acc, [key, val]) => ({ ...acc, [`* .${key}`]: val }), {})
);
export interface WrapperProps {
bordered?: boolean;
padded?: boolean;
}
const Wrapper = styled.div(
({ theme }) => ({
position: 'relative',
import jsx from 'react-syntax-highlighter/dist/esm/languages/prism/jsx';
import bash from 'react-syntax-highlighter/dist/esm/languages/prism/bash';
import css from 'react-syntax-highlighter/dist/esm/languages/prism/css';
import html from 'react-syntax-highlighter/dist/esm/languages/prism/markup';
import { PrismLight as ReactSyntaxHighlighter } from 'react-syntax-highlighter';
import { ActionBar } from '../ActionBar/ActionBar';
import { ScrollArea } from '../ScrollArea/ScrollArea';
import { formatter } from './formatter';
ReactSyntaxHighlighter.registerLanguage('jsx', jsx);
ReactSyntaxHighlighter.registerLanguage('bash', bash);
ReactSyntaxHighlighter.registerLanguage('css', css);
ReactSyntaxHighlighter.registerLanguage('html', html);
const themedSyntax = memoize(2)(theme =>
Object.entries(theme.code || {}).reduce((acc, [key, val]) => ({ ...acc, [`* .${key}`]: val }), {})
);
export interface WrapperProps {
bordered?: boolean;
padded?: boolean;
}
const Wrapper = styled.div(
({ theme }) => ({
position: 'relative',
overflow: 'hidden',
color: theme.color.defaultText,
}),
import memoize from 'memoizerific';
import jsx from 'react-syntax-highlighter/dist/esm/languages/prism/jsx';
import bash from 'react-syntax-highlighter/dist/esm/languages/prism/bash';
import css from 'react-syntax-highlighter/dist/esm/languages/prism/css';
import html from 'react-syntax-highlighter/dist/esm/languages/prism/markup';
import { PrismLight as ReactSyntaxHighlighter } from 'react-syntax-highlighter';
import { ActionBar } from '../ActionBar/ActionBar';
import { ScrollArea } from '../ScrollArea/ScrollArea';
import { formatter } from './formatter';
ReactSyntaxHighlighter.registerLanguage('jsx', jsx);
ReactSyntaxHighlighter.registerLanguage('bash', bash);
ReactSyntaxHighlighter.registerLanguage('css', css);
ReactSyntaxHighlighter.registerLanguage('html', html);
const themedSyntax = memoize(2)(theme =>
Object.entries(theme.code || {}).reduce((acc, [key, val]) => ({ ...acc, [`* .${key}`]: val }), {})
);
export interface WrapperProps {
bordered?: boolean;
padded?: boolean;
}
const Wrapper = styled.div(
({ theme }) => ({
position: 'relative',
overflow: 'hidden',
import React from 'react'
import { PrismLight } from 'react-syntax-highlighter'
import jsx from 'react-syntax-highlighter/dist/cjs/languages/prism/jsx'
import theme from 'react-syntax-highlighter/dist/cjs/styles/prism/tomorrow'
PrismLight.registerLanguage('javascript', jsx)
export default function SyntaxHighlighter({ code }) {
return (
{code}
)
}