File tree Expand file tree Collapse file tree 3 files changed +86
-1
lines changed
Expand file tree Collapse file tree 3 files changed +86
-1
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "name" : " @bytemd/react" ,
3+ "version" : " 0.0.1" ,
4+ "description" : " Full-featured markdown editor and viewer" ,
5+ "main" : " dist/bytemd-react.cjs.js" ,
6+ "module" : " dist/bytemd-react.esm.js" ,
7+ "keywords" : [],
8+ "files" : [
9+ " dist"
10+ ],
11+ "author" : " Rongjian Zhang <pd4d10@gmail.com>" ,
12+ "license" : " MIT" ,
13+ "dependencies" : {
14+ "@bytemd/core" : " 0.0.1"
15+ },
16+ "devDependencies" : {
17+ "@types/react" : " ^16.9.23" ,
18+ "react" : " ^16.13.0"
19+ },
20+ "peerDependencies" : {
21+ "react" : " ^16.0.0"
22+ }
23+ }
Original file line number Diff line number Diff line change 1+ import { createElement , Component } from 'react' ;
2+ import * as bytemd from '@bytemd/core' ;
3+
4+ export class Viewer extends Component {
5+ constructor ( ) {
6+ this . container = null ;
7+ this . setContainer = e => {
8+ this . container = e ;
9+ } ;
10+ }
11+ componentDidMount ( ) {
12+ new bytemd . Viewer ( {
13+ target : this . container ,
14+ props : this . props
15+ } ) ;
16+ }
17+ render ( ) {
18+ return createElement ( 'div' , {
19+ ref : this . setContainer
20+ } ) ;
21+ }
22+ }
23+
24+ export class Editor extends Component {
25+ constructor ( ) {
26+ this . container = null ;
27+ this . setContainer = e => {
28+ this . container = e ;
29+ } ;
30+ }
31+ componentDidMount ( ) {
32+ new bytemd . Editor ( {
33+ target : this . container ,
34+ props : this . props
35+ } ) ;
36+ }
37+ render ( ) {
38+ return createElement ( 'div' , {
39+ ref : this . setContainer
40+ } ) ;
41+ }
42+ }
Original file line number Diff line number Diff line change @@ -93,4 +93,24 @@ const core = {
9393 }
9494} ;
9595
96- export default [ core ] ;
96+ const reactPkg = require ( './packages/react/package.json' ) ;
97+
98+ /** @type {import('rollup').RollupOptions } */
99+ const react = {
100+ input : 'packages/react/src/index.js' ,
101+ output : [
102+ {
103+ ...outputConfig ,
104+ format : 'es' ,
105+ file : 'packages/react/' + reactPkg . module
106+ } ,
107+ {
108+ ...outputConfig ,
109+ format : 'cjs' ,
110+ file : 'packages/react/' + reactPkg . main
111+ }
112+ ] ,
113+ plugins : [ production && terser ( ) ]
114+ } ;
115+
116+ export default [ core , react ] ;
You can’t perform that action at this time.
0 commit comments