Skip to content

Releases: simonguo/react-code-view

2.4.0

18 Feb 09:29

Choose a tag to compare

What's Changed

Full Changelog: 2.3.1...2.4.0

2.3.0

26 Jan 07:26

Choose a tag to compare

What's Changed

  • feat: add support for one-click copy code by @simonguo in #53

image

Full Changelog: 2.2.1...2.3.0

2.2.1

10 Oct 05:57

Choose a tag to compare

What's Changed

  • fix(CodeEditor): fix Codemirror being initialized twice by @simonguo in #40

Full Changelog: 2.2.0...2.2.1

2.2.0

10 Oct 05:57

Choose a tag to compare

What's Changed

  • improve(transform): use sucrase instead of @swc/wasm-web to improve t… by @simonguo in #38
  • fix(Renderer): fix timely re-renders by @simonguo in #39

Full Changelog: 2.1.0...2.2.0

2.1.0

10 Oct 05:57

Choose a tag to compare

What's Changed

Full Changelog: 2.0.0...2.1.0

v2.0.0

07 Jul 04:11

Choose a tag to compare

Features

Use @swc/wasm-web instead of babel to compile code in the browser.

Importing babel.min.js on the page will no longer be required. How it is used in v1 (legacy)

Refactored webpack loader for markdown.

Webpack Configuration Guide https://github.com/simonguo/react-code-view#configure-webpack

// v1exportdefault{module: {rules: [{test: /\.md$/,use: [{loader: 'html-loader'},{loader: 'markdown-loader',options: {renderer: markdownRenderer()}}]}]}};// v2exportdefault{module: {rules: [{test: /\.md$/,use:[loader: 'react-code-view/webpack-md-loader',options:{parseLanguages: ['typescript','rust']}]}]}};

Props redefined

v1

NameTypeDefault valueDescription
babelTransformOptionsObject{presets: ['stage-0', 'react', 'es2015'] }Babel configuration parameters [options][babeljs]
dependenciesObjectDependent components.
renderToolbarFunctionCustom toolbar.
showCodebooleantrueDisplay code.
themestring'light'Theme, options light and dark.

v2

NameTypeDefault valueDescription
afterCompile(code: string) => stringExecuted after compiling the code
beforeCompile(code: string) => stringExecuted before compiling the code
childrenanyThe code to be rendered is executed. Usually imported via markdown-loader
compiler(code: string) => stringA compiler that transforms the code. Use swc.transformSync by default
dependenciesobjectDependent objects required by the executed code
editablebooleanfalseRenders a code editor that can modify the source code
editorobjectEditor properties
onChange(code?: string) => voidCallback triggered after code change
renderToolbar(buttons: ReactNode) => ReactNodeCustomize the rendering toolbar
sourceCodestringThe code to be rendered is executed
theme'light' , 'dark''light'Code editor theme, applied to CodeMirror
compileOptionsobjectdefaultTransformOptionsswc configuration https://swc.rs/docs/configuration/compilation