|
1 |
| -# 1.2.6 |
| 1 | +# 2.0.0 |
2 | 2 |
|
3 |
| -- Replace with svg icon |
| 3 | +## Features |
4 | 4 |
|
5 |
| -# 1.2.2 |
| 5 | +### Use @swc/wasm-web instead of babel to compile code in the browser. |
6 | 6 |
|
7 |
| -- Fixed component not rendering when the code property value was updated. |
| 7 | +Importing `babel.min.js` on the page will no longer be required. [How it is used in v1](https://github.com/simonguo/react-code-view/blob/1.2.6/README.md#add-babel) |
8 | 8 |
|
9 |
| -# 1.2.0 |
| 9 | +### Refactored webpack loader for markdown. |
10 | 10 |
|
11 |
| -- Update dependencies |
12 |
| - |
13 |
| - |
| 11 | +```js |
| 12 | + |
| 13 | +// v1 |
| 14 | + |
| 15 | +export default { |
| 16 | + module: { |
| 17 | + rules: [ |
| 18 | + { |
| 19 | + test: /\.md$/, |
| 20 | + use: [{ |
| 21 | + loader: 'html-loader' |
| 22 | + }, { |
| 23 | + loader: 'markdown-loader', |
| 24 | + options: { |
| 25 | + renderer: markdownRenderer() |
| 26 | + } |
| 27 | + }] |
| 28 | + } |
| 29 | + ] |
| 30 | + |
| 31 | + } |
| 32 | +}; |
| 33 | + |
| 34 | +// v2 |
| 35 | +export default { |
| 36 | + module: { |
| 37 | + rules: [ |
| 38 | + { |
| 39 | + test: /\.md$/, |
| 40 | + use:[ |
| 41 | + loader: 'react-code-view/webpack-md-loader', |
| 42 | + options:{ |
| 43 | + parseLanguages: ['typescript','rust'] |
| 44 | + } |
| 45 | + ] |
| 46 | + } |
| 47 | + ] |
| 48 | + } |
| 49 | +}; |
| 50 | +``` |
| 51 | + |
| 52 | +### Props redefined |
| 53 | + |
| 54 | +**v1** |
| 55 | + |
| 56 | +| Name | Type | Default value | Description | |
| 57 | +| --------------------- | -------- | ------------------------------------------- | ------------------------------------------------- | |
| 58 | +| babelTransformOptions | Object | { presets: ['stage-0', 'react', 'es2015'] } | Babel configuration parameters [options][babeljs] | |
| 59 | +| dependencies | Object | | Dependent components. | |
| 60 | +| renderToolbar | Function | | Custom toolbar. | |
| 61 | +| showCode | boolean | true | Display code. | |
| 62 | +| theme | string | 'light' | Theme, options `light` and `dark`. | |
| 63 | + |
| 64 | +**v2** |
| 65 | + |
| 66 | +| Name | Type | Default value | Description | |
| 67 | +| -------------- | --------------------------------- | ----------------------- | ------------------------------------------------------------------------- | |
| 68 | +| afterCompile | (code: string) => string | | Executed after compiling the code | |
| 69 | +| beforeCompile | (code: string) => string | | Executed before compiling the code | |
| 70 | +| children | any | | The code to be rendered is executed. Usually imported via markdown-loader | |
| 71 | +| compiler | (code: string) => string | | A compiler that transforms the code. Use swc.transformSync by default | |
| 72 | +| dependencies | object | | Dependent objects required by the executed code | |
| 73 | +| editable | boolean | false | Renders a code editor that can modify the source code | |
| 74 | +| editor | object | | Editor properties | |
| 75 | +| onChange | (code?: string) => void | | Callback triggered after code change | |
| 76 | +| renderToolbar | (buttons: ReactNode) => ReactNode | | Customize the rendering toolbar | |
| 77 | +| sourceCode | string | | The code to be rendered is executed | |
| 78 | +| theme | 'light' , 'dark' | 'light' | Code editor theme, applied to CodeMirror | |
| 79 | +| compileOptions | object | defaultTransformOptions | swc configuration https://swc.rs/docs/configuration/compilation | |
0 commit comments