通用评论

index.js.map 3.1KB

1
  1. {"version":3,"sources":["../src/index.js"],"names":["Index","props","editorProps","renderComment","config","id","Error","type","businessId","console","warn","API","ReactDOM","render","document","getElementById","window","businessUserId","userId","onCountChange","c","log"],"mappings":";;;;AAAA;;;;AACA;;;;AACA;;;;;;AACA;;AAEA,IAAMA,QAAQ,SAARA,KAAQ;AAAA,SACZ;AAAC,iBAAD;AAAA,eAAK,sBAAL,EAAsB,oBAAtB,EAAqC,oBAArC,EAAoD,eAApD,IAAkEC,KAAlE;AACE,kCAAC,WAAD,aAAQ,WAAW,CAAnB,EAAsB,eAAtB,IAAoCA,MAAMC,WAA1C;AADF,GADY;AAAA,CAAd;;AAMA;;;;;;;;AAQA,SAASC,aAAT,CAAuBC,MAAvB,EAA+B;AAC7B,MAAI,CAACA,OAAOC,EAAZ,EAAgB;AACd,UAAM,IAAIC,KAAJ,CAAU,gBAAV,CAAN;AACD;AACD,MAAI,CAACF,OAAOG,IAAZ,EAAkB;AAChB,UAAM,IAAID,KAAJ,CAAU,kBAAV,CAAN;AACD;AACD,MAAI,CAACF,OAAOI,UAAZ,EAAwB;AACtB;AACAJ,WAAOI,UAAP,GAAoB,MAApB;AACAC,YAAQC,IAAR,CAAa,+BAAb;AACD;AACD,MAAI,CAACN,OAAOO,GAAZ,EAAiB;AACf;AACAP,WAAOO,GAAP,GAAa,oCAAb;AACAF,YAAQC,IAAR,CACE,sDADF;AAGD;;AAEDE,qBAASC,MAAT,CAAgB,8BAAC,KAAD,EAAWT,MAAX,CAAhB,EAAuCU,SAASC,cAAT,CAAwBX,OAAOC,EAA/B,CAAvC;AACA;AACD;;AAEDW,OAAOb,aAAP,GAAuBA,aAAvB;;AAEAA,cAAc;AACZE,MAAI,cADQ;AAEZE,QAAM,CAFM;AAGZC,cAAY,MAHA;AAIZS,kBAAgB,CAJJ;AAKZC,UAAQ,KALI;AAMZC,iBAAe,uBAACC,CAAD,EAAO;AAAEX,YAAQY,GAAR,CAAYD,CAAZ;AAAgB;AAN5B,CAAd;;AASA;AACA;AACA;AACA;AACA;AACA","file":"index.js","sourcesContent":["import React from \"react\";\r\nimport ReactDOM from \"react-dom\";\r\nimport App, { Editor } from \"./App\";\r\n// import registerServiceWorker from \"./registerServiceWorker\";\r\n\r\nconst Index = props => (\r\n <App showAlertComment showAlertReply showAlertFavor showError {...props}>\r\n <Editor maxUpload={9} autoFocus {...props.editorProps} />\r\n </App>\r\n);\r\n\r\n/**\r\n * 渲染评论组件\r\n * @param {object} config 编辑器配置\r\n * - {string} id 渲染评论的DOM的 ID\r\n * - {number} type 评论的 type\r\n * - {string} businessId 评论的 businessId\r\n * - {string} API, API 前缀, 默认 http://api.links123.net/comment/v1\r\n */\r\nfunction renderComment(config) {\r\n if (!config.id) {\r\n throw new Error(\"id is required\");\r\n }\r\n if (!config.type) {\r\n throw new Error(\"type is required\");\r\n }\r\n if (!config.businessId) {\r\n // throw new Error(\"businessId is required\");\r\n config.businessId = \"test\";\r\n console.warn(\"没有传入 businessId 参数,默认使用: test\");\r\n }\r\n if (!config.API) {\r\n // throw new Error(\"API is required\");\r\n config.API = \"http://api.links123.net/comment/v1\";\r\n console.warn(\r\n \"没有传入 API 参数,默认使用: http://api.links123.net/comment/v1\"\r\n );\r\n }\r\n\r\n ReactDOM.render(<Index {...config} />, document.getElementById(config.id));\r\n // registerServiceWorker();\r\n}\r\n\r\nwindow.renderComment = renderComment;\r\n\r\nrenderComment({\r\n id: \"root-comment\",\r\n type: 1,\r\n businessId: \"test\",\r\n businessUserId: 4,\r\n userId: 71299,\r\n onCountChange: (c) => { console.log(c) }\r\n});\r\n\r\n// renderComment({\r\n// id: \"root-comment\",\r\n// type: 1,\r\n// businessId: \"test\",\r\n// API: 'http://api.links123.net/comment/v1',\r\n// });\r\n"]}