Text.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _react = _interopRequireDefault(require("react"));
  7. var _Module2 = _interopRequireDefault(require("../Module"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  10. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  11. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  12. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  14. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  16. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  17. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  18. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  19. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  20. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  21. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  22. var Text =
  23. /*#__PURE__*/
  24. function (_Module) {
  25. _inherits(Text, _Module);
  26. function Text(props) {
  27. var _this;
  28. _classCallCheck(this, Text);
  29. _this = _possibleConstructorReturn(this, _getPrototypeOf(Text).call(this, props));
  30. _this.state = {
  31. edit: false
  32. };
  33. _this.input.onUpdate(function (e) {
  34. return _this.forceUpdate();
  35. });
  36. return _this;
  37. }
  38. _createClass(Text, [{
  39. key: "edit",
  40. value: function edit() {
  41. if (this._mode === "normal" || this._mode === "admin") {
  42. this.setState({
  43. edit: true
  44. });
  45. }
  46. }
  47. }, {
  48. key: "change",
  49. value: function change(value) {
  50. this._change('text', value, this.text);
  51. this.setState({
  52. edit: false
  53. });
  54. }
  55. }, {
  56. key: "render",
  57. value: function render() {
  58. var _this2 = this;
  59. console.log("TEXT", this.text.value);
  60. return this.state.edit ? _react.default.createElement("div", _defineProperty({
  61. style: _objectSpread({}, this.props.style),
  62. className: this.props.className + " Text"
  63. }, "style", {
  64. fontSize: parseInt(this.size.value),
  65. color: this.color.value
  66. }), _react.default.createElement("textarea", {
  67. onBlur: function onBlur(e) {
  68. return _this2.change(e.target.value);
  69. },
  70. defaultValue: this.text.value
  71. }), _get(_getPrototypeOf(Text.prototype), "render", this).call(this)) : _react.default.createElement("div", _defineProperty({
  72. onClick: function onClick() {
  73. return _this2.edit();
  74. },
  75. style: _objectSpread({}, this.props.style),
  76. className: this.props.className + " Text"
  77. }, "style", {
  78. fontFamily: this.family.value,
  79. fontSize: parseInt(this.size.value),
  80. color: this.color.value
  81. }), this.input.value, this.text.value, _get(_getPrototypeOf(Text.prototype), "render", this).call(this));
  82. }
  83. }]);
  84. return Text;
  85. }(_Module2.default);
  86. Text.Inputs = {
  87. text: {
  88. type: _Module2.default.Types.Text,
  89. defaultValue: "DefaultText"
  90. },
  91. size: {
  92. type: _Module2.default.Types.Number,
  93. defaultValue: "14"
  94. },
  95. family: {
  96. type: _Module2.default.Types.Text,
  97. defaultValue: "Arial"
  98. },
  99. color: {
  100. type: _Module2.default.Types.Text,
  101. defaultValue: "black"
  102. },
  103. input: {
  104. type: _Module2.default.Types.Link
  105. }
  106. };
  107. Text.Category = "Basic";
  108. var _default = Text;
  109. exports.default = _default;