"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var types_1 = require("oak-domain/lib/types"); exports.default = OakComponent({ entity: 'article', projection: { id: 1, iState: 1, title: 1, author: 1, abstract: 1, content: 1, }, isList: false, formData: function (_a) { var article = _a.data, features = _a.features; return tslib_1.__awaiter(this, void 0, void 0, function () { return tslib_1.__generator(this, function (_b) { return [2 /*return*/, { id: article === null || article === void 0 ? void 0 : article.id, iState: article === null || article === void 0 ? void 0 : article.iState, title: article === null || article === void 0 ? void 0 : article.title, abstract: article === null || article === void 0 ? void 0 : article.abstract, author: article === null || article === void 0 ? void 0 : article.author, content: article === null || article === void 0 ? void 0 : article.content, }]; }); }); }, data: { editor: null, html: '', origin: 'qiniu', contentTip: false, }, observers: { 'editor,content': function (editor, content) { if (editor && content) { editor.setHtml(content); this.setHtml(content); } }, }, lifetimes: { detached: function () { var editor = this.state.editor; if (editor == null) return; editor.destroy(); this.setEditor(null); } }, methods: { addExtraFile: function (extraFile) { return tslib_1.__awaiter(this, void 0, void 0, function () { var result, _a, _b, _c, error_1; var _d; return tslib_1.__generator(this, function (_e) { switch (_e.label) { case 0: _e.trys.push([0, 3, , 4]); _b = (_a = this.features.cache).operate; _c = ['extraFile']; _d = { action: 'create', data: extraFile }; return [4 /*yield*/, generateNewId()]; case 1: return [4 /*yield*/, _b.apply(_a, _c.concat([(_d.id = _e.sent(), _d)]))]; case 2: result = _e.sent(); return [2 /*return*/, result]; case 3: error_1 = _e.sent(); if (error_1.constructor.name === types_1.OakUnloggedInException.name) { this.navigateTo({ url: '/login', }); return [2 /*return*/]; } throw error_1; case 4: return [2 /*return*/]; } }); }); }, setEditor: function (editor) { this.setState({ editor: editor, }); }, setHtml: function (html) { return tslib_1.__awaiter(this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: this.setState({ html: html, }); if (!(html && html !== '