"use strict";
(self["webpackChunk"] = self["webpackChunk"] || []).push([[52806,10014],{
/***/ 56672:
/*!*********************************!*\
!*** ./src/pages/tasks/util.js ***!
\*********************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ Ax: function() { return /* binding */ processTreeData; },
/* harmony export */ Ds: function() { return /* binding */ debounce; },
/* harmony export */ KI: function() { return /* binding */ apiPref; },
/* harmony export */ SI: function() { return /* binding */ getTreeData; },
/* harmony export */ f1: function() { return /* binding */ isCompileOk; }
/* harmony export */ });
/* unused harmony export isProd */
/* harmony import */ var _utils_env__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/utils/env */ 47015);
function isCompileOk(rs) {
var flag = true;
if (rs.length > 0) {
for (var i = 0; i < rs.length; i++) {
if (rs[i].compile_success == 0 || !rs[i].compile_success) {
flag = false;
break;
}
}
} else {
flag = false;
}
return flag;
}
function getTreeData(data) {
var parentKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var result = [];
for (var i = 0; i < data.length; i++) {
var item = data[i];
var key = parentKey ? "".concat(parentKey, "/").concat(item.name) : "".concat(item.name);
result.push({
title: item.name,
isLeaf: item.type === 'tree' ? false : true,
key: key
});
}
return result;
}
function processTreeData(repos, key, newData) {
for (var i = 0; i < repos.length; i++) {
var item = repos[i];
if (item.key === key) {
item.children = newData;
break;
}
if (item.children) {
processTreeData(item.children, key, newData);
}
}
return repos;
}
function debounce(func, wait, immediate) {
var timeout;
return function () {
var context = this,
args = arguments;
var later = function later() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
}
var isProd = true;
var apiPref = _utils_env__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z.API_SERVER;
// export const isProd =
// window.location.href.indexOf('test-') > 0 ||
// window.location.href.indexOf('localhost') > 0
// ? false
// : true;
// export const apiPref = isProd
// ? 'https://www.educoder.net'
// : 'https://test-newweb.educoder.net';
/***/ }),
/***/ 5886:
/*!*********************************************************************!*\
!*** ./src/components/Editor/NullChildEditor/index.jsx + 1 modules ***!
\*********************************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
Z: function() { return /* binding */ Editor_NullChildEditor; }
});
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/classCallCheck.js
var classCallCheck = __webpack_require__(94312);
var classCallCheck_default = /*#__PURE__*/__webpack_require__.n(classCallCheck);
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/createClass.js
var createClass = __webpack_require__(24127);
var createClass_default = /*#__PURE__*/__webpack_require__.n(createClass);
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/inherits.js
var inherits = __webpack_require__(93242);
var inherits_default = /*#__PURE__*/__webpack_require__.n(inherits);
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/createSuper.js
var createSuper = __webpack_require__(10564);
var createSuper_default = /*#__PURE__*/__webpack_require__.n(createSuper);
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
var _react_17_0_2_react = __webpack_require__(59301);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/input/index.js + 5 modules
var input = __webpack_require__(1056);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/tag/index.js + 5 modules
var es_tag = __webpack_require__(12563);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/message/index.js + 4 modules
var message = __webpack_require__(8591);
;// CONCATENATED MODULE: ./src/components/Editor/NullChildEditor/index.less?modules
// extracted by mini-css-extract-plugin
/* harmony default export */ var NullChildEditormodules = ({"flex":"flex___eLcnP","flex1":"flex1___yUTT7","color666":"color666___TiUhG","error":"error___gTTtv","deleteIcon":"deleteIcon___mnZW1","addIcon":"addIcon___JC5NS"});
// EXTERNAL MODULE: ./node_modules/_@ant-design_icons@5.2.6@@ant-design/icons/es/icons/PlusOutlined.js + 1 modules
var PlusOutlined = __webpack_require__(378);
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/jsx-runtime.js
var jsx_runtime = __webpack_require__(37712);
;// CONCATENATED MODULE: ./src/components/Editor/NullChildEditor/index.jsx
var TextArea = input/* default */.Z.TextArea;
var NullChildEditor = /*#__PURE__*/function (_Component) {
inherits_default()(NullChildEditor, _Component);
var _super = createSuper_default()(NullChildEditor);
function NullChildEditor(props) {
var _this;
classCallCheck_default()(this, NullChildEditor);
_this = _super.call(this, props);
_this.state = {
inputVisible: false,
EditInputIndex: -1
};
return _this;
}
// componentDidMount() {
// // console.log(`${this.props.index}----`,this.props,e);
// if (this.props.answers[0].length <= 0) {
// this.setState({
// EditInputIndex: 0,
// });
// }
// }
createClass_default()(NullChildEditor, [{
key: "render",
value: function render() {
var _this2 = this;
var _this$props = this.props,
index = _this$props.index,
onAnswerChange = _this$props.onAnswerChange,
addChildAnswer = _this$props.addChildAnswer,
exerciseIsPublish = _this$props.exerciseIsPublish,
answers = _this$props.answers,
activeOptionErrorIndex = _this$props.activeOptionErrorIndex,
_this$props$flex = _this$props.flex,
flex = _this$props$flex === void 0 ? '0 0 1000px' : _this$props$flex;
console.log('----', answers);
var _this$state = this.state,
inputVisible = _this$state.inputVisible,
EditInputIndex = _this$state.EditInputIndex;
return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: NullChildEditormodules.flex,
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: "".concat(NullChildEditormodules.color666, " mb5 mt6"),
style: {
flex: '0 0 90px'
},
children: ["\u7B54\u6848(\u586B\u7A7A", index + 1, "):"]
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
style: {
border: '1px solid #f6f6f6',
flex: 1,
padding: 10
},
children: [answers === null || answers === void 0 ? void 0 : answers.map(function (tag, itemIndex) {
return /*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment, {
children: EditInputIndex !== itemIndex ? (tag === null || tag === void 0 ? void 0 : tag.length) > 0 ? /*#__PURE__*/(0,jsx_runtime.jsx)(es_tag/* default */.Z, {
className: "edit-tag",
closable: true,
onClose: function onClose(e) {
e.preventDefault();
if ((answers === null || answers === void 0 ? void 0 : answers.length) === 1 && itemIndex === 0) {
_this2.props.deleteChildAnswermain(index, itemIndex);
} else {
_this2.props.deleteChildAnswer(index, itemIndex);
}
},
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
onDoubleClick: function onDoubleClick(e) {
_this2.setState({
EditInputIndex: itemIndex
});
e.preventDefault();
},
children: tag
})
}, tag) : /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, {
defaultValue: tag,
style: {
width: 78,
marginRight: 8,
height: 24,
verticalAlign: 'top'
},
onBlur: function onBlur(e) {
if (e.target.value.replaceAll(' ', '').length <= 0) {
message/* default */.ZP.info('内容不能为纯空格');
return;
}
onAnswerChange(index, itemIndex, e.target.value);
_this2.setState({
EditInputIndex: -1,
inputVisible: false
});
}
}) : /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, {
defaultValue: tag,
style: {
width: 78,
marginRight: 8,
height: 24,
verticalAlign: 'top'
},
onBlur: function onBlur(e) {
if (e.target.value.replaceAll(' ', '').length <= 0) {
message/* default */.ZP.info('内容不能为纯空格');
return;
}
onAnswerChange(index, itemIndex, e.target.value);
_this2.setState({
EditInputIndex: -1,
inputVisible: false
});
}
})
});
}), !inputVisible && /*#__PURE__*/(0,jsx_runtime.jsxs)(es_tag/* default */.Z, {
className: "site-tag-plus",
onClick: function onClick() {
addChildAnswer(index);
// console.log(this.props.index);
_this2.setState({
inputVisible: true
});
},
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(PlusOutlined/* default */.Z, {}), " \u65B0\u589E\u7B54\u6848"]
})]
})]
});
}
}]);
return NullChildEditor;
}(_react_17_0_2_react.Component);
/* harmony default export */ var Editor_NullChildEditor = (NullChildEditor);
/***/ }),
/***/ 92147:
/*!************************************************!*\
!*** ./src/components/Editor/NullMDEditor.jsx ***!
\************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ Z: function() { return /* binding */ NullMDEditor; }
/* harmony export */ });
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectSpread2.js */ 26801);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_classCallCheck_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/classCallCheck.js */ 94312);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_classCallCheck_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_classCallCheck_js__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createClass_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/createClass.js */ 24127);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createClass_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createClass_js__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_assertThisInitialized_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/assertThisInitialized.js */ 1300);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_assertThisInitialized_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_assertThisInitialized_js__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_inherits_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/inherits.js */ 93242);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_inherits_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_inherits_js__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createSuper_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/createSuper.js */ 10564);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createSuper_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createSuper_js__WEBPACK_IMPORTED_MODULE_5__);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_defineProperty_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/defineProperty.js */ 22060);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_defineProperty_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_defineProperty_js__WEBPACK_IMPORTED_MODULE_6__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react */ 59301);
/* harmony import */ var _markdown_editor__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../markdown-editor */ 20755);
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! react/jsx-runtime */ 37712);
var NULL_CH = '▁';
var NullMDEditor = /*#__PURE__*/function (_Component) {
_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_inherits_js__WEBPACK_IMPORTED_MODULE_4___default()(NullMDEditor, _Component);
var _super = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createSuper_js__WEBPACK_IMPORTED_MODULE_5___default()(NullMDEditor);
function NullMDEditor() {
var _this;
_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_classCallCheck_js__WEBPACK_IMPORTED_MODULE_1___default()(this, NullMDEditor);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.call.apply(_super, [this].concat(args));
_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_defineProperty_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_assertThisInitialized_js__WEBPACK_IMPORTED_MODULE_3___default()(_this), "getChCountBeforeCursor", function (cm, cursor) {
var currentLine = cursor.line;
var placeholderCountBefore = 0;
for (var _line = 0; _line < currentLine; _line++) {
placeholderCountBefore += cm.getLine(_line).split(NULL_CH).length - 1;
}
var currentLineStringBeforeCursor = cm.getLine(currentLine).substring(0, cursor.ch);
placeholderCountBefore += currentLineStringBeforeCursor.split(NULL_CH).length - 1;
return placeholderCountBefore;
});
_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_defineProperty_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_assertThisInitialized_js__WEBPACK_IMPORTED_MODULE_3___default()(_this), "onCMBeforeChange", function (cm, change) {
var rangeText = cm.getRange(change.from, change.to);
var totalPlaceholderCount = 0;
change.text.forEach(function (item) {
totalPlaceholderCount += item.split(NULL_CH).length - 1;
});
if (rangeText && rangeText.indexOf(NULL_CH) != -1) {
var placeholderCountInRange = rangeText.split(NULL_CH).length - 1;
var placeholderCountBefore = _this.getChCountBeforeCursor(cm, change.from);
console.log("\u5220\u9664".concat(placeholderCountInRange, "\u4E2A\uFF0C \u4E4B\u524D\u6709").concat(placeholderCountBefore, "\u4E2A\uFF0C\u65B0\u589E").concat(totalPlaceholderCount, "\u4E2A"));
if (_this.props.deleteEmptyDisabled) {
// 删除空格不检测
change.cancel();
} else {
// const ret = window.confirm(
// `确认要删除第${
// placeholderCountInRange == 1
// ? placeholderCountBefore + 1
// : `${placeholderCountBefore + 1}-${placeholderCountBefore +
// placeholderCountInRange}`
// }个空吗?`,
// );
// if (ret) {
_this.props.onPlaceholderChange && _this.props.onPlaceholderChange(placeholderCountBefore, placeholderCountInRange, totalPlaceholderCount);
// } else {
// change.cancel();
// }
}
} else if (totalPlaceholderCount) {
var _placeholderCountBefore = _this.getChCountBeforeCursor(cm, change.from);
console.log("\u65B0\u589E".concat(totalPlaceholderCount, "\u4E2A\uFF0C\u4E4B\u524D\u6709").concat(_placeholderCountBefore, "\u4E2A"));
_this.props.onPlaceholderChange && _this.props.onPlaceholderChange(_placeholderCountBefore, 0, totalPlaceholderCount);
}
});
return _this;
}
_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createClass_js__WEBPACK_IMPORTED_MODULE_2___default()(NullMDEditor, [{
key: "render",
value: function render() {
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(_markdown_editor__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z, _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()({}, this.props), {}, {
onCMBeforeChange: this.onCMBeforeChange
}));
}
}]);
return NullMDEditor;
}(react__WEBPACK_IMPORTED_MODULE_7__.Component);
/***/ }),
/***/ 95635:
/*!*************************************************************!*\
!*** ./src/components/markdown-editor/code-block/index.tsx ***!
\*************************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ h: function() { return /* binding */ MyCodeMirror; }
/* harmony export */ });
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectSpread2.js */ 26801);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/slicedToArray.js */ 11006);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ 59301);
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! antd */ 57809);
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! antd */ 78241);
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! antd */ 3113);
/* harmony import */ var codemirror__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! codemirror */ 89780);
/* harmony import */ var codemirror__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(codemirror__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var codemirror_lib_codemirror_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! codemirror/lib/codemirror.css */ 39416);
/* harmony import */ var codemirror_theme_blackboard_css__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! codemirror/theme/blackboard.css */ 23626);
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ 37712);
var Option = antd__WEBPACK_IMPORTED_MODULE_7__["default"].Option;
//https://github.com/codemirror/CodeMirror/issues/4838
var formItemLayout = {
labelCol: {
span: 4
},
wrapperCol: {
span: 20
}
};
var LanguageDesc = {
asp: ['ASP', 'vbscript'],
actionscript: ['ActionScript(3.0)/Flash/Flex', 'clike'],
bash: ['Bash/Bat', 'shell'],
css: ['CSS', 'css'],
c: ['C', 'clike'],
cpp: ['C++', 'clike'],
csharp: ['C#', 'clike'],
coffeescript: ['CoffeeScript', 'coffeescript'],
d: ['D', 'd'],
dart: ['Dart', 'dart'],
delphi: ['Delphi/Pascal', 'pascal'],
erlang: ['Erlang', 'erlang'],
go: ['Golang', 'go'],
groovy: ['Groovy', 'groovy'],
html: ['HTML', 'text/html'],
java: ['Java', 'clike'],
json: ['JSON', 'text/json'],
javascript: ['Javascript', 'javascript'],
lua: ['Lua', 'lua'],
less: ['LESS', 'css'],
markdown: ['Markdown', 'gfm'],
'objective-c': ['Objective-C', 'clike'],
php: ['PHP', 'php'],
perl: ['Perl', 'perl'],
python: ['Python', 'python'],
r: ['R', 'r'],
rst: ['reStructedText', 'rst'],
ruby: ['Ruby', 'ruby'],
sql: ['SQL', 'sql'],
sass: ['SASS/SCSS', 'sass'],
shell: ['Shell', 'shell'],
scala: ['Scala', 'clike'],
swift: ['Swift', 'clike'],
vb: ['VB/VBScript', 'vb'],
xml: ['XML', 'text/xml'],
yaml: ['YAML', 'yaml']
};
/* harmony default export */ __webpack_exports__.Z = (function (_ref) {
var callback = _ref.callback,
onCancel = _ref.onCancel;
var _useState = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)('python'),
_useState2 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_1___default()(_useState, 2),
mode = _useState2[0],
setMode = _useState2[1];
function onSetMode(value) {
setMode(LanguageDesc[value][1]);
}
function onSubmit(values) {
callback(values);
}
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(antd__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z, _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()({}, formItemLayout), {}, {
className: "code-block-panel",
initialValues: {
language: 'python',
content: ''
},
onFinish: onSubmit,
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(antd__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z.Item, {
label: "\u4EE3\u7801\u8BED\u8A00",
name: "language",
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(antd__WEBPACK_IMPORTED_MODULE_7__["default"], {
getPopupContainer: function getPopupContainer(trigger) {
return trigger.parentNode;
},
onChange: onSetMode,
children: Object.keys(LanguageDesc).map(function (item) {
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(Option, {
value: item,
children: LanguageDesc[item][0]
}, item);
})
})
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(antd__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z.Item, {
label: "\u4EE3\u7801\u5185\u5BB9",
name: "content",
rules: [{
required: true,
message: '请输入代码内容'
}],
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(MyCodeMirror, {
mode: mode
})
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)("div", {
className: "flex-container flex-end",
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .ZP, {
type: "primary",
htmlType: "submit",
style: {
marginRight: 10
},
children: "\u786E\u5B9A"
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .ZP, {
type: "ghost",
onClick: onCancel,
children: "\u53D6\u6D88"
})]
})]
}));
});
function MyCodeMirror(_ref2) {
var value = _ref2.value,
onChange = _ref2.onChange,
mode = _ref2.mode,
_ref2$options = _ref2.options,
options = _ref2$options === void 0 ? {} : _ref2$options;
var el = (0,react__WEBPACK_IMPORTED_MODULE_2__.useRef)();
var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)(),
_useState4 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_1___default()(_useState3, 2),
cm = _useState4[0],
setCm = _useState4[1];
(0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(function () {
if (cm) {
var onChangeHandler = function onChangeHandler(cm) {
var content = cm.getValue();
onChange && onChange(content);
};
cm.on('change', onChangeHandler);
return function () {
cm.off('change', onChangeHandler);
};
}
}, [cm, onChange]);
(0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(function () {
if (cm) {
cm.setOption('mode', mode);
}
}, [cm, mode]);
(0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(function () {
if (cm) {
if (value !== cm.getValue() || value === '') {
setTimeout(function () {
cm.setValue(value || '');
}, 300);
}
}
}, [cm, value]);
(0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(function () {
if (el.current && !cm) {
var instance = codemirror__WEBPACK_IMPORTED_MODULE_3___default().fromTextArea(el.current, _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()({
mode: mode,
lineNumbers: true,
lineWrapping: true,
autoCloseBrackets: true,
tabSize: 4,
autofocus: true,
autoCloseTags: true,
matchBrackets: true,
styleActiveLine: true
}, options));
setCm(instance);
}
}, [el.current, cm]);
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("div", {
className: "my-codemirror-container",
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("textarea", {
ref: el
})
});
}
/***/ }),
/***/ 20755:
/*!***************************************************************!*\
!*** ./src/components/markdown-editor/index.tsx + 10 modules ***!
\***************************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
Z: function() { return /* binding */ markdown_editor; }
});
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/createForOfIteratorHelper.js
var createForOfIteratorHelper = __webpack_require__(98190);
var createForOfIteratorHelper_default = /*#__PURE__*/__webpack_require__.n(createForOfIteratorHelper);
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/slicedToArray.js
var slicedToArray = __webpack_require__(11006);
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/defineProperty.js
var defineProperty = __webpack_require__(22060);
var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty);
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
var _react_17_0_2_react = __webpack_require__(59301);
// EXTERNAL MODULE: ./node_modules/_codemirror@5.58.2@codemirror/lib/codemirror.js
var codemirror = __webpack_require__(89780);
var codemirror_default = /*#__PURE__*/__webpack_require__.n(codemirror);
// EXTERNAL MODULE: ./node_modules/_resize-observer-polyfill@1.5.1@resize-observer-polyfill/dist/ResizeObserver.es.js
var ResizeObserver_es = __webpack_require__(76374);
// EXTERNAL MODULE: ./node_modules/_codemirror@5.58.2@codemirror/lib/codemirror.css
var lib_codemirror = __webpack_require__(39416);
// EXTERNAL MODULE: ./node_modules/_codemirror@5.58.2@codemirror/addon/edit/closetag.js
var closetag = __webpack_require__(6313);
// EXTERNAL MODULE: ./node_modules/_codemirror@5.58.2@codemirror/addon/edit/closebrackets.js
var closebrackets = __webpack_require__(25717);
// EXTERNAL MODULE: ./node_modules/_codemirror@5.58.2@codemirror/addon/display/placeholder.js
var placeholder = __webpack_require__(99498);
// EXTERNAL MODULE: ./node_modules/_codemirror@5.58.2@codemirror/mode/markdown/markdown.js
var markdown = __webpack_require__(25419);
// EXTERNAL MODULE: ./node_modules/_codemirror@5.58.2@codemirror/mode/stex/stex.js
var stex = __webpack_require__(67549);
;// CONCATENATED MODULE: ./src/components/markdown-editor/index.less
// extracted by mini-css-extract-plugin
// EXTERNAL MODULE: ./src/components/RenderHtml/index.tsx + 1 modules
var RenderHtml = __webpack_require__(55523);
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/jsx-runtime.js
var jsx_runtime = __webpack_require__(37712);
;// CONCATENATED MODULE: ./src/components/RenderHtml/stex.tsx
// const latexjs = require('latex-l.js/dist/latex.js');
// import "latex-l.js/dist/css/base.css"
/* harmony default export */ var RenderHtml_stex = (function (_ref) {
var _ref$value = _ref.value,
value = _ref$value === void 0 ? '' : _ref$value,
className = _ref.className,
showTextOnly = _ref.showTextOnly,
showLines = _ref.showLines,
_ref$style = _ref.style,
style = _ref$style === void 0 ? {} : _ref$style;
var html = (0,_react_17_0_2_react.useMemo)(function () {
// try {
// const latex = value || 'This is some text';
// let generator = new latexjs.default.HtmlGenerator({ hyphenate: true })
// let doc = latexjs.default.parse(latex, { generator: generator }).htmlDocument()
// return doc.body.innerHTML
// }catch(e){
// console.log("e:",e)
// return "错误的latex语法,请检查"
// }
return "";
}, [value]);
return /*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment, {
children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
dangerouslySetInnerHTML: {
__html: html
}
})
});
});
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectSpread2.js
var objectSpread2 = __webpack_require__(26801);
var objectSpread2_default = /*#__PURE__*/__webpack_require__.n(objectSpread2);
;// CONCATENATED MODULE: ./src/components/markdown-editor/toolbar/index.less
// extracted by mini-css-extract-plugin
;// CONCATENATED MODULE: ./src/components/markdown-editor/css/iconfont.css
// extracted by mini-css-extract-plugin
;// CONCATENATED MODULE: ./src/components/markdown-editor/toolbar/index.tsx
var DEFAULTICONS = [{
title: '粗体',
icon: 'icon-bold',
actionName: 'bold'
}, {
title: '斜体',
icon: 'icon-italic',
actionName: 'italic'
}, '|', {
title: '无序列表',
icon: 'icon-unorder-list',
actionName: 'list-ul'
}, {
title: '有序列表',
icon: 'icon-order-list',
actionName: 'list-ol'
}, '|', {
title: '行内代码',
icon: 'icon-code',
actionName: 'code'
}, {
title: '代码块(多语言风格)',
icon: 'icon-file-code',
actionName: 'code-block'
}, {
title: '链接',
icon: 'icon-link',
actionName: 'link'
}, '|', {
title: '行内公式',
icon: 'icon-sum',
actionName: 'inline-latex'
}, {
title: '多行公式',
icon: 'icon-formula',
actionName: 'latex'
}, '|', {
title: '添加图片',
icon: 'icon-picture',
actionName: 'upload-image'
}, {
title: '表格',
icon: 'icon-table',
actionName: 'add-table'
}, '|', {
title: '换行',
icon: 'icon-minus',
actionName: 'line-break'
}, {
title: '清空',
icon: 'icon-eraser',
actionName: 'eraser'
}];
function AButton(_ref) {
var onActionCallback = _ref.onActionCallback,
title = _ref.title,
icon = _ref.icon,
actionName = _ref.actionName,
_ref$className = _ref.className,
className = _ref$className === void 0 ? '' : _ref$className,
children = _ref.children;
function onAction() {
onActionCallback(actionName);
}
return /*#__PURE__*/(0,jsx_runtime.jsxs)("a", {
title: title,
className: className,
onClick: onAction,
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("i", {
className: "md-iconfont ".concat(icon)
}), children]
});
}
/* harmony default export */ var toolbar = (function (_ref2) {
var watch = _ref2.watch,
showNullButton = _ref2.showNullButton,
showNullProgramButton = _ref2.showNullProgramButton,
onActionCallback = _ref2.onActionCallback,
fullScreen = _ref2.fullScreen,
insertTemp = _ref2.insertTemp,
hidetoolBar = _ref2.hidetoolBar;
var icons = [].concat(DEFAULTICONS, [{
title: "".concat(watch ? '关闭实时预览' : '开启实时预览'),
icon: "".concat(watch ? 'icon-eye-slash' : 'icon-eye'),
actionName: 'trigger-watch'
}]);
return /*#__PURE__*/(0,jsx_runtime.jsxs)("ul", {
className: "markdown-toolbar-container",
children: [!hidetoolBar && icons.map(function (item, index) {
return /*#__PURE__*/(0,jsx_runtime.jsx)("li", {
children: item.actionName ? /*#__PURE__*/(0,jsx_runtime.jsx)(AButton, objectSpread2_default()(objectSpread2_default()({}, item), {}, {
onActionCallback: onActionCallback
})) : /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "v-line"
})
}, index);
}), showNullButton ? /*#__PURE__*/(0,jsx_runtime.jsx)("li", {
children: /*#__PURE__*/(0,jsx_runtime.jsx)(AButton, {
icon: "icon-edit insert-blank",
className: "btn-null",
title: "\u589E\u52A0\u586B\u7A7A",
actionName: "add-null-ch",
onActionCallback: onActionCallback,
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "fill-tip",
children: "\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"
})
})
}) : null, showNullProgramButton ? /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("li", {
children: /*#__PURE__*/(0,jsx_runtime.jsx)(AButton, {
icon: "icon-edit insert-blank",
className: "btn-null",
title: "\u589E\u52A0\u586B\u7A7A",
actionName: "add-signal",
onActionCallback: onActionCallback,
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "fill-tip",
children: "\u6DFB\u52A0\u5355\u884C\u586B\u7A7A\u9879"
})
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)("li", {
children: /*#__PURE__*/(0,jsx_runtime.jsx)(AButton, {
icon: "icon-uniE900 insert-blank",
className: "btn-null",
title: "\u589E\u52A0\u586B\u7A7A",
actionName: "add-multiple",
onActionCallback: onActionCallback,
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "fill-tip",
children: "\u6DFB\u52A0\u591A\u884C\u586B\u7A7A\u9879"
})
})
})]
}) : null, insertTemp && /*#__PURE__*/(0,jsx_runtime.jsx)("li", {
children: /*#__PURE__*/(0,jsx_runtime.jsx)(AButton, {
icon: "icon-edit",
className: "btn-null",
title: "\u63D2\u5165\u6A21\u677F",
actionName: "inster-template-".concat(insertTemp),
onActionCallback: onActionCallback,
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "fill-tip",
children: "\u63D2\u5165\u6A21\u677F"
})
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)("li", {
className: "btn-full-screen",
children: /*#__PURE__*/(0,jsx_runtime.jsx)(AButton, {
icon: "".concat(fullScreen ? 'icon-shrink' : 'icon-enlarge'),
title: fullScreen ? '关闭全屏' : '开启全屏',
actionName: "trigger-full-screen",
onActionCallback: onActionCallback
})
})]
});
});
// EXTERNAL MODULE: ./src/components/modal.tsx
var modal = __webpack_require__(44668);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/form/index.js + 19 modules
var es_form = __webpack_require__(78241);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/input/index.js + 5 modules
var input = __webpack_require__(1056);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/button/index.js
var es_button = __webpack_require__(3113);
;// CONCATENATED MODULE: ./src/components/markdown-editor/link/index.tsx
var formItemLayout = {
labelCol: {
span: 4
},
wrapperCol: {
span: 20
}
};
/* harmony default export */ var markdown_editor_link = (function (_ref) {
var callback = _ref.callback,
onCancel = _ref.onCancel;
function onSubmit(values) {
callback(values);
}
return /*#__PURE__*/(0,jsx_runtime.jsxs)(es_form/* default */.Z, objectSpread2_default()(objectSpread2_default()({}, formItemLayout), {}, {
initialValues: {
link: 'http://',
title: ''
},
className: "link-panel",
onFinish: onSubmit,
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
label: "\u94FE\u63A5\u5730\u5740",
name: "link",
rules: [{
required: true,
message: '请输入链接地址'
}],
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, {})
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
label: "\u94FE\u63A5\u6807\u9898",
name: "title",
rules: [{
required: true,
message: '请输入链接标题'
}],
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, {})
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: "flex-container flex-end",
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
type: "primary",
htmlType: "submit",
style: {
marginRight: 10
},
children: "\u786E\u5B9A"
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
type: "ghost",
onClick: onCancel,
children: "\u53D6\u6D88"
})]
})]
}));
});
// EXTERNAL MODULE: ./src/components/markdown-editor/code-block/index.tsx
var code_block = __webpack_require__(95635);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/message/index.js + 4 modules
var message = __webpack_require__(8591);
;// CONCATENATED MODULE: ./src/components/markdown-editor/upload-image/index.less
// extracted by mini-css-extract-plugin
// EXTERNAL MODULE: ./src/pages/tasks/util.js
var util = __webpack_require__(56672);
;// CONCATENATED MODULE: ./src/components/markdown-editor/upload-image/index.tsx
var useForm = es_form/* default */.Z.useForm;
var style = {
width: 280,
marginRight: 10
};
var upload_image_formItemLayout = {
labelCol: {
span: 5
},
wrapperCol: {
span: 19
}
};
/* harmony default export */ var upload_image = (function (_ref) {
var callback = _ref.callback,
onCancel = _ref.onCancel;
var _useForm = useForm(),
_useForm2 = slicedToArray_default()(_useForm, 1),
form = _useForm2[0];
function onSubmit(values) {
callback(values);
}
function onAddUrl(data, file) {
if (data.status === -1) {
message/* default */.ZP.error(data.message);
return;
}
form.setFieldsValue({
src: "/api/attachments/".concat(data.id),
type: file.type
});
}
function onFileChange(e) {
var file = e.target.files[0];
uploadImage(file, onAddUrl);
}
return /*#__PURE__*/(0,jsx_runtime.jsxs)(es_form/* default */.Z, objectSpread2_default()(objectSpread2_default()({
form: form
}, upload_image_formItemLayout), {}, {
className: "upload-image-panel",
onFinish: onSubmit,
style: {
width: 470,
overflow: "hidden"
},
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
label: "\u56FE\u7247\u5730\u5740",
required: true,
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: "flex-container",
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
noStyle: true,
name: "src",
rules: [{
required: true,
message: '请输入图片地址'
}],
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, {
style: style
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)(UploadButton, {
onFileChange: onFileChange
})]
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
label: "\u56FE\u7247\u63CF\u8FF0",
name: "alt"
// rules={[{ required: true, message: '请输入图片描述' }]}
,
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, {
style: {
width: 264
}
})
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(es_form/* default */.Z.Item, {
style: {
textAlign: "right"
},
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
type: "primary",
htmlType: "submit",
style: {
marginRight: 10
},
children: "\u786E\u5B9A"
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
type: "default",
onClick: onCancel,
children: "\u53D6\u6D88"
})]
})]
}));
});
function UploadButton(_ref2) {
var onFileChange = _ref2.onFileChange;
return /*#__PURE__*/(0,jsx_runtime.jsxs)("label", {
className: "upload-button",
style: {
cursor: "pointer"
},
children: ["\u672C\u5730\u4E0A\u4F20", /*#__PURE__*/(0,jsx_runtime.jsx)("input", {
type: "file",
onChange: onFileChange
})]
});
}
function uploadImage(file, callback) {
if (!file) {
throw new String('没有文件');
return;
}
var formData = new FormData();
formData.append('editormd-image-file', file);
formData.append('file_param_name', 'editormd-image-file');
formData.append('byxhr', 'true');
var xhr = new window.XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('load', function (response) {
callback(JSON.parse(response.target.responseText), file);
}, false);
xhr.addEventListener('error', function (error) {
console.error(error);
}, false);
xhr.open('POST', "".concat(util/* apiPref */.KI, "/api/attachments.json"));
xhr.send(formData);
}
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/radio/index.js + 5 modules
var es_radio = __webpack_require__(5112);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/input-number/index.js + 14 modules
var input_number = __webpack_require__(85731);
;// CONCATENATED MODULE: ./src/components/markdown-editor/add-table-panel/index.tsx
var RadioGroup = es_radio/* default.Group */.ZP.Group;
var add_table_panel_style = {
margin: '0 8px'
};
/* harmony default export */ var add_table_panel = (function (_ref) {
var callback = _ref.callback,
onCancel = _ref.onCancel;
function onSubmit(values) {
callback(values);
}
return /*#__PURE__*/(0,jsx_runtime.jsxs)(es_form/* default */.Z, {
className: "add-table-panel",
initialValues: {
row: 3,
col: 2,
align: 'default'
},
onFinish: onSubmit,
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: "flex-container",
style: {
alignItems: "baseline"
},
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
style: add_table_panel_style,
children: "\u5355\u5143\u683C\u6570\uFF1A"
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
style: add_table_panel_style,
children: "\u884C\u6570"
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
name: "row",
rules: [{
required: true,
message: '请输入行数'
}],
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, {})
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
style: add_table_panel_style,
children: "\u5217\u6570"
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
name: "col",
rules: [{
required: true,
message: '请输入列数'
}],
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, {})
})]
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: "flex-container",
style: {
marginTop: 12,
alignItems: "baseline"
},
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
style: add_table_panel_style,
children: "\u5BF9\u9F50\u65B9\u5F0F\uFF1A"
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
name: "align",
children: /*#__PURE__*/(0,jsx_runtime.jsxs)(RadioGroup, {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default */.ZP, {
value: "default",
children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
className: "fa fa-align-justify"
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default */.ZP, {
value: "left",
children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
className: "fa fa-align-left"
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default */.ZP, {
value: "center",
children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
className: "fa fa-align-center"
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default */.ZP, {
value: "right",
children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
className: "fa fa-align-right"
})
})]
})
})]
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: "flex-container flex-end",
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
type: "primary",
htmlType: "submit",
style: {
marginRight: 10
},
children: "\u786E\u5B9A"
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
type: "ghost",
onClick: onCancel,
children: "\u53D6\u6D88"
})]
})]
});
});
// EXTERNAL MODULE: ./src/utils/env.ts + 1 modules
var env = __webpack_require__(47015);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/modal/index.js + 16 modules
var es_modal = __webpack_require__(43418);
;// CONCATENATED MODULE: ./src/components/markdown-editor/constant.ts
var LINK = 'link';
var UPLOAD_IMAGE = 'upload-image';
var CODE_BLOCK = 'code-block';
var ADD_TABLE = 'add-table';
var HRLINE = '------------';
var ALIGNSIGN = {
"default": HRLINE,
left: ":".concat(HRLINE),
center: ":".concat(HRLINE, ":"),
right: "".concat(HRLINE, ":")
};
// EXTERNAL MODULE: ./src/components/useInterval.tsx
var useInterval = __webpack_require__(14332);
;// CONCATENATED MODULE: ./src/components/markdown-editor/index.tsx
var _DEFAULTKEYMAP, _TitleDesc;
function noop() {}
var pending = 0;
var StorageTimeTicket = 10000;
var NULL_CH = '▁';
var ADD_MULTI = '@▁▁@';
var ADD_SINGLE = '@▁@';
var TEMP1 = '\n**模板标题**\n模板正文内容,可输入文本内容和粘贴图片等操作'; //课程须知模板
function processSize(size) {
return !/^\d+$/.test(size) ? size : "".concat(size, "px");
}
var isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0;
var key = isMac ? 'Cmd' : 'Ctrl';
var DEFAULTKEYMAP = (_DEFAULTKEYMAP = {}, defineProperty_default()(_DEFAULTKEYMAP, key + '-B', 'bold'), defineProperty_default()(_DEFAULTKEYMAP, key + '-I', 'italic'), _DEFAULTKEYMAP);
var TitleDesc = (_TitleDesc = {}, defineProperty_default()(_TitleDesc, LINK, '添加链接'), defineProperty_default()(_TitleDesc, CODE_BLOCK, '添加代码块'), defineProperty_default()(_TitleDesc, UPLOAD_IMAGE, '添加图片'), defineProperty_default()(_TitleDesc, ADD_TABLE, '添加表格'), _TitleDesc);
//https://codemirror.net/demo
//The height can be set through CSS (by giving the .CodeMirror class a height property), or by calling the cm's setSize method.
/* harmony default export */ var markdown_editor = (function (_ref) {
var _ref$defaultValue = _ref.defaultValue,
defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue,
onChange = _ref.onChange,
_ref$width = _ref.width,
width = _ref$width === void 0 ? '100%' : _ref$width,
_ref$height = _ref.height,
height = _ref$height === void 0 ? 400 : _ref$height,
_ref$miniToolbar = _ref.miniToolbar,
miniToolbar = _ref$miniToolbar === void 0 ? false : _ref$miniToolbar,
_ref$isFocus = _ref.isFocus,
isFocus = _ref$isFocus === void 0 ? false : _ref$isFocus,
watch = _ref.watch,
insertTemp = _ref.insertTemp,
_ref$mode = _ref.mode,
mode = _ref$mode === void 0 ? "markdown" : _ref$mode,
_ref$id = _ref.id,
id = _ref$id === void 0 ? 'markdown-editor-id' : _ref$id,
_ref$showResizeBar = _ref.showResizeBar,
showResizeBar = _ref$showResizeBar === void 0 ? false : _ref$showResizeBar,
_ref$noStorage = _ref.noStorage,
noStorage = _ref$noStorage === void 0 ? false : _ref$noStorage,
_ref$showNullButton = _ref.showNullButton,
showNullButton = _ref$showNullButton === void 0 ? false : _ref$showNullButton,
_ref$showNullProgramB = _ref.showNullProgramButton,
showNullProgramButton = _ref$showNullProgramB === void 0 ? false : _ref$showNullProgramB,
_ref$hidetoolBar = _ref.hidetoolBar,
hidetoolBar = _ref$hidetoolBar === void 0 ? false : _ref$hidetoolBar,
_ref$fullScreen = _ref.fullScreen,
fullScreen = _ref$fullScreen === void 0 ? false : _ref$fullScreen,
onBlur = _ref.onBlur,
onCMBeforeChange = _ref.onCMBeforeChange,
onFullScreen = _ref.onFullScreen,
_ref$className = _ref.className,
className = _ref$className === void 0 ? '' : _ref$className,
_ref$disablePaste = _ref.disablePaste,
disablePaste = _ref$disablePaste === void 0 ? false : _ref$disablePaste,
_ref$disabled = _ref.disabled,
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
_ref$disabledFill = _ref.disabledFill,
disabledFill = _ref$disabledFill === void 0 ? false : _ref$disabledFill,
_ref$placeholder = _ref.placeholder,
placeholder = _ref$placeholder === void 0 ? '' : _ref$placeholder,
_ref$values = _ref.values,
values = _ref$values === void 0 ? '' : _ref$values;
var _useState = (0,_react_17_0_2_react.useState)(null),
_useState2 = slicedToArray_default()(_useState, 2),
cm = _useState2[0],
setCm = _useState2[1];
var _useState3 = (0,_react_17_0_2_react.useState)(defaultValue),
_useState4 = slicedToArray_default()(_useState3, 2),
value = _useState4[0],
setValue = _useState4[1];
var _useState5 = (0,_react_17_0_2_react.useState)(watch),
_useState6 = slicedToArray_default()(_useState5, 2),
preview = _useState6[0],
setPreview = _useState6[1];
var _useState7 = (0,_react_17_0_2_react.useState)(fullScreen),
_useState8 = slicedToArray_default()(_useState7, 2),
isFull = _useState8[0],
setIsFull = _useState8[1];
var _useState9 = (0,_react_17_0_2_react.useState)(''),
_useState10 = slicedToArray_default()(_useState9, 2),
action = _useState10[0],
setAction = _useState10[1];
var _useState11 = (0,_react_17_0_2_react.useState)(0),
_useState12 = slicedToArray_default()(_useState11, 2),
lastedUpdateTime = _useState12[0],
setLastedUpdateTime = _useState12[1];
var _useState13 = (0,_react_17_0_2_react.useState)(height),
_useState14 = slicedToArray_default()(_useState13, 2),
h = _useState14[0],
setH = _useState14[1];
var _useState15 = (0,_react_17_0_2_react.useState)(false),
_useState16 = slicedToArray_default()(_useState15, 2),
tip = _useState16[0],
setTip = _useState16[1];
var cmEl = (0,_react_17_0_2_react.useRef)();
var containerEl = (0,_react_17_0_2_react.useRef)();
var resizeBarEl = (0,_react_17_0_2_react.useRef)();
var previewEl = (0,_react_17_0_2_react.useRef)();
// useEffect(() => {
// setValue(defaultValue)
// cm?.setValue(defaultValue)
// },[])
(0,_react_17_0_2_react.useEffect)(function () {
var scrollTop = window.scrollY || window.pageYOffset;
setValue(values);
cm === null || cm === void 0 || cm.setValue(values);
window.scrollTo(0, scrollTop);
}, [values]);
(0,_react_17_0_2_react.useEffect)(function () {
onFullScreen === null || onFullScreen === void 0 || onFullScreen(isFull);
}, [isFull]);
(0,_react_17_0_2_react.useEffect)(function () {
if (cmEl.current) {
var onPaste = function onPaste(_, e) {
if (disablePaste) {
e.preventDefault();
return;
}
var clipboardData = e.clipboardData;
if (clipboardData) {
var types = clipboardData.types.toString();
var items = clipboardData.items;
var officeSix = ["pptm", "pptx", "ppt", "pot", "pps", "ppa", "potx", "ppsx", "ppam", "pptm", "potm", "ppsm", "doc", "docx", "dot", "dotx", "docm", "dotm", "xls", "xlsx", "csv", "xlt", "xla", "xltx", "xlsm", "xltm", "xlam", "xlsb"];
if (types === 'Files' || clipboardData.types.indexOf("Files") > -1) {
e.preventDefault();
if (mode == "stex") return;
try {
var _items$;
var item = items[1];
if (((_items$ = items[0]) === null || _items$ === void 0 ? void 0 : _items$.kind) === 'file') {
item = items[0];
}
var file = item.getAsFile();
var fileSix = file.name.split(".").pop();
// console.log("item:", item, file, item?.type?.match(/^video\//i))
uploadImage(file, function (data) {
if (data.id) {
var _file$type, _file$type2, _file$type3;
if ((file === null || file === void 0 || (_file$type = file.type) === null || _file$type === void 0 ? void 0 : _file$type.indexOf("image")) > -1) {
instance.replaceSelection(".concat(data.content_type, ")"));
} else if ((file === null || file === void 0 || (_file$type2 = file.type) === null || _file$type2 === void 0 ? void 0 : _file$type2.indexOf("video")) > -1) {
instance.replaceSelection(""));
} else if ((file === null || file === void 0 || (_file$type3 = file.type) === null || _file$type3 === void 0 ? void 0 : _file$type3.indexOf("pdf")) > -1) {
instance.replaceSelection("").concat(file.name, ""));
} else if (officeSix.includes(fileSix)) {
instance.replaceSelection("").concat(file.name, ""));
} else {
instance.replaceSelection("[".concat(file.name, "](").concat(env/* default */.Z.API_SERVER, "/api/attachments/").concat(data.id, "?type=").concat(data.content_type, ")"));
}
} else {
if ((data === null || data === void 0 ? void 0 : data.status) === 401) document.location.href = '/user/login';
}
});
} catch (e) {
message/* default */.ZP.warning("请使用chrome浏览器粘贴");
}
return true;
} else {
//toMarkdown ?
// let html = clipboardData.getData('text/html')
return true;
}
}
return true;
};
var instance = codemirror_default().fromTextArea(cmEl.current, {
mode: mode,
// inputStyle: 'contenteditable',
lineNumbers: miniToolbar ? false : true,
lineWrapping: true,
value: defaultValue,
autoCloseTags: true,
autoCloseBrackets: true
});
instance.on("keyup", function (cm, event) {
if (event.keyCode === 8) {
if (cm.getValue() == "") {
instance.setOption("placeholder", placeholder);
} else {
instance.setOption("placeholder", null);
}
}
});
instance.on("keydown", function (cm, event) {
if (event.keyCode === 8) {
var pos = deleteAtSymbol(cm);
if (pos) {
event.preventDefault();
}
}
});
isFocus && instance.focus();
instance.on('paste', onPaste);
if (disabled) {
instance.on("beforeChange", function (instances, change) {
if (change.origin === "paste" || change.origin === "+input") {
change.cancel();
}
});
}
setCm(instance);
return function () {
instance.off('paste', onPaste);
};
}
}, []);
var resizeEditorBodyHeight = (0,_react_17_0_2_react.useCallback)(function () {
if (containerEl.current) {
try {
// let toolH = containerEl.current.getElementsByClassName('markdown-toolbar-container')[0].offsetHeight
// let mdBody = containerEl.current.getElementsByClassName('markdown-editor-body')[0]
// if (!isFull) {
// mdBody.style.height = `${h - toolH}px`
// } else {
// mdBody.style.height = `calc(100vh - ${toolH}px)`
// }
} catch (error) {
console.log(error, '---- to set md editor body height');
}
}
}, [h, containerEl, isFull]);
(0,_react_17_0_2_react.useEffect)(function () {
function onLayout() {
var ro = new ResizeObserver_es/* default */.Z(function (entries) {
var _iterator = createForOfIteratorHelper_default()(entries),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var entry = _step.value;
if (entry.target.offsetHeight > 0 || entry.target.offsetWidth > 0) {
resizeEditorBodyHeight();
cm.setSize('100%', '100%');
cm.refresh();
}
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
});
ro.observe(cmEl.current.parentElement);
return ro;
}
if (cm) {
var ro = onLayout();
return function () {
var _cmEl$current, _cmEl$current2;
if ((_cmEl$current = cmEl.current) !== null && _cmEl$current !== void 0 && _cmEl$current.parentElement) ro.unobserve((_cmEl$current2 = cmEl.current) === null || _cmEl$current2 === void 0 ? void 0 : _cmEl$current2.parentElement);
};
}
}, [cm, resizeEditorBodyHeight]);
//keymap
(0,_react_17_0_2_react.useEffect)(function () {
if (cm) {
var keymap = [];
var _loop = function _loop() {
var _Object$entries$_i = slicedToArray_default()(_Object$entries[_i], 2),
k = _Object$entries$_i[0],
value = _Object$entries$_i[1];
var map = defineProperty_default()({}, k, function () {
onActionCallback(value);
});
keymap.push(map);
cm.addKeyMap(map);
};
for (var _i = 0, _Object$entries = Object.entries(DEFAULTKEYMAP); _i < _Object$entries.length; _i++) {
_loop();
}
return function () {
for (var _i2 = 0, _keymap = keymap; _i2 < _keymap.length; _i2++) {
var m = _keymap[_i2];
cm.removeKeyMap(m);
}
};
}
}, [cm]);
(0,_react_17_0_2_react.useEffect)(function () {
if (fullScreen !== isFull) {
setIsFull(fullScreen);
}
}, [fullScreen]);
(0,useInterval/* default */.Z)(function () {
if (!noStorage && lastedUpdateTime > 0) {
var currentTime = new Date().getTime();
var lastedValue = window.sessionStorage.getItem(id);
if (currentTime >= lastedUpdateTime + StorageTimeTicket && (!lastedValue || lastedValue !== value)) {
window.sessionStorage.setItem(id, value);
setTip(true);
}
}
}, StorageTimeTicket);
(0,_react_17_0_2_react.useEffect)(function () {
setPreview(watch);
}, [cm, watch]);
(0,_react_17_0_2_react.useEffect)(function () {
if (cm) {
isFocus && cm.focus();
}
}, [cm, isFocus]);
(0,_react_17_0_2_react.useEffect)(function () {
if (preview && cm) {
var syncScroll = function syncScroll(e) {
var target = e.target;
if (previewEl.current) {
var ratio = target.scrollTop / target.scrollHeight;
previewEl.current.scrollTop = previewEl.current.scrollHeight * ratio;
}
};
var scrollEl = cm.getScrollerElement();
scrollEl.addEventListener('scroll', syncScroll);
return function () {
scrollEl.removeEventListener('scroll', syncScroll);
};
}
}, [cm, preview]);
(0,_react_17_0_2_react.useEffect)(function () {
if (cm && onCMBeforeChange) {
var onChangeHandler = function onChangeHandler(cm, change) {
onCMBeforeChange(cm, change);
};
cm.on('beforeChange', onChangeHandler);
return function () {
cm.off('beforeChange', onChangeHandler);
};
}
}, [cm, onCMBeforeChange]);
(0,_react_17_0_2_react.useEffect)(function () {
if (cm && onBlur) {
var onBlurHandler = function onBlurHandler() {
onBlur(cm.getValue());
};
cm.on('blur', onBlurHandler);
return function () {
cm.off('blur', onBlurHandler);
};
}
}, [cm, onBlur]);
function deleteAtSymbol(cm, change) {
var doc = cm.getDoc();
var cursor = doc.getCursor();
var line = doc.getLine(cursor.line);
var ch = line.charAt(cursor.ch - 1);
var p1 = line.lastIndexOf("@▁@", cursor.ch);
var p2 = line.lastIndexOf("@▁▁@", cursor.ch);
var posStart = p1 > p2 ? p1 : p2;
var n = p1 > p2 ? 3 : 4;
if (ADD_MULTI.indexOf(ch) === -1) return null;
console.log("change1:", change, cm, line, cursor, posStart, p1, p2, ch);
if (posStart >= 0 && cursor.ch - posStart < 5) {
var posEnd = posStart + n;
doc.replaceRange("", {
line: cursor.line,
ch: posStart
}, {
line: cursor.line,
ch: posEnd
});
return {
line: cursor.line,
ch: posEnd
};
}
return null;
}
(0,_react_17_0_2_react.useEffect)(function () {
if (cm) {
var onChangeHandler = function onChangeHandler(cm, change) {
var content = cm.getValue();
setValue(content);
setLastedUpdateTime(new Date().getTime());
cm.getScrollerElement().dispatchEvent(new CustomEvent('scroll'));
if (onChange) {
if (showNullProgramButton) {
onChange(content, formatProgramFill(content));
} else {
onChange(content);
}
}
};
cm.on('change', onChangeHandler);
return function () {
cm.off('change', onChangeHandler);
};
}
}, [cm, onChange]);
(0,_react_17_0_2_react.useEffect)(function () {
if (cm) {
// isFocus && cm.focus()
if (defaultValue === null || defaultValue === undefined) {
cm.setValue('');
setValue('');
} else {
var scrollTop = window.scrollY || window.pageYOffset;
if (defaultValue !== cm.getValue()) {
cm.setValue(defaultValue);
setValue(defaultValue);
cm.setCursor(disabled ? 1 : cm.lineCount(), 0);
window.scrollTo(0, scrollTop);
}
}
}
}, [cm, defaultValue]);
var onActionCallback = (0,_react_17_0_2_react.useCallback)(function (actionName) {
var cursor = cm.getCursor();
var selection = cm.getSelection();
var selectionText = selection.split('\n');
switch (actionName) {
case 'bold':
cm.replaceSelection('**' + selection + '**');
if (selection === '') {
cm.setCursor(cursor.line, cursor.ch + 2);
}
return cm.focus();
case 'italic':
cm.replaceSelection('*' + selection + '*');
if (selection === '') {
cm.setCursor(cursor.line, cursor.ch + 1);
}
return cm.focus();
case 'code':
cm.replaceSelection('`' + selection + '`');
if (selection === '') {
cm.setCursor(cursor.line, cursor.ch + 1);
}
return cm.focus();
case 'inline-latex':
cm.replaceSelection('`$$' + selection + '$$`');
if (selection === '') {
cm.setCursor(cursor.line, cursor.ch + 3);
}
return cm.focus();
case 'latex':
cm.replaceSelection("```latex\n" + selection + "\n```");
cm.setCursor(cursor.line + 1, selection.length + 1);
return cm.focus();
case 'line-break':
cm.replaceSelection('
\n');
return cm.focus();
case 'list-ul':
if (selection === '') {
cm.replaceSelection('- ' + selection);
} else {
cm.replaceSelection(selectionText.map(function (item) {
return item === '' ? '' : "- ".concat(item);
}).join('\n'));
}
return cm.focus();
case 'list-ol':
if (selection === '') {
cm.replaceSelection('1. ' + selection);
} else {
cm.replaceSelection(selectionText.map(function (item, index) {
return item === '' ? '' : "".concat(index + 1, ". ").concat(item);
}).join('\n'));
}
return cm.focus();
case 'add-null-ch':
if (selection === '') {
cm.setCursor(cursor.line, cursor.ch);
}
cm.replaceSelection(NULL_CH);
return cm.focus();
case 'add-signal':
if (selection === '') {
cm.setCursor(cursor.line, cursor.ch);
}
cm.replaceSelection(ADD_SINGLE);
return cm.focus();
case 'add-multiple':
if (selection === '') {
cm.setCursor(cursor.line, cursor.ch);
}
cm.replaceSelection(ADD_MULTI);
return cm.focus();
case 'inster-template-1':
if (selection === '') {
cm.setCursor(cursor.line, cursor.ch);
}
cm.replaceSelection(TEMP1);
return cm.focus();
case 'eraser':
cm.setValue('');
return cm.focus();
case 'trigger-watch':
setPreview(!preview);
return cm.focus();
case 'trigger-full-screen':
setIsFull(!isFull);
return cm.focus();
case LINK:
setAction(LINK);
return;
case CODE_BLOCK:
setAction(CODE_BLOCK);
return;
case UPLOAD_IMAGE:
setAction(UPLOAD_IMAGE);
return;
case ADD_TABLE:
setAction(ADD_TABLE);
return;
default:
throw new Error();
}
}, [cm, preview, isFull]);
var ExecutePluginAction = (0,_react_17_0_2_react.useCallback)(function (values) {
setAction('');
switch (action) {
case LINK:
var title = values.title,
link = values.link;
cm.replaceSelection("[".concat(title, "](").concat(link, ")"));
return cm.focus();
case CODE_BLOCK:
var language = values.language,
content = values.content;
cm.replaceSelection(['```' + language, content, '```'].join('\n'));
return cm.focus();
case UPLOAD_IMAGE:
var src = values.src,
alt = values.alt;
if (alt) {
cm.replaceSelection(".concat(src, " \"").concat(alt, "\" )"));
} else {
cm.replaceSelection(""));
}
return cm.focus();
case ADD_TABLE:
var row = values.row,
col = values.col,
align = values.align;
var table = '\n';
for (var r = 0; r < row; r++) {
var rows = [];
var heads = [];
for (var c = 0; c < col; c++) {
if (r === 1) {
heads.push(ALIGNSIGN[align]);
}
rows.push(' ');
}
if (r === 1) {
table += "| ".concat(heads.join(' | '), " |\n");
}
table += "| ".concat(rows.join(col === 1 ? '' : ' | '), " |\n");
}
cm.replaceSelection(table + '\n');
return cm.focus();
default:
throw new Error();
}
}, [cm, action]);
var PluginEl = (0,_react_17_0_2_react.useMemo)(function () {
switch (action) {
case LINK:
return /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor_link, {
callback: ExecutePluginAction,
onCancel: onCancel
});
case CODE_BLOCK:
return /*#__PURE__*/(0,jsx_runtime.jsx)(code_block/* default */.Z, {
callback: ExecutePluginAction,
onCancel: onCancel
});
case UPLOAD_IMAGE:
return /*#__PURE__*/(0,jsx_runtime.jsx)(upload_image, {
callback: ExecutePluginAction,
onCancel: onCancel
});
case ADD_TABLE:
return /*#__PURE__*/(0,jsx_runtime.jsx)(add_table_panel, {
callback: ExecutePluginAction,
onCancel: onCancel
});
default:
return null;
}
}, [action]);
function onCancel() {
setAction('');
}
(0,_react_17_0_2_react.useEffect)(function () {
if (resizeBarEl.current) {
var onMouseDown = function onMouseDown(e) {
dragging = true;
startY = e.pageY;
};
var onMouseUp = function onMouseUp() {
dragging = false;
};
var onMouseMove = function onMouseMove(e) {
if (dragging) {
var delta = e.pageY - startY;
if (delta < 0) {
delta = 0;
}
if (delta > 300) {
delta = 300;
}
var resizeH = height + delta + 'px';
setH(resizeH);
}
};
var resizeBar = resizeBarEl.current;
var dragging = false;
var startY = 0;
resizeBar.addEventListener('mousedown', onMouseDown);
document.addEventListener('mousemove', onMouseMove);
document.addEventListener('mouseup', onMouseUp);
return function () {
resizeBar.removeEventListener('mousedown', onMouseDown);
document.removeEventListener('mousemove', onMouseMove);
document.removeEventListener('mouseup', onMouseUp);
};
}
}, [cm, resizeBarEl]);
(0,_react_17_0_2_react.useEffect)(function () {
setH(height);
}, [height]);
var fixedWidth = processSize(width);
var fixedHeight = processSize(h);
var style = {
width: fixedWidth,
height: fixedHeight
};
var saveTime = (0,_react_17_0_2_react.useMemo)(function () {
if (lastedUpdateTime) {
var d = new Date(lastedUpdateTime);
var _h = d.getHours();
var m = d.getMinutes();
var s = d.getSeconds();
_h = _h < 10 ? '0' + _h : _h;
m = m < 10 ? '0' + m : m;
s = s < 10 ? '0' + s : s;
return "".concat(_h, ":").concat(m, ":").concat(s);
}
return 0;
}, [lastedUpdateTime]);
var formatProgramFill = function formatProgramFill(str) {
var arr = [];
if (showNullProgramButton) {
var num = -1;
str = str.replace(/(@▁▁@|@▁@)/g, function (a, b, c) {
arr.push({
multiLine: !(a === ADD_SINGLE)
});
});
}
return arr;
};
function onCancelStorage() {
window.sessionStorage.removeItem(id);
setTip(false);
setLastedUpdateTime(0);
}
function onReset() {
setTip(false);
setLastedUpdateTime(0);
cm.setValue(window.sessionStorage.getItem(id));
}
return /*#__PURE__*/(0,jsx_runtime.jsxs)(_react_17_0_2_react.Fragment, {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: "markdown-editor-wrapper",
ref: containerEl,
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: "markdown-editor-container ".concat(className, " ").concat(preview ? 'on-preview' : '', " ").concat(miniToolbar ? 'mini' : '', " ").concat(isFull ? 'full-screen' : ''),
style: style,
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(toolbar, {
insertTemp: insertTemp,
watch: preview,
fullScreen: isFull,
showNullButton: showNullButton,
showNullProgramButton: showNullProgramButton,
onActionCallback: onActionCallback,
hidetoolBar: hidetoolBar
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: "markdown-editor-body",
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: "codemirror-container",
children: /*#__PURE__*/(0,jsx_runtime.jsx)("textarea", {
ref: cmEl,
placeholder: placeholder
})
}), preview ? /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
ref: previewEl,
className: "preview-container",
children: [mode === "stex" && /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml_stex, {
value: value
}), mode !== "stex" && /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, {
disabledFill: disabledFill,
showProgramFill: showNullProgramButton,
value: value
})]
}) : null]
})]
})
}), showResizeBar ? /*#__PURE__*/(0,jsx_runtime.jsx)("a", {
ref: resizeBarEl,
className: "editor-resize"
}) : null, /*#__PURE__*/(0,jsx_runtime.jsx)(modal/* default */.Z, {
children: TitleDesc[action] ? /*#__PURE__*/(0,jsx_runtime.jsx)(es_modal/* default */.Z, {
centered: true,
title: TitleDesc[action],
open: true,
onCancel: onCancel,
footer: null,
className: "markdown-popup-form",
children: PluginEl
}) : null
})]
});
});
/***/ }),
/***/ 44668:
/*!**********************************!*\
!*** ./src/components/modal.tsx ***!
\**********************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ Z: function() { return /* binding */ Dialog; }
/* harmony export */ });
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_classCallCheck_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/classCallCheck.js */ 94312);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_classCallCheck_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_classCallCheck_js__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createClass_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/createClass.js */ 24127);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createClass_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createClass_js__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_inherits_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/inherits.js */ 93242);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_inherits_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_inherits_js__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createSuper_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/createSuper.js */ 10564);
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createSuper_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createSuper_js__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react */ 59301);
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react-dom */ 4676);
var Dialog = /*#__PURE__*/function (_React$Component) {
_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_inherits_js__WEBPACK_IMPORTED_MODULE_2___default()(Dialog, _React$Component);
var _super = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createSuper_js__WEBPACK_IMPORTED_MODULE_3___default()(Dialog);
function Dialog(props) {
var _this;
_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_classCallCheck_js__WEBPACK_IMPORTED_MODULE_0___default()(this, Dialog);
_this = _super.call(this, props);
var doc = window.document;
_this.node = doc.createElement('div');
doc.body.appendChild(_this.node);
return _this;
}
_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createClass_js__WEBPACK_IMPORTED_MODULE_1___default()(Dialog, [{
key: "render",
value: function render() {
var children = this.props.children;
return /*#__PURE__*/(0,react_dom__WEBPACK_IMPORTED_MODULE_5__.createPortal)(children, this.node);
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
window.document.body.removeChild(this.node);
}
}]);
return Dialog;
}(react__WEBPACK_IMPORTED_MODULE_4__.Component);
/***/ }),
/***/ 14332:
/*!****************************************!*\
!*** ./src/components/useInterval.tsx ***!
\****************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ Z: function() { return /* binding */ useInterval; }
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ 59301);
function useInterval(callback, delay) {
var savedCallback = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
// 保存新回调
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
savedCallback.current = callback;
});
// 建立 interval
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
function tick() {
savedCallback.current();
}
if (delay !== null) {
var id = setInterval(tick, delay);
return function () {
return clearInterval(id);
};
}
}, [delay]);
}
/***/ }),
/***/ 51024:
/*!****************************************************************************!*\
!*** ./src/pages/User/Detail/Topics/Exercise/Detail/index.tsx + 8 modules ***!
\****************************************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
"default": function() { return /* binding */ Detail; }
});
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/regeneratorRuntime.js
var regeneratorRuntime = __webpack_require__(10574);
var regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(regeneratorRuntime);
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/asyncToGenerator.js
var asyncToGenerator = __webpack_require__(39343);
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectSpread2.js
var objectSpread2 = __webpack_require__(26801);
var objectSpread2_default = /*#__PURE__*/__webpack_require__.n(objectSpread2);
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/toConsumableArray.js
var toConsumableArray = __webpack_require__(93923);
var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray);
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/slicedToArray.js
var slicedToArray = __webpack_require__(11006);
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectWithoutProperties.js
var objectWithoutProperties = __webpack_require__(27161);
var objectWithoutProperties_default = /*#__PURE__*/__webpack_require__.n(objectWithoutProperties);
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
var _react_17_0_2_react = __webpack_require__(59301);
// EXTERNAL MODULE: ./src/.umi-production/exports.ts + 8 modules
var _umi_production_exports = __webpack_require__(66660);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/menu/index.js + 11 modules
var menu = __webpack_require__(20834);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/layout/index.js
var layout = __webpack_require__(44000);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/form/index.js + 19 modules
var es_form = __webpack_require__(78241);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/message/index.js + 4 modules
var message = __webpack_require__(8591);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/divider/index.js + 1 modules
var divider = __webpack_require__(28103);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/breadcrumb/index.js + 6 modules
var breadcrumb = __webpack_require__(66104);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/row/index.js
var row = __webpack_require__(95237);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/col/index.js
var col = __webpack_require__(43604);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/modal/index.js + 16 modules
var modal = __webpack_require__(43418);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/tabs/index.js + 24 modules
var tabs = __webpack_require__(99313);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/input/index.js + 5 modules
var input = __webpack_require__(1056);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/button/index.js
var es_button = __webpack_require__(3113);
// EXTERNAL MODULE: ./src/service/polls.ts
var service_polls = __webpack_require__(81764);
// EXTERNAL MODULE: ./src/service/user.ts
var service_user = __webpack_require__(52138);
// EXTERNAL MODULE: ./src/components/NoData/index.tsx
var NoData = __webpack_require__(72020);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/tooltip/index.js + 3 modules
var tooltip = __webpack_require__(6848);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/checkbox/index.js + 3 modules
var es_checkbox = __webpack_require__(24905);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/input-number/index.js + 14 modules
var input_number = __webpack_require__(85731);
// EXTERNAL MODULE: ./src/service/exercise.ts
var exercise = __webpack_require__(6303);
// EXTERNAL MODULE: ./src/components/markdown-editor/index.tsx + 10 modules
var markdown_editor = __webpack_require__(20755);
// EXTERNAL MODULE: ./src/components/RenderHtml/index.tsx + 1 modules
var RenderHtml = __webpack_require__(55523);
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/Exercise/Detail/components/editor.less?modules
// extracted by mini-css-extract-plugin
/* harmony default export */ var editormodules = ({"flex_box_center":"flex_box_center___p1qG1","flex_space_between":"flex_space_between___EHoRl","flex_box_vertical_center":"flex_box_vertical_center___c0u2d","flex_box_center_end":"flex_box_center_end___ueiDD","flex_box_column":"flex_box_column___tyRHS","wrap":"wrap___ce8sS","modal":"modal___yzD47","titleWrap":"titleWrap___OBPcs","required":"required___ncxFF","title":"title___cxIaz","colorGray":"colorGray___NXXsn","choiceWrap":"choiceWrap___AhJbr","answer":"answer____f42Z","activeAnswer":"activeAnswer___BqxNg","deleteIcon":"deleteIcon___iHXv4","addIcon":"addIcon___Kb1l4","editorWrap":"editorWrap___UmeId","htmlWrap":"htmlWrap____EtjV","radio":"radio___zqqhF","color333":"color333___PUxW5","color999":"color999___Uiwst","questionType":"questionType___GcJoU","questionChoices":"questionChoices___WgikS"});
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/jsx-runtime.js
var jsx_runtime = __webpack_require__(37712);
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/Exercise/Detail/components/MultipleEditor/index.tsx
var _excluded = ["problemset", "globalSetting", "loading", "dispatch", "onRef", "editData"];
var tagList = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
var SingleEditor = function SingleEditor(_ref, ref) {
var problemset = _ref.problemset,
globalSetting = _ref.globalSetting,
loading = _ref.loading,
dispatch = _ref.dispatch,
_ref$onRef = _ref.onRef,
onRef = _ref$onRef === void 0 ? function () {} : _ref$onRef,
editData = _ref.editData,
props = objectWithoutProperties_default()(_ref, _excluded);
var _useState = (0,_react_17_0_2_react.useState)([]),
_useState2 = slicedToArray_default()(_useState, 2),
questionChoiceList = _useState2[0],
setQuestionChoiceList = _useState2[1];
var _useState3 = (0,_react_17_0_2_react.useState)(),
_useState4 = slicedToArray_default()(_useState3, 2),
activeEditor = _useState4[0],
setActiveEditor = _useState4[1];
var _useState5 = (0,_react_17_0_2_react.useState)([]),
_useState6 = slicedToArray_default()(_useState5, 2),
activeAnswer = _useState6[0],
setActiveAnswer = _useState6[1];
var _useState7 = (0,_react_17_0_2_react.useState)(''),
_useState8 = slicedToArray_default()(_useState7, 2),
title = _useState8[0],
setTitle = _useState8[1];
var _useState9 = (0,_react_17_0_2_react.useState)(5),
_useState10 = slicedToArray_default()(_useState9, 2),
score = _useState10[0],
setScore = _useState10[1];
var _useState11 = (0,_react_17_0_2_react.useState)(false),
_useState12 = slicedToArray_default()(_useState11, 2),
isEdit = _useState12[0],
setIsEdit = _useState12[1];
var params = (0,_umi_production_exports.useParams)();
(0,_react_17_0_2_react.useEffect)(function () {
setQuestionChoiceList(['', '', '', '']);
}, []);
(0,_react_17_0_2_react.useEffect)(function () {
if (!(editData !== null && editData !== void 0 && editData.question_choices)) {
setIsEdit(true);
return;
}
setTitle(editData === null || editData === void 0 ? void 0 : editData.question_title);
setScore(parseInt(editData === null || editData === void 0 ? void 0 : editData.question_score));
setQuestionChoiceList(editData === null || editData === void 0 ? void 0 : editData.question_choices.map(function (item) {
return item.choice_text;
}));
var answerIndexs = [];
editData === null || editData === void 0 || editData.standard_answer.map(function (item, index) {
answerIndexs.push(item - 1);
});
setActiveAnswer(answerIndexs);
}, [editData]);
(0,_react_17_0_2_react.useImperativeHandle)(ref, function () {
return {
onSave: onSave,
isEdit: isEdit
};
});
var onSave = /*#__PURE__*/function () {
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() {
var findNotAnswerIndex, choices, res;
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
if (title) {
_context.next = 3;
break;
}
message/* default */.ZP.info("请您输入题目");
return _context.abrupt("return", false);
case 3:
findNotAnswerIndex = questionChoiceList.findIndex(function (item) {
return !item;
});
if (!(findNotAnswerIndex > -1)) {
_context.next = 7;
break;
}
message/* default */.ZP.info("\u8BF7\u5148\u8F93\u5165 ".concat(tagList[findNotAnswerIndex], " \u9009\u9879\u7684\u5185\u5BB9"));
return _context.abrupt("return", false);
case 7:
if (activeAnswer.length) {
_context.next = 10;
break;
}
message/* default */.ZP.info("请设置本题的正确答案,点击选项A/B...即可完成设置");
return _context.abrupt("return", false);
case 10:
if (!(activeAnswer.length < 1)) {
_context.next = 13;
break;
}
message/* default */.ZP.info("请选择答案");
return _context.abrupt("return", false);
case 13:
choices = questionChoiceList.map(function (item, index) {
return {
choice_text: item,
is_answer: activeAnswer.includes(index) ? index + 1 : 0
};
});
if (!editData.question_id) {
_context.next = 20;
break;
}
_context.next = 17;
return dispatch({
type: "exercise/editExerciseQuestion",
payload: {
"id": editData.question_id,
"question_title": title,
"question_type": 1,
"question_score": "5.0",
"question_choices": choices.map(function (item) {
return item.choice_text;
}),
"standard_answers": choices.filter(function (item) {
return item.is_answer;
}).map(function (item) {
return item.is_answer;
})
}
});
case 17:
res = _context.sent;
_context.next = 23;
break;
case 20:
_context.next = 22;
return dispatch({
type: "exercise/addExerciseQuestion",
payload: {
"categoryId": params.categoryId,
"question_title": title,
"question_type": 1,
"question_score": "5.0",
"question_choices": choices.map(function (item) {
return item.choice_text;
}),
"standard_answers": choices.filter(function (item) {
return item.is_answer;
}).map(function (item) {
return item.is_answer;
})
}
});
case 22:
res = _context.sent;
case 23:
if (res.status === 0) {
message/* default */.ZP.success("保存成功");
setIsEdit(false);
dispatch({
type: "exercise/editExercise",
payload: objectSpread2_default()({}, params)
});
}
case 24:
case "end":
return _context.stop();
}
}, _callee);
}));
return function onSave() {
return _ref2.apply(this, arguments);
};
}();
var actionArr = [{
name: "删除",
icon: "iconfont c-light-black ml30 icon-shanchu",
id: "del"
}, {
name: "上移",
icon: "iconfont c-green ml30 icon-shangyi_Hover",
id: "up"
}, {
name: "下移",
icon: "iconfont c-green ml30 icon-xiayi_moren",
id: "down"
}, {
name: "编辑",
icon: "iconfont c-green ml30 icon-bianjishijuan3x",
id: "edit"
}];
var actionClick = /*#__PURE__*/function () {
var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3(item) {
return regeneratorRuntime_default()().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
_context3.t0 = item.id;
_context3.next = _context3.t0 === "del" ? 3 : _context3.t0 === "up" ? 5 : _context3.t0 === "down" ? 5 : _context3.t0 === "edit" ? 9 : 11;
break;
case 3:
modal/* default */.Z.confirm({
centered: true,
okText: '确定',
cancelText: '取消',
title: '确认要删除这个问题吗?',
onOk: function onOk() {
return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() {
return regeneratorRuntime_default()().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return (0,exercise/* exeriseQuestionDelete */.Fl)({
id: editData.question_id
});
case 2:
dispatch({
type: "exercise/editExercise",
payload: objectSpread2_default()({}, params)
});
case 3:
case "end":
return _context2.stop();
}
}, _callee2);
}))();
}
});
return _context3.abrupt("break", 11);
case 5:
_context3.next = 7;
return dispatch({
type: "exercise/exeriseMoveUpDown",
payload: {
id: editData.question_id,
opr: item.id
}
});
case 7:
dispatch({
type: "exercise/editExercise",
payload: objectSpread2_default()({}, params)
});
return _context3.abrupt("break", 11);
case 9:
setIsEdit(true);
return _context3.abrupt("break", 11);
case 11:
case "end":
return _context3.stop();
}
}, _callee3);
}));
return function actionClick(_x) {
return _ref3.apply(this, arguments);
};
}();
var showList = function showList() {
var _editData$question_ch;
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: editormodules.questionType,
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
className: "font16 c-blue",
children: [editData.key, "\u3001\u591A\u9009\u9898"]
}), "\uFF08", editData.question_score, "\u5206\uFF09"]
}), !editData.hideAction && actionArr.map(function (item, index) {
if (item.id === "up" && editData.key === 1) return null;
if (item.id === "down" && editData.key === editData.len) return null;
return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
placement: "bottom",
title: item.name,
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
onClick: function onClick() {
return actionClick(item);
},
className: item.icon
})
}, index);
})]
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: "mt5",
children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, {
value: editData.question_title
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: editormodules.questionChoices,
children: editData === null || editData === void 0 || (_editData$question_ch = editData.question_choices) === null || _editData$question_ch === void 0 ? void 0 : _editData$question_ch.map(function (item, index) {
return /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
children: /*#__PURE__*/(0,jsx_runtime.jsxs)(es_checkbox/* default */.Z, {
checked: editData.standard_answer.includes(index + 1),
disabled: true,
children: [tagList[index], "."]
}, index)
}), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
flex: "1",
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "c-black font14",
children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, {
value: item.choice_text
})
})
})]
});
})
})]
});
};
var showEdit = function showEdit() {
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: editormodules.questionType,
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "font16 c-blue",
children: "\u9009\u62E9\u9898"
}), "\uFF08\u5BA2\u89C2\u9898\uFF0C\u7531\u7CFB\u7EDF\u81EA\u52A8\u8BC4\u5206\uFF0C\u8BF7\u8BBE\u7F6E\u6807\u51C6\u7B54\u6848\uFF09"]
})
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", {
className: editormodules.titleWrap,
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: editormodules.required,
children: "*"
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: editormodules.title,
children: "\u9898\u5E72\uFF1A"
})]
}), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, {
id: "single-question-title",
watch: true,
height: 155,
placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u5E72",
defaultValue: title,
onChange: function onChange(value) {
return setTitle(value);
}
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", {
className: editormodules.titleWrap,
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: editormodules.required,
children: "*"
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
className: editormodules.title,
children: ["\u7B54\u6848\u9009\u9879\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: editormodules.colorGray,
children: "\u70B9\u51FB\u9009\u9879\u53EF\u8BBE\u7F6E\u6B63\u786E\u7B54\u6848"
})]
})]
}), questionChoiceList.map(function (item, index) {
return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: editormodules.choiceWrap,
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
title: "\u70B9\u51FB\u8BBE\u7F6E\u4E3A\u6807\u51C6\u7B54\u6848",
placement: "left",
children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: "".concat(editormodules.answer, " ").concat(activeAnswer.includes(index) ? editormodules.activeAnswer : ''),
onClick: function onClick() {
if (activeAnswer.includes(index)) {
setActiveAnswer(activeAnswer.filter(function (item) {
return item !== index;
}));
} else {
setActiveAnswer([].concat(toConsumableArray_default()(activeAnswer), [index]));
}
},
children: tagList[index]
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: editormodules.editorWrap,
children: activeEditor === index ? /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, {
id: "single-question-option-".concat(index),
watch: true,
height: 155,
placeholder: "\u8BF7\u60A8\u8F93\u5165\u9009\u9879",
defaultValue: item,
onChange: function onChange(value) {
questionChoiceList[index] = value;
setQuestionChoiceList(questionChoiceList);
}
}) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: editormodules.htmlWrap,
onClick: function onClick() {
return setActiveEditor(index);
},
children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, {
value: item
})
})
}), index > 1 && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
title: "\u5220\u9664",
children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
className: "".concat(editormodules.deleteIcon, " iconfont icon-htmal5icon19"),
onClick: function onClick() {
return setQuestionChoiceList(questionChoiceList.filter(function (_, key) {
return key !== index;
}));
}
})
}), index < 7 && index === questionChoiceList.length - 1 && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
title: "\u65B0\u589E\u53C2\u8003\u7B54\u6848",
children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
className: "".concat(editormodules.addIcon, " iconfont icon-roundaddfill ml6"),
onClick: function onClick() {
return setQuestionChoiceList([].concat(toConsumableArray_default()(questionChoiceList), ['']));
}
})
})]
}, index);
}), /*#__PURE__*/(0,jsx_runtime.jsx)("p", {
className: "c-orange",
children: "\u6E29\u99A8\u63D0\u793A\uFF1A\u70B9\u51FB\u9009\u9879\u8F93\u5165\u6846\u53EF\u8BBE\u7F6E\u7B54\u6848\uFF1B\u9009\u4E2D\u7684\u9009\u9879\u5373\u4E3A\u6B63\u786E\u7B54\u6848\uFF0C\u9009\u62E9\u591A\u4E2A\u7B54\u6848\u5373\u4E3A\u591A\u9009\u9898"
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", {
className: "",
children: ["\u5206\u503C\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, {
value: score,
max: 10000,
min: -1,
onChange: function onChange(value) {
setScore(value);
}
}), " \u5206"]
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
className: "tr",
children: [editData.question_id && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
type: "default",
onClick: function onClick() {
return setIsEdit(false);
},
children: "\u53D6\u6D88"
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
className: "ml20",
type: "primary",
onClick: function onClick() {
return onSave();
},
children: "\u4FDD\u5B58"
})]
})]
});
};
return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
className: editormodules.wrap,
children: [!isEdit && showList(), isEdit && showEdit()]
});
};
/* harmony default export */ var MultipleEditor = ((0,_umi_production_exports.connect)(function (_ref4) {
var problemset = _ref4.problemset,
loading = _ref4.loading,
globalSetting = _ref4.globalSetting;
return {
problemset: problemset,
globalSetting: globalSetting,
loading: loading.effects
};
}, null, null, {
forwardRef: true
})( /*#__PURE__*/(0,_react_17_0_2_react.forwardRef)(SingleEditor)));
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/radio/index.js + 5 modules
var es_radio = __webpack_require__(5112);
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/Exercise/Detail/components/SingleEditor/index.tsx
var SingleEditor_excluded = ["problemset", "globalSetting", "loading", "dispatch", "onRef", "editData"];
var SingleEditor_tagList = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
var SingleEditor_SingleEditor = function SingleEditor(_ref, ref) {
var problemset = _ref.problemset,
globalSetting = _ref.globalSetting,
loading = _ref.loading,
dispatch = _ref.dispatch,
_ref$onRef = _ref.onRef,
onRef = _ref$onRef === void 0 ? function () {} : _ref$onRef,
editData = _ref.editData,
props = objectWithoutProperties_default()(_ref, SingleEditor_excluded);
var _useState = (0,_react_17_0_2_react.useState)([]),
_useState2 = slicedToArray_default()(_useState, 2),
questionChoiceList = _useState2[0],
setQuestionChoiceList = _useState2[1];
var _useState3 = (0,_react_17_0_2_react.useState)(),
_useState4 = slicedToArray_default()(_useState3, 2),
activeEditor = _useState4[0],
setActiveEditor = _useState4[1];
var _useState5 = (0,_react_17_0_2_react.useState)([]),
_useState6 = slicedToArray_default()(_useState5, 2),
activeAnswer = _useState6[0],
setActiveAnswer = _useState6[1];
var _useState7 = (0,_react_17_0_2_react.useState)(''),
_useState8 = slicedToArray_default()(_useState7, 2),
title = _useState8[0],
setTitle = _useState8[1];
var _useState9 = (0,_react_17_0_2_react.useState)(0),
_useState10 = slicedToArray_default()(_useState9, 2),
score = _useState10[0],
setScore = _useState10[1];
var _useState11 = (0,_react_17_0_2_react.useState)(false),
_useState12 = slicedToArray_default()(_useState11, 2),
isEdit = _useState12[0],
setIsEdit = _useState12[1];
var params = (0,_umi_production_exports.useParams)();
(0,_react_17_0_2_react.useEffect)(function () {
setQuestionChoiceList(['', '', '', '']);
}, []);
(0,_react_17_0_2_react.useEffect)(function () {
if (!(editData !== null && editData !== void 0 && editData.question_choices)) {
setIsEdit(true);
return;
}
setTitle(editData === null || editData === void 0 ? void 0 : editData.question_title);
setScore(parseInt(editData === null || editData === void 0 ? void 0 : editData.question_score));
setQuestionChoiceList(editData === null || editData === void 0 ? void 0 : editData.question_choices.map(function (item) {
return item.choice_text;
}));
var answerIndexs = [];
editData === null || editData === void 0 || editData.standard_answer.map(function (item, index) {
answerIndexs.push(item - 1);
});
setActiveAnswer(answerIndexs);
}, [editData]);
(0,_react_17_0_2_react.useImperativeHandle)(ref, function () {
return {
onSave: onSave,
isEdit: isEdit
};
});
var onSave = /*#__PURE__*/function () {
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() {
var findNotAnswerIndex, choices, res;
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
if (title) {
_context.next = 3;
break;
}
message/* default */.ZP.info("请您输入题目");
return _context.abrupt("return", false);
case 3:
findNotAnswerIndex = questionChoiceList.findIndex(function (item) {
return !item;
});
if (!(findNotAnswerIndex > -1)) {
_context.next = 7;
break;
}
message/* default */.ZP.info("\u8BF7\u5148\u8F93\u5165 ".concat(SingleEditor_tagList[findNotAnswerIndex], " \u9009\u9879\u7684\u5185\u5BB9"));
return _context.abrupt("return", false);
case 7:
if (activeAnswer.length) {
_context.next = 10;
break;
}
message/* default */.ZP.info("请设置本题的正确答案,点击选项A/B...即可完成设置");
return _context.abrupt("return", false);
case 10:
if (!(activeAnswer.length < 1)) {
_context.next = 13;
break;
}
message/* default */.ZP.info("请选择答案");
return _context.abrupt("return", false);
case 13:
choices = questionChoiceList.map(function (item, index) {
return {
choice_text: item,
is_answer: activeAnswer.includes(index) ? index + 1 : 0
};
});
if (!editData.question_id) {
_context.next = 20;
break;
}
_context.next = 17;
return (0,service_polls/* putExerciseBankQuestions */.Kc)({
"id": editData.question_id,
"question_title": title,
"question_type": 1,
"question_score": score,
"question_choices": choices.map(function (item) {
return item.choice_text;
}),
"standard_answers": choices.filter(function (item) {
return item.is_answer;
}).map(function (item) {
return item.is_answer;
})
});
case 17:
res = _context.sent;
_context.next = 23;
break;
case 20:
_context.next = 22;
return (0,service_polls/* addExerciseBankQuestions */.iV)({
"exercise_bank_id": params.topicId,
"question_title": title,
"question_type": 1,
"question_score": "5.0",
"question_choices": choices.map(function (item) {
return item.choice_text;
}),
"standard_answers": choices.filter(function (item) {
return item.is_answer;
}).map(function (item) {
return item.is_answer;
})
});
case 22:
res = _context.sent;
case 23:
if (res.status === 0) {
message/* default */.ZP.success("保存成功");
setIsEdit(false);
}
_context.next = 26;
return dispatch({
type: "polls/getExerciseBanks",
payload: objectSpread2_default()({}, params)
});
case 26:
case "end":
return _context.stop();
}
}, _callee);
}));
return function onSave() {
return _ref2.apply(this, arguments);
};
}();
var actionArr = [{
name: "删除",
icon: "iconfont c-light-black ml30 icon-shanchu",
id: "del"
}, {
name: "上移",
icon: "iconfont c-green ml30 icon-shangyi_Hover",
id: "up"
}, {
name: "下移",
icon: "iconfont c-green ml30 icon-xiayi_moren",
id: "down"
}, {
name: "编辑",
icon: "iconfont c-green ml30 icon-bianjishijuan3x",
id: "edit"
}];
var actionClick = /*#__PURE__*/function () {
var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3(item) {
return regeneratorRuntime_default()().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
_context3.t0 = item.id;
_context3.next = _context3.t0 === "del" ? 3 : _context3.t0 === "up" ? 5 : _context3.t0 === "down" ? 5 : _context3.t0 === "edit" ? 9 : 11;
break;
case 3:
modal/* default */.Z.confirm({
centered: true,
okText: '确定',
cancelText: '取消',
title: '确认要删除这个问题吗?',
onOk: function onOk() {
return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() {
return regeneratorRuntime_default()().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return (0,service_polls/* deleteExerciseBanksQuestion */.x$)({
pollsId: editData.question_id
});
case 2:
dispatch({
type: "polls/getExerciseBanks",
payload: objectSpread2_default()({}, params)
});
case 3:
case "end":
return _context2.stop();
}
}, _callee2);
}))();
}
});
return _context3.abrupt("break", 11);
case 5:
_context3.next = 7;
return (0,service_polls/* exercisesBanksMoveUpDown */.W)({
exerciseId: editData === null || editData === void 0 ? void 0 : editData.question_id,
opr: item.id
});
case 7:
dispatch({
type: "polls/getExerciseBanks",
payload: objectSpread2_default()({}, params)
});
return _context3.abrupt("break", 11);
case 9:
setIsEdit(true);
return _context3.abrupt("break", 11);
case 11:
case "end":
return _context3.stop();
}
}, _callee3);
}));
return function actionClick(_x) {
return _ref3.apply(this, arguments);
};
}();
var showList = function showList() {
var _editData$question_ch;
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: editormodules.questionType,
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
className: "font16 c-blue",
children: [editData.key, "\u3001\u5355\u9009\u9898"]
}), "\uFF08", editData.question_score, "\u5206\uFF09"]
}), !editData.hideAction && actionArr.map(function (item, index) {
if (item.id === "up" && editData.key === 1) return null;
if (item.id === "down" && editData.key === editData.len) return null;
return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
placement: "bottom",
title: item.name,
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
onClick: function onClick() {
return actionClick(item);
},
className: item.icon
})
}, index);
})]
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: "mt5",
children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, {
value: editData.question_title
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: editormodules.questionChoices,
children: editData === null || editData === void 0 || (_editData$question_ch = editData.question_choices) === null || _editData$question_ch === void 0 ? void 0 : _editData$question_ch.map(function (item, index) {
return /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
children: /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default */.ZP, {
checked: editData.standard_answer.includes(index + 1),
disabled: true,
children: [SingleEditor_tagList[index], "."]
}, index)
}), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
flex: "1",
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "c-black font14",
children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, {
value: item.choice_text
})
})
})]
});
})
})]
});
};
var showEdit = function showEdit() {
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: editormodules.questionType,
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "font16 c-blue",
children: "\u9009\u62E9\u9898"
}), "\uFF08\u5BA2\u89C2\u9898\uFF0C\u7531\u7CFB\u7EDF\u81EA\u52A8\u8BC4\u5206\uFF0C\u8BF7\u8BBE\u7F6E\u6807\u51C6\u7B54\u6848\uFF09"]
})
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", {
className: editormodules.titleWrap,
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: editormodules.required,
children: "*"
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: editormodules.title,
children: "\u9898\u5E72\uFF1A"
})]
}), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, {
id: "single-question-title",
watch: true,
height: 155,
placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u5E72",
defaultValue: title,
onChange: function onChange(value) {
return setTitle(value);
}
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", {
className: editormodules.titleWrap,
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: editormodules.required,
children: "*"
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
className: editormodules.title,
children: ["\u7B54\u6848\u9009\u9879\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: editormodules.colorGray,
children: "\u70B9\u51FB\u9009\u9879\u53EF\u8BBE\u7F6E\u6B63\u786E\u7B54\u6848"
})]
})]
}), questionChoiceList.map(function (item, index) {
return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: editormodules.choiceWrap,
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
title: "\u70B9\u51FB\u8BBE\u7F6E\u4E3A\u6807\u51C6\u7B54\u6848",
placement: "left",
children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: "".concat(editormodules.answer, " ").concat(activeAnswer.includes(index) ? editormodules.activeAnswer : ''),
onClick: function onClick() {
if (activeAnswer.includes(index)) {
setActiveAnswer(activeAnswer.filter(function (item) {
return item !== index;
}));
} else {
setActiveAnswer([].concat(toConsumableArray_default()(activeAnswer), [index]));
}
},
children: SingleEditor_tagList[index]
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: editormodules.editorWrap,
children: activeEditor === index ? /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, {
id: "single-question-option-".concat(index),
watch: true,
height: 155,
placeholder: "\u8BF7\u60A8\u8F93\u5165\u9009\u9879",
defaultValue: item,
onChange: function onChange(value) {
questionChoiceList[index] = value;
setQuestionChoiceList(questionChoiceList);
}
}) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: editormodules.htmlWrap,
onClick: function onClick() {
return setActiveEditor(index);
},
children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, {
value: item
})
})
}), index > 1 && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
title: "\u5220\u9664",
children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
className: "".concat(editormodules.deleteIcon, " iconfont icon-htmal5icon19"),
onClick: function onClick() {
return setQuestionChoiceList(questionChoiceList.filter(function (_, key) {
return key !== index;
}));
}
})
}), index < 7 && index === questionChoiceList.length - 1 && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
title: "\u65B0\u589E\u53C2\u8003\u7B54\u6848",
children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
className: "".concat(editormodules.addIcon, " iconfont icon-roundaddfill ml6"),
onClick: function onClick() {
return setQuestionChoiceList([].concat(toConsumableArray_default()(questionChoiceList), ['']));
}
})
})]
}, index);
}), /*#__PURE__*/(0,jsx_runtime.jsx)("p", {
className: "c-orange",
children: "\u6E29\u99A8\u63D0\u793A\uFF1A\u70B9\u51FB\u9009\u9879\u8F93\u5165\u6846\u53EF\u8BBE\u7F6E\u7B54\u6848\uFF1B\u9009\u4E2D\u7684\u9009\u9879\u5373\u4E3A\u6B63\u786E\u7B54\u6848\uFF0C\u9009\u62E9\u591A\u4E2A\u7B54\u6848\u5373\u4E3A\u591A\u9009\u9898"
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", {
className: "",
children: ["\u5206\u503C\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, {
value: score,
max: 10000,
min: -1,
onChange: function onChange(value) {
setScore(value);
}
}), " \u5206"]
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
className: "tr",
children: [editData.question_id && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
type: "default",
onClick: function onClick() {
return setIsEdit(false);
},
children: "\u53D6\u6D88"
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
className: "ml20",
type: "primary",
onClick: function onClick() {
return onSave();
},
children: "\u4FDD\u5B58"
})]
})]
});
};
return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
className: editormodules.wrap,
children: [!isEdit && showList(), isEdit && showEdit()]
});
};
/* harmony default export */ var components_SingleEditor = ((0,_umi_production_exports.connect)(function (_ref4) {
var problemset = _ref4.problemset,
loading = _ref4.loading,
globalSetting = _ref4.globalSetting;
return {
problemset: problemset,
globalSetting: globalSetting,
loading: loading.effects
};
}, null, null, {
forwardRef: true
})( /*#__PURE__*/(0,_react_17_0_2_react.forwardRef)(SingleEditor_SingleEditor)));
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/Exercise/Detail/components/JudgmentEditor/index.tsx
var JudgmentEditor_excluded = ["problemset", "globalSetting", "loading", "dispatch", "onRef", "editData"];
var JudgmentEditor_tagList = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
var JudgmentEditor = function JudgmentEditor(_ref, ref) {
var problemset = _ref.problemset,
globalSetting = _ref.globalSetting,
loading = _ref.loading,
dispatch = _ref.dispatch,
_ref$onRef = _ref.onRef,
onRef = _ref$onRef === void 0 ? function () {} : _ref$onRef,
editData = _ref.editData,
props = objectWithoutProperties_default()(_ref, JudgmentEditor_excluded);
var _useState = (0,_react_17_0_2_react.useState)(),
_useState2 = slicedToArray_default()(_useState, 2),
activeAnswer = _useState2[0],
setActiveAnswer = _useState2[1];
var _useState3 = (0,_react_17_0_2_react.useState)(''),
_useState4 = slicedToArray_default()(_useState3, 2),
title = _useState4[0],
setTitle = _useState4[1];
var _useState5 = (0,_react_17_0_2_react.useState)(false),
_useState6 = slicedToArray_default()(_useState5, 2),
isEdit = _useState6[0],
setIsEdit = _useState6[1];
var _useState7 = (0,_react_17_0_2_react.useState)(5),
_useState8 = slicedToArray_default()(_useState7, 2),
score = _useState8[0],
setScore = _useState8[1];
var params = (0,_umi_production_exports.useParams)();
(0,_react_17_0_2_react.useEffect)(function () {
if (!(editData !== null && editData !== void 0 && editData.question_choices)) {
setIsEdit(true);
return;
}
setTitle(editData === null || editData === void 0 ? void 0 : editData.question_title);
setScore(editData === null || editData === void 0 ? void 0 : editData.question_score);
// const answer = editData?.question_choices.find(item => item.is_answer);
setActiveAnswer(editData.standard_answer[0] + '');
}, [editData]);
(0,_react_17_0_2_react.useImperativeHandle)(ref, function () {
return {
onSave: onSave,
isEdit: isEdit
};
});
var onSave = /*#__PURE__*/function () {
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() {
var choices, res;
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
if (title) {
_context.next = 3;
break;
}
message/* default */.ZP.info("请您输入题干");
return _context.abrupt("return", false);
case 3:
if (activeAnswer) {
_context.next = 6;
break;
}
message/* default */.ZP.info("请先点击选择本选择题的正确选项");
return _context.abrupt("return", false);
case 6:
choices = [{
choice_text: "正确",
is_answer: activeAnswer === "1" ? 1 : 0
}, {
choice_text: "错误",
is_answer: activeAnswer === "2" ? 2 : 0
}];
if (!editData.question_id) {
_context.next = 13;
break;
}
_context.next = 10;
return (0,service_polls/* putExerciseBankQuestions */.Kc)({
"id": editData.question_id,
"question_title": title,
"question_type": 2,
"question_score": score,
"question_choices": choices.map(function (item) {
return item.choice_text;
}),
"standard_answers": choices.filter(function (item) {
return item.is_answer;
}).map(function (item) {
return item.is_answer;
})
});
case 10:
res = _context.sent;
_context.next = 16;
break;
case 13:
_context.next = 15;
return (0,service_polls/* addExerciseBankQuestions */.iV)({
"exercise_bank_id": params.topicId,
"question_title": title,
"question_type": 2,
"question_score": score,
"question_choices": choices.map(function (item) {
return item.choice_text;
}),
"standard_answers": choices.filter(function (item) {
return item.is_answer;
}).map(function (item) {
return item.is_answer;
})
});
case 15:
res = _context.sent;
case 16:
if (res.status === 0) {
message/* default */.ZP.success("保存成功");
setIsEdit(false);
}
dispatch({
type: "polls/getExerciseBanks",
payload: objectSpread2_default()({}, params)
});
return _context.abrupt("return", {
name: title,
choices: choices
});
case 19:
case "end":
return _context.stop();
}
}, _callee);
}));
return function onSave() {
return _ref2.apply(this, arguments);
};
}();
var actionArr = [{
name: "删除",
icon: "iconfont c-light-black ml30 icon-shanchu",
id: "del"
}, {
name: "上移",
icon: "iconfont c-green ml30 icon-shangyi_Hover",
id: "up"
}, {
name: "下移",
icon: "iconfont c-green ml30 icon-xiayi_moren",
id: "down"
}, {
name: "编辑",
icon: "iconfont c-green ml30 icon-bianjishijuan3x",
id: "edit"
}];
var actionClick = /*#__PURE__*/function () {
var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3(item) {
return regeneratorRuntime_default()().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
_context3.t0 = item.id;
_context3.next = _context3.t0 === "del" ? 3 : _context3.t0 === "up" ? 5 : _context3.t0 === "down" ? 5 : _context3.t0 === "edit" ? 9 : 11;
break;
case 3:
modal/* default */.Z.confirm({
centered: true,
okText: '确定',
cancelText: '取消',
title: '确认要删除这个问题吗?',
onOk: function onOk() {
return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() {
return regeneratorRuntime_default()().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return (0,service_polls/* deleteExerciseBanksQuestion */.x$)({
pollsId: editData.question_id
});
case 2:
dispatch({
type: "polls/getExerciseBanks",
payload: objectSpread2_default()({}, params)
});
case 3:
case "end":
return _context2.stop();
}
}, _callee2);
}))();
}
});
return _context3.abrupt("break", 11);
case 5:
_context3.next = 7;
return (0,service_polls/* exercisesBanksMoveUpDown */.W)({
exerciseId: editData === null || editData === void 0 ? void 0 : editData.question_id,
opr: item.id
});
case 7:
dispatch({
type: "polls/getExerciseBanks",
payload: objectSpread2_default()({}, params)
});
return _context3.abrupt("break", 11);
case 9:
setIsEdit(true);
return _context3.abrupt("break", 11);
case 11:
case "end":
return _context3.stop();
}
}, _callee3);
}));
return function actionClick(_x) {
return _ref3.apply(this, arguments);
};
}();
var showList = function showList() {
var _editData$question_ch;
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: editormodules.questionType,
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
className: "font16 c-blue",
children: [editData.key, "\u3001\u5224\u65AD\u9898"]
}), "\uFF08", editData.question_score, "\u5206\uFF09"]
}), !editData.hideAction && actionArr.map(function (item, index) {
if (item.id === "up" && editData.key === 1) return null;
if (item.id === "down" && editData.key === editData.len) return null;
return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
placement: "bottom",
title: item.name,
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
onClick: function onClick() {
return actionClick(item);
},
className: item.icon
})
}, index);
})]
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: "mt5",
children: editData.question_title
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: editormodules.questionChoices,
children: editData === null || editData === void 0 || (_editData$question_ch = editData.question_choices) === null || _editData$question_ch === void 0 ? void 0 : _editData$question_ch.map(function (item, index) {
return /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default */.ZP, {
checked: editData.standard_answer.includes(index + 1),
disabled: true,
children: [JudgmentEditor_tagList[index], ". ", /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "c-black font14",
children: item.choice_text
})]
}, index);
})
})]
});
};
var showEdit = function showEdit() {
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "font16 c-blue",
children: "\u5224\u65AD\u9898"
}), "\uFF08\u5BA2\u89C2\u9898\uFF0C\u7531\u7CFB\u7EDF\u81EA\u52A8\u8BC4\u5206\uFF0C\u8BF7\u8BBE\u7F6E\u6807\u51C6\u7B54\u6848\uFF09"]
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", {
className: editormodules.titleWrap,
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: editormodules.required,
children: "*"
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: editormodules.title,
children: "\u9898\u5E72\uFF1A"
})]
}), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, {
id: "single-question-title",
watch: true,
height: 155,
placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u5E72",
defaultValue: title,
onChange: function onChange(value) {
return setTitle(value);
}
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", {
className: editormodules.titleWrap,
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: editormodules.required,
children: "*"
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
className: editormodules.title,
children: ["\u7B54\u6848\u9009\u9879\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: editormodules.colorGray,
children: "\u70B9\u51FB\u9009\u9879\u53EF\u8BBE\u7F6E\u6B63\u786E\u7B54\u6848"
})]
})]
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default.Group */.ZP.Group, {
buttonStyle: "solid",
value: activeAnswer,
onChange: function onChange(e) {
return setActiveAnswer(e.target.value);
},
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, {
value: "1",
className: "".concat(editormodules.radio, " mr40"),
children: "\u6B63\u786E"
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, {
value: "2",
className: editormodules.radio,
children: "\u9519\u8BEF"
})]
}), /*#__PURE__*/(0,jsx_runtime.jsx)("p", {
className: "c-orange",
children: "\u6E29\u99A8\u63D0\u793A\uFF1A\u70B9\u51FB\u9009\u9879\uFF0C\u53EF\u4EE5\u76F4\u63A5\u8BBE\u7F6E\u6807\u51C6\u7B54\u6848"
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", {
className: "",
children: ["\u5206\u503C\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, {
value: score,
max: 10000,
min: -1,
onChange: function onChange(value) {
setScore(value);
}
}), " \u5206"]
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
className: "tr",
children: [editData.question_id && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
type: "default",
onClick: function onClick() {
return setIsEdit(false);
},
children: "\u53D6\u6D88"
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
className: "ml20",
type: "primary",
onClick: function onClick() {
return onSave();
},
children: "\u4FDD\u5B58"
})]
})]
});
};
return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
className: editormodules.wrap,
children: [!isEdit && showList(), isEdit && showEdit()]
});
};
/* harmony default export */ var components_JudgmentEditor = ((0,_umi_production_exports.connect)(function (_ref4) {
var problemset = _ref4.problemset,
loading = _ref4.loading,
globalSetting = _ref4.globalSetting;
return {
problemset: problemset,
globalSetting: globalSetting,
loading: loading.effects
};
}, null, null, {
forwardRef: true
})( /*#__PURE__*/(0,_react_17_0_2_react.forwardRef)(JudgmentEditor)));
// EXTERNAL MODULE: ./src/components/Editor/NullMDEditor.jsx
var NullMDEditor = __webpack_require__(92147);
// EXTERNAL MODULE: ./src/components/Editor/NullChildEditor/index.jsx + 1 modules
var NullChildEditor = __webpack_require__(5886);
// EXTERNAL MODULE: ./src/utils/util.tsx
var util = __webpack_require__(27291);
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/Exercise/Detail/components/CompletionEditor/index.tsx
var CompletionEditor_excluded = ["problemset", "globalSetting", "loading", "dispatch", "editData"];
var CompletionEditor_tagList = (/* unused pure expression or super */ null && (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']));
var CompletionEditor = function CompletionEditor(_ref, ref) {
var problemset = _ref.problemset,
globalSetting = _ref.globalSetting,
loading = _ref.loading,
dispatch = _ref.dispatch,
editData = _ref.editData,
props = objectWithoutProperties_default()(_ref, CompletionEditor_excluded);
var _useState = (0,_react_17_0_2_react.useState)(''),
_useState2 = slicedToArray_default()(_useState, 2),
title = _useState2[0],
setTitle = _useState2[1];
var _useState3 = (0,_react_17_0_2_react.useState)(''),
_useState4 = slicedToArray_default()(_useState3, 2),
analysis = _useState4[0],
setAnalysis = _useState4[1];
var _useState5 = (0,_react_17_0_2_react.useState)([]),
_useState6 = slicedToArray_default()(_useState5, 2),
answerList = _useState6[0],
setAnswerList = _useState6[1];
var _useState7 = (0,_react_17_0_2_react.useState)(''),
_useState8 = slicedToArray_default()(_useState7, 2),
activeOptionErrorIndex = _useState8[0],
setActiveOptionErrorIndex = _useState8[1];
var _useState9 = (0,_react_17_0_2_react.useState)(),
_useState10 = slicedToArray_default()(_useState9, 2),
checked = _useState10[0],
setChecked = _useState10[1];
var _useState11 = (0,_react_17_0_2_react.useState)(false),
_useState12 = slicedToArray_default()(_useState11, 2),
firstSetAnswerFlag = _useState12[0],
setFirstSetAnswerFlag = _useState12[1];
var _useState13 = (0,_react_17_0_2_react.useState)(5),
_useState14 = slicedToArray_default()(_useState13, 2),
score = _useState14[0],
setScore = _useState14[1];
var _useState15 = (0,_react_17_0_2_react.useState)(false),
_useState16 = slicedToArray_default()(_useState15, 2),
isEdit = _useState16[0],
setIsEdit = _useState16[1];
var params = (0,_umi_production_exports.useParams)();
(0,_react_17_0_2_react.useEffect)(function () {
if (!(editData !== null && editData !== void 0 && editData.question_title)) {
setIsEdit(true);
return;
}
setTitle(editData === null || editData === void 0 ? void 0 : editData.question_title);
setChecked(editData === null || editData === void 0 ? void 0 : editData.is_ordered);
setScore(editData === null || editData === void 0 ? void 0 : editData.question_score);
var answer = editData === null || editData === void 0 ? void 0 : editData.standard_answer.map(function (item) {
return item.answer_text;
});
setAnswerList(answer);
}, [problemset.editData]);
(0,_react_17_0_2_react.useEffect)(function () {
setFirstSetAnswerFlag(false);
}, [isEdit]);
(0,_react_17_0_2_react.useImperativeHandle)(ref, function () {
return {
onSave: onSave,
isEdit: isEdit
};
});
var onSave = /*#__PURE__*/function () {
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() {
var answerArray, isEmpty, res;
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
answerArray = [];
isEmpty = false;
answerList.forEach(function (answers, index) {
answerArray.push({
choice_id: index + 1,
answer_text: []
});
answers.forEach(function (item, itemIndex) {
answerArray[index].answer_text.push(item);
if (!item || !(0,util/* validateLength */.eR)(item, 10000)) {
setActiveOptionErrorIndex("".concat(index, "-").concat(itemIndex));
message/* default */.ZP.info(!item ? "\u7B54\u6848\uFF1A\u4E0D\u80FD\u4E3A\u7A7A" : "答案不能超过10000字符");
isEmpty = true;
}
});
});
if (!isEmpty) {
_context.next = 5;
break;
}
return _context.abrupt("return", false);
case 5:
if (!editData.question_id) {
_context.next = 11;
break;
}
_context.next = 8;
return (0,service_polls/* putExerciseBankQuestions */.Kc)({
"id": editData.question_id,
"question_title": title,
"question_type": 3,
"question_score": score,
"is_ordered": checked,
"standard_answers": answerArray
});
case 8:
res = _context.sent;
_context.next = 14;
break;
case 11:
_context.next = 13;
return (0,service_polls/* addExerciseBankQuestions */.iV)({
"exercise_bank_id": params.topicId,
"question_title": title,
"question_type": 3,
"question_score": score,
"is_ordered": checked,
"standard_answers": answerArray
});
case 13:
res = _context.sent;
case 14:
if (res.status === 0) {
message/* default */.ZP.success("保存成功");
setIsEdit(false);
}
dispatch({
type: "polls/getExerciseBanks",
payload: objectSpread2_default()({}, params)
});
return _context.abrupt("return", {
name: title,
analysis: analysis,
standard_answers: answerArray,
is_ordered: checked
});
case 17:
case "end":
return _context.stop();
}
}, _callee);
}));
return function onSave() {
return _ref2.apply(this, arguments);
};
}();
var handlePlaceholderChange = function handlePlaceholderChange(placeholderCountBefore, placeholderCountInRange, totalPlaceholderCount) {
var newStandardAnswers = answerList.slice();
if (placeholderCountInRange) {
newStandardAnswers.splice(placeholderCountBefore, placeholderCountInRange);
}
if (totalPlaceholderCount && firstSetAnswerFlag) {
for (var i = 0; i < totalPlaceholderCount; i++) {
newStandardAnswers.splice(placeholderCountBefore + i, 0, [""]);
}
}
setFirstSetAnswerFlag(true);
setAnswerList(newStandardAnswers);
};
var handleAnswerChange = function handleAnswerChange(index, itemIndex, val) {
setActiveOptionErrorIndex('');
var newStandardAnswers = answerList.slice();
newStandardAnswers[index][itemIndex] = val;
setAnswerList(newStandardAnswers);
};
var handleAddChildAnswer = function handleAddChildAnswer(index) {
var newStandardAnswers = answerList.slice();
newStandardAnswers[index] = [].concat(toConsumableArray_default()(newStandardAnswers[index]), ['']);
setAnswerList(newStandardAnswers);
};
var handleDeleteChildAnswer = function handleDeleteChildAnswer(index, childIndex) {
var newStandardAnswers = answerList.slice();
if (!newStandardAnswers[index][childIndex]) {
newStandardAnswers[index] = newStandardAnswers[index].filter(function (_, key) {
return key !== childIndex;
});
setAnswerList(newStandardAnswers);
return;
}
modal/* default */.Z.confirm({
centered: true,
okText: '确定',
cancelText: '取消',
title: '提示',
content: '确认要删除这个参考答案吗?',
className: editormodules.modal,
onOk: function onOk() {
newStandardAnswers[index] = newStandardAnswers[index].filter(function (_, key) {
return key !== childIndex;
});
setAnswerList(newStandardAnswers);
}
});
};
var handleDeleteChildAnswermain = function handleDeleteChildAnswermain(index) {
modal/* default */.Z.confirm({
centered: true,
okText: '确定',
cancelText: '取消',
title: '提示',
content: '确认要删除这个参考答案吗?',
className: editormodules.modal,
onOk: function onOk() {
var newStandardAnswers = answerList.slice();
newStandardAnswers = answerList.filter(function (_, key) {
return index !== key;
});
setAnswerList(newStandardAnswers);
}
});
};
var showEdit = function showEdit() {
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: editormodules.questionType,
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "font16 c-blue",
children: "\u586B\u7A7A\u9898"
}), "\uFF08\u5BA2\u89C2\u9898\uFF0C\u7531\u7CFB\u7EDF\u81EA\u52A8\u8BC4\u5206\uFF0C\u5141\u8BB8\u624B\u52A8\u8C03\u5206\uFF0C\u8BF7\u8BBE\u7F6E\u6807\u51C6\u7B54\u6848 \uFF1B\u652F\u6301\u6700\u591A5\u4E2A\u7A7A\uFF0C\u6BCF\u7A7A\u5F97\u5206\u6309\u7167\u672C\u9898\u7684\u603B\u5206\u5E73\u5747\u8BA1\u7B97\uFF09"]
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
children: /*#__PURE__*/(0,jsx_runtime.jsx)(NullMDEditor/* default */.Z, {
id: "completion-question-tittle",
placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u76EE",
height: 155,
defaultValue: title,
onChange: function onChange(value) {
return setTitle(value);
},
showNullButton: true,
onPlaceholderChange: handlePlaceholderChange
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: "mt20",
children: answerList.map(function (answers, index) {
return /*#__PURE__*/(0,jsx_runtime.jsx)(NullChildEditor/* default */.Z, {
answers: answers,
index: index,
is_md: true,
activeOptionErrorIndex: activeOptionErrorIndex,
onAnswerChange: handleAnswerChange,
addChildAnswer: handleAddChildAnswer,
deleteChildAnswer: handleDeleteChildAnswer,
deleteChildAnswermain: handleDeleteChildAnswermain
}, index);
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: "mt20",
children: answerList.length > 1 && /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z, {
checked: checked,
onChange: function onChange(e) {
return setChecked(e.target.checked);
},
className: "".concat(editormodules.color333, " font14"),
children: "\u591A\u4E2A\u586B\u7A7A\u7684\u7B54\u6848\u6709\u987A\u5E8F\u8981\u6C42"
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "".concat(editormodules.color999, " font12"),
children: "\uFF08\u9009\u4E2D\uFF0C\u6BCF\u4E2A\u586B\u7A7A\u7684\u7B54\u6848\u987A\u5E8F\u5FC5\u987B\u4E0E\u53C2\u8003\u7B54\u6848\u4E00\u81F4\uFF09"
})]
})
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", {
className: "",
children: ["\u5206\u503C\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, {
value: score,
max: 10000,
min: -1,
onChange: function onChange(value) {
setScore(value);
}
}), " \u5206"]
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
className: "tr",
children: [editData.question_id && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
type: "default",
onClick: function onClick() {
return setIsEdit(false);
},
children: "\u53D6\u6D88"
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
className: "ml20",
type: "primary",
onClick: function onClick() {
return onSave();
},
children: "\u4FDD\u5B58"
})]
})]
});
};
var actionArr = [{
name: "删除",
icon: "iconfont c-light-black ml30 icon-shanchu",
id: "del"
}, {
name: "上移",
icon: "iconfont c-green ml30 icon-shangyi_Hover",
id: "up"
}, {
name: "下移",
icon: "iconfont c-green ml30 icon-xiayi_moren",
id: "down"
}, {
name: "编辑",
icon: "iconfont c-green ml30 icon-bianjishijuan3x",
id: "edit"
}];
var actionClick = /*#__PURE__*/function () {
var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3(item) {
return regeneratorRuntime_default()().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
_context3.t0 = item.id;
_context3.next = _context3.t0 === "del" ? 3 : _context3.t0 === "up" ? 5 : _context3.t0 === "down" ? 5 : _context3.t0 === "edit" ? 9 : 11;
break;
case 3:
modal/* default */.Z.confirm({
centered: true,
okText: '确定',
cancelText: '取消',
title: '确认要删除这个问题吗?',
onOk: function onOk() {
return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() {
return regeneratorRuntime_default()().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return (0,service_polls/* deleteExerciseBanksQuestion */.x$)({
pollsId: editData.question_id
});
case 2:
dispatch({
type: "polls/getExerciseBanks",
payload: objectSpread2_default()({}, params)
});
case 3:
case "end":
return _context2.stop();
}
}, _callee2);
}))();
}
});
return _context3.abrupt("break", 11);
case 5:
_context3.next = 7;
return (0,service_polls/* exercisesBanksMoveUpDown */.W)({
exerciseId: editData === null || editData === void 0 ? void 0 : editData.question_id,
opr: item.id
});
case 7:
dispatch({
type: "polls/getExerciseBanks",
payload: objectSpread2_default()({}, params)
});
return _context3.abrupt("break", 11);
case 9:
setIsEdit(true);
return _context3.abrupt("break", 11);
case 11:
case "end":
return _context3.stop();
}
}, _callee3);
}));
return function actionClick(_x) {
return _ref3.apply(this, arguments);
};
}();
var showList = function showList() {
var _editData$standard_an;
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: editormodules.questionType,
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
className: "font16 c-blue",
children: [editData.key, "\u3001\u586B\u7A7A\u9898"]
}), "\uFF08", editData.question_score, "\u5206\uFF09"]
}), !editData.hideAction && actionArr.map(function (item, index) {
if (item.id === "up" && editData.key === 1) return null;
if (item.id === "down" && editData.key === editData.len) return null;
return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
placement: "bottom",
title: item.name,
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
onClick: function onClick() {
return actionClick(item);
},
className: item.icon
})
}, index);
})]
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: "mt5",
children: editData.question_title
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: editormodules.questionChoices,
children: editData === null || editData === void 0 || (_editData$standard_an = editData.standard_answer) === null || _editData$standard_an === void 0 ? void 0 : _editData$standard_an.map(function (item, index) {
return /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, {
children: ["\u7B54\u6848\uFF08\u586B\u7A7A", item.choice_id, "\uFF09\uFF1A"]
}), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
flex: "1",
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, {
checked: editData.standard_answer.includes(index),
disabled: true,
value: item.answer_text
}, index)
})]
});
})
})]
});
};
return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
className: editormodules.wrap,
children: [!isEdit && showList(), isEdit && showEdit()]
});
};
/* harmony default export */ var components_CompletionEditor = ((0,_umi_production_exports.connect)(function (_ref4) {
var problemset = _ref4.problemset,
loading = _ref4.loading,
globalSetting = _ref4.globalSetting;
return {
problemset: problemset,
globalSetting: globalSetting,
loading: loading.effects
};
}, null, null, {
forwardRef: true
})( /*#__PURE__*/(0,_react_17_0_2_react.forwardRef)(CompletionEditor)));
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/Exercise/Detail/components/SubjectiveEditor/index.tsx
var SubjectiveEditor_excluded = ["problemset", "globalSetting", "loading", "dispatch", "onRef", "editData"];
var SubjectiveEditor_tagList = (/* unused pure expression or super */ null && (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']));
var SubjectiveEditor = function SubjectiveEditor(_ref, ref) {
var problemset = _ref.problemset,
globalSetting = _ref.globalSetting,
loading = _ref.loading,
dispatch = _ref.dispatch,
_ref$onRef = _ref.onRef,
onRef = _ref$onRef === void 0 ? function () {} : _ref$onRef,
editData = _ref.editData,
props = objectWithoutProperties_default()(_ref, SubjectiveEditor_excluded);
var _useState = (0,_react_17_0_2_react.useState)(''),
_useState2 = slicedToArray_default()(_useState, 2),
title = _useState2[0],
setTitle = _useState2[1];
var _useState3 = (0,_react_17_0_2_react.useState)(''),
_useState4 = slicedToArray_default()(_useState3, 2),
analysis = _useState4[0],
setAnalysis = _useState4[1];
var _useState5 = (0,_react_17_0_2_react.useState)(''),
_useState6 = slicedToArray_default()(_useState5, 2),
answer = _useState6[0],
setAnswer = _useState6[1];
var _useState7 = (0,_react_17_0_2_react.useState)(5),
_useState8 = slicedToArray_default()(_useState7, 2),
score = _useState8[0],
setScore = _useState8[1];
var _useState9 = (0,_react_17_0_2_react.useState)(false),
_useState10 = slicedToArray_default()(_useState9, 2),
isEdit = _useState10[0],
setIsEdit = _useState10[1];
var params = (0,_umi_production_exports.useParams)();
(0,_react_17_0_2_react.useEffect)(function () {
var _editData$standard_an;
if (!(editData !== null && editData !== void 0 && editData.question_title)) {
setIsEdit(true);
return;
}
setTitle(editData === null || editData === void 0 ? void 0 : editData.question_title);
setAnswer(editData === null || editData === void 0 || (_editData$standard_an = editData.standard_answer) === null || _editData$standard_an === void 0 ? void 0 : _editData$standard_an[0]);
setScore(editData === null || editData === void 0 ? void 0 : editData.question_score);
}, [problemset.editData]);
(0,_react_17_0_2_react.useImperativeHandle)(ref, function () {
return {
onSave: onSave,
isEdit: isEdit
};
});
var onSave = /*#__PURE__*/function () {
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() {
var res;
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
if (title) {
_context.next = 3;
break;
}
message/* default */.ZP.info("请您输入题干");
return _context.abrupt("return", false);
case 3:
if (!editData.question_id) {
_context.next = 9;
break;
}
_context.next = 6;
return (0,service_polls/* putExerciseBankQuestions */.Kc)({
"id": editData.question_id,
"question_title": title,
"question_type": 4,
"question_score": score,
"standard_answers": [answer]
});
case 6:
res = _context.sent;
_context.next = 12;
break;
case 9:
_context.next = 11;
return (0,service_polls/* addExerciseBankQuestions */.iV)({
"exercise_bank_id": params.topicId,
"question_title": title,
"question_type": 4,
"question_score": score,
"standard_answers": [answer]
});
case 11:
res = _context.sent;
case 12:
if (res.status === 0) {
message/* default */.ZP.success("保存成功");
setIsEdit(false);
dispatch({
type: "polls/getExerciseBanks",
payload: objectSpread2_default()({}, params)
});
}
return _context.abrupt("return", {
name: title,
answer_texts: [answer],
analysis: analysis
});
case 14:
case "end":
return _context.stop();
}
}, _callee);
}));
return function onSave() {
return _ref2.apply(this, arguments);
};
}();
var showEdit = function showEdit() {
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: editormodules.questionType,
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "font16 c-blue",
children: "\u7B80\u7B54\u9898"
}), "\uFF08\u4E3B\u89C2\u9898\uFF0C\u672A\u4F5C\u7B54\u7684\u60C5\u51B5\u4E0B\u81EA\u52A8\u8BC4\u4E3A\u96F6\u5206\uFF09"]
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, {
id: "single-question-title",
watch: true,
height: 155,
placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u5E72",
defaultValue: title,
onChange: function onChange(value) {
return setTitle(value);
}
}), /*#__PURE__*/(0,jsx_runtime.jsx)("p", {
className: editormodules.titleWrap,
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: editormodules.title,
children: "\u53C2\u8003\u7B54\u6848\uFF1A"
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, {
id: "single-question-reference-answer",
watch: true,
height: 155,
placeholder: "\u8BF7\u60A8\u8F93\u5165\u53C2\u8003\u7B54\u6848",
defaultValue: answer,
onChange: function onChange(value) {
return setAnswer(value);
}
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", {
className: "",
children: ["\u5206\u503C\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, {
value: score,
max: 10000,
min: -1,
onChange: function onChange(value) {
setScore(value);
}
}), " \u5206"]
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
className: "tr",
children: [editData.question_id && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
type: "default",
onClick: function onClick() {
return setIsEdit(false);
},
children: "\u53D6\u6D88"
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
className: "ml20",
type: "primary",
onClick: function onClick() {
return onSave();
},
children: "\u4FDD\u5B58"
})]
})]
});
};
var actionArr = [{
name: "删除",
icon: "iconfont c-light-black ml30 icon-shanchu",
id: "del"
}, {
name: "上移",
icon: "iconfont c-green ml30 icon-shangyi_Hover",
id: "up"
}, {
name: "下移",
icon: "iconfont c-green ml30 icon-xiayi_moren",
id: "down"
}, {
name: "编辑",
icon: "iconfont c-green ml30 icon-bianjishijuan3x",
id: "edit"
}];
var actionClick = /*#__PURE__*/function () {
var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3(item) {
return regeneratorRuntime_default()().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
_context3.t0 = item.id;
_context3.next = _context3.t0 === "del" ? 3 : _context3.t0 === "up" ? 5 : _context3.t0 === "down" ? 5 : _context3.t0 === "edit" ? 9 : 11;
break;
case 3:
modal/* default */.Z.confirm({
centered: true,
okText: '确定',
cancelText: '取消',
title: '确认要删除这个问题吗?',
onOk: function onOk() {
return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() {
return regeneratorRuntime_default()().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return (0,service_polls/* deleteExerciseBanksQuestion */.x$)({
pollsId: editData.question_id
});
case 2:
dispatch({
type: "polls/getExerciseBanks",
payload: objectSpread2_default()({}, params)
});
case 3:
case "end":
return _context2.stop();
}
}, _callee2);
}))();
}
});
return _context3.abrupt("break", 11);
case 5:
_context3.next = 7;
return (0,service_polls/* exercisesBanksMoveUpDown */.W)({
exerciseId: editData === null || editData === void 0 ? void 0 : editData.question_id,
opr: item.id
});
case 7:
dispatch({
type: "polls/getExerciseBanks",
payload: objectSpread2_default()({}, params)
});
return _context3.abrupt("break", 11);
case 9:
setIsEdit(true);
return _context3.abrupt("break", 11);
case 11:
case "end":
return _context3.stop();
}
}, _callee3);
}));
return function actionClick(_x) {
return _ref3.apply(this, arguments);
};
}();
var showList = function showList() {
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: editormodules.questionType,
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
className: "font16 c-blue",
children: [editData.key, "\u3001\u7B80\u7B54\u9898"]
}), "\uFF08", editData.question_score, "\u5206\uFF09"]
}), !editData.hideAction && actionArr.map(function (item, index) {
if (item.id === "up" && editData.key === 1) return null;
if (item.id === "down" && editData.key === editData.len) return null;
return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
placement: "bottom",
title: item.name,
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
onClick: function onClick() {
return actionClick(item);
},
className: item.icon
})
}, index);
})]
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: "mt5",
children: editData.question_title
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: editormodules.questionChoices,
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("p", {
children: /*#__PURE__*/(0,jsx_runtime.jsx)("strong", {
children: "\u53C2\u8003\u7B54\u6848\uFF1A"
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, {
value: answer
})]
})]
});
};
return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
className: editormodules.wrap,
children: [!isEdit && showList(), isEdit && showEdit()]
});
};
/* harmony default export */ var components_SubjectiveEditor = ((0,_umi_production_exports.connect)(function (_ref4) {
var problemset = _ref4.problemset,
loading = _ref4.loading,
globalSetting = _ref4.globalSetting;
return {
problemset: problemset,
globalSetting: globalSetting,
loading: loading.effects
};
}, null, null, {
forwardRef: true
})( /*#__PURE__*/(0,_react_17_0_2_react.forwardRef)(SubjectiveEditor)));
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/Exercise/Detail/components/ShixunEditor/index.tsx
var ShixunEditor_excluded = ["problemset", "globalSetting", "loading", "dispatch", "editData"];
var ShixunEditor_tagList = (/* unused pure expression or super */ null && (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']));
var ShixunEditor = function ShixunEditor(_ref, ref) {
var problemset = _ref.problemset,
globalSetting = _ref.globalSetting,
loading = _ref.loading,
dispatch = _ref.dispatch,
editData = _ref.editData,
props = objectWithoutProperties_default()(_ref, ShixunEditor_excluded);
var _useState = (0,_react_17_0_2_react.useState)(''),
_useState2 = slicedToArray_default()(_useState, 2),
name = _useState2[0],
setName = _useState2[1];
var _useState3 = (0,_react_17_0_2_react.useState)(''),
_useState4 = slicedToArray_default()(_useState3, 2),
title = _useState4[0],
setTitle = _useState4[1];
var _useState5 = (0,_react_17_0_2_react.useState)(''),
_useState6 = slicedToArray_default()(_useState5, 2),
analysis = _useState6[0],
setAnalysis = _useState6[1];
var _useState7 = (0,_react_17_0_2_react.useState)([]),
_useState8 = slicedToArray_default()(_useState7, 2),
answerList = _useState8[0],
setAnswerList = _useState8[1];
var _useState9 = (0,_react_17_0_2_react.useState)(''),
_useState10 = slicedToArray_default()(_useState9, 2),
activeOptionErrorIndex = _useState10[0],
setActiveOptionErrorIndex = _useState10[1];
var _useState11 = (0,_react_17_0_2_react.useState)(),
_useState12 = slicedToArray_default()(_useState11, 2),
checked = _useState12[0],
setChecked = _useState12[1];
var _useState13 = (0,_react_17_0_2_react.useState)(false),
_useState14 = slicedToArray_default()(_useState13, 2),
firstSetAnswerFlag = _useState14[0],
setFirstSetAnswerFlag = _useState14[1];
var _useState15 = (0,_react_17_0_2_react.useState)([]),
_useState16 = slicedToArray_default()(_useState15, 2),
score = _useState16[0],
setScore = _useState16[1];
var _useState17 = (0,_react_17_0_2_react.useState)(false),
_useState18 = slicedToArray_default()(_useState17, 2),
isEdit = _useState18[0],
setIsEdit = _useState18[1];
var params = (0,_umi_production_exports.useParams)();
(0,_react_17_0_2_react.useEffect)(function () {
var _editData$shixun;
if (editData.edit) {
setIsEdit(true);
}
setName(editData.shixun_name);
setTitle(editData.question_title);
var arr = [];
(_editData$shixun = editData.shixun) === null || _editData$shixun === void 0 || _editData$shixun.map(function (item) {
arr.push(item.challenge_score);
});
setScore(arr);
}, [editData]);
(0,_react_17_0_2_react.useEffect)(function () {
setFirstSetAnswerFlag(false);
}, [isEdit]);
(0,_react_17_0_2_react.useImperativeHandle)(ref, function () {
return {
onSave: onSave,
isEdit: isEdit
};
});
var onSave = /*#__PURE__*/function () {
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() {
var answerArray, isEmpty, res;
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
answerArray = [];
isEmpty = false;
if (!isEmpty) {
_context.next = 4;
break;
}
return _context.abrupt("return", false);
case 4:
if (!editData.question_id) {
_context.next = 10;
break;
}
_context.next = 7;
return (0,service_polls/* putExerciseBankQuestions */.Kc)({
"id": editData.question_id,
"question_title": title,
"shixun_name": name,
"shixun_id": editData.shixun_id,
"question_type": 5,
"question_scores": score
});
case 7:
res = _context.sent;
_context.next = 13;
break;
case 10:
_context.next = 12;
return (0,service_polls/* addExerciseBankQuestions */.iV)({
"exercise_bank_id": params.topicId,
"question_title": title,
"shixun_name": name,
"shixun_id": editData.shixun_id,
"question_type": 5,
"question_scores": score
});
case 12:
res = _context.sent;
case 13:
if (res.status === 0) {
message/* default */.ZP.success("保存成功");
setIsEdit(false);
}
_context.next = 16;
return dispatch({
type: "polls/getExerciseBanks",
payload: objectSpread2_default()({}, params)
});
case 16:
return _context.abrupt("return", {
name: title,
analysis: analysis,
standard_answers: answerArray,
is_ordered: checked
});
case 17:
case "end":
return _context.stop();
}
}, _callee);
}));
return function onSave() {
return _ref2.apply(this, arguments);
};
}();
var showEdit = function showEdit() {
var _editData$shixun2;
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: editormodules.questionType,
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "font16 c-blue",
children: "\u5B9E\u8BAD\u9898"
}), "\uFF08\u5BA2\u89C2\u9898\uFF0C\u7531\u7CFB\u7EDF\u81EA\u52A8\u8BC4\u5206\uFF0C\u5141\u8BB8\u624B\u52A8\u8C03\u5206\uFF09"]
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: "mt10",
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, {
defaultValue: name,
onChange: function onChange(e) {
;
setName(e.target.value);
}
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: "mt10",
children: /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, {
id: "single-question-option-0",
height: 155,
placeholder: "\u8BF7\u8F93\u5165\u5B9E\u8BAD\u9898\u5B8C\u6210\u8981\u6C42",
defaultValue: title,
onChange: function onChange(value) {
setTitle(value);
}
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: "mt20",
children: (_editData$shixun2 = editData.shixun) === null || _editData$shixun2 === void 0 ? void 0 : _editData$shixun2.map(function (item, index) {
return /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
gutter: [20, 20],
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, {
flex: "1",
children: [index + 1, ".", item.challenge_name]
}), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, {
defaultValue: score[index],
onChange: function onChange(value) {
score[index] = value;
setScore(score);
console.log("srore:L", score[index]);
}
})
})]
});
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: "mt20",
children: answerList.length > 1 && /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z, {
checked: checked,
onChange: function onChange(e) {
return setChecked(e.target.checked);
},
className: "".concat(editormodules.color333, " font14"),
children: "\u591A\u4E2A\u586B\u7A7A\u7684\u7B54\u6848\u6709\u987A\u5E8F\u8981\u6C42"
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "".concat(editormodules.color999, " font12"),
children: "\uFF08\u9009\u4E2D\uFF0C\u6BCF\u4E2A\u586B\u7A7A\u7684\u7B54\u6848\u987A\u5E8F\u5FC5\u987B\u4E0E\u53C2\u8003\u7B54\u6848\u4E00\u81F4\uFF09"
})]
})
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
className: "tr",
children: [!(editData !== null && editData !== void 0 && editData.edit) && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
type: "default",
onClick: function onClick() {
return setIsEdit(false);
},
children: "\u53D6\u6D88"
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
className: "ml20",
type: "primary",
onClick: function onClick() {
return onSave();
},
children: "\u4FDD\u5B58"
})]
})]
});
};
var actionArr = [{
name: "删除",
icon: "iconfont c-light-black ml30 icon-shanchu",
id: "del"
}, {
name: "上移",
icon: "iconfont c-green ml30 icon-shangyi_Hover",
id: "up"
}, {
name: "下移",
icon: "iconfont c-green ml30 icon-xiayi_moren",
id: "down"
}, {
name: "编辑",
icon: "iconfont c-green ml30 icon-bianjishijuan3x",
id: "edit"
}];
var actionClick = /*#__PURE__*/function () {
var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3(item) {
return regeneratorRuntime_default()().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
_context3.t0 = item.id;
_context3.next = _context3.t0 === "del" ? 3 : _context3.t0 === "up" ? 5 : _context3.t0 === "down" ? 5 : _context3.t0 === "edit" ? 9 : 11;
break;
case 3:
modal/* default */.Z.confirm({
centered: true,
okText: '确定',
cancelText: '取消',
title: '确认要删除这个问题吗?',
onOk: function onOk() {
return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() {
return regeneratorRuntime_default()().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return (0,service_polls/* deleteExerciseBanksQuestion */.x$)({
pollsId: editData.question_id
});
case 2:
dispatch({
type: "polls/getExerciseBanks",
payload: objectSpread2_default()({}, params)
});
case 3:
case "end":
return _context2.stop();
}
}, _callee2);
}))();
}
});
return _context3.abrupt("break", 11);
case 5:
_context3.next = 7;
return (0,service_polls/* exercisesBanksMoveUpDown */.W)({
exerciseId: editData === null || editData === void 0 ? void 0 : editData.question_id,
opr: item.id
});
case 7:
dispatch({
type: "polls/getExerciseBanks",
payload: objectSpread2_default()({}, params)
});
return _context3.abrupt("break", 11);
case 9:
setIsEdit(true);
return _context3.abrupt("break", 11);
case 11:
case "end":
return _context3.stop();
}
}, _callee3);
}));
return function actionClick(_x) {
return _ref3.apply(this, arguments);
};
}();
var showList = function showList() {
var _editData$shixun3;
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: editormodules.questionType,
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
className: "font16 c-blue",
children: [editData.key, "\u3001\u5B9E\u8BAD\u9898"]
}), "\uFF08", editData.question_score, "\u5206\uFF09"]
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: "tr",
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(_umi_production_exports.Link, {
target: "_blank",
to: "/shixuns/".concat(editData.shixun_identifier, "/challenges"),
children: "\u5B9E\u8BAD\u8BE6\u60C5"
}), !editData.hideAction && actionArr.map(function (item, index) {
if (item.id === "up" && editData.key === 1) return null;
if (item.id === "down" && editData.key === editData.len) return null;
return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
placement: "bottom",
title: item.name,
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
onClick: function onClick() {
return actionClick(item);
},
className: item.icon
})
}, index);
})]
})]
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: "font16",
children: editData.shixun_name
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: "mt30"
}), (_editData$shixun3 = editData.shixun) === null || _editData$shixun3 === void 0 ? void 0 : _editData$shixun3.map(function (item, index) {
return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
children: ["\u7B2C", index + 1, "\u5173 ", /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "ml10",
children: item.challenge_name
}), " ", /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "ml10",
children: item.challenge_score
})]
}, index);
})]
});
};
return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
className: editormodules.wrap,
children: [!isEdit && showList(), isEdit && showEdit()]
});
};
// export default connect(
// ({
// problemset,
// loading,
// globalSetting,
// }: {
// problemset: ProblemsetModelState;
// loading: Loading;
// globalSetting: GlobalSettingModelState;
// }) => ({
// problemset,
// globalSetting,
// loading: loading.effects,
// }),
// )(ShixunEditor);
/* harmony default export */ var components_ShixunEditor = ((0,_umi_production_exports.connect)(function (_ref4) {
var problemset = _ref4.problemset,
loading = _ref4.loading,
globalSetting = _ref4.globalSetting;
return {
problemset: problemset,
globalSetting: globalSetting,
loading: loading.effects
};
}, null, null, {
forwardRef: true
})( /*#__PURE__*/(0,_react_17_0_2_react.forwardRef)(ShixunEditor)));
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/Exercise/Detail/index.less?modules
// extracted by mini-css-extract-plugin
/* harmony default export */ var Detailmodules = ({"flex_box_center":"flex_box_center___eWsYC","flex_space_between":"flex_space_between___RALuo","flex_box_vertical_center":"flex_box_vertical_center___f7uVp","flex_box_center_end":"flex_box_center_end___UxPR3","flex_box_column":"flex_box_column___YUFuv","bg":"bg___zWTsF","containerTitle":"containerTitle___DzTZh","containerDesc":"containerDesc___a3TiA","listItem":"listItem____nHKG","info":"info___LWlgA","title":"title___gtaI4","titleLeft":"titleLeft___Ce3h9","titleRight":"titleRight___gARIc","acitons":"acitons___MrR2u","export":"export___u_8cL"});
// EXTERNAL MODULE: ./src/pages/User/Detail/Topics/components/SendToClassModal.tsx + 2 modules
var SendToClassModal = __webpack_require__(8979);
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/Exercise/Detail/index.tsx
var Detail_excluded = ["polls", "globalSetting", "loading", "user", "dispatch"];
var SubMenu = menu/* default */.Z.SubMenu;
var Content = layout/* default */.Z.Content,
Sider = layout/* default */.Z.Sider;
var ShixunsListPage = function ShixunsListPage(_ref) {
var _polls$exerciseBanks6, _polls$exerciseBanks7, _polls$exerciseBanks8, _polls$exerciseBanks9, _polls$exerciseBanks10, _polls$exerciseBanks11, _polls$exerciseBanks12, _polls$exerciseBanks13, _polls$exerciseBanks14, _polls$exerciseBanks15, _polls$exerciseBanks16, _polls$exerciseBanks17, _polls$exerciseBanks18, _polls$exerciseBanks19, _polls$exerciseBanks20, _polls$exerciseBanks21, _polls$exerciseBanks22, _polls$exerciseBanks23, _polls$exerciseBanks24, _polls$exerciseBanks25, _polls$exerciseBanks26, _polls$exerciseBanks27, _polls$exerciseBanks28, _polls$exerciseBanks29, _polls$exerciseBanks30, _polls$exerciseBanks31, _polls$exerciseBanks32, _polls$exerciseBanks33, _polls$exerciseBanks34;
var polls = _ref.polls,
globalSetting = _ref.globalSetting,
loading = _ref.loading,
user = _ref.user,
dispatch = _ref.dispatch,
props = objectWithoutProperties_default()(_ref, Detail_excluded);
var params = (0,_umi_production_exports.useParams)();
var location = (0,_umi_production_exports.useLocation)();
var userInfo = user.userInfo;
var _Form$useForm = es_form/* default */.Z.useForm(),
_Form$useForm2 = slicedToArray_default()(_Form$useForm, 1),
form = _Form$useForm2[0];
var _useState = (0,_react_17_0_2_react.useState)([]),
_useState2 = slicedToArray_default()(_useState, 2),
editData = _useState2[0],
setEditData = _useState2[1];
var _useState3 = (0,_react_17_0_2_react.useState)(false),
_useState4 = slicedToArray_default()(_useState3, 2),
isEdit = _useState4[0],
setIsEdit = _useState4[1];
var questionType = [{
name: "选择题",
id: 0
}, {
name: "判断题",
id: 2
}, {
name: "填空题",
id: 3
}, {
name: "简答题",
id: 4
}, {
name: "实训题",
id: 5
}];
var childrenRef = (0,_react_17_0_2_react.useRef)();
(0,_react_17_0_2_react.useEffect)(function () {
var _polls$exerciseBanks;
if ((_polls$exerciseBanks = polls.exerciseBanks) !== null && _polls$exerciseBanks !== void 0 && _polls$exerciseBanks.exercise_questions) {
var _polls$exerciseBanks2, _polls$exerciseBanks3, _polls$exerciseBanks4;
setEditData(toConsumableArray_default()((_polls$exerciseBanks2 = polls.exerciseBanks) === null || _polls$exerciseBanks2 === void 0 ? void 0 : _polls$exerciseBanks2.exercise_questions));
form.setFieldsValue({
exercise_name: (_polls$exerciseBanks3 = polls.exerciseBanks) === null || _polls$exerciseBanks3 === void 0 || (_polls$exerciseBanks3 = _polls$exerciseBanks3.exercise) === null || _polls$exerciseBanks3 === void 0 ? void 0 : _polls$exerciseBanks3.exercise_name,
exercise_description: (_polls$exerciseBanks4 = polls.exerciseBanks) === null || _polls$exerciseBanks4 === void 0 || (_polls$exerciseBanks4 = _polls$exerciseBanks4.exercise) === null || _polls$exerciseBanks4 === void 0 ? void 0 : _polls$exerciseBanks4.exercise_description
});
}
}, [polls.exerciseBanks]);
(0,_react_17_0_2_react.useEffect)(function () {
dispatch({
type: "polls/getExerciseBanks",
payload: objectSpread2_default()({}, params)
});
}, [params.categoryId]);
var save = /*#__PURE__*/function () {
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() {
var _polls$exerciseBanks5;
var value;
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return form.validateFields();
case 2:
value = form.getFieldValue();
value.is_md = true;
value.topicId = (_polls$exerciseBanks5 = polls.exerciseBanks) === null || _polls$exerciseBanks5 === void 0 || (_polls$exerciseBanks5 = _polls$exerciseBanks5.exercise) === null || _polls$exerciseBanks5 === void 0 ? void 0 : _polls$exerciseBanks5.id;
setIsEdit(false);
_context.next = 8;
return (0,service_polls/* putExerciseBanks */.hO)(objectSpread2_default()({}, value));
case 8:
dispatch({
type: "polls/getExerciseBanks",
payload: objectSpread2_default()({}, params)
});
case 9:
case "end":
return _context.stop();
}
}, _callee);
}));
return function save() {
return _ref2.apply(this, arguments);
};
}();
var addQuestion = /*#__PURE__*/function () {
var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2(type) {
var d;
return regeneratorRuntime_default()().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return childrenRef === null || childrenRef === void 0 ? void 0 : childrenRef.current;
case 2:
d = _context2.sent;
if (!(d !== null && d !== void 0 && d.isEdit)) {
_context2.next = 6;
break;
}
message/* default */.ZP.error("不能同时编辑两题");
return _context2.abrupt("return");
case 6:
if (type === 5) {
dispatch({
type: "classroomList/setActionTabs",
payload: {
key: "选用实践项目"
}
});
} else {
setEditData([].concat(toConsumableArray_default()(editData), [{
question_type: type
}]));
}
case 7:
case "end":
return _context2.stop();
}
}, _callee2);
}));
return function addQuestion(_x) {
return _ref3.apply(this, arguments);
};
}();
var handleSend = function handleSend() {
dispatch({
type: 'userDetail/setActionTabs',
payload: {
key: 'UserDetail-SendToClass',
params: {
object_id: [params.topicId],
object_type: 'exercise'
}
}
});
};
var renderQuestion = function renderQuestion() {
return editData === null || editData === void 0 ? void 0 : editData.map(function (v, k) {
v.key = k + 1;
v.len = editData.length;
if (v.question_type === 0) {
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(components_SingleEditor, {
ref: childrenRef,
editData: v
}), /*#__PURE__*/(0,jsx_runtime.jsx)(divider/* default */.Z, {})]
});
}
if (v.question_type === 1) {
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(MultipleEditor, {
ref: childrenRef,
editData: v
}), /*#__PURE__*/(0,jsx_runtime.jsx)(divider/* default */.Z, {})]
});
}
if (v.question_type === 2) {
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(components_JudgmentEditor, {
ref: childrenRef,
editData: v
}), /*#__PURE__*/(0,jsx_runtime.jsx)(divider/* default */.Z, {})]
});
}
if (v.question_type === 3) {
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(components_CompletionEditor, {
editData: v
}), /*#__PURE__*/(0,jsx_runtime.jsx)(divider/* default */.Z, {})]
});
}
if (v.question_type === 4) {
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(components_SubjectiveEditor, {
editData: v
}), /*#__PURE__*/(0,jsx_runtime.jsx)(divider/* default */.Z, {})]
});
}
if (v.question_type === 5) {
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(components_ShixunEditor, {
editData: v
}), /*#__PURE__*/(0,jsx_runtime.jsx)(divider/* default */.Z, {})]
});
}
});
};
return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
className: "edu-container",
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
className: "animated fadeIn",
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("aside", {
className: "mt10",
children: userInfo && /*#__PURE__*/(0,jsx_runtime.jsxs)(breadcrumb/* default */.Z, {
separator: ">",
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(breadcrumb/* default */.Z.Item, {
children: /*#__PURE__*/(0,jsx_runtime.jsx)(_umi_production_exports.Link, {
to: "/users/".concat(params.username, "/").concat(params.topictype === 'personal' ? 'topics' : 'topicbank', "/").concat(params.topictype),
children: params.topictype === 'personal' ? '我的题库' : '公共题库'
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)(breadcrumb/* default */.Z.Item, {
children: "\u8BE6\u60C5"
})]
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)("aside", {
className: [Detailmodules.title, 'mt20'].join(' '),
children: /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
style: {
width: "100%"
},
align: "middle",
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, {
flex: "1",
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("strong", {
className: "font20 ml5",
children: (_polls$exerciseBanks6 = polls.exerciseBanks) === null || _polls$exerciseBanks6 === void 0 || (_polls$exerciseBanks6 = _polls$exerciseBanks6.exercise) === null || _polls$exerciseBanks6 === void 0 ? void 0 : _polls$exerciseBanks6.exercise_name
}), /*#__PURE__*/(0,jsx_runtime.jsx)(util/* StatusClassroomsTags */.VV, {
status: [(_polls$exerciseBanks7 = polls.exerciseBanks) !== null && _polls$exerciseBanks7 !== void 0 && (_polls$exerciseBanks7 = _polls$exerciseBanks7.exercise) !== null && _polls$exerciseBanks7 !== void 0 && _polls$exerciseBanks7.is_public ? "公开" : "私有"]
})]
}), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
children: /*#__PURE__*/(0,jsx_runtime.jsx)(_umi_production_exports.Link, {
className: "font16 c-light-black",
to: "/users/".concat(userInfo.login, "/topics/").concat(params.topictype),
children: "\u8FD4\u56DE"
})
})]
})
})]
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
className: [Detailmodules.bg, 'pl30', 'pr30', 'pb30', 'mt20 relative'].join(' '),
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: Detailmodules["export"],
children: [((_polls$exerciseBanks8 = polls.exerciseBanks) === null || _polls$exerciseBanks8 === void 0 ? void 0 : _polls$exerciseBanks8.authorize) && /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("a", {
onClick: function onClick(e) {
e.preventDefault();
modal/* default */.Z.confirm({
centered: true,
okText: '确定',
cancelText: '取消',
title: "提示",
content: "是否确认删除?",
onOk: function () {
var _onOk = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3() {
var res;
return regeneratorRuntime_default()().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return (0,service_user/* deleteQuestionBanks */.Tv)({
object_type: "normal",
object_id: [params.topicId]
});
case 2:
res = _context3.sent;
if (res.status === 0) {
_umi_production_exports.history.push("/users/".concat(params.username, "/topics/personal"));
}
case 4:
case "end":
return _context3.stop();
}
}, _callee3);
}));
function onOk() {
return _onOk.apply(this, arguments);
}
return onOk;
}()
});
},
children: "\u5220\u9664"
}), /*#__PURE__*/(0,jsx_runtime.jsx)(_umi_production_exports.Link, {
to: "/users/".concat(userInfo.login, "/topics/").concat(params.topicId, "/").concat(params.topictype, "/exercise/edit"),
children: "\u7F16\u8F91"
})]
}), /*#__PURE__*/(0,jsx_runtime.jsx)("a", {
onClick: function onClick(e) {
e.preventDefault();
handleSend();
},
children: "\u53D1\u9001"
})]
}), /*#__PURE__*/(0,jsx_runtime.jsx)(tabs/* default */.Z, {
className: Detailmodules.tabs,
children: /*#__PURE__*/(0,jsx_runtime.jsx)(tabs/* default */.Z.TabPane, {
tab: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "font16 pt10 pb12",
children: "\u5185\u5BB9\u8BE6\u60C5"
}),
children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: "c-light-black",
children: (_polls$exerciseBanks9 = polls.exerciseBanks) === null || _polls$exerciseBanks9 === void 0 || (_polls$exerciseBanks9 = _polls$exerciseBanks9.exercise) === null || _polls$exerciseBanks9 === void 0 ? void 0 : _polls$exerciseBanks9.exercise_description
})
}, "1")
}), isEdit && /*#__PURE__*/(0,jsx_runtime.jsxs)(es_form/* default */.Z, {
layout: "vertical",
form: form,
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
name: "exercise_name",
label: "\u8BD5\u5377\u6807\u9898\uFF1A",
rules: [{
required: true,
message: "请填写试卷标题"
}],
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, {
maxLength: 60,
placeholder: "\u8BD5\u5377\u6807\u9898\uFF0C\u6700\u5927\u9650\u523660\u4E2A\u5B57\u7B26"
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
label: "\u8BD5\u5377\u987B\u77E5\uFF1A",
name: "exercise_description",
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z.TextArea, {
rows: 6,
placeholder: "\u8BF7\u5728\u6B64\u8F93\u5165\u672C\u6B21\u8BD5\u5377\u7B54\u9898\u7684\u76F8\u5173\u8BF4\u660E\uFF0C\u6700\u5927\u9650\u5236100\u4E2A\u5B57\u7B26"
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
className: "tr",
children: /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
type: "primary",
onClick: function onClick() {
save();
},
children: "\u4FDD\u5B58"
})
})]
})]
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", {
className: "mt10",
style: {
display: 'flex'
},
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
className: "fl",
style: {
flex: '1'
},
children: [!!((_polls$exerciseBanks10 = polls.exerciseBanks) !== null && _polls$exerciseBanks10 !== void 0 && (_polls$exerciseBanks10 = _polls$exerciseBanks10.exercise_types) !== null && _polls$exerciseBanks10 !== void 0 && _polls$exerciseBanks10.q_singles) && /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
className: "ml20",
children: ["\u5355\u9009\u9898", (_polls$exerciseBanks11 = polls.exerciseBanks) === null || _polls$exerciseBanks11 === void 0 || (_polls$exerciseBanks11 = _polls$exerciseBanks11.exercise_types) === null || _polls$exerciseBanks11 === void 0 ? void 0 : _polls$exerciseBanks11.q_singles, "\u9898\uFF0C\u5171", (_polls$exerciseBanks12 = polls.exerciseBanks) === null || _polls$exerciseBanks12 === void 0 || (_polls$exerciseBanks12 = _polls$exerciseBanks12.exercise_types) === null || _polls$exerciseBanks12 === void 0 ? void 0 : _polls$exerciseBanks12.q_singles_scores, "\u5206"]
}), !!((_polls$exerciseBanks13 = polls.exerciseBanks) !== null && _polls$exerciseBanks13 !== void 0 && (_polls$exerciseBanks13 = _polls$exerciseBanks13.exercise_types) !== null && _polls$exerciseBanks13 !== void 0 && _polls$exerciseBanks13.q_doubles) && /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
className: "ml20",
children: ["\u591A\u9009\u9898", (_polls$exerciseBanks14 = polls.exerciseBanks) === null || _polls$exerciseBanks14 === void 0 || (_polls$exerciseBanks14 = _polls$exerciseBanks14.exercise_types) === null || _polls$exerciseBanks14 === void 0 ? void 0 : _polls$exerciseBanks14.q_doubles, "\u9898\uFF0C\u5171", (_polls$exerciseBanks15 = polls.exerciseBanks) === null || _polls$exerciseBanks15 === void 0 || (_polls$exerciseBanks15 = _polls$exerciseBanks15.exercise_types) === null || _polls$exerciseBanks15 === void 0 ? void 0 : _polls$exerciseBanks15.q_doubles_scores, "\u5206"]
}), !!((_polls$exerciseBanks16 = polls.exerciseBanks) !== null && _polls$exerciseBanks16 !== void 0 && (_polls$exerciseBanks16 = _polls$exerciseBanks16.exercise_types) !== null && _polls$exerciseBanks16 !== void 0 && _polls$exerciseBanks16.q_judges) && /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
className: "ml20",
children: ["\u5224\u65AD\u9898", (_polls$exerciseBanks17 = polls.exerciseBanks) === null || _polls$exerciseBanks17 === void 0 || (_polls$exerciseBanks17 = _polls$exerciseBanks17.exercise_types) === null || _polls$exerciseBanks17 === void 0 ? void 0 : _polls$exerciseBanks17.q_judges, "\u9898\uFF0C\u5171", (_polls$exerciseBanks18 = polls.exerciseBanks) === null || _polls$exerciseBanks18 === void 0 || (_polls$exerciseBanks18 = _polls$exerciseBanks18.exercise_types) === null || _polls$exerciseBanks18 === void 0 ? void 0 : _polls$exerciseBanks18.q_judges_scores, "\u5206"]
}), !!((_polls$exerciseBanks19 = polls.exerciseBanks) !== null && _polls$exerciseBanks19 !== void 0 && (_polls$exerciseBanks19 = _polls$exerciseBanks19.exercise_types) !== null && _polls$exerciseBanks19 !== void 0 && _polls$exerciseBanks19.q_nulls) && /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
className: "ml20",
children: ["\u586B\u7A7A\u9898", (_polls$exerciseBanks20 = polls.exerciseBanks) === null || _polls$exerciseBanks20 === void 0 || (_polls$exerciseBanks20 = _polls$exerciseBanks20.exercise_types) === null || _polls$exerciseBanks20 === void 0 ? void 0 : _polls$exerciseBanks20.q_nulls, "\u9898\uFF0C\u5171", (_polls$exerciseBanks21 = polls.exerciseBanks) === null || _polls$exerciseBanks21 === void 0 || (_polls$exerciseBanks21 = _polls$exerciseBanks21.exercise_types) === null || _polls$exerciseBanks21 === void 0 ? void 0 : _polls$exerciseBanks21.q_nulls_scores, "\u5206"]
}), !!((_polls$exerciseBanks22 = polls.exerciseBanks) !== null && _polls$exerciseBanks22 !== void 0 && (_polls$exerciseBanks22 = _polls$exerciseBanks22.exercise_types) !== null && _polls$exerciseBanks22 !== void 0 && _polls$exerciseBanks22.q_mains) && /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
className: "ml20",
children: ["\u7B80\u7B54\u9898", (_polls$exerciseBanks23 = polls.exerciseBanks) === null || _polls$exerciseBanks23 === void 0 || (_polls$exerciseBanks23 = _polls$exerciseBanks23.exercise_types) === null || _polls$exerciseBanks23 === void 0 ? void 0 : _polls$exerciseBanks23.q_mains, "\u9898\uFF0C\u5171", (_polls$exerciseBanks24 = polls.exerciseBanks) === null || _polls$exerciseBanks24 === void 0 || (_polls$exerciseBanks24 = _polls$exerciseBanks24.exercise_types) === null || _polls$exerciseBanks24 === void 0 ? void 0 : _polls$exerciseBanks24.q_mains_scores, "\u5206"]
}), !!((_polls$exerciseBanks25 = polls.exerciseBanks) !== null && _polls$exerciseBanks25 !== void 0 && (_polls$exerciseBanks25 = _polls$exerciseBanks25.exercise_types) !== null && _polls$exerciseBanks25 !== void 0 && _polls$exerciseBanks25.q_shixuns) && /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
className: "ml20",
children: ["\u5B9E\u8BAD\u9898", (_polls$exerciseBanks26 = polls.exerciseBanks) === null || _polls$exerciseBanks26 === void 0 || (_polls$exerciseBanks26 = _polls$exerciseBanks26.exercise_types) === null || _polls$exerciseBanks26 === void 0 ? void 0 : _polls$exerciseBanks26.q_shixuns, "\u9898\uFF0C\u5171", (_polls$exerciseBanks27 = polls.exerciseBanks) === null || _polls$exerciseBanks27 === void 0 || (_polls$exerciseBanks27 = _polls$exerciseBanks27.exercise_types) === null || _polls$exerciseBanks27 === void 0 ? void 0 : _polls$exerciseBanks27.q_shixuns_scores, "\u5206"]
}), !!((_polls$exerciseBanks28 = polls.exerciseBanks) !== null && _polls$exerciseBanks28 !== void 0 && (_polls$exerciseBanks28 = _polls$exerciseBanks28.exercise_types) !== null && _polls$exerciseBanks28 !== void 0 && _polls$exerciseBanks28.q_pros) && /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
className: "ml20",
children: ["\u7F16\u7A0B\u9898", (_polls$exerciseBanks29 = polls.exerciseBanks) === null || _polls$exerciseBanks29 === void 0 || (_polls$exerciseBanks29 = _polls$exerciseBanks29.exercise_types) === null || _polls$exerciseBanks29 === void 0 ? void 0 : _polls$exerciseBanks29.q_pros, "\u9898\uFF0C\u5171", (_polls$exerciseBanks30 = polls.exerciseBanks) === null || _polls$exerciseBanks30 === void 0 || (_polls$exerciseBanks30 = _polls$exerciseBanks30.exercise_types) === null || _polls$exerciseBanks30 === void 0 ? void 0 : _polls$exerciseBanks30.q_pros_scores, "\u5206"]
})]
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "fr",
children: !!((_polls$exerciseBanks31 = polls.exerciseBanks) !== null && _polls$exerciseBanks31 !== void 0 && (_polls$exerciseBanks31 = _polls$exerciseBanks31.exercise_types) !== null && _polls$exerciseBanks31 !== void 0 && _polls$exerciseBanks31.q_counts) && /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
children: ["\u5408\u8BA1 ", /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "color-blue",
children: (_polls$exerciseBanks32 = polls.exerciseBanks) === null || _polls$exerciseBanks32 === void 0 || (_polls$exerciseBanks32 = _polls$exerciseBanks32.exercise_types) === null || _polls$exerciseBanks32 === void 0 ? void 0 : _polls$exerciseBanks32.q_counts
}), " \u9898\uFF0C \u5171 ", /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
className: "".concat(((_polls$exerciseBanks33 = polls.exerciseBanks) === null || _polls$exerciseBanks33 === void 0 || (_polls$exerciseBanks33 = _polls$exerciseBanks33.exercise_types) === null || _polls$exerciseBanks33 === void 0 ? void 0 : _polls$exerciseBanks33.q_scores) > 100 ? 'color-red font-bd' : 'color-orange'),
children: (_polls$exerciseBanks34 = polls.exerciseBanks) === null || _polls$exerciseBanks34 === void 0 || (_polls$exerciseBanks34 = _polls$exerciseBanks34.exercise_types) === null || _polls$exerciseBanks34 === void 0 ? void 0 : _polls$exerciseBanks34.q_scores
}), " \u5206"]
})
})]
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
className: [Detailmodules.bg, 'pt30', 'pl20', 'pr20', 'pb20', 'mt20'].join(' '),
children: [editData != '' && renderQuestion(), editData == '' && /*#__PURE__*/(0,jsx_runtime.jsx)(NoData/* default */.Z, {})]
}), /*#__PURE__*/(0,jsx_runtime.jsx)(SendToClassModal/* default */.Z, {})]
});
};
/* harmony default export */ var Detail = ((0,_umi_production_exports.connect)(function (_ref4) {
var polls = _ref4.polls,
loading = _ref4.loading,
user = _ref4.user,
globalSetting = _ref4.globalSetting;
return {
polls: polls,
globalSetting: globalSetting,
user: user,
loading: loading.effects
};
})(ShixunsListPage));
/***/ }),
/***/ 8979:
/*!**********************************************************************************!*\
!*** ./src/pages/User/Detail/Topics/components/SendToClassModal.tsx + 2 modules ***!
\**********************************************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
Z: function() { return /* binding */ components_SendToClassModal; }
});
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectSpread2.js
var objectSpread2 = __webpack_require__(26801);
var objectSpread2_default = /*#__PURE__*/__webpack_require__.n(objectSpread2);
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/regeneratorRuntime.js
var regeneratorRuntime = __webpack_require__(10574);
var regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(regeneratorRuntime);
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/asyncToGenerator.js
var asyncToGenerator = __webpack_require__(39343);
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/slicedToArray.js
var slicedToArray = __webpack_require__(11006);
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectWithoutProperties.js
var objectWithoutProperties = __webpack_require__(27161);
var objectWithoutProperties_default = /*#__PURE__*/__webpack_require__.n(objectWithoutProperties);
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
var _react_17_0_2_react = __webpack_require__(59301);
// EXTERNAL MODULE: ./src/.umi-production/exports.ts + 8 modules
var _umi_production_exports = __webpack_require__(66660);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/message/index.js + 4 modules
var message = __webpack_require__(8591);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/modal/index.js + 16 modules
var modal = __webpack_require__(43418);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/tabs/index.js + 24 modules
var tabs = __webpack_require__(99313);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/skeleton/index.js + 12 modules
var skeleton = __webpack_require__(59981);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/radio/index.js + 5 modules
var es_radio = __webpack_require__(5112);
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/components/SendToClassModal.less?modules
// extracted by mini-css-extract-plugin
/* harmony default export */ var SendToClassModalmodules = ({"title":"title___XAxiE","radioWrap":"radioWrap___k0pOB","radio":"radio___x9kMt","colorFF0000":"colorFF0000___IMgd0","pagination":"pagination___ou2ht","checkboxWrapper":"checkboxWrapper___kF7xI"});
// EXTERNAL MODULE: ./src/utils/util.tsx
var util = __webpack_require__(27291);
// EXTERNAL MODULE: ./src/components/ui-customization/index.tsx + 34 modules
var ui_customization = __webpack_require__(6487);
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/toConsumableArray.js
var toConsumableArray = __webpack_require__(93923);
var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/spin/index.js + 1 modules
var spin = __webpack_require__(71418);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/checkbox/index.js + 3 modules
var es_checkbox = __webpack_require__(24905);
// EXTERNAL MODULE: ./src/service/user.ts
var user = __webpack_require__(52138);
// EXTERNAL MODULE: ./node_modules/_react-infinite-scroller@1.2.4@react-infinite-scroller/index.js
var _react_infinite_scroller_1_2_4_react_infinite_scroller = __webpack_require__(26724);
var _react_infinite_scroller_1_2_4_react_infinite_scroller_default = /*#__PURE__*/__webpack_require__.n(_react_infinite_scroller_1_2_4_react_infinite_scroller);
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/jsx-runtime.js
var jsx_runtime = __webpack_require__(37712);
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/components/SendToSubject.tsx
var SendToSubject = function SendToSubject(_ref) {
var username = _ref.username,
setStages = _ref.setStages,
stages = _ref.stages,
hasError = _ref.hasError,
setHasError = _ref.setHasError;
var _useState = (0,_react_17_0_2_react.useState)(''),
_useState2 = slicedToArray_default()(_useState, 2),
searchValue = _useState2[0],
setSearchValue = _useState2[1];
var _useState3 = (0,_react_17_0_2_react.useState)(1),
_useState4 = slicedToArray_default()(_useState3, 2),
page = _useState4[0],
setPage = _useState4[1];
var _useState5 = (0,_react_17_0_2_react.useState)([]),
_useState6 = slicedToArray_default()(_useState5, 2),
subjectList = _useState6[0],
setSubjectList = _useState6[1];
var _useState7 = (0,_react_17_0_2_react.useState)(false),
_useState8 = slicedToArray_default()(_useState7, 2),
listLoading = _useState8[0],
setListLoading = _useState8[1];
var _useState9 = (0,_react_17_0_2_react.useState)(0),
_useState10 = slicedToArray_default()(_useState9, 2),
totalCount = _useState10[0],
setTotalCount = _useState10[1];
(0,_react_17_0_2_react.useEffect)(function () {
getSubjectList({
page: 1,
search: ''
}, true);
}, []);
var getSubjectList = /*#__PURE__*/function () {
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee(params, reset) {
var res;
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
setListLoading(true);
_context.next = 3;
return (0,user/* getPaths */.w3)({
username: username,
category: 'manage',
page: params.page,
search: params.search
});
case 3:
res = _context.sent;
setListLoading(false);
setSubjectList(function (pre) {
return reset ? res === null || res === void 0 ? void 0 : res.subjects : [].concat(toConsumableArray_default()(pre), toConsumableArray_default()(res === null || res === void 0 ? void 0 : res.subjects));
});
setTotalCount(res === null || res === void 0 ? void 0 : res.count);
case 7:
case "end":
return _context.stop();
}
}, _callee);
}));
return function getSubjectList(_x, _x2) {
return _ref2.apply(this, arguments);
};
}();
var scrollElementRef = (0,_react_17_0_2_react.useRef)();
return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: SendToClassModalmodules.wrap,
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: "mb10",
children: /*#__PURE__*/(0,jsx_runtime.jsx)(ui_customization/* CustomInput */.t7, {
placeholder: "\u8BF7\u8F93\u5165\u5B9E\u8DF5\u8BFE\u7A0B\u540D\u79F0\u7684\u5173\u952E\u5B57\u8FDB\u884C\u641C\u7D22",
value: searchValue,
style: {
width: 500
},
onChange: function onChange(value) {
setSearchValue(value);
setPage(1);
scrollElementRef.current.scrollTo({
behavior: 'smooth',
top: 0
});
getSubjectList({
page: 1,
search: value
}, true);
}
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)(spin/* default */.Z, {
spinning: listLoading,
children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: SendToClassModalmodules.radioWrap,
ref: scrollElementRef,
children: /*#__PURE__*/(0,jsx_runtime.jsx)((_react_infinite_scroller_1_2_4_react_infinite_scroller_default()), {
initialLoad: false,
pageStart: 1,
threshold: 6,
loadMore: function loadMore() {
setPage(page + 1);
getSubjectList({
page: page + 1,
search: searchValue
}, false);
},
hasMore: subjectList.length < totalCount,
useWindow: false,
children: /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Group */.ZP.Group, {
value: stages.subjectId,
onChange: function onChange(e) {
setStages({
subjectId: e.target.value,
stage_ids: []
});
setHasError(false);
},
children: subjectList.map(function (item) {
var options = item.stages.map(function (stage) {
return {
label: stage.name,
value: stage.id
};
});
return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default */.ZP, {
className: SendToClassModalmodules.radio,
value: item.id,
children: item.name
}), item.id === stages.subjectId && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: SendToClassModalmodules.checkboxWrapper,
children: [options.length > 0 && /*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z, {
indeterminate: stages.stage_ids.length > 0 && stages.stage_ids.length < options.length,
onChange: function onChange(e) {
setStages({
subjectId: item.id,
stage_ids: e.target.checked ? options.map(function (option) {
return option.value;
}) : []
});
},
checked: stages.stage_ids.length === options.length,
children: "\u5168\u9009"
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z.Group, {
options: options,
value: stages.stage_ids,
onChange: function onChange(checkedValue) {
return setStages({
subjectId: item.id,
stage_ids: checkedValue
});
}
})]
})]
}, item.id);
})
})
})
})
}), hasError && /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: SendToClassModalmodules.colorFF0000,
children: "\u8BF7\u5148\u9009\u62E9\u5B9E\u8DF5\u8BFE\u7A0B\u53CA\u7AE0\u8282"
})]
});
};
/* harmony default export */ var components_SendToSubject = (SendToSubject);
// EXTERNAL MODULE: ./src/components/ui-customization/reset.less?modules
var resetmodules = __webpack_require__(33529);
// EXTERNAL MODULE: ./src/service/account.ts
var account = __webpack_require__(43971);
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/components/SendToClassModal.tsx
var _excluded = ["userDetail", "globalSetting", "loading", "user", "dispatch"];
var SendToClassModal = function SendToClassModal(_ref) {
var _userDetail$actionTab4, _user$userInfo2, _userDetail$actionTab5;
var userDetail = _ref.userDetail,
globalSetting = _ref.globalSetting,
loading = _ref.loading,
user = _ref.user,
dispatch = _ref.dispatch,
props = objectWithoutProperties_default()(_ref, _excluded);
var _useState = (0,_react_17_0_2_react.useState)('course'),
_useState2 = slicedToArray_default()(_useState, 2),
activeKey = _useState2[0],
setActiveKey = _useState2[1];
var _useState3 = (0,_react_17_0_2_react.useState)(''),
_useState4 = slicedToArray_default()(_useState3, 2),
searchValue = _useState4[0],
setSearchValue = _useState4[1];
var _useState5 = (0,_react_17_0_2_react.useState)([]),
_useState6 = slicedToArray_default()(_useState5, 2),
courseList = _useState6[0],
setCourseList = _useState6[1];
var _useState7 = (0,_react_17_0_2_react.useState)(),
_useState8 = slicedToArray_default()(_useState7, 2),
radioValue = _useState8[0],
setRadioValue = _useState8[1];
var _useState9 = (0,_react_17_0_2_react.useState)(false),
_useState10 = slicedToArray_default()(_useState9, 2),
listLoading = _useState10[0],
setListLoading = _useState10[1];
var _useState11 = (0,_react_17_0_2_react.useState)(false),
_useState12 = slicedToArray_default()(_useState11, 2),
hasError = _useState12[0],
setHasError = _useState12[1];
(0,_react_17_0_2_react.useEffect)(function () {
if (userDetail.actionTabs.key === 'UserDetail-SendToClass') {
getCourseList(searchValue);
}
}, [userDetail.actionTabs.key]);
var getCourseList = /*#__PURE__*/function () {
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee(value) {
var res;
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
setListLoading(true);
_context.next = 3;
return dispatch({
type: 'userDetail/topicGetCourseList',
payload: {
search: value
}
});
case 3:
res = _context.sent;
if (res) {
setCourseList((res === null || res === void 0 ? void 0 : res.courses) || []);
}
setListLoading(false);
case 6:
case "end":
return _context.stop();
}
}, _callee);
}));
return function getCourseList(_x) {
return _ref2.apply(this, arguments);
};
}();
var _useState13 = (0,_react_17_0_2_react.useState)({
subjectId: '',
stage_ids: []
}),
_useState14 = slicedToArray_default()(_useState13, 2),
stages = _useState14[0],
setStages = _useState14[1];
var handleOk = /*#__PURE__*/function () {
var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() {
var _userDetail$actionTab, res, _userDetail$actionTab2, urlMapping, _userDetail$actionTab3, _user$userInfo, _res;
return regeneratorRuntime_default()().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
if (!(activeKey === 'course')) {
_context2.next = 11;
break;
}
if (radioValue) {
_context2.next = 4;
break;
}
setHasError(true);
return _context2.abrupt("return");
case 4:
_context2.next = 6;
return dispatch({
type: 'userDetail/topicSendToClass',
payload: objectSpread2_default()({
course_id: radioValue
}, (_userDetail$actionTab = userDetail.actionTabs) === null || _userDetail$actionTab === void 0 ? void 0 : _userDetail$actionTab.params)
});
case 6:
res = _context2.sent;
dispatch({
type: 'userDetail/setActionTabs',
payload: {}
});
if (res && res.status === 0) {
urlMapping = {
'normal': 'common_homework',
'group': 'group_homework',
'exercise': 'exercise',
'poll': 'poll',
'videos': 'video'
};
(0,util/* openNewWindow */.xg)("/classrooms/".concat(radioValue, "/").concat(urlMapping[(_userDetail$actionTab2 = userDetail.actionTabs) === null || _userDetail$actionTab2 === void 0 || (_userDetail$actionTab2 = _userDetail$actionTab2.params) === null || _userDetail$actionTab2 === void 0 ? void 0 : _userDetail$actionTab2.object_type]));
}
_context2.next = 18;
break;
case 11:
if (!(!stages.subjectId || !stages.stage_ids.length)) {
_context2.next = 14;
break;
}
setHasError(true);
return _context2.abrupt("return");
case 14:
_context2.next = 16;
return (0,account/* createSubjectVideo */.nI)({
id: (_userDetail$actionTab3 = userDetail.actionTabs) === null || _userDetail$actionTab3 === void 0 || (_userDetail$actionTab3 = _userDetail$actionTab3.params) === null || _userDetail$actionTab3 === void 0 ? void 0 : _userDetail$actionTab3.object_id,
login: (_user$userInfo = user.userInfo) === null || _user$userInfo === void 0 ? void 0 : _user$userInfo.login
}, {
stage_ids: stages.stage_ids
});
case 16:
_res = _context2.sent;
if (_res.status === 0) {
message/* default */.ZP.success('发送成功');
dispatch({
type: 'userDetail/setActionTabs',
payload: {}
});
(0,util/* openNewWindow */.xg)("/paths/".concat(stages.subjectId));
}
case 18:
case "end":
return _context2.stop();
}
}, _callee2);
}));
return function handleOk() {
return _ref3.apply(this, arguments);
};
}();
return /*#__PURE__*/(0,jsx_runtime.jsx)(modal/* default */.Z, {
centered: true,
keyboard: false,
closable: false,
destroyOnClose: true,
open: userDetail.actionTabs.key === 'UserDetail-SendToClass',
title: "\u53D1\u9001",
okText: "\u786E\u5B9A",
cancelText: "\u53D6\u6D88",
confirmLoading: loading['userDetail/sendToClass'],
width: 600,
afterClose: function afterClose() {
setHasError(false);
setCourseList([]);
setStages({
subjectId: '',
stage_ids: []
});
setSearchValue('');
},
onOk: handleOk,
wrapClassName: resetmodules/* default */.Z.CustomCss,
onCancel: function onCancel() {
dispatch({
type: 'userDetail/setActionTabs',
payload: {}
});
},
children: /*#__PURE__*/(0,jsx_runtime.jsx)(tabs/* default */.Z, {
activeKey: activeKey,
onChange: function onChange(key) {
setHasError(false);
setActiveKey(key);
},
items: [{
label: '课堂',
key: 'course',
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
className: SendToClassModalmodules.wrap,
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: "mb10",
children: /*#__PURE__*/(0,jsx_runtime.jsx)(ui_customization/* CustomInput */.t7, {
placeholder: "\u8BF7\u8F93\u5165\u8BFE\u5802\u540D\u79F0\u7684\u5173\u952E\u5B57\u8FDB\u884C\u641C\u7D22",
value: searchValue,
style: {
width: 500
},
onChange: function onChange(value) {
setSearchValue(value);
getCourseList(value);
}
})
}), /*#__PURE__*/(0,jsx_runtime.jsx)(skeleton/* default */.Z, {
active: true,
loading: listLoading,
children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: SendToClassModalmodules.radioWrap,
children: /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Group */.ZP.Group, {
value: radioValue,
onChange: function onChange(e) {
setRadioValue(e.target.value);
setHasError(false);
},
children: courseList.map(function (item, key) {
return /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default */.ZP, {
className: SendToClassModalmodules.radio,
value: item.course_id,
children: item.course_name
}, item.course_id);
})
})
})
}), ((_userDetail$actionTab4 = userDetail.actionTabs) === null || _userDetail$actionTab4 === void 0 || (_userDetail$actionTab4 = _userDetail$actionTab4.params) === null || _userDetail$actionTab4 === void 0 ? void 0 : _userDetail$actionTab4.object_type) !== 'videos' && /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: SendToClassModalmodules.title,
children: "\u6E29\u99A8\u63D0\u793A\uFF1A\u9009\u62E9\u7684\u9898\u5C06\u4F1A\u53D1\u9001\u5230\u6307\u5B9A\u8BFE\u5802"
}), hasError && /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
className: SendToClassModalmodules.colorFF0000,
children: "\u8BF7\u5148\u9009\u62E9\u8BFE\u5802"
})]
}),
show: true
}, {
label: '实践课程',
key: 'subject',
children: /*#__PURE__*/(0,jsx_runtime.jsx)(components_SendToSubject, {
username: (_user$userInfo2 = user.userInfo) === null || _user$userInfo2 === void 0 ? void 0 : _user$userInfo2.login,
stages: stages,
setStages: setStages,
hasError: hasError,
setHasError: setHasError
}),
show: ((_userDetail$actionTab5 = userDetail.actionTabs) === null || _userDetail$actionTab5 === void 0 || (_userDetail$actionTab5 = _userDetail$actionTab5.params) === null || _userDetail$actionTab5 === void 0 ? void 0 : _userDetail$actionTab5.object_type) === 'videos'
}].filter(function (item) {
return item.show;
})
})
});
};
/* harmony default export */ var components_SendToClassModal = ((0,_umi_production_exports.connect)(function (_ref4) {
var userDetail = _ref4.userDetail,
loading = _ref4.loading,
globalSetting = _ref4.globalSetting,
user = _ref4.user;
return {
userDetail: userDetail,
globalSetting: globalSetting,
loading: loading.effects,
user: user
};
})(SendToClassModal));
/***/ }),
/***/ 33529:
/*!************************************************************!*\
!*** ./src/components/ui-customization/reset.less?modules ***!
\************************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__) {
// extracted by mini-css-extract-plugin
/* harmony default export */ __webpack_exports__.Z = ({"flex_box_center":"flex_box_center___vG4eV","flex_space_between":"flex_space_between___qVVxe","flex_box_vertical_center":"flex_box_vertical_center___P8Z8s","flex_box_center_end":"flex_box_center_end___VMme3","flex_box_column":"flex_box_column___VMHwm","dropdownmenus":"dropdownmenus___oVzoj","popupClassNames":"popupClassNames___OcZq7","selectdown":"selectdown___mmcA8"});
/***/ })
}]);