UNPKG

tfp

Version:

A Web UI framework for TaskBuilder

107 lines (87 loc) 3.89 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); var _controller = require("../controller.js"); function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** * 富文本组件 * @param {[type]} dataModel [description] */ var RichText = /*#__PURE__*/function (_FormInput) { (0, _inherits2["default"])(RichText, _FormInput); var _super = _createSuper(RichText); function RichText(__tfp, dataModel, parent) { (0, _classCallCheck2["default"])(this, RichText); return _super.call(this, __tfp, "RichText", dataModel, parent); } //属性 (0, _createClass2["default"])(RichText, [{ key: "value", get: function get() { if (!this._tfp.isDesigning && this.editor) this.dataModel.value = this.editor.html(); if (!this.dataModel.value) return ""; return this.dataModel.value; }, set: function set(value) { this.dataModel.value = value; if (this._jqObj && !this._tfp.isDesigning) { this.editor.html(value); } if (!this._tfp.isDesigning) { this.valueOnChange(); this.exeEventHandler("onChange", value); } } }, { key: "dataBindingFormat", get: function get() { return this.dataModel.dataBindingFormat; }, set: function set(value) { this.dataModel.dataBindingFormat = value; } }, { key: "initRuntime", value: function initRuntime() { var that = this; var uploadUrl = "/Upload?appCode=KindEditor"; try { if (top.taskMsgAuthObj) uploadUrl = tfp.setUrlAuthData(uploadUrl); } catch (err) { try { if (window.parent.taskMsgAuthObj) uploadUrl = tfp.setUrlAuthData(uploadUrl); } catch (err2) {// } } var options = { allowImageUpload: true, allowFlashUpload: false, allowMediaUpload: false, designMode: true, allowFileManager: false, uploadJson: uploadUrl, resizeType: 0, width: this._jqObj.width() + "px", height: this._jqObj.height() + "px", afterBlur: function afterBlur() { that.dataModel.value = that.editor.html(); that.valueOnChange(); that.exeEventHandler("onChange", that.dataModel.value); } }; this.editor = KindEditor.create("#" + this.id + "_textarea", options); this.css("border", "0"); if (this.value) this.editor.html(this.value); } }]); return RichText; }(_controller.FormInput); exports["default"] = RichText;