UNPKG

kf-slate-editor

Version:

Another rich text editor using Slate framework with toolbar support

58 lines (42 loc) 2.95 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Window = function (_React$Component) { _inherits(Window, _React$Component); function Window(props) { _classCallCheck(this, Window); var _this = _possibleConstructorReturn(this, (Window.__proto__ || Object.getPrototypeOf(Window)).call(this, props)); _this.container = _react2.default.createRef(); return _this; } _createClass(Window, [{ key: 'componentWillReceiveProps', value: function componentWillReceiveProps(next) {} }, { key: 'componentDidMount', value: function componentDidMount() { this.container.current.appendChild(this.props.window.canvas); } }, { key: 'render', value: function render() { var _props$window = this.props.window, x = _props$window.x, y = _props$window.y, width = _props$window.width, height = _props$window.height, show = _props$window.show; return _react2.default.createElement('div', { ref: this.container, 'x-wid': this.props.window.wid, style: { display: show ? 'block' : 'none', position: 'absolute', left: x + 'px', top: y + 'px', width: width + 'px', height: height + 'px' } }); } }]); return Window; }(_react2.default.Component); exports.default = Window;