通用评论

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. "use strict";
  2. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  3. var _react = require("react");
  4. var _react2 = _interopRequireDefault(_react);
  5. var _reactDom = require("react-dom");
  6. var _reactDom2 = _interopRequireDefault(_reactDom);
  7. var _App = require("./App");
  8. var _App2 = _interopRequireDefault(_App);
  9. var _registerServiceWorker = require("./registerServiceWorker");
  10. var _registerServiceWorker2 = _interopRequireDefault(_registerServiceWorker);
  11. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12. var Index = function Index(props) {
  13. return _react2.default.createElement(
  14. _App2.default,
  15. _extends({ showAlertComment: true, showAlertReply: true, showAlertFavor: true, showError: true }, props),
  16. _react2.default.createElement(_App.Editor, { maxUpload: 9, autoFocus: true })
  17. );
  18. };
  19. /**
  20. * 渲染评论组件
  21. * @param {object} config 编辑器配置
  22. * - {string} id 渲染评论的DOM的 ID
  23. * - {number} type 评论的 type
  24. * - {string} businessId 评论的 businessId
  25. */
  26. function renderComment(config) {
  27. if (!config.id) {
  28. throw new Error("id is required");
  29. }
  30. if (!config.id) {
  31. throw new Error("type is required");
  32. }
  33. if (!config.id) {
  34. throw new Error("businessId is required");
  35. }
  36. var id = config.id,
  37. _config$type = config.type,
  38. type = _config$type === undefined ? 1 : _config$type,
  39. _config$businessId = config.businessId,
  40. businessId = _config$businessId === undefined ? "test" : _config$businessId,
  41. userId = config.userId;
  42. _reactDom2.default.render(_react2.default.createElement(Index, { type: type, businessId: businessId, userId: userId }), document.getElementById(id));
  43. // registerServiceWorker();
  44. }
  45. window.renderComment = renderComment;
  46. // renderComment({
  47. // id: "root-comment",
  48. // type: 1,
  49. // businessId: "test"
  50. // });
  51. //# sourceMappingURL=index.js.map