You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2726 lines
123 KiB
2726 lines
123 KiB
"use strict";
|
|
(self["webpackChunk"] = self["webpackChunk"] || []).push([[75043],{
|
|
|
|
/***/ 56971:
|
|
/*!*****************************************!*\
|
|
!*** ./src/components/NoData/index.tsx ***!
|
|
\*****************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/objectSpread2.js */ 82242);
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_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_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ 59301);
|
|
/* harmony import */ var _assets_images_icons_nodata_png__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/assets/images/icons/nodata.png */ 93314);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! antd */ 3113);
|
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ 37712);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var noData = function noData(_ref) {
|
|
var img = _ref.img,
|
|
_ref$buttonProps = _ref.buttonProps,
|
|
buttonProps = _ref$buttonProps === void 0 ? {} : _ref$buttonProps,
|
|
_ref$styles = _ref.styles,
|
|
styles = _ref$styles === void 0 ? {} : _ref$styles,
|
|
customText = _ref.customText,
|
|
ButtonText = _ref.ButtonText,
|
|
ButtonClick = _ref.ButtonClick,
|
|
Buttonclass = _ref.Buttonclass,
|
|
ButtonTwo = _ref.ButtonTwo,
|
|
imgStyles = _ref.imgStyles,
|
|
_ref$loading = _ref.loading,
|
|
loading = _ref$loading === void 0 ? false : _ref$loading;
|
|
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsxs)("section", {
|
|
className: "tc animated fadeIn",
|
|
style: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()({}, {
|
|
color: '#999',
|
|
margin: '100px auto',
|
|
visibility: loading ? 'hidden' : 'visible'
|
|
}), styles),
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("img", {
|
|
src: img || _assets_images_icons_nodata_png__WEBPACK_IMPORTED_MODULE_2__,
|
|
style: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()({}, imgStyles), {}, {
|
|
pointerEvents: "none",
|
|
userSelect: "none"
|
|
})
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)("p", {
|
|
className: "mt20 font14",
|
|
children: customText || '暂时还没有相关数据哦!'
|
|
}), ButtonText && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(antd__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .ZP, _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()({
|
|
className: Buttonclass,
|
|
onClick: ButtonClick
|
|
}, buttonProps), {}, {
|
|
children: ButtonText
|
|
})), ButtonTwo && ButtonTwo]
|
|
});
|
|
};
|
|
/* harmony default export */ __webpack_exports__.Z = (noData);
|
|
|
|
/***/ }),
|
|
|
|
/***/ 32272:
|
|
/*!*********************************************************!*\
|
|
!*** ./src/components/PreviewAll/index.tsx + 1 modules ***!
|
|
\*********************************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
// EXPORTS
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
Z: function() { return /* binding */ PreviewAll; }
|
|
});
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/objectSpread2.js
|
|
var objectSpread2 = __webpack_require__(82242);
|
|
var objectSpread2_default = /*#__PURE__*/__webpack_require__.n(objectSpread2);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/regeneratorRuntime.js
|
|
var regeneratorRuntime = __webpack_require__(7557);
|
|
var regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(regeneratorRuntime);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/asyncToGenerator.js
|
|
var asyncToGenerator = __webpack_require__(41498);
|
|
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/slicedToArray.js
|
|
var slicedToArray = __webpack_require__(79800);
|
|
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
|
|
var _react_17_0_2_react = __webpack_require__(59301);
|
|
;// CONCATENATED MODULE: ./src/components/PreviewAll/index.less?modules
|
|
// extracted by mini-css-extract-plugin
|
|
/* harmony default export */ var PreviewAllmodules = ({"wrp":"wrp___dq7YK","bgBlack":"bgBlack___ARIUV","monaco":"monaco___VnZC3","darkBlue":"darkBlue___UprA9","close":"close___LKoWu","embed":"embed___hvpEJ"});
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/button/index.js
|
|
var es_button = __webpack_require__(3113);
|
|
// EXTERNAL MODULE: ./node_modules/_@ant-design_icons@5.3.5@@ant-design/icons/es/icons/ArrowDownOutlined.js + 1 modules
|
|
var ArrowDownOutlined = __webpack_require__(52702);
|
|
// EXTERNAL MODULE: ./src/components/monaco-editor/index.jsx + 4 modules
|
|
var monaco_editor = __webpack_require__(34776);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/tooltip/index.js + 3 modules
|
|
var tooltip = __webpack_require__(6848);
|
|
// EXTERNAL MODULE: ./src/utils/util.tsx
|
|
var util = __webpack_require__(73400);
|
|
// EXTERNAL MODULE: ./src/service/exercise.ts
|
|
var exercise = __webpack_require__(86886);
|
|
// EXTERNAL MODULE: ./src/components/NoData/index.tsx
|
|
var NoData = __webpack_require__(56971);
|
|
// EXTERNAL MODULE: ./src/utils/env.ts + 1 modules
|
|
var env = __webpack_require__(2367);
|
|
// EXTERNAL MODULE: ./src/service/attachment.ts
|
|
var attachment = __webpack_require__(84710);
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/jsx-runtime.js
|
|
var jsx_runtime = __webpack_require__(37712);
|
|
;// CONCATENATED MODULE: ./src/components/PreviewAll/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* harmony default export */ var PreviewAll = (function (_ref) {
|
|
var _data, _data2, _data3, _data4, _data5, _data6;
|
|
var _ref$editOffice = _ref.editOffice,
|
|
editOffice = _ref$editOffice === void 0 ? 'view' : _ref$editOffice,
|
|
data = _ref.data,
|
|
theme = _ref.theme,
|
|
type = _ref.type,
|
|
filename = _ref.filename,
|
|
monacoEditor = _ref.monacoEditor,
|
|
className = _ref.className,
|
|
style = _ref.style,
|
|
close = _ref.close,
|
|
onClose = _ref.onClose,
|
|
hasMask = _ref.hasMask,
|
|
disabledDownload = _ref.disabledDownload,
|
|
onImgDimensions = _ref.onImgDimensions,
|
|
showNodata = _ref.showNodata,
|
|
recordInfo = _ref.recordInfo;
|
|
var _useState = (0,_react_17_0_2_react.useState)('https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt'),
|
|
_useState2 = slicedToArray_default()(_useState, 2),
|
|
src = _useState2[0],
|
|
setSrc = _useState2[1];
|
|
var _useState3 = (0,_react_17_0_2_react.useState)(""),
|
|
_useState4 = slicedToArray_default()(_useState3, 2),
|
|
token = _useState4[0],
|
|
setToken = _useState4[1];
|
|
var _useState5 = (0,_react_17_0_2_react.useState)(),
|
|
_useState6 = slicedToArray_default()(_useState5, 2),
|
|
officeData = _useState6[0],
|
|
setOfficeData = _useState6[1];
|
|
var officePath = window.ENV === "build" ? "/react/build" : "";
|
|
var apiServer = location.host.startsWith("localhost") ? env/* default */.Z.PROXY_SERVER : env/* default */.Z.API_SERVER;
|
|
// let size;
|
|
var unit = 1024 * 1024;
|
|
var maxSize = 10 * unit;
|
|
var closeRef = (0,_react_17_0_2_react.useRef)();
|
|
if ((_data = data) !== null && _data !== void 0 && _data.startsWith("/api") && type !== "txt") {
|
|
data = env/* default */.Z.API_SERVER + data;
|
|
}
|
|
var getFileExtension = function getFileExtension(url) {
|
|
var filename = url.substring(url.lastIndexOf('/') + 1);
|
|
var extension = filename.split('.').pop();
|
|
return extension;
|
|
};
|
|
if (filename) monacoEditor.filename = filename;
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
var _document$cookie;
|
|
var cookies = (_document$cookie = document.cookie) === null || _document$cookie === void 0 || (_document$cookie = _document$cookie.replace(/\s/g, "")) === null || _document$cookie === void 0 ? void 0 : _document$cookie.split(";");
|
|
cookies === null || cookies === void 0 || cookies.map(function (item) {
|
|
var i = item.split("=");
|
|
if (i[0] === '_educoder_session') {
|
|
setToken(i[1]);
|
|
}
|
|
});
|
|
}, []);
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
if (type === "office") {
|
|
if (data.indexOf("bigfilescdn.") > -1 || data.indexOf("bigfiles1") > -1) {
|
|
setOfficeData({
|
|
url: data,
|
|
fileType: getFileExtension(data),
|
|
model: data.indexOf("model=edit") ? "edit" : "view"
|
|
});
|
|
} else {
|
|
getData();
|
|
}
|
|
}
|
|
}, [type, data]);
|
|
var getData = /*#__PURE__*/function () {
|
|
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() {
|
|
var _url, _id, res;
|
|
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
|
|
while (1) switch (_context.prev = _context.next) {
|
|
case 0:
|
|
console.log("data:", data);
|
|
_url = data;
|
|
if (!data.startsWith("http")) {
|
|
_url = location.origin + _url;
|
|
}
|
|
_id = new URL(_url).pathname.split("/").pop();
|
|
_context.next = 6;
|
|
return (0,exercise/* setEcsAttachment */.gJ)({
|
|
attachment_id: _id
|
|
});
|
|
case 6:
|
|
res = _context.sent;
|
|
res.url = apiServer + res.url;
|
|
setOfficeData(res);
|
|
case 9:
|
|
case "end":
|
|
return _context.stop();
|
|
}
|
|
}, _callee);
|
|
}));
|
|
return function getData() {
|
|
return _ref2.apply(this, arguments);
|
|
};
|
|
}();
|
|
var handleClick = function handleClick() {
|
|
if (data.startsWith("http") || data.startsWith('blob:')) {
|
|
handleDown();
|
|
return;
|
|
}
|
|
(0,util/* downloadFile */.Sv)(filename || 'educoder', data, filename);
|
|
};
|
|
var handleDown = function handleDown() {
|
|
if (recordInfo) {
|
|
// 教学资料--点击下载资料时记录下载信息
|
|
(0,attachment/* add_file_quantity */.fc)({
|
|
id: recordInfo === null || recordInfo === void 0 ? void 0 : recordInfo.id,
|
|
watch_type: 1,
|
|
course_id: recordInfo === null || recordInfo === void 0 ? void 0 : recordInfo.course_id
|
|
});
|
|
}
|
|
(0,util/* downLoadLink */.Nd)(filename || 'educoder', decodeURIComponent(data));
|
|
};
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
style: objectSpread2_default()({}, style || {}),
|
|
className: "".concat(hasMask && PreviewAllmodules.bgBlack, " ").concat(!!type ? PreviewAllmodules.wrp : "hide"),
|
|
children: [close && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
className: PreviewAllmodules.close,
|
|
ref: closeRef,
|
|
children: [!!onImgDimensions && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
|
|
title: "\u70B9\u51FB\u5BF9\u56FE\u7247\u8FDB\u884C\u6279\u6CE8",
|
|
getPopupContainer: function getPopupContainer() {
|
|
return closeRef.current;
|
|
},
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
onClick: function onClick() {
|
|
onClose();
|
|
onImgDimensions();
|
|
},
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
|
|
className: "icon-yulanpizhu"
|
|
})
|
|
})
|
|
}), !disabledDownload && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
|
|
title: "\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",
|
|
getPopupContainer: function getPopupContainer() {
|
|
return closeRef.current;
|
|
},
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
onClick: handleDown,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
|
|
className: "icon-quxiaozhiding"
|
|
})
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
|
|
title: "\u5173\u95ED",
|
|
getPopupContainer: function getPopupContainer() {
|
|
return closeRef.current;
|
|
},
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "",
|
|
onClick: onClose,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
|
|
className: "icon-guanbi1"
|
|
})
|
|
})
|
|
})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: "".concat(PreviewAllmodules[className], " ").concat(className, " ").concat(PreviewAllmodules.monaco, " ").concat(type === "txt" ? "show" : "hide"),
|
|
children: type === "txt" && /*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment, {
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(monaco_editor/* default */.ZP, objectSpread2_default()({}, monacoEditor))
|
|
})
|
|
}), type === "audio" && /*#__PURE__*/(0,jsx_runtime.jsx)("audio", {
|
|
src: "".concat(((_data2 = data) === null || _data2 === void 0 ? void 0 : _data2.indexOf("http://")) > -1 || ((_data3 = data) === null || _data3 === void 0 ? void 0 : _data3.indexOf("https://")) > -1 ? "" : "data:audio/mp3;base64,").concat(data),
|
|
autoPlay: true
|
|
}), type === "video" && /*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment, {
|
|
children: ((_data4 = data) === null || _data4 === void 0 ? void 0 : _data4.indexOf("http")) > -1 ? /*#__PURE__*/(0,jsx_runtime.jsx)("video", {
|
|
controls: true,
|
|
src: "".concat(data),
|
|
autoPlay: true
|
|
}) : /*#__PURE__*/(0,jsx_runtime.jsx)("video", {
|
|
controls: true,
|
|
src: "data:video/mp4;base64,".concat(data),
|
|
autoPlay: true
|
|
})
|
|
}), type === 'office' && officeData && /*#__PURE__*/(0,jsx_runtime.jsx)("iframe", {
|
|
src: "".concat(officePath, "/office.html?key=").concat(officeData.key, "&url=").concat(btoa(officeData.url), "&callbackUrl=").concat(apiServer + officeData.callbackUrl, "&fileType=").concat(officeData.fileType, "&title=").concat(officeData.title, "&model=").concat(editOffice, "&officeServer=").concat(env/* default */.Z.ONLYOFFICE, "&disabledDownload=").concat(!!disabledDownload)
|
|
}), type === 'html' && /*#__PURE__*/(0,jsx_runtime.jsx)("iframe", {
|
|
src: data + '&disposition=inline'
|
|
}), type === 'pdf' && /*#__PURE__*/(0,jsx_runtime.jsx)("iframe", {
|
|
src: "".concat(officePath, "/js/pdfview/index.html?url=").concat(data, "&disabledDownload=").concat(!!disabledDownload)
|
|
}) //<embed className={styles.embed + "#toolbar=0"} src={data} />
|
|
, type === "image" && /*#__PURE__*/(0,jsx_runtime.jsx)("img", {
|
|
src: "".concat(((_data5 = data) === null || _data5 === void 0 ? void 0 : _data5.indexOf("http://")) > -1 || ((_data6 = data) === null || _data6 === void 0 ? void 0 : _data6.indexOf("https://")) > -1 ? "" : "data:image/png;base64,").concat(data)
|
|
}), (type === "other" || type === "download") && /*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment, {
|
|
children: showNodata ? /*#__PURE__*/(0,jsx_runtime.jsx)(NoData/* default */.Z, {
|
|
customText: "\u5F53\u524D\u6587\u4EF6\u4E0D\u652F\u6301\u9884\u89C8\uFF0C\u53EF\u70B9\u51FB\u4E0B\u8F7D\u67E5\u770B",
|
|
ButtonTwo: /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
icon: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
|
|
className: "iconfont icon-xiazai4 font14"
|
|
}),
|
|
type: "primary",
|
|
size: 'middle',
|
|
onClick: handleClick,
|
|
children: "\u4E0B\u8F7D"
|
|
})
|
|
}) : /*#__PURE__*/(0,jsx_runtime.jsxs)(es_button/* default */.ZP, {
|
|
type: "primary",
|
|
size: 'middle',
|
|
onClick: handleClick,
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(ArrowDownOutlined/* default */.Z, {}), "\u70B9\u51FB\u4E0B\u8F7D"]
|
|
})
|
|
})]
|
|
});
|
|
});
|
|
|
|
/***/ }),
|
|
|
|
/***/ 78653:
|
|
/*!*********************************************!*\
|
|
!*** ./src/components/RenderHtml/index.tsx ***!
|
|
\*********************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/objectSpread2.js */ 82242);
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_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_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/toConsumableArray.js */ 37205);
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_1__);
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_createForOfIteratorHelper_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/createForOfIteratorHelper.js */ 91232);
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_createForOfIteratorHelper_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_createForOfIteratorHelper_js__WEBPACK_IMPORTED_MODULE_2__);
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/slicedToArray.js */ 79800);
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_3__);
|
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react */ 59301);
|
|
/* harmony import */ var katex_dist_katex_min_css__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! katex/dist/katex.min.css */ 53664);
|
|
/* harmony import */ var _utils_marked__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/utils/marked */ 89206);
|
|
/* harmony import */ var code_prettify__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! code-prettify */ 64018);
|
|
/* harmony import */ var code_prettify__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(code_prettify__WEBPACK_IMPORTED_MODULE_7__);
|
|
/* harmony import */ var hls_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! hls.js */ 70169);
|
|
/* harmony import */ var _utils_env__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @/utils/env */ 2367);
|
|
/* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! katex */ 15342);
|
|
/* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(katex__WEBPACK_IMPORTED_MODULE_10__);
|
|
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! uuid */ 1012);
|
|
/* harmony import */ var _components_PreviewAll__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @/components/PreviewAll */ 32272);
|
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! react/jsx-runtime */ 37712);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ADD_MULTI = '@▁▁@';
|
|
var ADD_SINGLE = '@▁@';
|
|
var preRegex = /<pre[^>]*>/g;
|
|
function _unescape(str) {
|
|
var div = document.createElement('div');
|
|
div.innerHTML = str;
|
|
return div.childNodes.length === 0 ? '' : div.childNodes[0].nodeValue;
|
|
}
|
|
/* harmony default export */ __webpack_exports__.Z = (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,
|
|
_ref$stylesPrev = _ref.stylesPrev,
|
|
stylesPrev = _ref$stylesPrev === void 0 ? {} : _ref$stylesPrev,
|
|
highlightKeywords = _ref.highlightKeywords,
|
|
showProgramFill = _ref.showProgramFill,
|
|
isProgramFill = _ref.isProgramFill,
|
|
_ref$disabledFill = _ref.disabledFill,
|
|
disabledFill = _ref$disabledFill === void 0 ? false : _ref$disabledFill,
|
|
programFillValue = _ref.programFillValue,
|
|
_ref$onFillChange = _ref.onFillChange,
|
|
onFillChange = _ref$onFillChange === void 0 ? function (value) {} : _ref$onFillChange,
|
|
_ref$onFillBlur = _ref.onFillBlur,
|
|
onFillBlur = _ref$onFillBlur === void 0 ? function () {} : _ref$onFillBlur;
|
|
var str = String(value);
|
|
var _useState = (0,react__WEBPACK_IMPORTED_MODULE_4__.useState)(""),
|
|
_useState2 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_3___default()(_useState, 2),
|
|
data = _useState2[0],
|
|
setData = _useState2[1];
|
|
var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_4__.useState)("office"),
|
|
_useState4 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_3___default()(_useState3, 2),
|
|
type = _useState4[0],
|
|
setType = _useState4[1];
|
|
var _useState5 = (0,react__WEBPACK_IMPORTED_MODULE_4__.useState)([]),
|
|
_useState6 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_3___default()(_useState5, 2),
|
|
projectValue = _useState6[0],
|
|
setProjectValue = _useState6[1];
|
|
var classNamesRef = (0,react__WEBPACK_IMPORTED_MODULE_4__.useRef)("a" + (0,uuid__WEBPACK_IMPORTED_MODULE_13__/* ["default"] */ .Z)());
|
|
var formObj = {};
|
|
var createInput = function createInput(a, num) {
|
|
// const wrap = document.createElement("span")
|
|
// wrap.className =
|
|
var input = document.createElement(a === ADD_SINGLE ? "input" : "textarea");
|
|
input.style.width = "100%";
|
|
input.style.height = a === ADD_SINGLE ? "40px" : "151px";
|
|
input.rows = 5;
|
|
input.spellcheck = false;
|
|
input.name = "edu-program-fill";
|
|
input.placeholder = "请输入";
|
|
input.dataset.id = num;
|
|
var key = Object.keys(formObj).length;
|
|
formObj[key] = input;
|
|
return "<span class=\"edu-program-fill-wrap ".concat(a === ADD_SINGLE ? "" : "show", "\" style=\"width:").concat(a === ADD_SINGLE ? "200px" : "100%", "\"><span>").concat(input.outerHTML, "<span class=\"edu-program-fill-score\"></span></span></span>");
|
|
};
|
|
var formatMD = function formatMD(rs) {
|
|
return rs.replace(/<style.*?>([\s\S]+?)<\/style>/gim, function (_, css) {
|
|
var _css = css.replace(/(\n|\r)/g, "").split("}");
|
|
var arr = [];
|
|
_css.map(function (item) {
|
|
if (item != '') {
|
|
arr.push(".".concat(classNamesRef.current, " ").concat(item));
|
|
}
|
|
});
|
|
return "<style>".concat(arr.join("}"), "</style>");
|
|
});
|
|
};
|
|
var html = (0,react__WEBPACK_IMPORTED_MODULE_4__.useMemo)(function () {
|
|
try {
|
|
var reg = /\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g;
|
|
var reg2 = /\"\/api\/attachments\/|\"\/attachments\/download\//g;
|
|
var reg3 = /\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;
|
|
str = str.replace(reg, "(" + _utils_env__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z.API_SERVER + "/api/attachments/").replace(reg2, '"' + _utils_env__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z.API_SERVER + "/api/attachments/").replace(reg3, '"' + _utils_env__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z.API_SERVER + "/files/uploads/").replaceAll("http://video.educoder", "https://video.educoder").replaceAll("http://www.educoder.net/api", "https://data.educoder.net/api").replaceAll("https://www.educoder.net/api", "https://data.educoder.net/api").replace(/\r\n/g, "\n");
|
|
// str = str.replace(new RegExp("(?<!\\n)\\n(?!\\n)", "g"), " \n")
|
|
} catch (e) {}
|
|
;
|
|
if (showProgramFill) {
|
|
var num = -1;
|
|
str = str.replaceAll("<", "<").replaceAll(">", ">").replace(/(@▁▁@|@▁@)/g, function (a, b, c) {
|
|
++num;
|
|
return createInput(a, num);
|
|
});
|
|
return "<pre style=\"background:#fff;padding:4px\">".concat(formatMD(str || ""), "</pre>");
|
|
}
|
|
var rs = formatMD(str);
|
|
rs = (0,_utils_marked__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .ZP)(rs);
|
|
var math_expressions = (0,_utils_marked__WEBPACK_IMPORTED_MODULE_6__/* .getMathExpressions */ .ez)();
|
|
if (str.match(/\[TOC\]/)) {
|
|
rs = rs.replace('<p>[TOC]</p>', (0,_utils_marked__WEBPACK_IMPORTED_MODULE_6__/* .getTocContent */ .Qv)());
|
|
(0,_utils_marked__WEBPACK_IMPORTED_MODULE_6__/* .cleanToc */ .Iy)();
|
|
}
|
|
rs = rs.replace(/(__special_katext_id_\d+__)/g, function (_match, capture) {
|
|
var _math_expressions$cap = math_expressions[capture],
|
|
type = _math_expressions$cap.type,
|
|
expression = _math_expressions$cap.expression;
|
|
return (0,katex__WEBPACK_IMPORTED_MODULE_10__.renderToString)(_unescape(expression) || '', {
|
|
displayMode: type === 'block',
|
|
throwOnError: false,
|
|
output: 'html'
|
|
});
|
|
});
|
|
rs = rs.replace(/▁/g, '▁▁▁');
|
|
(0,_utils_marked__WEBPACK_IMPORTED_MODULE_6__/* .resetMathExpressions */ .AL)();
|
|
// return dompurify.sanitize(rs)
|
|
var dom = document.createElement('div');
|
|
dom.innerHTML = rs;
|
|
if (highlightKeywords) {
|
|
var escapedKeywords = highlightKeywords.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
findKeyword(dom, escapedKeywords);
|
|
return dom.innerHTML;
|
|
}
|
|
if (showTextOnly) {
|
|
return dom.innerText;
|
|
}
|
|
setTimeout(function () {
|
|
return onLoad();
|
|
}, 500);
|
|
return dom.innerHTML;
|
|
}, [str, highlightKeywords]);
|
|
(0,react__WEBPACK_IMPORTED_MODULE_4__.useEffect)(function () {
|
|
if (el.current) {
|
|
var inputs = el.current.querySelectorAll(["input", "textarea"]);
|
|
inputs.forEach(function (input) {
|
|
input.oninput = onInput;
|
|
input.onblur = onBlur;
|
|
});
|
|
}
|
|
}, [projectValue]);
|
|
(0,react__WEBPACK_IMPORTED_MODULE_4__.useEffect)(function () {
|
|
if (!!(programFillValue !== null && programFillValue !== void 0 && programFillValue.length)) {
|
|
try {
|
|
var scoreDom = el.current.querySelectorAll(".edu-program-fill-score");
|
|
var dom = el.current.querySelectorAll('[name="edu-program-fill"]');
|
|
var _iterator = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_createForOfIteratorHelper_js__WEBPACK_IMPORTED_MODULE_2___default()(dom.entries()),
|
|
_step;
|
|
try {
|
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
var _programFillValue$k;
|
|
var _step$value = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_3___default()(_step.value, 2),
|
|
k = _step$value[0],
|
|
i = _step$value[1];
|
|
i.value = (_programFillValue$k = programFillValue[k]) === null || _programFillValue$k === void 0 ? void 0 : _programFillValue$k.value;
|
|
if (programFillValue[k].type === "warning") {
|
|
i.className = "program-fill-warning";
|
|
} else if (programFillValue[k].type === "success") {
|
|
i.className = "program-fill-success";
|
|
} else {
|
|
i.className = "";
|
|
}
|
|
}
|
|
} catch (err) {
|
|
_iterator.e(err);
|
|
} finally {
|
|
_iterator.f();
|
|
}
|
|
var _iterator2 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_createForOfIteratorHelper_js__WEBPACK_IMPORTED_MODULE_2___default()(scoreDom.entries()),
|
|
_step2;
|
|
try {
|
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
var _programFillValue$_k, _programFillValue$_k2;
|
|
var _step2$value = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_3___default()(_step2.value, 2),
|
|
_k = _step2$value[0],
|
|
_i = _step2$value[1];
|
|
_i.innerHTML = (_programFillValue$_k = programFillValue[_k]) !== null && _programFillValue$_k !== void 0 && _programFillValue$_k.score ? "".concat((_programFillValue$_k2 = programFillValue[_k]) === null || _programFillValue$_k2 === void 0 ? void 0 : _programFillValue$_k2.score, "\u5206") : "";
|
|
}
|
|
} catch (err) {
|
|
_iterator2.e(err);
|
|
} finally {
|
|
_iterator2.f();
|
|
}
|
|
setProjectValue(programFillValue);
|
|
} catch (error) {}
|
|
}
|
|
}, [programFillValue]);
|
|
var onInput = function onInput(e) {
|
|
projectValue[e.target.dataset.id] = projectValue[e.target.dataset.id] || {};
|
|
projectValue[e.target.dataset.id]["value"] = e.target.value;
|
|
setProjectValue(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_1___default()(projectValue));
|
|
onFillChange(projectValue, e.target.dataset.id);
|
|
};
|
|
var onBlur = function onBlur(e) {
|
|
projectValue[e.target.dataset.id] = projectValue[e.target.dataset.id] || {};
|
|
projectValue[e.target.dataset.id]["value"] = e.target.value;
|
|
setProjectValue(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_1___default()(projectValue));
|
|
onFillBlur(projectValue, e.target.dataset.id);
|
|
};
|
|
function findKeyword(node, keyword) {
|
|
return node.childNodes.forEach(function (childNode) {
|
|
if (childNode.childNodes.length > 0) {
|
|
findKeyword(childNode, keyword);
|
|
} else if (childNode.nodeName !== "IMG") {
|
|
if (childNode.innerHTML) {
|
|
var _childNode$innerHTML;
|
|
childNode.innerHTML = (_childNode$innerHTML = childNode.innerHTML) === null || _childNode$innerHTML === void 0 ? void 0 : _childNode$innerHTML.replace(new RegExp(keyword, "gi"), '<span style="color:#0152d9;background-color:#1890ff33">$&</span>');
|
|
} else {
|
|
var dom = document.createElement("span");
|
|
dom.innerHTML = childNode.textContent.replace(new RegExp(keyword, "gi"), '<span style="color:#0152d9;background-color:#1890ff33">$&</span>');
|
|
childNode.replaceWith(dom);
|
|
}
|
|
}
|
|
});
|
|
|
|
// return dom.childNodes.forEach((node:any) => {
|
|
// console.log("nodeLen:",node.childNodes.length)
|
|
// if(node.childNodes.length > 0){
|
|
// debugger
|
|
// // findKeyword(dom.childNodes,keyword)
|
|
// }else{
|
|
// if(node.nodeName !== "#text"){
|
|
// node.innerHTML = node.innerHTML.replaceAll(keyword,`<span class="c-blue">${keyword}</span>`)
|
|
// console.log("node:",node,dom,node.nodeName,node.innerHTML,node.childNodes.length)
|
|
// debugger
|
|
// }
|
|
// }
|
|
|
|
// return node
|
|
// });
|
|
}
|
|
var el = (0,react__WEBPACK_IMPORTED_MODULE_4__.useRef)();
|
|
_utils_marked__WEBPACK_IMPORTED_MODULE_6__/* .lines */ .jb['WebkitLineClamp'] = showLines;
|
|
if (showLines) {
|
|
style = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()({}, style), _utils_marked__WEBPACK_IMPORTED_MODULE_6__/* .lines */ .jb);
|
|
}
|
|
function onAncherHandler(e) {
|
|
var target = e.target;
|
|
if (target.tagName.toUpperCase() === 'A') {
|
|
var ancher = target.getAttribute('href');
|
|
if (ancher.indexOf("office") > -1) {
|
|
e.preventDefault();
|
|
setData(ancher);
|
|
setType("office");
|
|
} else if (ancher.indexOf("application/pdf") > -1) {
|
|
e.preventDefault();
|
|
setData(ancher);
|
|
setType("pdf");
|
|
} else if (ancher.indexOf("text/html") > -1) {
|
|
e.preventDefault();
|
|
setData(ancher);
|
|
setType("html");
|
|
} else if (ancher.startsWith('#')) {
|
|
e.preventDefault();
|
|
var viewEl = document.getElementById(ancher.replace('#', ''));
|
|
if (viewEl) {
|
|
viewEl.scrollIntoView(true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var onLoad = function onLoad() {
|
|
var _el$current;
|
|
var videoElement = (_el$current = el.current) === null || _el$current === void 0 ? void 0 : _el$current.querySelectorAll('video');
|
|
videoElement === null || videoElement === void 0 || videoElement.forEach(function (item) {
|
|
item.oncontextmenu = function () {
|
|
return false;
|
|
};
|
|
if (item.src.indexOf('.m3u8') > -1) {
|
|
if (item.canPlayType('application/vnd.apple.mpegurl')) {} else if (hls_js__WEBPACK_IMPORTED_MODULE_8__/* ["default"].isSupported */ .ZP.isSupported()) {
|
|
var hls = new hls_js__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .ZP();
|
|
hls.loadSource(item.src);
|
|
hls.attachMedia(item);
|
|
}
|
|
}
|
|
});
|
|
};
|
|
(0,react__WEBPACK_IMPORTED_MODULE_4__.useEffect)(function () {
|
|
if (el.current && html) {
|
|
if (html.match(preRegex)) {
|
|
window.PR.prettyPrint();
|
|
}
|
|
}
|
|
if (el.current) {
|
|
el.current.addEventListener('click', onAncherHandler);
|
|
return function () {
|
|
var _el$current2;
|
|
(_el$current2 = el.current) === null || _el$current2 === void 0 || _el$current2.removeEventListener('click', onAncherHandler);
|
|
(0,_utils_marked__WEBPACK_IMPORTED_MODULE_6__/* .resetMathExpressions */ .AL)();
|
|
(0,_utils_marked__WEBPACK_IMPORTED_MODULE_6__/* .cleanToc */ .Iy)();
|
|
};
|
|
}
|
|
}, [html, el.current, onAncherHandler]);
|
|
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.Fragment, {
|
|
children: [showTextOnly && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)("div", {
|
|
ref: el,
|
|
children: html
|
|
}), !showTextOnly && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)("div", {
|
|
ref: el,
|
|
style: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()({}, style),
|
|
className: "".concat(className ? className : '', " ").concat(disabledFill ? "disabled-fill" : "", " markdown-body ").concat(classNamesRef.current),
|
|
dangerouslySetInnerHTML: {
|
|
__html: html
|
|
}
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_PreviewAll__WEBPACK_IMPORTED_MODULE_11__/* ["default"] */ .Z, {
|
|
close: true,
|
|
data: data,
|
|
type: !!(data !== null && data !== void 0 && data.length) ? type : "",
|
|
style: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()({}, stylesPrev),
|
|
onClose: function onClose() {
|
|
return setData("");
|
|
}
|
|
})]
|
|
});
|
|
});
|
|
|
|
/***/ }),
|
|
|
|
/***/ 82086:
|
|
/*!**********************************************************************!*\
|
|
!*** ./src/pages/User/Detail/Topics/Poll/Edit/index.tsx + 5 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 */ Edit; }
|
|
});
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/regeneratorRuntime.js
|
|
var regeneratorRuntime = __webpack_require__(7557);
|
|
var regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(regeneratorRuntime);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/asyncToGenerator.js
|
|
var asyncToGenerator = __webpack_require__(41498);
|
|
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/objectSpread2.js
|
|
var objectSpread2 = __webpack_require__(82242);
|
|
var objectSpread2_default = /*#__PURE__*/__webpack_require__.n(objectSpread2);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/toConsumableArray.js
|
|
var toConsumableArray = __webpack_require__(37205);
|
|
var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/slicedToArray.js
|
|
var slicedToArray = __webpack_require__(79800);
|
|
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/objectWithoutProperties.js
|
|
var objectWithoutProperties = __webpack_require__(39647);
|
|
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 + 15 modules
|
|
var _umi_production_exports = __webpack_require__(58011);
|
|
// 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/tooltip/index.js + 3 modules
|
|
var tooltip = __webpack_require__(6848);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/input/index.js + 5 modules
|
|
var input = __webpack_require__(62680);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/button/index.js
|
|
var es_button = __webpack_require__(3113);
|
|
// EXTERNAL MODULE: ./node_modules/_@ant-design_icons@5.3.5@@ant-design/icons/es/icons/PlusCircleOutlined.js + 1 modules
|
|
var PlusCircleOutlined = __webpack_require__(8877);
|
|
// EXTERNAL MODULE: ./src/service/polls.ts
|
|
var service_polls = __webpack_require__(78036);
|
|
// 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/checkbox/index.js + 3 modules
|
|
var es_checkbox = __webpack_require__(24905);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/select/index.js
|
|
var es_select = __webpack_require__(57809);
|
|
// EXTERNAL MODULE: ./src/components/RenderHtml/index.tsx
|
|
var RenderHtml = __webpack_require__(78653);
|
|
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/Poll/Edit/components/editor.less?modules
|
|
// extracted by mini-css-extract-plugin
|
|
/* harmony default export */ var editormodules = ({"flex_box_center":"flex_box_center___z7AIK","flex_space_between":"flex_space_between___zcbqj","flex_box_vertical_center":"flex_box_vertical_center___dTgjR","flex_box_center_end":"flex_box_center_end___z9WhB","flex_box_column":"flex_box_column___fDtsr","wrap":"wrap___fuJ7x","modal":"modal___Gq9oV","titleWrap":"titleWrap___T__HP","required":"required___CzJ8q","title":"title___PM33R","colorGray":"colorGray___jFiKo","choiceWrap":"choiceWrap___Htfyz","answer":"answer___AW61F","activeAnswer":"activeAnswer___Bt5i9","deleteIcon":"deleteIcon___mbWjv","addIcon":"addIcon___K4tkj","editorWrap":"editorWrap___RqcyT","htmlWrap":"htmlWrap___QqgN2","radio":"radio___UBWFG","color333":"color333___bOiTN","color999":"color999___ead_D","questionType":"questionType___VkggW","questionChoices":"questionChoices___Erma4"});
|
|
// 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/Poll/Edit/components/MultipleEditor/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _excluded = ["problemset", "globalSetting", "loading", "dispatch", "onRef", "editData", "editKey", "callback"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
|
editKey = _ref.editKey,
|
|
callback = _ref.callback,
|
|
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)(0),
|
|
_useState10 = slicedToArray_default()(_useState9, 2),
|
|
score = _useState10[0],
|
|
setScore = _useState10[1];
|
|
var _useState11 = (0,_react_17_0_2_react.useState)(true),
|
|
_useState12 = slicedToArray_default()(_useState11, 2),
|
|
isNecessary = _useState12[0],
|
|
setIsNecessary = _useState12[1];
|
|
var _useState13 = (0,_react_17_0_2_react.useState)(false),
|
|
_useState14 = slicedToArray_default()(_useState13, 2),
|
|
other = _useState14[0],
|
|
setOther = _useState14[1];
|
|
var params = (0,_umi_production_exports.useParams)();
|
|
var _useState15 = (0,_react_17_0_2_react.useState)(''),
|
|
_useState16 = slicedToArray_default()(_useState15, 2),
|
|
maxChoices = _useState16[0],
|
|
setMaxChoices = _useState16[1];
|
|
var _useState17 = (0,_react_17_0_2_react.useState)(''),
|
|
_useState18 = slicedToArray_default()(_useState17, 2),
|
|
minChoices = _useState18[0],
|
|
setMinChoices = _useState18[1];
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
var _editData$question, _editData$question2, _editData$question3, _editData$question4, _editData$question5, _editData$question6, _editData$question7;
|
|
if (!(editData !== null && editData !== void 0 && (_editData$question = editData.question) !== null && _editData$question !== void 0 && _editData$question.question_title)) {
|
|
setQuestionChoiceList([{
|
|
disabled: false,
|
|
value: ""
|
|
}, {
|
|
disabled: false,
|
|
value: ""
|
|
}, {
|
|
disabled: false,
|
|
value: ""
|
|
}, {
|
|
disabled: false,
|
|
value: ""
|
|
}]);
|
|
setIsNecessary(true);
|
|
setTitle('');
|
|
setOther(false);
|
|
return;
|
|
}
|
|
setMaxChoices(editData === null || editData === void 0 || (_editData$question2 = editData.question) === null || _editData$question2 === void 0 ? void 0 : _editData$question2.max_choices);
|
|
setMinChoices(editData === null || editData === void 0 || (_editData$question3 = editData.question) === null || _editData$question3 === void 0 ? void 0 : _editData$question3.min_choices);
|
|
setTitle(editData === null || editData === void 0 || (_editData$question4 = editData.question) === null || _editData$question4 === void 0 ? void 0 : _editData$question4.question_title);
|
|
setIsNecessary(!!(editData !== null && editData !== void 0 && (_editData$question5 = editData.question) !== null && _editData$question5 !== void 0 && _editData$question5.is_necessary));
|
|
setQuestionChoiceList(editData === null || editData === void 0 || (_editData$question6 = editData.question) === null || _editData$question6 === void 0 ? void 0 : _editData$question6.answers.map(function (item) {
|
|
return {
|
|
value: item.answer_text,
|
|
disabled: item.answer_text === '其它' ? true : false
|
|
};
|
|
}));
|
|
setOther(!!(editData !== null && editData !== void 0 && (_editData$question7 = editData.question) !== null && _editData$question7 !== void 0 && (_editData$question7 = _editData$question7.answers) !== null && _editData$question7 !== void 0 && _editData$question7.find(function (item) {
|
|
return item.answer_text === '其它';
|
|
})));
|
|
}, [editData]);
|
|
(0,_react_17_0_2_react.useImperativeHandle)(ref, function () {
|
|
return {
|
|
onSave: onSave
|
|
};
|
|
});
|
|
var onSave = /*#__PURE__*/function () {
|
|
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee(status) {
|
|
var _editData$question8;
|
|
var findNotAnswerIndex, res, bodyData, editRes, callbackEditData;
|
|
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
|
|
while (1) switch (_context.prev = _context.next) {
|
|
case 0:
|
|
if (!(maxChoices && !minChoices || !maxChoices && minChoices)) {
|
|
_context.next = 3;
|
|
break;
|
|
}
|
|
message/* default */.ZP.info('可选:最小和最大限制须同时为数值或者“--"');
|
|
return _context.abrupt("return");
|
|
case 3:
|
|
if (!(minChoices > maxChoices)) {
|
|
_context.next = 6;
|
|
break;
|
|
}
|
|
message/* default */.ZP.info('可选的最大限制不能小于最小限制');
|
|
return _context.abrupt("return");
|
|
case 6:
|
|
if (title) {
|
|
_context.next = 9;
|
|
break;
|
|
}
|
|
message/* default */.ZP.info("请您输入题目");
|
|
return _context.abrupt("return", false);
|
|
case 9:
|
|
findNotAnswerIndex = questionChoiceList.findIndex(function (item) {
|
|
return !item.value;
|
|
});
|
|
if (!(findNotAnswerIndex > -1)) {
|
|
_context.next = 13;
|
|
break;
|
|
}
|
|
message/* default */.ZP.info("\u8BF7\u5148\u8F93\u5165 ".concat(tagList[findNotAnswerIndex], " \u9009\u9879\u7684\u5185\u5BB9"));
|
|
return _context.abrupt("return", false);
|
|
case 13:
|
|
bodyData = {
|
|
"question_title": title,
|
|
"question_type": 2,
|
|
"insert_id": editData.insert_id,
|
|
"is_necessary": Math.ceil(isNecessary),
|
|
"max_choices": maxChoices,
|
|
"min_choices": minChoices,
|
|
"question_answers": questionChoiceList.map(function (item) {
|
|
return item.value;
|
|
})
|
|
};
|
|
if (!((_editData$question8 = editData.question) !== null && _editData$question8 !== void 0 && _editData$question8.id)) {
|
|
_context.next = 20;
|
|
break;
|
|
}
|
|
_context.next = 17;
|
|
return (0,service_polls/* putPollBankQuestions */.wo)(objectSpread2_default()({
|
|
"pollsId": editData.question.id
|
|
}, bodyData));
|
|
case 17:
|
|
res = _context.sent;
|
|
_context.next = 23;
|
|
break;
|
|
case 20:
|
|
_context.next = 22;
|
|
return (0,service_polls/* addPollBankQuestions */.Fd)(objectSpread2_default()({
|
|
"exercise_bank_id": params.topicId
|
|
}, bodyData));
|
|
case 22:
|
|
res = _context.sent;
|
|
case 23:
|
|
if (!(res.status === 0)) {
|
|
_context.next = 30;
|
|
break;
|
|
}
|
|
message/* default */.ZP.success("保存成功");
|
|
callback('edit', -1);
|
|
_context.next = 28;
|
|
return dispatch({
|
|
type: "polls/getExerciseBanks",
|
|
payload: objectSpread2_default()({}, params)
|
|
});
|
|
case 28:
|
|
editRes = _context.sent;
|
|
if (status) {
|
|
bodyData.answers = bodyData.question_answers.map(function (item) {
|
|
return {
|
|
answer_text: item
|
|
};
|
|
});
|
|
callbackEditData = [].concat(toConsumableArray_default()(editRes === null || editRes === void 0 ? void 0 : editRes.questions), [{
|
|
question: objectSpread2_default()({
|
|
type: 2,
|
|
insert_id: editData.question.id,
|
|
key: editData.key,
|
|
question_type: 2
|
|
}, bodyData)
|
|
}]);
|
|
callback('addContinue', {
|
|
editData: callbackEditData
|
|
});
|
|
}
|
|
case 30:
|
|
case "end":
|
|
return _context.stop();
|
|
}
|
|
}, _callee);
|
|
}));
|
|
return function onSave(_x) {
|
|
return _ref2.apply(this, arguments);
|
|
};
|
|
}();
|
|
var actionArr = [{
|
|
name: "删除",
|
|
icon: "iconfont c-light-black ml30 icon-shanchu current",
|
|
id: "del"
|
|
}, {
|
|
name: "上移",
|
|
icon: "iconfont c-green ml30 icon-xiangshangyi current",
|
|
id: "up"
|
|
}, {
|
|
name: "下移",
|
|
icon: "iconfont c-green ml30 icon-xiangxiayi current",
|
|
id: "down"
|
|
}, {
|
|
name: "添加",
|
|
icon: "iconfont c-green ml30 icon-tianjia current",
|
|
id: "add"
|
|
}, {
|
|
name: "编辑",
|
|
icon: "iconfont c-green ml30 icon-bianjidaibeijing current",
|
|
id: "edit"
|
|
}];
|
|
var actionClick = /*#__PURE__*/function () {
|
|
var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3(item) {
|
|
var _editData$question10, _editData$question11;
|
|
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 : _context3.t0 === "add" ? 11 : 13;
|
|
break;
|
|
case 3:
|
|
modal/* default */.Z.confirm({
|
|
centered: true,
|
|
okText: '确定',
|
|
cancelText: '取消',
|
|
title: '确认要删除这个问题吗?',
|
|
onOk: function onOk() {
|
|
return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() {
|
|
var _editData$question9;
|
|
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 === null || editData === void 0 || (_editData$question9 = editData.question) === null || _editData$question9 === void 0 ? void 0 : _editData$question9.id
|
|
});
|
|
case 2:
|
|
dispatch({
|
|
type: "polls/getExerciseBanks",
|
|
payload: objectSpread2_default()({}, params)
|
|
});
|
|
case 3:
|
|
case "end":
|
|
return _context2.stop();
|
|
}
|
|
}, _callee2);
|
|
}))();
|
|
}
|
|
});
|
|
return _context3.abrupt("break", 13);
|
|
case 5:
|
|
_context3.next = 7;
|
|
return (0,service_polls/* exerciseBanksMoveUpDown */.vf)({
|
|
pollsId: editData === null || editData === void 0 || (_editData$question10 = editData.question) === null || _editData$question10 === void 0 ? void 0 : _editData$question10.id,
|
|
opr: item.id
|
|
});
|
|
case 7:
|
|
dispatch({
|
|
type: "polls/getExerciseBanks",
|
|
payload: objectSpread2_default()({}, params)
|
|
});
|
|
return _context3.abrupt("break", 13);
|
|
case 9:
|
|
callback('edit', editData.key);
|
|
return _context3.abrupt("break", 13);
|
|
case 11:
|
|
callback('add', {
|
|
type: 2,
|
|
key: editData.key,
|
|
insert_id: editData === null || editData === void 0 || (_editData$question11 = editData.question) === null || _editData$question11 === void 0 ? void 0 : _editData$question11.id,
|
|
question_type: 2
|
|
});
|
|
return _context3.abrupt("break", 13);
|
|
case 13:
|
|
case "end":
|
|
return _context3.stop();
|
|
}
|
|
}, _callee3);
|
|
}));
|
|
return function actionClick(_x2) {
|
|
return _ref3.apply(this, arguments);
|
|
};
|
|
}();
|
|
var showList = function showList() {
|
|
var _editData$question12, _editData$question13, _editData$question14, _editData$question$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",
|
|
children: ["\u7B2C", editData.key, "\u9898"]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "font16 c-light-black ml10",
|
|
children: "\u591A\u9009\u9898"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "tag-grey-eae ml10 mr10",
|
|
children: (editData === null || editData === void 0 || (_editData$question12 = editData.question) === null || _editData$question12 === void 0 ? void 0 : _editData$question12.is_necessary) === 0 ? "选答" : "必答"
|
|
}), "\u53EF\u9009", editData === null || editData === void 0 || (_editData$question13 = editData.question) === null || _editData$question13 === void 0 ? void 0 : _editData$question13.min_choices, "-", editData === null || editData === void 0 || (_editData$question14 = editData.question) === null || _editData$question14 === void 0 ? void 0 : _editData$question14.max_choices, "\u9879"]
|
|
}), 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.question_title
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: editormodules.questionChoices,
|
|
children: editData === null || editData === void 0 || (_editData$question$an = editData.question.answers) === null || _editData$question$an === void 0 ? void 0 : _editData$question$an.map(function (item, index) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(row/* default */.Z, {
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z, {
|
|
disabled: true,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "c-black font14",
|
|
children: item.answer_text
|
|
})
|
|
}, index)
|
|
})
|
|
});
|
|
})
|
|
})]
|
|
});
|
|
};
|
|
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: "\u591A\u9009\u9898"
|
|
}), " ", /*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z, {
|
|
checked: isNecessary ? true : false,
|
|
className: "ml10",
|
|
onChange: function onChange(e) {
|
|
return setIsNecessary(e.target.checked);
|
|
},
|
|
children: "\u5FC5\u7B54"
|
|
})]
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("p", {
|
|
className: editormodules.titleWrap,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z.TextArea, {
|
|
autoSize: {
|
|
maxRows: 5
|
|
},
|
|
rows: 1,
|
|
value: title,
|
|
placeholder: "\u8BF7\u8F93\u5165\u9898\u76EE",
|
|
onChange: function onChange(e) {
|
|
return setTitle(e.target.value);
|
|
}
|
|
})
|
|
}), questionChoiceList.map(function (item, index) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
|
|
className: editormodules.choiceWrap,
|
|
gutter: [12, 12],
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "font16",
|
|
children: "\u9009\u9879"
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
className: editormodules.editorWrap,
|
|
flex: "1",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z.TextArea, {
|
|
autoSize: {
|
|
maxRows: 5
|
|
},
|
|
value: questionChoiceList[index]['value'],
|
|
rows: 1,
|
|
disabled: item.disabled ? true : false,
|
|
onChange: function onChange(e) {
|
|
questionChoiceList[index]['value'] = e.target.value;
|
|
setQuestionChoiceList(toConsumableArray_default()(questionChoiceList));
|
|
}
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
children: 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() {
|
|
setQuestionChoiceList(questionChoiceList.filter(function (_, key) {
|
|
return key !== index;
|
|
}));
|
|
if (item.disabled) setOther(false);
|
|
}
|
|
})
|
|
})
|
|
})]
|
|
}, index);
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
|
|
gutter: [12, 12],
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
children: "\u53EF\u9009"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)(es_select["default"], {
|
|
value: minChoices || "",
|
|
style: {
|
|
width: 120
|
|
},
|
|
onChange: function onChange(value) {
|
|
return setMinChoices(value);
|
|
},
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_select["default"].Option, {
|
|
value: "",
|
|
children: "--"
|
|
}), questionChoiceList.map(function (item, index) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(es_select["default"].Option, {
|
|
value: String(index + 1),
|
|
children: index + 1
|
|
});
|
|
})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "ml10 mr10",
|
|
children: "~"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(es_select["default"], {
|
|
style: {
|
|
width: 120
|
|
},
|
|
value: maxChoices || "",
|
|
onChange: function onChange(value) {
|
|
return setMaxChoices(value);
|
|
},
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_select["default"].Option, {
|
|
value: "",
|
|
children: "--"
|
|
}), questionChoiceList.map(function (item, index) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(es_select["default"].Option, {
|
|
value: String(index + 1),
|
|
children: index + 1
|
|
});
|
|
})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "font14 c-grey-999",
|
|
children: "\uFF08\u5B66\u751F\u7B54\u9898\u65F6\uFF0C\u7CFB\u7EDF\u5BF9\u5176\u9009\u62E9\u7684\u9009\u9879\u4E2A\u6570\u8FDB\u884C\u9650\u5236\uFF0C--\u8868\u793A\u4E0D\u9650\u5236\uFF09"
|
|
})]
|
|
})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
|
|
gutter: [12, 12],
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, {
|
|
flex: "1",
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
type: "default",
|
|
onClick: function onClick() {
|
|
if (questionChoiceList.find(function (i) {
|
|
return i.value === '其它';
|
|
})) {
|
|
setQuestionChoiceList([].concat(toConsumableArray_default()(questionChoiceList.filter(function (i) {
|
|
return i.value !== '其它';
|
|
})), [{
|
|
value: ''
|
|
}, {
|
|
value: '其它',
|
|
disabled: true
|
|
}]));
|
|
} else {
|
|
setQuestionChoiceList([].concat(toConsumableArray_default()(questionChoiceList), [{
|
|
value: ''
|
|
}]));
|
|
}
|
|
},
|
|
children: "\u65B0\u589E\u9009\u9879"
|
|
}), !other && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
type: "default",
|
|
className: "ml20",
|
|
onClick: function onClick() {
|
|
setQuestionChoiceList([].concat(toConsumableArray_default()(questionChoiceList), [{
|
|
disabled: true,
|
|
value: "其它"
|
|
}]));
|
|
setOther(true);
|
|
},
|
|
children: "\u65B0\u589E\u5176\u5B83\u9009\u9879"
|
|
})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, {
|
|
className: "tl",
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
type: "default",
|
|
onClick: function onClick() {
|
|
var _editData$question15;
|
|
if ((_editData$question15 = editData.question) !== null && _editData$question15 !== void 0 && _editData$question15.id) {
|
|
callback('edit', -1);
|
|
} else {
|
|
callback('del', editData.key);
|
|
}
|
|
},
|
|
children: "\u53D6\u6D88"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
className: "ml20",
|
|
type: "primary",
|
|
onClick: function onClick() {
|
|
return onSave();
|
|
},
|
|
children: "\u4FDD\u5B58"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
className: "ml20",
|
|
type: "primary",
|
|
onClick: function onClick() {
|
|
return onSave(true);
|
|
},
|
|
children: "\u4FDD\u5B58\u5E76\u7EE7\u7EED"
|
|
})]
|
|
})]
|
|
})]
|
|
});
|
|
};
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
|
|
className: editormodules.wrap,
|
|
children: [editKey !== editData.key && showList(), editKey === editData.key && 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/Poll/Edit/components/SingleEditor/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var SingleEditor_excluded = ["problemset", "globalSetting", "loading", "dispatch", "onRef", "editData", "editKey", "callback"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
|
editKey = _ref.editKey,
|
|
callback = _ref.callback,
|
|
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),
|
|
isNecessary = _useState12[0],
|
|
setIsNecessary = _useState12[1];
|
|
var _useState13 = (0,_react_17_0_2_react.useState)(false),
|
|
_useState14 = slicedToArray_default()(_useState13, 2),
|
|
other = _useState14[0],
|
|
setOther = _useState14[1];
|
|
var params = (0,_umi_production_exports.useParams)();
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
var _editData$question, _editData$question2, _editData$question3, _editData$question4, _editData$question5;
|
|
if (!(editData !== null && editData !== void 0 && (_editData$question = editData.question) !== null && _editData$question !== void 0 && _editData$question.question_title)) {
|
|
setQuestionChoiceList([{
|
|
disabled: false,
|
|
value: ""
|
|
}, {
|
|
disabled: false,
|
|
value: ""
|
|
}, {
|
|
disabled: false,
|
|
value: ""
|
|
}, {
|
|
disabled: false,
|
|
value: ""
|
|
}]);
|
|
setIsNecessary(false);
|
|
setTitle('');
|
|
setOther(false);
|
|
return;
|
|
}
|
|
setTitle(editData === null || editData === void 0 || (_editData$question2 = editData.question) === null || _editData$question2 === void 0 ? void 0 : _editData$question2.question_title);
|
|
setIsNecessary(!!(editData !== null && editData !== void 0 && (_editData$question3 = editData.question) !== null && _editData$question3 !== void 0 && _editData$question3.is_necessary));
|
|
setQuestionChoiceList(editData === null || editData === void 0 || (_editData$question4 = editData.question) === null || _editData$question4 === void 0 ? void 0 : _editData$question4.answers.map(function (item) {
|
|
return {
|
|
value: item.answer_text,
|
|
disabled: item.answer_text === '其它' ? true : false
|
|
};
|
|
}));
|
|
setOther(!!(editData !== null && editData !== void 0 && (_editData$question5 = editData.question) !== null && _editData$question5 !== void 0 && (_editData$question5 = _editData$question5.answers) !== null && _editData$question5 !== void 0 && _editData$question5.find(function (item) {
|
|
return item.answer_text === '其它';
|
|
})));
|
|
}, [editData]);
|
|
(0,_react_17_0_2_react.useImperativeHandle)(ref, function () {
|
|
return {
|
|
onSave: onSave
|
|
};
|
|
});
|
|
var onSave = /*#__PURE__*/function () {
|
|
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee(status) {
|
|
var _editData$question6;
|
|
var findNotAnswerIndex, res, bodyData, editRes, callbackEditData;
|
|
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.value;
|
|
});
|
|
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:
|
|
bodyData = {
|
|
"question_title": title,
|
|
"question_type": 1,
|
|
"insert_id": editData.insert_id,
|
|
"is_necessary": Math.ceil(isNecessary),
|
|
"question_answers": questionChoiceList.map(function (item) {
|
|
return item.value;
|
|
})
|
|
};
|
|
if (!((_editData$question6 = editData.question) !== null && _editData$question6 !== void 0 && _editData$question6.id)) {
|
|
_context.next = 14;
|
|
break;
|
|
}
|
|
_context.next = 11;
|
|
return (0,service_polls/* putPollBankQuestions */.wo)(objectSpread2_default()({
|
|
"pollsId": editData.question.id
|
|
}, bodyData));
|
|
case 11:
|
|
res = _context.sent;
|
|
_context.next = 17;
|
|
break;
|
|
case 14:
|
|
_context.next = 16;
|
|
return (0,service_polls/* addPollBankQuestions */.Fd)(objectSpread2_default()({
|
|
"exercise_bank_id": params.topicId
|
|
}, bodyData));
|
|
case 16:
|
|
res = _context.sent;
|
|
case 17:
|
|
if (!(res.status === 0)) {
|
|
_context.next = 24;
|
|
break;
|
|
}
|
|
message/* default */.ZP.success("保存成功");
|
|
callback('edit', -1);
|
|
_context.next = 22;
|
|
return dispatch({
|
|
type: "polls/getExerciseBanks",
|
|
payload: objectSpread2_default()({}, params)
|
|
});
|
|
case 22:
|
|
editRes = _context.sent;
|
|
if (status) {
|
|
bodyData.answers = bodyData.question_answers.map(function (item) {
|
|
return {
|
|
answer_text: item
|
|
};
|
|
});
|
|
callbackEditData = [].concat(toConsumableArray_default()(editRes === null || editRes === void 0 ? void 0 : editRes.questions), [{
|
|
question: objectSpread2_default()({
|
|
type: 1,
|
|
insert_id: editData.question.id,
|
|
key: editData.key,
|
|
question_type: 1
|
|
}, bodyData)
|
|
}]);
|
|
callback('addContinue', {
|
|
editData: callbackEditData
|
|
});
|
|
}
|
|
case 24:
|
|
case "end":
|
|
return _context.stop();
|
|
}
|
|
}, _callee);
|
|
}));
|
|
return function onSave(_x) {
|
|
return _ref2.apply(this, arguments);
|
|
};
|
|
}();
|
|
var actionArr = [{
|
|
name: "删除",
|
|
icon: "iconfont c-light-black ml30 icon-shanchu current",
|
|
id: "del"
|
|
}, {
|
|
name: "上移",
|
|
icon: "iconfont c-green ml30 icon-xiangshangyi current",
|
|
id: "up"
|
|
}, {
|
|
name: "下移",
|
|
icon: "iconfont c-green ml30 icon-xiangxiayi current",
|
|
id: "down"
|
|
}, {
|
|
name: "添加",
|
|
icon: "iconfont c-green ml30 icon-tianjia current",
|
|
id: "add"
|
|
}, {
|
|
name: "编辑",
|
|
icon: "iconfont c-green ml30 icon-bianjidaibeijing current",
|
|
id: "edit"
|
|
}];
|
|
var actionClick = /*#__PURE__*/function () {
|
|
var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3(item) {
|
|
var _editData$question8, _editData$question9;
|
|
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 : _context3.t0 === "add" ? 11 : 13;
|
|
break;
|
|
case 3:
|
|
modal/* default */.Z.confirm({
|
|
centered: true,
|
|
okText: '确定',
|
|
cancelText: '取消',
|
|
title: '确认要删除这个问题吗?',
|
|
onOk: function onOk() {
|
|
return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() {
|
|
var _editData$question7;
|
|
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 === null || editData === void 0 || (_editData$question7 = editData.question) === null || _editData$question7 === void 0 ? void 0 : _editData$question7.id
|
|
});
|
|
case 2:
|
|
dispatch({
|
|
type: "polls/getExerciseBanks",
|
|
payload: objectSpread2_default()({}, params)
|
|
});
|
|
case 3:
|
|
case "end":
|
|
return _context2.stop();
|
|
}
|
|
}, _callee2);
|
|
}))();
|
|
}
|
|
});
|
|
return _context3.abrupt("break", 13);
|
|
case 5:
|
|
_context3.next = 7;
|
|
return (0,service_polls/* exerciseBanksMoveUpDown */.vf)({
|
|
pollsId: editData === null || editData === void 0 || (_editData$question8 = editData.question) === null || _editData$question8 === void 0 ? void 0 : _editData$question8.id,
|
|
opr: item.id
|
|
});
|
|
case 7:
|
|
dispatch({
|
|
type: "polls/getExerciseBanks",
|
|
payload: objectSpread2_default()({}, params)
|
|
});
|
|
return _context3.abrupt("break", 13);
|
|
case 9:
|
|
callback('edit', editData.key);
|
|
return _context3.abrupt("break", 13);
|
|
case 11:
|
|
callback('add', {
|
|
type: 1,
|
|
key: editData.key,
|
|
insert_id: editData === null || editData === void 0 || (_editData$question9 = editData.question) === null || _editData$question9 === void 0 ? void 0 : _editData$question9.id,
|
|
question_type: 1
|
|
});
|
|
return _context3.abrupt("break", 13);
|
|
case 13:
|
|
case "end":
|
|
return _context3.stop();
|
|
}
|
|
}, _callee3);
|
|
}));
|
|
return function actionClick(_x2) {
|
|
return _ref3.apply(this, arguments);
|
|
};
|
|
}();
|
|
var showList = function showList() {
|
|
var _editData$question10, _editData$question$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",
|
|
children: ["\u7B2C", editData.key, "\u9898"]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "font16 c-light-black ml10",
|
|
children: "\u5355\u9009\u9898"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "tag-grey-eae ml10",
|
|
children: (editData === null || editData === void 0 || (_editData$question10 = editData.question) === null || _editData$question10 === void 0 ? void 0 : _editData$question10.is_necessary) === 0 ? "选答" : "必答"
|
|
})]
|
|
}), 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.question_title
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: editormodules.questionChoices,
|
|
children: editData === null || editData === void 0 || (_editData$question$an = editData.question.answers) === null || _editData$question$an === void 0 ? void 0 : _editData$question$an.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.jsx)(es_radio/* default */.ZP, {
|
|
disabled: true
|
|
}, index)
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
flex: "1",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "c-black font14",
|
|
children: item.answer_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: "\u5355\u9009\u9898"
|
|
}), " ", /*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z, {
|
|
checked: isNecessary ? true : false,
|
|
className: "ml10",
|
|
onChange: function onChange(e) {
|
|
return setIsNecessary(e.target.checked);
|
|
},
|
|
children: "\u5FC5\u7B54"
|
|
})]
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("p", {
|
|
className: editormodules.titleWrap,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z.TextArea, {
|
|
autoSize: {
|
|
maxRows: 5
|
|
},
|
|
rows: 1,
|
|
value: title,
|
|
placeholder: "\u8BF7\u8F93\u5165\u9898\u76EE",
|
|
onChange: function onChange(e) {
|
|
return setTitle(e.target.value);
|
|
}
|
|
})
|
|
}), questionChoiceList.map(function (item, index) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
|
|
className: editormodules.choiceWrap,
|
|
gutter: [12, 12],
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "font16",
|
|
children: "\u9009\u9879"
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
className: editormodules.editorWrap,
|
|
flex: "1",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z.TextArea, {
|
|
autoSize: {
|
|
maxRows: 5
|
|
},
|
|
value: questionChoiceList[index]['value'],
|
|
rows: 1,
|
|
disabled: item.disabled ? true : false,
|
|
onChange: function onChange(e) {
|
|
questionChoiceList[index]['value'] = e.target.value;
|
|
setQuestionChoiceList(toConsumableArray_default()(questionChoiceList));
|
|
}
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
children: 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() {
|
|
setQuestionChoiceList(questionChoiceList.filter(function (_, key) {
|
|
return key !== index;
|
|
}));
|
|
if (item.disabled) setOther(false);
|
|
}
|
|
})
|
|
})
|
|
})]
|
|
}, index);
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
|
|
gutter: [12, 12],
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, {
|
|
flex: "1",
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
type: "default",
|
|
onClick: function onClick() {
|
|
if (questionChoiceList.find(function (i) {
|
|
return i.value === '其它';
|
|
})) {
|
|
setQuestionChoiceList([].concat(toConsumableArray_default()(questionChoiceList.filter(function (i) {
|
|
return i.value !== '其它';
|
|
})), [{
|
|
value: ''
|
|
}, {
|
|
value: '其它',
|
|
disabled: true
|
|
}]));
|
|
} else {
|
|
setQuestionChoiceList([].concat(toConsumableArray_default()(questionChoiceList), [{
|
|
value: ''
|
|
}]));
|
|
}
|
|
},
|
|
children: "\u65B0\u589E\u9009\u9879"
|
|
}), !other && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
type: "default",
|
|
className: "ml20",
|
|
onClick: function onClick() {
|
|
setQuestionChoiceList([].concat(toConsumableArray_default()(questionChoiceList), [{
|
|
disabled: true,
|
|
value: "其它"
|
|
}]));
|
|
setOther(true);
|
|
},
|
|
children: "\u65B0\u589E\u5176\u5B83\u9009\u9879"
|
|
})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, {
|
|
className: "tl",
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
type: "default",
|
|
onClick: function onClick() {
|
|
var _editData$question11;
|
|
if ((_editData$question11 = editData.question) !== null && _editData$question11 !== void 0 && _editData$question11.id) {
|
|
callback('edit', -1);
|
|
} else {
|
|
callback('del', editData.key);
|
|
}
|
|
},
|
|
children: "\u53D6\u6D88"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
className: "ml20",
|
|
type: "primary",
|
|
onClick: function onClick() {
|
|
return onSave();
|
|
},
|
|
children: "\u4FDD\u5B58"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
className: "ml20",
|
|
type: "primary",
|
|
onClick: function onClick() {
|
|
return onSave(true);
|
|
},
|
|
children: "\u4FDD\u5B58\u5E76\u7EE7\u7EED"
|
|
})]
|
|
})]
|
|
})]
|
|
});
|
|
};
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
|
|
className: editormodules.wrap,
|
|
children: [editKey !== editData.key && showList(), editKey === editData.key && 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/Poll/Edit/components/SubjectiveEditor/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var SubjectiveEditor_excluded = ["problemset", "globalSetting", "loading", "dispatch", "onRef", "editData", "editKey", "callback"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_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,
|
|
editKey = _ref.editKey,
|
|
callback = _ref.callback,
|
|
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)(true),
|
|
_useState4 = slicedToArray_default()(_useState3, 2),
|
|
isNecessary = _useState4[0],
|
|
setIsNecessary = _useState4[1];
|
|
var params = (0,_umi_production_exports.useParams)();
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
var _editData$question, _editData$question2, _editData$question3;
|
|
if (!(editData !== null && editData !== void 0 && (_editData$question = editData.question) !== null && _editData$question !== void 0 && _editData$question.question_title)) {
|
|
setIsNecessary(true);
|
|
setTitle('');
|
|
return;
|
|
}
|
|
setTitle(editData === null || editData === void 0 || (_editData$question2 = editData.question) === null || _editData$question2 === void 0 ? void 0 : _editData$question2.question_title);
|
|
setIsNecessary(!!(editData !== null && editData !== void 0 && (_editData$question3 = editData.question) !== null && _editData$question3 !== void 0 && _editData$question3.is_necessary));
|
|
}, [editData]);
|
|
(0,_react_17_0_2_react.useImperativeHandle)(ref, function () {
|
|
return {
|
|
onSave: onSave
|
|
};
|
|
});
|
|
var onSave = /*#__PURE__*/function () {
|
|
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee(status) {
|
|
var _editData$question4;
|
|
var res, bodyData, editRes, callbackEditData;
|
|
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:
|
|
bodyData = {
|
|
"question_title": title,
|
|
"question_type": 3,
|
|
"insert_id": editData.insert_id,
|
|
"is_necessary": Math.ceil(isNecessary)
|
|
};
|
|
if (!((_editData$question4 = editData.question) !== null && _editData$question4 !== void 0 && _editData$question4.id)) {
|
|
_context.next = 10;
|
|
break;
|
|
}
|
|
_context.next = 7;
|
|
return (0,service_polls/* putPollBankQuestions */.wo)(objectSpread2_default()({
|
|
"pollsId": editData.question.id
|
|
}, bodyData));
|
|
case 7:
|
|
res = _context.sent;
|
|
_context.next = 13;
|
|
break;
|
|
case 10:
|
|
_context.next = 12;
|
|
return (0,service_polls/* addPollBankQuestions */.Fd)(objectSpread2_default()({
|
|
"exercise_bank_id": params.topicId
|
|
}, bodyData));
|
|
case 12:
|
|
res = _context.sent;
|
|
case 13:
|
|
if (!(res.status === 0)) {
|
|
_context.next = 20;
|
|
break;
|
|
}
|
|
message/* default */.ZP.success("保存成功");
|
|
callback('edit', -1);
|
|
_context.next = 18;
|
|
return dispatch({
|
|
type: "polls/getExerciseBanks",
|
|
payload: objectSpread2_default()({}, params)
|
|
});
|
|
case 18:
|
|
editRes = _context.sent;
|
|
if (status) {
|
|
callbackEditData = [].concat(toConsumableArray_default()(editRes === null || editRes === void 0 ? void 0 : editRes.questions), [{
|
|
question: objectSpread2_default()({
|
|
type: 3,
|
|
insert_id: editData.question.id,
|
|
key: editData.key,
|
|
question_type: 3
|
|
}, bodyData)
|
|
}]);
|
|
callback('addContinue', {
|
|
editData: callbackEditData
|
|
});
|
|
}
|
|
case 20:
|
|
case "end":
|
|
return _context.stop();
|
|
}
|
|
}, _callee);
|
|
}));
|
|
return function onSave(_x) {
|
|
return _ref2.apply(this, arguments);
|
|
};
|
|
}();
|
|
var actionArr = [{
|
|
name: "删除",
|
|
icon: "iconfont c-light-black ml30 icon-shanchu current",
|
|
id: "del"
|
|
}, {
|
|
name: "上移",
|
|
icon: "iconfont c-green ml30 icon-xiangshangyi current",
|
|
id: "up"
|
|
}, {
|
|
name: "下移",
|
|
icon: "iconfont c-green ml30 icon-xiangxiayi current",
|
|
id: "down"
|
|
}, {
|
|
name: "添加",
|
|
icon: "iconfont c-green ml30 icon-tianjia current",
|
|
id: "add"
|
|
}, {
|
|
name: "编辑",
|
|
icon: "iconfont c-green ml30 icon-bianjidaibeijing current",
|
|
id: "edit"
|
|
}];
|
|
var actionClick = /*#__PURE__*/function () {
|
|
var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3(item) {
|
|
var _editData$question6, _editData$question7;
|
|
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 : _context3.t0 === "add" ? 11 : 13;
|
|
break;
|
|
case 3:
|
|
modal/* default */.Z.confirm({
|
|
centered: true,
|
|
okText: '确定',
|
|
cancelText: '取消',
|
|
title: '确认要删除这个问题吗?',
|
|
onOk: function onOk() {
|
|
return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() {
|
|
var _editData$question5;
|
|
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 === null || editData === void 0 || (_editData$question5 = editData.question) === null || _editData$question5 === void 0 ? void 0 : _editData$question5.id
|
|
});
|
|
case 2:
|
|
dispatch({
|
|
type: "polls/getExerciseBanks",
|
|
payload: objectSpread2_default()({}, params)
|
|
});
|
|
case 3:
|
|
case "end":
|
|
return _context2.stop();
|
|
}
|
|
}, _callee2);
|
|
}))();
|
|
}
|
|
});
|
|
return _context3.abrupt("break", 13);
|
|
case 5:
|
|
_context3.next = 7;
|
|
return (0,service_polls/* exerciseBanksMoveUpDown */.vf)({
|
|
pollsId: editData === null || editData === void 0 || (_editData$question6 = editData.question) === null || _editData$question6 === void 0 ? void 0 : _editData$question6.id,
|
|
opr: item.id
|
|
});
|
|
case 7:
|
|
dispatch({
|
|
type: "polls/getExerciseBanks",
|
|
payload: objectSpread2_default()({}, params)
|
|
});
|
|
return _context3.abrupt("break", 13);
|
|
case 9:
|
|
callback('edit', editData.key);
|
|
return _context3.abrupt("break", 13);
|
|
case 11:
|
|
callback('add', {
|
|
type: 3,
|
|
key: editData.key,
|
|
insert_id: editData === null || editData === void 0 || (_editData$question7 = editData.question) === null || _editData$question7 === void 0 ? void 0 : _editData$question7.id,
|
|
question_type: 3
|
|
});
|
|
return _context3.abrupt("break", 13);
|
|
case 13:
|
|
case "end":
|
|
return _context3.stop();
|
|
}
|
|
}, _callee3);
|
|
}));
|
|
return function actionClick(_x2) {
|
|
return _ref3.apply(this, arguments);
|
|
};
|
|
}();
|
|
var showList = function showList() {
|
|
var _editData$question8, _editData$question$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",
|
|
children: ["\u7B2C", editData.key, "\u9898"]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "font16 c-light-black ml10",
|
|
children: "\u4E3B\u89C2\u9898"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "tag-grey-eae ml10 mr10",
|
|
children: (editData === null || editData === void 0 || (_editData$question8 = editData.question) === null || _editData$question8 === void 0 ? void 0 : _editData$question8.is_necessary) === 0 ? "选答" : "必答"
|
|
})]
|
|
}), 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.jsxs)("div", {
|
|
className: "mt5",
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, {
|
|
value: editData.question.question_title
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: "mt15",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z.TextArea, {
|
|
placeholder: "\u5728\u6B64\u586B\u5165\u7B54\u6848",
|
|
rows: 5,
|
|
disabled: true
|
|
})
|
|
})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: editormodules.questionChoices,
|
|
children: editData === null || editData === void 0 || (_editData$question$an = editData.question.answers) === null || _editData$question$an === void 0 ? void 0 : _editData$question$an.map(function (item, index) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(row/* default */.Z, {
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z, {
|
|
disabled: true,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "c-black font14",
|
|
children: item.answer_text
|
|
})
|
|
}, index)
|
|
})
|
|
});
|
|
})
|
|
})]
|
|
});
|
|
};
|
|
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: "\u4E3B\u89C2\u9898"
|
|
}), " ", /*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z, {
|
|
checked: isNecessary ? true : false,
|
|
className: "ml10",
|
|
onChange: function onChange(e) {
|
|
return setIsNecessary(e.target.checked);
|
|
},
|
|
children: "\u5FC5\u7B54"
|
|
})]
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("p", {
|
|
className: editormodules.titleWrap,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z.TextArea, {
|
|
autoSize: {
|
|
maxRows: 5
|
|
},
|
|
rows: 1,
|
|
value: title,
|
|
placeholder: "\u8BF7\u8F93\u5165\u9898\u76EE",
|
|
onChange: function onChange(e) {
|
|
return setTitle(e.target.value);
|
|
}
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
|
|
gutter: [12, 12],
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
flex: "1"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, {
|
|
className: "tl",
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
type: "default",
|
|
onClick: function onClick() {
|
|
var _editData$question9;
|
|
if ((_editData$question9 = editData.question) !== null && _editData$question9 !== void 0 && _editData$question9.id) {
|
|
callback('edit', -1);
|
|
} else {
|
|
callback('del', editData.key);
|
|
}
|
|
},
|
|
children: "\u53D6\u6D88"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
className: "ml20",
|
|
type: "primary",
|
|
onClick: function onClick() {
|
|
return onSave();
|
|
},
|
|
children: "\u4FDD\u5B58"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
className: "ml20",
|
|
type: "primary",
|
|
onClick: function onClick() {
|
|
return onSave(true);
|
|
},
|
|
children: "\u4FDD\u5B58\u5E76\u7EE7\u7EED"
|
|
})]
|
|
})]
|
|
})]
|
|
});
|
|
};
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
|
|
className: editormodules.wrap,
|
|
children: [editKey !== editData.key && showList(), editKey === editData.key && showEdit()]
|
|
});
|
|
};
|
|
/* harmony default export */ var 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_SingleEditor)));
|
|
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/Poll/Edit/index.less?modules
|
|
// extracted by mini-css-extract-plugin
|
|
/* harmony default export */ var Editmodules = ({"flex_box_center":"flex_box_center___jFb53","flex_space_between":"flex_space_between___eaFhb","flex_box_vertical_center":"flex_box_vertical_center___Rp5aN","flex_box_center_end":"flex_box_center_end___EpEQ2","flex_box_column":"flex_box_column___hEFHr","bg":"bg___Y7Bmz","containerTitle":"containerTitle___xdxGQ","containerDesc":"containerDesc___pXaV0","listItem":"listItem___P0Hq4","info":"info___nZ3vt","title":"title___p_v5i","titleLeft":"titleLeft___d8_hx","titleRight":"titleRight___xz4zW","acitons":"acitons___BCczQ"});
|
|
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/Poll/Edit/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var Edit_excluded = ["polls", "globalSetting", "loading", "user", "dispatch"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ShixunsListPage = function ShixunsListPage(_ref) {
|
|
var _polls$exerciseBanks5, _polls$exerciseBanks6, _polls$exerciseBanks7, _polls$exerciseBanks8, _polls$exerciseBanks9, _polls$exerciseBanks10;
|
|
var polls = _ref.polls,
|
|
globalSetting = _ref.globalSetting,
|
|
loading = _ref.loading,
|
|
user = _ref.user,
|
|
dispatch = _ref.dispatch,
|
|
props = objectWithoutProperties_default()(_ref, Edit_excluded);
|
|
var params = (0,_umi_production_exports.useParams)();
|
|
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 _useState5 = (0,_react_17_0_2_react.useState)(-1),
|
|
_useState6 = slicedToArray_default()(_useState5, 2),
|
|
editKey = _useState6[0],
|
|
setEditKey = _useState6[1];
|
|
var questionType = [{
|
|
name: "单选题",
|
|
id: 1
|
|
}, {
|
|
name: "多选题",
|
|
id: 2
|
|
}, {
|
|
name: "主观题",
|
|
id: 3
|
|
}];
|
|
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.questions) {
|
|
var _polls$exerciseBanks2, _polls$exerciseBanks3, _polls$exerciseBanks4;
|
|
setEditData(toConsumableArray_default()((_polls$exerciseBanks2 = polls.exerciseBanks) === null || _polls$exerciseBanks2 === void 0 ? void 0 : _polls$exerciseBanks2.questions));
|
|
form.setFieldsValue({
|
|
exercise_name: (_polls$exerciseBanks3 = polls.exerciseBanks) === null || _polls$exerciseBanks3 === void 0 || (_polls$exerciseBanks3 = _polls$exerciseBanks3.poll) === null || _polls$exerciseBanks3 === void 0 ? void 0 : _polls$exerciseBanks3.name,
|
|
exercise_description: (_polls$exerciseBanks4 = polls.exerciseBanks) === null || _polls$exerciseBanks4 === void 0 || (_polls$exerciseBanks4 = _polls$exerciseBanks4.poll) === null || _polls$exerciseBanks4 === void 0 ? void 0 : _polls$exerciseBanks4.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 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 = params.topicId;
|
|
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:
|
|
d = childrenRef === null || childrenRef === void 0 ? void 0 : childrenRef.current;
|
|
if (!(editKey !== -1)) {
|
|
_context2.next = 4;
|
|
break;
|
|
}
|
|
message/* default */.ZP.error("不能同时编辑两题");
|
|
return _context2.abrupt("return");
|
|
case 4:
|
|
setEditKey(editData.length + 1);
|
|
setEditData([].concat(toConsumableArray_default()(editData), [{
|
|
question: {
|
|
question_type: type
|
|
}
|
|
}]));
|
|
case 6:
|
|
case "end":
|
|
return _context2.stop();
|
|
}
|
|
}, _callee2);
|
|
}));
|
|
return function addQuestion(_x) {
|
|
return _ref3.apply(this, arguments);
|
|
};
|
|
}();
|
|
var callback = function callback(key, data, allData) {
|
|
var _data$editData;
|
|
switch (key) {
|
|
case "edit":
|
|
if (data !== -1 && editKey !== -1 && data !== editKey) {
|
|
message/* default */.ZP.error("不能同时编辑两题");
|
|
return;
|
|
}
|
|
setEditKey(data);
|
|
return;
|
|
case "add":
|
|
if (editKey != -1) {
|
|
message/* default */.ZP.error("不能同时编辑两题");
|
|
return;
|
|
}
|
|
setEditKey(-1);
|
|
break;
|
|
case "addContinue":
|
|
setEditData(toConsumableArray_default()(data === null || data === void 0 ? void 0 : data.editData));
|
|
setEditKey(data === null || data === void 0 || (_data$editData = data.editData) === null || _data$editData === void 0 ? void 0 : _data$editData.length);
|
|
break;
|
|
case "del":
|
|
editData.splice(data - 1, 1);
|
|
setEditData(toConsumableArray_default()(editData));
|
|
setEditKey(-1);
|
|
break;
|
|
}
|
|
};
|
|
var renderQuestion = function renderQuestion() {
|
|
return editData === null || editData === void 0 ? void 0 : editData.map(function (v, k) {
|
|
var _v$question;
|
|
v.key = k + 1;
|
|
v.len = editData.length;
|
|
if (v.question.question_type === 1) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(components_SingleEditor, {
|
|
ref: childrenRef,
|
|
editKey: editKey,
|
|
callback: callback,
|
|
editData: v
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(divider/* default */.Z, {})]
|
|
}, v.id);
|
|
}
|
|
if (v.question.question_type === 2) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(MultipleEditor, {
|
|
ref: childrenRef,
|
|
editKey: editKey,
|
|
callback: callback,
|
|
editData: v
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(divider/* default */.Z, {})]
|
|
}, v.id);
|
|
}
|
|
if (((_v$question = v.question) === null || _v$question === void 0 ? void 0 : _v$question.question_type) === 3) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(SubjectiveEditor, {
|
|
ref: childrenRef,
|
|
editKey: editKey,
|
|
callback: callback,
|
|
editData: v
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(divider/* default */.Z, {})]
|
|
}, v.id);
|
|
}
|
|
});
|
|
};
|
|
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: /*#__PURE__*/(0,jsx_runtime.jsx)(_umi_production_exports.Link, {
|
|
to: "/users/".concat(userInfo === null || userInfo === void 0 ? void 0 : userInfo.login, "/topics/").concat(params.topicId, "/").concat(params.topictype, "/poll/detail"),
|
|
children: "\u8BE6\u60C5"
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(breadcrumb/* default */.Z.Item, {
|
|
children: "\u7F16\u8F91"
|
|
})]
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("aside", {
|
|
className: [Editmodules.title, 'mt20'].join(' '),
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
|
|
style: {
|
|
width: "100%"
|
|
},
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
flex: "1",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("strong", {
|
|
className: "font20 ml5",
|
|
children: "\u7F16\u8F91"
|
|
})
|
|
}), /*#__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: [Editmodules.bg, 'pt30', 'pl30', 'pr30', 'pb30', 'mt20'].join(' '),
|
|
children: [!isEdit && /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
className: Editmodules.containerDesc,
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
children: (_polls$exerciseBanks5 = polls.exerciseBanks) === null || _polls$exerciseBanks5 === void 0 || (_polls$exerciseBanks5 = _polls$exerciseBanks5.poll) === null || _polls$exerciseBanks5 === void 0 ? void 0 : _polls$exerciseBanks5.name
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
|
|
title: "\u7F16\u8F91",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
onClick: function onClick() {
|
|
return setIsEdit(true);
|
|
},
|
|
className: "iconfont c-green ml30 icon-bianjidaibeijing"
|
|
})
|
|
})
|
|
})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: "c-light-black",
|
|
children: (_polls$exerciseBanks6 = polls.exerciseBanks) === null || _polls$exerciseBanks6 === void 0 || (_polls$exerciseBanks6 = _polls$exerciseBanks6.poll) === null || _polls$exerciseBanks6 === void 0 ? void 0 : _polls$exerciseBanks6.description
|
|
})]
|
|
}), 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: "\u95EE\u5377\u6807\u9898\uFF1A",
|
|
rules: [{
|
|
required: true,
|
|
message: "请填写问卷标题"
|
|
}],
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, {
|
|
maxLength: 60,
|
|
placeholder: "\u95EE\u5377\u6807\u9898\uFF0C\u6700\u5927\u9650\u523660\u4E2A\u5B57\u7B26"
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
|
|
label: "\u95EE\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\u95EE\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.jsx)("section", {
|
|
className: "mt20",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, {
|
|
flex: 1,
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
|
|
className: "c-light-black mr20",
|
|
children: ["\u5355\u9009\u9898 ", (_polls$exerciseBanks7 = polls.exerciseBanks) === null || _polls$exerciseBanks7 === void 0 || (_polls$exerciseBanks7 = _polls$exerciseBanks7.question_types) === null || _polls$exerciseBanks7 === void 0 ? void 0 : _polls$exerciseBanks7.q_singles, " \u9898"]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
|
|
className: "c-light-black mr20",
|
|
children: ["\u591A\u9009\u9898 ", (_polls$exerciseBanks8 = polls.exerciseBanks) === null || _polls$exerciseBanks8 === void 0 || (_polls$exerciseBanks8 = _polls$exerciseBanks8.question_types) === null || _polls$exerciseBanks8 === void 0 ? void 0 : _polls$exerciseBanks8.q_doubles, " \u9898"]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
|
|
className: "c-light-black",
|
|
children: ["\u4E3B\u89C2\u9898 ", (_polls$exerciseBanks9 = polls.exerciseBanks) === null || _polls$exerciseBanks9 === void 0 || (_polls$exerciseBanks9 = _polls$exerciseBanks9.question_types) === null || _polls$exerciseBanks9 === void 0 ? void 0 : _polls$exerciseBanks9.q_mains, " \u9898"]
|
|
})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, {
|
|
className: "c-light-black",
|
|
children: ["\u5408\u8BA1 ", /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "c-orange",
|
|
children: (_polls$exerciseBanks10 = polls.exerciseBanks) === null || _polls$exerciseBanks10 === void 0 || (_polls$exerciseBanks10 = _polls$exerciseBanks10.question_types) === null || _polls$exerciseBanks10 === void 0 ? void 0 : _polls$exerciseBanks10.q_counts
|
|
}), " \u9898"]
|
|
})]
|
|
})
|
|
}), editData != '' && /*#__PURE__*/(0,jsx_runtime.jsx)("section", {
|
|
className: [Editmodules.bg, 'pt30', 'pl20', 'pr20', 'pb20', 'mt20'].join(' '),
|
|
children: renderQuestion()
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("section", {
|
|
className: [Editmodules.bg, 'pt30', 'pl30', 'pr30', 'pb30', 'mt20'].join(' '),
|
|
children: questionType.map(function (item, index) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)(es_button/* default */.ZP, {
|
|
className: "mr20",
|
|
type: "primary",
|
|
onClick: function onClick() {
|
|
return addQuestion(item.id);
|
|
},
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(PlusCircleOutlined/* default */.Z, {
|
|
className: "mr5"
|
|
}), item.name]
|
|
});
|
|
})
|
|
})]
|
|
});
|
|
};
|
|
/* harmony default export */ var Edit = ((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));
|
|
|
|
/***/ }),
|
|
|
|
/***/ 89206:
|
|
/*!*****************************!*\
|
|
!*** ./src/utils/marked.ts ***!
|
|
\*****************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ AL: function() { return /* binding */ resetMathExpressions; },
|
|
/* harmony export */ Iy: function() { return /* binding */ cleanToc; },
|
|
/* harmony export */ Qv: function() { return /* binding */ getTocContent; },
|
|
/* harmony export */ ez: function() { return /* binding */ getMathExpressions; },
|
|
/* harmony export */ jb: function() { return /* binding */ lines; }
|
|
/* harmony export */ });
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/slicedToArray.js */ 79800);
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var marked__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! marked */ 32834);
|
|
/* harmony import */ var marked__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(marked__WEBPACK_IMPORTED_MODULE_1__);
|
|
/* harmony import */ var marked_src_helpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! marked/src/helpers */ 11690);
|
|
/* harmony import */ var marked_src_helpers__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(marked_src_helpers__WEBPACK_IMPORTED_MODULE_2__);
|
|
|
|
|
|
|
|
function indentCodeCompensation(raw, text) {
|
|
var matchIndentToCode = raw.match(/^(\s+)(?:```)/);
|
|
if (matchIndentToCode === null) {
|
|
return text;
|
|
}
|
|
var indentToCode = matchIndentToCode[1];
|
|
return text.split('\n').map(function (node) {
|
|
var matchIndentInNode = node.match(/^\s+/);
|
|
if (matchIndentInNode === null) {
|
|
return node;
|
|
}
|
|
var _matchIndentInNode = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_0___default()(matchIndentInNode, 1),
|
|
indentInNode = _matchIndentInNode[0];
|
|
if (indentInNode.length >= indentToCode.length) {
|
|
return node.slice(indentToCode.length);
|
|
}
|
|
return node;
|
|
}).join('\n');
|
|
}
|
|
//兼容之前的 ##标题式写法
|
|
var toc = [];
|
|
var ctx = ["<ul>"];
|
|
var renderer = new (marked__WEBPACK_IMPORTED_MODULE_1___default().Renderer)();
|
|
var headingRegex = /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;
|
|
function cleanToc() {
|
|
toc.length = 0;
|
|
ctx = ["<ul>"];
|
|
}
|
|
var lines = {
|
|
overflow: "hidden",
|
|
WebkitBoxOrient: "vertical",
|
|
display: "-webkit-box",
|
|
WebkitLineClamp: 2
|
|
};
|
|
function buildToc(coll, k, level, ctx) {
|
|
if (k >= coll.length || coll[k].level <= level) {
|
|
return k;
|
|
}
|
|
var node = coll[k];
|
|
ctx.push("<li><a href='#" + node.anchor + "'>" + node.text + "</a>");
|
|
k++;
|
|
var childCtx = [];
|
|
k = buildToc(coll, k, node.level, childCtx);
|
|
if (childCtx.length > 0) {
|
|
ctx.push("<ul>");
|
|
childCtx.forEach(function (idm) {
|
|
ctx.push(idm);
|
|
});
|
|
ctx.push("</ul>");
|
|
}
|
|
ctx.push("</li>");
|
|
k = buildToc(coll, k, level, ctx);
|
|
return k;
|
|
}
|
|
function getTocContent() {
|
|
buildToc(toc, 0, 0, ctx);
|
|
ctx.push("</ul>");
|
|
return ctx.join("");
|
|
}
|
|
var tokenizer = {
|
|
heading: function heading(src) {
|
|
var cap = headingRegex.exec(src);
|
|
if (cap) {
|
|
return {
|
|
type: 'heading',
|
|
raw: cap[0],
|
|
depth: cap[1].length,
|
|
text: cap[2]
|
|
};
|
|
}
|
|
},
|
|
fences: function fences(src) {
|
|
var cap = this.rules.block.fences.exec(src);
|
|
if (cap) {
|
|
var raw = cap[0];
|
|
var text = indentCodeCompensation(raw, cap[3] || '');
|
|
var lang = cap[2] ? cap[2].trim() : cap[2];
|
|
if (['latex', 'katex', 'math'].indexOf(lang) >= 0) {
|
|
var id = next_id();
|
|
var expression = text;
|
|
text = id;
|
|
math_expressions[id] = {
|
|
type: 'block',
|
|
expression: expression
|
|
};
|
|
}
|
|
return {
|
|
type: 'code',
|
|
raw: raw,
|
|
lang: lang,
|
|
text: text
|
|
};
|
|
}
|
|
}
|
|
};
|
|
var latexRegex = /(?:\${2})([^\n`]+?)(?:\${2})/gi;
|
|
var katex_count = 0;
|
|
var next_id = function next_id() {
|
|
return "__special_katext_id_".concat(katex_count++, "__");
|
|
};
|
|
var math_expressions = {};
|
|
function getMathExpressions() {
|
|
return math_expressions;
|
|
}
|
|
function resetMathExpressions() {
|
|
katex_count = 0;
|
|
math_expressions = {};
|
|
}
|
|
function replace_math_with_ids(text) {
|
|
text = text.replace(latexRegex, function (_match, expression) {
|
|
var id = next_id();
|
|
math_expressions[id] = {
|
|
type: 'inline',
|
|
expression: expression
|
|
};
|
|
return id;
|
|
});
|
|
return text;
|
|
}
|
|
var original_listitem = renderer.listitem;
|
|
renderer.listitem = function (text) {
|
|
return original_listitem(replace_math_with_ids(text));
|
|
};
|
|
var original_paragraph = renderer.paragraph;
|
|
renderer.paragraph = function (text) {
|
|
return original_paragraph(replace_math_with_ids(text));
|
|
};
|
|
var original_tablecell = renderer.tablecell;
|
|
renderer.tablecell = function (content, flags) {
|
|
return original_tablecell(replace_math_with_ids(content), flags);
|
|
};
|
|
renderer.code = function (code, infostring, escaped) {
|
|
var lang = (infostring || '').match(/\S*/)[0];
|
|
if (!lang) {
|
|
return '<pre class="prettyprint linenums"><code>' + (escaped ? code : (0,marked_src_helpers__WEBPACK_IMPORTED_MODULE_2__.escape)(code, true)) + '</code></pre>';
|
|
}
|
|
if (['latex', 'katex', 'math'].indexOf(lang) >= 0) {
|
|
return "<p class='editormd-tex'>".concat(code, "</p>");
|
|
} else {
|
|
return "<pre class=\"prettyprint linenums\"><code class=\"language-".concat(infostring, "\">").concat(escaped ? code : (0,marked_src_helpers__WEBPACK_IMPORTED_MODULE_2__.escape)(code, true), "</code></pre>\n");
|
|
}
|
|
};
|
|
renderer.heading = function (text, level, raw) {
|
|
var anchor = this.options.headerPrefix + raw.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g, '-');
|
|
toc.push({
|
|
anchor: anchor,
|
|
level: level,
|
|
text: text
|
|
});
|
|
return '<h' + level + ' id="' + anchor + '">' + text + '</h' + level + '>';
|
|
};
|
|
marked__WEBPACK_IMPORTED_MODULE_1___default().setOptions({
|
|
silent: true,
|
|
gfm: true,
|
|
pedantic: false
|
|
});
|
|
marked__WEBPACK_IMPORTED_MODULE_1___default().use({
|
|
tokenizer: tokenizer,
|
|
renderer: renderer
|
|
});
|
|
/* harmony default export */ __webpack_exports__.ZP = ((marked__WEBPACK_IMPORTED_MODULE_1___default()));
|
|
|
|
/***/ })
|
|
|
|
}]); |