通用评论

index.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. _reactDom2.default.render(_react2.default.createElement(Index, { type: type, businessId: businessId }), document.getElementById(id));
  42. // registerServiceWorker();
  43. }
  44. window.renderComment = renderComment;
  45. // renderComment({
  46. // id: "root-comment",
  47. // type: 1,
  48. // businessId: "test"
  49. // });
  50. //# sourceMappingURL=index.js.map