|
|
"use strict";
|
|
|
(self["webpackChunk"] = self["webpackChunk"] || []).push([[34994,19253],{
|
|
|
|
|
|
/***/ 47104:
|
|
|
/*!*************************************************************************************************************!*\
|
|
|
!*** ./node_modules/_@ant-design_icons@5.2.6@@ant-design/icons/es/icons/CloseCircleOutlined.js + 1 modules ***!
|
|
|
\*************************************************************************************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
|
// EXPORTS
|
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
|
Z: function() { return /* binding */ icons_CloseCircleOutlined; }
|
|
|
});
|
|
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/esm/extends.js
|
|
|
var esm_extends = __webpack_require__(38329);
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
|
|
|
var _react_17_0_2_react = __webpack_require__(59301);
|
|
|
;// CONCATENATED MODULE: ./node_modules/_@ant-design_icons-svg@4.3.1@@ant-design/icons-svg/es/asn/CloseCircleOutlined.js
|
|
|
// This icon file is generated automatically.
|
|
|
var CloseCircleOutlined = { "icon": { "tag": "svg", "attrs": { "fill-rule": "evenodd", "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M512 64c247.4 0 448 200.6 448 448S759.4 960 512 960 64 759.4 64 512 264.6 64 512 64zm0 76c-205.4 0-372 166.6-372 372s166.6 372 372 372 372-166.6 372-372-166.6-372-372-372zm128.01 198.83c.03 0 .05.01.09.06l45.02 45.01a.2.2 0 01.05.09.12.12 0 010 .07c0 .02-.01.04-.05.08L557.25 512l127.87 127.86a.27.27 0 01.05.06v.02a.12.12 0 010 .07c0 .03-.01.05-.05.09l-45.02 45.02a.2.2 0 01-.09.05.12.12 0 01-.07 0c-.02 0-.04-.01-.08-.05L512 557.25 384.14 685.12c-.04.04-.06.05-.08.05a.12.12 0 01-.07 0c-.03 0-.05-.01-.09-.05l-45.02-45.02a.2.2 0 01-.05-.09.12.12 0 010-.07c0-.02.01-.04.06-.08L466.75 512 338.88 384.14a.27.27 0 01-.05-.06l-.01-.02a.12.12 0 010-.07c0-.03.01-.05.05-.09l45.02-45.02a.2.2 0 01.09-.05.12.12 0 01.07 0c.02 0 .04.01.08.06L512 466.75l127.86-127.86c.04-.05.06-.06.08-.06a.12.12 0 01.07 0z" } }] }, "name": "close-circle", "theme": "outlined" };
|
|
|
/* harmony default export */ var asn_CloseCircleOutlined = (CloseCircleOutlined);
|
|
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_@ant-design_icons@5.2.6@@ant-design/icons/es/components/AntdIcon.js + 3 modules
|
|
|
var AntdIcon = __webpack_require__(91851);
|
|
|
;// CONCATENATED MODULE: ./node_modules/_@ant-design_icons@5.2.6@@ant-design/icons/es/icons/CloseCircleOutlined.js
|
|
|
|
|
|
// GENERATE BY ./scripts/generate.ts
|
|
|
// DON NOT EDIT IT MANUALLY
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var CloseCircleOutlined_CloseCircleOutlined = function CloseCircleOutlined(props, ref) {
|
|
|
return /*#__PURE__*/_react_17_0_2_react.createElement(AntdIcon/* default */.Z, (0,esm_extends/* default */.Z)({}, props, {
|
|
|
ref: ref,
|
|
|
icon: asn_CloseCircleOutlined
|
|
|
}));
|
|
|
};
|
|
|
if (false) {}
|
|
|
/* harmony default export */ var icons_CloseCircleOutlined = (/*#__PURE__*/_react_17_0_2_react.forwardRef(CloseCircleOutlined_CloseCircleOutlined));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 22321:
|
|
|
/*!**********************************************************************************************************!*\
|
|
|
!*** ./node_modules/_@ant-design_icons@5.2.6@@ant-design/icons/es/icons/PoweroffOutlined.js + 1 modules ***!
|
|
|
\**********************************************************************************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
|
// EXPORTS
|
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
|
Z: function() { return /* binding */ icons_PoweroffOutlined; }
|
|
|
});
|
|
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/esm/extends.js
|
|
|
var esm_extends = __webpack_require__(38329);
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
|
|
|
var _react_17_0_2_react = __webpack_require__(59301);
|
|
|
;// CONCATENATED MODULE: ./node_modules/_@ant-design_icons-svg@4.3.1@@ant-design/icons-svg/es/asn/PoweroffOutlined.js
|
|
|
// This icon file is generated automatically.
|
|
|
var PoweroffOutlined = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M705.6 124.9a8 8 0 00-11.6 7.2v64.2c0 5.5 2.9 10.6 7.5 13.6a352.2 352.2 0 0162.2 49.8c32.7 32.8 58.4 70.9 76.3 113.3a355 355 0 0127.9 138.7c0 48.1-9.4 94.8-27.9 138.7a355.92 355.92 0 01-76.3 113.3 353.06 353.06 0 01-113.2 76.4c-43.8 18.6-90.5 28-138.5 28s-94.7-9.4-138.5-28a353.06 353.06 0 01-113.2-76.4A355.92 355.92 0 01184 650.4a355 355 0 01-27.9-138.7c0-48.1 9.4-94.8 27.9-138.7 17.9-42.4 43.6-80.5 76.3-113.3 19-19 39.8-35.6 62.2-49.8 4.7-2.9 7.5-8.1 7.5-13.6V132c0-6-6.3-9.8-11.6-7.2C178.5 195.2 82 339.3 80 506.3 77.2 745.1 272.5 943.5 511.2 944c239 .5 432.8-193.3 432.8-432.4 0-169.2-97-315.7-238.4-386.7zM480 560h64c4.4 0 8-3.6 8-8V88c0-4.4-3.6-8-8-8h-64c-4.4 0-8 3.6-8 8v464c0 4.4 3.6 8 8 8z" } }] }, "name": "poweroff", "theme": "outlined" };
|
|
|
/* harmony default export */ var asn_PoweroffOutlined = (PoweroffOutlined);
|
|
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_@ant-design_icons@5.2.6@@ant-design/icons/es/components/AntdIcon.js + 3 modules
|
|
|
var AntdIcon = __webpack_require__(91851);
|
|
|
;// CONCATENATED MODULE: ./node_modules/_@ant-design_icons@5.2.6@@ant-design/icons/es/icons/PoweroffOutlined.js
|
|
|
|
|
|
// GENERATE BY ./scripts/generate.ts
|
|
|
// DON NOT EDIT IT MANUALLY
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var PoweroffOutlined_PoweroffOutlined = function PoweroffOutlined(props, ref) {
|
|
|
return /*#__PURE__*/_react_17_0_2_react.createElement(AntdIcon/* default */.Z, (0,esm_extends/* default */.Z)({}, props, {
|
|
|
ref: ref,
|
|
|
icon: asn_PoweroffOutlined
|
|
|
}));
|
|
|
};
|
|
|
if (false) {}
|
|
|
/* harmony default export */ var icons_PoweroffOutlined = (/*#__PURE__*/_react_17_0_2_react.forwardRef(PoweroffOutlined_PoweroffOutlined));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 51811:
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/pages/tasks/util.js ***!
|
|
|
\*********************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
|
/* harmony export */ Ax: function() { return /* binding */ processTreeData; },
|
|
|
/* harmony export */ Ds: function() { return /* binding */ debounce; },
|
|
|
/* harmony export */ KI: function() { return /* binding */ apiPref; },
|
|
|
/* harmony export */ SI: function() { return /* binding */ getTreeData; },
|
|
|
/* harmony export */ f1: function() { return /* binding */ isCompileOk; }
|
|
|
/* harmony export */ });
|
|
|
/* unused harmony export isProd */
|
|
|
/* harmony import */ var _utils_env__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/utils/env */ 67871);
|
|
|
|
|
|
function isCompileOk(rs) {
|
|
|
var flag = true;
|
|
|
if (rs.length > 0) {
|
|
|
for (var i = 0; i < rs.length; i++) {
|
|
|
if (rs[i].compile_success == 0 || !rs[i].compile_success) {
|
|
|
flag = false;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
flag = false;
|
|
|
}
|
|
|
return flag;
|
|
|
}
|
|
|
function getTreeData(data) {
|
|
|
var parentKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
|
var result = [];
|
|
|
for (var i = 0; i < data.length; i++) {
|
|
|
var item = data[i];
|
|
|
var key = parentKey ? "".concat(parentKey, "/").concat(item.name) : "".concat(item.name);
|
|
|
result.push({
|
|
|
title: item.name,
|
|
|
isLeaf: item.type === 'tree' ? false : true,
|
|
|
key: key
|
|
|
});
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
function processTreeData(repos, key, newData) {
|
|
|
for (var i = 0; i < repos.length; i++) {
|
|
|
var item = repos[i];
|
|
|
if (item.key === key) {
|
|
|
item.children = newData;
|
|
|
break;
|
|
|
}
|
|
|
if (item.children) {
|
|
|
processTreeData(item.children, key, newData);
|
|
|
}
|
|
|
}
|
|
|
return repos;
|
|
|
}
|
|
|
function debounce(func, wait, immediate) {
|
|
|
var timeout;
|
|
|
return function () {
|
|
|
var context = this,
|
|
|
args = arguments;
|
|
|
var later = function later() {
|
|
|
timeout = null;
|
|
|
if (!immediate) func.apply(context, args);
|
|
|
};
|
|
|
var callNow = immediate && !timeout;
|
|
|
clearTimeout(timeout);
|
|
|
timeout = setTimeout(later, wait);
|
|
|
if (callNow) func.apply(context, args);
|
|
|
};
|
|
|
}
|
|
|
var isProd = true;
|
|
|
var apiPref = _utils_env__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z.API_SERVER;
|
|
|
// export const isProd =
|
|
|
// window.location.href.indexOf('test-') > 0 ||
|
|
|
// window.location.href.indexOf('localhost') > 0
|
|
|
// ? false
|
|
|
// : true;
|
|
|
|
|
|
// export const apiPref = isProd
|
|
|
// ? 'https://www.educoder.net'
|
|
|
// : 'https://test-newweb.educoder.net';
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 99947:
|
|
|
/*!*********************************************************!*\
|
|
|
!*** ./src/components/CustomTree/index.tsx + 1 modules ***!
|
|
|
\*********************************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
|
// EXPORTS
|
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
|
Z: function() { return /* binding */ components_CustomTree; }
|
|
|
});
|
|
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectSpread2.js
|
|
|
var objectSpread2 = __webpack_require__(26801);
|
|
|
var objectSpread2_default = /*#__PURE__*/__webpack_require__.n(objectSpread2);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/regeneratorRuntime.js
|
|
|
var regeneratorRuntime = __webpack_require__(10574);
|
|
|
var regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(regeneratorRuntime);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/asyncToGenerator.js
|
|
|
var asyncToGenerator = __webpack_require__(39343);
|
|
|
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/slicedToArray.js
|
|
|
var slicedToArray = __webpack_require__(11006);
|
|
|
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectWithoutProperties.js
|
|
|
var objectWithoutProperties = __webpack_require__(27161);
|
|
|
var objectWithoutProperties_default = /*#__PURE__*/__webpack_require__.n(objectWithoutProperties);
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
|
|
|
var _react_17_0_2_react = __webpack_require__(59301);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/tree/index.js + 8 modules
|
|
|
var tree = __webpack_require__(51218);
|
|
|
// EXTERNAL MODULE: ./src/service/problemset.ts
|
|
|
var problemset = __webpack_require__(81513);
|
|
|
;// CONCATENATED MODULE: ./src/components/CustomTree/index.less?modules
|
|
|
// extracted by mini-css-extract-plugin
|
|
|
/* harmony default export */ var CustomTreemodules = ({"flex_box_center":"flex_box_center___SFmJH","flex_space_between":"flex_space_between___f2H1D","flex_box_vertical_center":"flex_box_vertical_center___hW_hp","flex_box_center_end":"flex_box_center_end___yklmJ","flex_box_column":"flex_box_column___m0oUw","customTree":"customTree___ZhEHU","name":"name___RIkn2"});
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/jsx-runtime.js
|
|
|
var jsx_runtime = __webpack_require__(37712);
|
|
|
;// CONCATENATED MODULE: ./src/components/CustomTree/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _excluded = ["value", "onChange", "defaultValue", "disabled"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var CustomTree = function CustomTree(_ref) {
|
|
|
var value = _ref.value,
|
|
|
onChange = _ref.onChange,
|
|
|
defaultValue = _ref.defaultValue,
|
|
|
disabled = _ref.disabled,
|
|
|
props = objectWithoutProperties_default()(_ref, _excluded);
|
|
|
var _useState = (0,_react_17_0_2_react.useState)([]),
|
|
|
_useState2 = slicedToArray_default()(_useState, 2),
|
|
|
treeData = _useState2[0],
|
|
|
setTreeData = _useState2[1];
|
|
|
var _useState3 = (0,_react_17_0_2_react.useState)('1'),
|
|
|
_useState4 = slicedToArray_default()(_useState3, 2),
|
|
|
keyIndex = _useState4[0],
|
|
|
setKeyIndex = _useState4[1];
|
|
|
// const sign = useRef(true)
|
|
|
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
getData();
|
|
|
}, []);
|
|
|
var getData = /*#__PURE__*/function () {
|
|
|
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() {
|
|
|
var res, item;
|
|
|
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
|
|
|
while (1) switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
_context.next = 2;
|
|
|
return (0,problemset/* getPaperList */.NZ)({});
|
|
|
case 2:
|
|
|
res = _context.sent;
|
|
|
// setFolderLoading(false)
|
|
|
if (res !== null && res !== void 0 && res.data) {
|
|
|
item = [{
|
|
|
title: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
title: '根目录',
|
|
|
className: CustomTreemodules.name,
|
|
|
children: "\u6839\u76EE\u5F55"
|
|
|
}),
|
|
|
value: 0,
|
|
|
key: 0,
|
|
|
icon: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
|
|
|
className: "iconfont icon-wenjianjia2 c-light-primary mr10",
|
|
|
style: {
|
|
|
lineHeight: '19px'
|
|
|
}
|
|
|
}),
|
|
|
children: transformTreeKey(res.data || [])
|
|
|
}];
|
|
|
setTreeData(item);
|
|
|
setKeyIndex('2');
|
|
|
}
|
|
|
case 4:
|
|
|
case "end":
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}, _callee);
|
|
|
}));
|
|
|
return function getData() {
|
|
|
return _ref2.apply(this, arguments);
|
|
|
};
|
|
|
}();
|
|
|
var transformTreeKey = function transformTreeKey(items) {
|
|
|
function mapTree(org) {
|
|
|
var realChildren = org.children;
|
|
|
var haveChildren = Array.isArray(realChildren) && realChildren.length > 0;
|
|
|
var key = org === null || org === void 0 ? void 0 : org.group_id;
|
|
|
return {
|
|
|
//分别将我们查询出来的值做出改变他的key
|
|
|
title: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
title: org === null || org === void 0 ? void 0 : org.name,
|
|
|
className: CustomTreemodules.name,
|
|
|
children: org === null || org === void 0 ? void 0 : org.name
|
|
|
}),
|
|
|
value: key,
|
|
|
key: key,
|
|
|
icon: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
|
|
|
className: "iconfont icon-wenjianjia2 c-light-primary mr10",
|
|
|
style: {
|
|
|
lineHeight: '19px'
|
|
|
}
|
|
|
}),
|
|
|
//判断它是否存在子集,若果存在就进行再次进行遍历操作,知道不存在子集便对其他的元素进行操作
|
|
|
children: haveChildren ? realChildren === null || realChildren === void 0 ? void 0 : realChildren.map(function (e) {
|
|
|
return mapTree(e);
|
|
|
}) : []
|
|
|
};
|
|
|
}
|
|
|
return items === null || items === void 0 ? void 0 : items.map(function (org) {
|
|
|
return mapTree(org);
|
|
|
});
|
|
|
};
|
|
|
var param = defaultValue ? {
|
|
|
defaultExpandedKeys: [0],
|
|
|
defaultSelectedKeys: [0]
|
|
|
} : {
|
|
|
selectedKeys: value,
|
|
|
defaultExpandedKeys: value
|
|
|
};
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
className: CustomTreemodules.customTree,
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(tree/* default */.Z, objectSpread2_default()(objectSpread2_default()({}, param), {}, {
|
|
|
showIcon: true,
|
|
|
treeData: treeData,
|
|
|
onSelect: onChange,
|
|
|
disabled: disabled
|
|
|
}, props), keyIndex)
|
|
|
});
|
|
|
};
|
|
|
/* harmony default export */ var components_CustomTree = (CustomTree);
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 11681:
|
|
|
/*!**************************************************************!*\
|
|
|
!*** ./src/components/ImageDimensions/index.tsx + 1 modules ***!
|
|
|
\**************************************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
|
// EXPORTS
|
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
|
Z: function() { return /* binding */ components_ImageDimensions; }
|
|
|
});
|
|
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/regeneratorRuntime.js
|
|
|
var regeneratorRuntime = __webpack_require__(10574);
|
|
|
var regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(regeneratorRuntime);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/asyncToGenerator.js
|
|
|
var asyncToGenerator = __webpack_require__(39343);
|
|
|
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/slicedToArray.js
|
|
|
var slicedToArray = __webpack_require__(11006);
|
|
|
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
|
|
|
var _react_17_0_2_react = __webpack_require__(59301);
|
|
|
;// CONCATENATED MODULE: ./src/components/ImageDimensions/index.less?modules
|
|
|
// extracted by mini-css-extract-plugin
|
|
|
/* harmony default export */ var ImageDimensionsmodules = ({"imageDimensions":"imageDimensions___a7crR","img":"img___Kroat","fullWidth":"fullWidth___c492T"});
|
|
|
// EXTERNAL MODULE: ./node_modules/_classnames@2.5.0@classnames/index.js
|
|
|
var _classnames_2_5_0_classnames = __webpack_require__(73287);
|
|
|
var _classnames_2_5_0_classnames_default = /*#__PURE__*/__webpack_require__.n(_classnames_2_5_0_classnames);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/spin/index.js + 1 modules
|
|
|
var spin = __webpack_require__(71418);
|
|
|
// EXTERNAL MODULE: ./node_modules/_markerjs3@2.29.1@markerjs3/markerjs2.esm.js
|
|
|
var markerjs2_esm = __webpack_require__(2859);
|
|
|
// EXTERNAL MODULE: ./src/utils/fetch.ts
|
|
|
var fetch = __webpack_require__(15830);
|
|
|
// EXTERNAL MODULE: ./src/utils/util.tsx
|
|
|
var util = __webpack_require__(85578);
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/jsx-runtime.js
|
|
|
var jsx_runtime = __webpack_require__(37712);
|
|
|
;// CONCATENATED MODULE: ./src/components/ImageDimensions/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ImageDimensions = function ImageDimensions(_ref) {
|
|
|
var data = _ref.data,
|
|
|
className = _ref.className,
|
|
|
fullWidth = _ref.fullWidth,
|
|
|
_ref$style = _ref.style,
|
|
|
style = _ref$style === void 0 ? {} : _ref$style,
|
|
|
onClose = _ref.onClose,
|
|
|
onOk = _ref.onOk,
|
|
|
showFullTools = _ref.showFullTools,
|
|
|
noAssociationId = _ref.noAssociationId;
|
|
|
var imgRef = (0,_react_17_0_2_react.useRef)(null);
|
|
|
var markerArea = (0,_react_17_0_2_react.useRef)(null);
|
|
|
var _useState = (0,_react_17_0_2_react.useState)(false),
|
|
|
_useState2 = slicedToArray_default()(_useState, 2),
|
|
|
loading = _useState2[0],
|
|
|
setLoading = _useState2[1];
|
|
|
var _useState3 = (0,_react_17_0_2_react.useState)('正在加载中'),
|
|
|
_useState4 = slicedToArray_default()(_useState3, 2),
|
|
|
loadingText = _useState4[0],
|
|
|
setLoadingText = _useState4[1];
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
if (data !== null && data !== void 0 && data.visible) {
|
|
|
document.body.setAttribute('data-custom', 'y-hidden');
|
|
|
} else {
|
|
|
document.body.removeAttribute('data-custom');
|
|
|
}
|
|
|
if (data !== null && data !== void 0 && data.src) {
|
|
|
getImg();
|
|
|
}
|
|
|
}, [data === null || data === void 0 ? void 0 : data.visible]);
|
|
|
var getImg = /*#__PURE__*/function () {
|
|
|
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() {
|
|
|
var res;
|
|
|
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
|
|
|
while (1) switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
setLoading(true);
|
|
|
setLoadingText('正在加载中');
|
|
|
_context.next = 4;
|
|
|
return (0,util/* toDataUrl */.ZJ)(data === null || data === void 0 ? void 0 : data.src);
|
|
|
case 4:
|
|
|
res = _context.sent;
|
|
|
imgRef.current.src = "";
|
|
|
imgRef.current.src = res;
|
|
|
imgRef.current.onload = function () {
|
|
|
initMarkerjs();
|
|
|
};
|
|
|
setLoading(false);
|
|
|
setLoadingText('');
|
|
|
case 10:
|
|
|
case "end":
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}, _callee);
|
|
|
}));
|
|
|
return function getImg() {
|
|
|
return _ref2.apply(this, arguments);
|
|
|
};
|
|
|
}();
|
|
|
var onSave = /*#__PURE__*/function () {
|
|
|
var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2(event) {
|
|
|
var res, result;
|
|
|
return regeneratorRuntime_default()().wrap(function _callee2$(_context2) {
|
|
|
while (1) switch (_context2.prev = _context2.next) {
|
|
|
case 0:
|
|
|
setLoading(true);
|
|
|
setLoadingText('正在保存中');
|
|
|
_context2.next = 4;
|
|
|
return (0,fetch/* default */.ZP)('/api/attachments.json', {
|
|
|
method: 'post',
|
|
|
body: {
|
|
|
file_type: 'base64',
|
|
|
original_filename: data.title,
|
|
|
file: event.dataUrl
|
|
|
}
|
|
|
});
|
|
|
case 4:
|
|
|
res = _context2.sent;
|
|
|
if (!(res !== null && res !== void 0 && res.id && !noAssociationId)) {
|
|
|
_context2.next = 12;
|
|
|
break;
|
|
|
}
|
|
|
_context2.next = 8;
|
|
|
return (0,fetch/* default */.ZP)("/api/attachments/".concat(data.id, "/add_subitem.json"), {
|
|
|
method: 'post',
|
|
|
body: {
|
|
|
subitem_id: res === null || res === void 0 ? void 0 : res.id,
|
|
|
settings: JSON.stringify(event.state)
|
|
|
}
|
|
|
});
|
|
|
case 8:
|
|
|
result = _context2.sent;
|
|
|
if (result.status === 0) {
|
|
|
onOk();
|
|
|
}
|
|
|
_context2.next = 13;
|
|
|
break;
|
|
|
case 12:
|
|
|
if (res !== null && res !== void 0 && res.id) {
|
|
|
onOk(res);
|
|
|
}
|
|
|
case 13:
|
|
|
setLoading(false);
|
|
|
setLoadingText('');
|
|
|
case 15:
|
|
|
case "end":
|
|
|
return _context2.stop();
|
|
|
}
|
|
|
}, _callee2);
|
|
|
}));
|
|
|
return function onSave(_x) {
|
|
|
return _ref3.apply(this, arguments);
|
|
|
};
|
|
|
}();
|
|
|
var dealDom = function dealDom() {
|
|
|
// 删除标签
|
|
|
// 找到href为"https://markerjs.com/"的a标签
|
|
|
var targetLink = document.querySelector('a[href="https://markerjs.com/"]');
|
|
|
if (targetLink && targetLink.parentNode) {
|
|
|
targetLink.parentNode.style.display = 'none';
|
|
|
}
|
|
|
|
|
|
// 设置title
|
|
|
var item = [{
|
|
|
name: '[data-action="select"]',
|
|
|
title: '选择'
|
|
|
}, {
|
|
|
name: '[data-action="delete"]',
|
|
|
title: '删除元素'
|
|
|
}, {
|
|
|
name: '[data-action="undo"]',
|
|
|
title: '撤销'
|
|
|
}, {
|
|
|
name: '[data-type-name="FrameMarker"]',
|
|
|
title: '矩形'
|
|
|
}, {
|
|
|
name: '[data-type-name="FreehandMarker"]',
|
|
|
title: '画线'
|
|
|
}, {
|
|
|
name: '[data-type-name="ArrowMarker"]',
|
|
|
title: '箭头'
|
|
|
}, {
|
|
|
name: '[data-type-name="TextMarker"]',
|
|
|
title: '文本'
|
|
|
}, {
|
|
|
name: '[data-type-name="EllipseMarker"]',
|
|
|
title: '椭圆'
|
|
|
}, {
|
|
|
name: '[data-type-name="HighlightMarker"]',
|
|
|
title: '方块'
|
|
|
}, {
|
|
|
name: '[data-type-name="CalloutMarker"]',
|
|
|
title: '注释'
|
|
|
}, {
|
|
|
name: '[data-action="render"]',
|
|
|
title: '保存'
|
|
|
}, {
|
|
|
name: '[data-action="close"]',
|
|
|
title: '退出'
|
|
|
}];
|
|
|
item.forEach(function (e) {
|
|
|
var targetElement = document.querySelector(e.name);
|
|
|
if (targetElement) {
|
|
|
targetElement.setAttribute('title', e.title);
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
var initMarkerjs = function initMarkerjs() {
|
|
|
markerArea.current = new markerjs2_esm/* MarkerArea */.hP(imgRef.current);
|
|
|
markerArea.current.addEventListener('render', onSave);
|
|
|
markerArea.current.addEventListener('beforeclose', onClose);
|
|
|
if (showFullTools) {
|
|
|
markerArea.current.availableMarkerTypes = markerArea.current.ALL_MARKER_TYPES;
|
|
|
markerArea.current.uiStyleSettings.redoButtonVisible = true;
|
|
|
markerArea.current.uiStyleSettings.notesButtonVisible = true;
|
|
|
markerArea.current.uiStyleSettings.zoomButtonVisible = true;
|
|
|
markerArea.current.uiStyleSettings.zoomOutButtonVisible = true;
|
|
|
markerArea.current.uiStyleSettings.clearButtonVisible = true;
|
|
|
}
|
|
|
window.markerArea = markerArea.current.uiStyleSettings;
|
|
|
markerArea.current.show();
|
|
|
if (data !== null && data !== void 0 && data.snapshotData) {
|
|
|
markerArea.current.restoreState(data.snapshotData);
|
|
|
}
|
|
|
setTimeout(function () {
|
|
|
dealDom();
|
|
|
}, 300);
|
|
|
};
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(_react_17_0_2_react.Fragment, {
|
|
|
children: (data === null || data === void 0 ? void 0 : data.visible) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
className: _classnames_2_5_0_classnames_default()(ImageDimensionsmodules.imageDimensions, className, fullWidth ? ImageDimensionsmodules.fullWidth : ""),
|
|
|
style: style,
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(spin/* default */.Z, {
|
|
|
spinning: loading,
|
|
|
tip: loadingText,
|
|
|
style: {
|
|
|
position: 'absolute'
|
|
|
}
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("img", {
|
|
|
className: ImageDimensionsmodules.img,
|
|
|
ref: imgRef
|
|
|
// crossOrigin='anonymous'
|
|
|
// src={data?.src}
|
|
|
})]
|
|
|
})
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/* harmony default export */ var components_ImageDimensions = (ImageDimensions);
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 53108:
|
|
|
/*!********************************************************!*\
|
|
|
!*** ./src/components/Knowledge/index.tsx + 1 modules ***!
|
|
|
\********************************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
|
// EXPORTS
|
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
|
N: function() { return /* binding */ Knowledge; }
|
|
|
});
|
|
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/regeneratorRuntime.js
|
|
|
var regeneratorRuntime = __webpack_require__(10574);
|
|
|
var regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(regeneratorRuntime);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/asyncToGenerator.js
|
|
|
var asyncToGenerator = __webpack_require__(39343);
|
|
|
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/toConsumableArray.js
|
|
|
var toConsumableArray = __webpack_require__(93923);
|
|
|
var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/slicedToArray.js
|
|
|
var slicedToArray = __webpack_require__(11006);
|
|
|
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
|
|
|
var _react_17_0_2_react = __webpack_require__(59301);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/select/index.js
|
|
|
var es_select = __webpack_require__(57809);
|
|
|
// 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/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/input/index.js + 5 modules
|
|
|
var input = __webpack_require__(1056);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/message/index.js + 4 modules
|
|
|
var message = __webpack_require__(8591);
|
|
|
// EXTERNAL MODULE: ./src/utils/fetch.ts
|
|
|
var fetch = __webpack_require__(15830);
|
|
|
;// CONCATENATED MODULE: ./src/components/Knowledge/index.less?modules
|
|
|
// extracted by mini-css-extract-plugin
|
|
|
/* harmony default export */ var Knowledgemodules = ({"wrap":"wrap___F7E3F","selectWrapper":"selectWrapper____kESB","tips":"tips___aHjQY","linkBtn":"linkBtn___uggVr","mainText":"mainText____S1I0"});
|
|
|
// EXTERNAL MODULE: ./node_modules/_@ant-design_icons@5.2.6@@ant-design/icons/es/icons/ExclamationCircleOutlined.js + 1 modules
|
|
|
var ExclamationCircleOutlined = __webpack_require__(80045);
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/jsx-runtime.js
|
|
|
var jsx_runtime = __webpack_require__(37712);
|
|
|
;// CONCATENATED MODULE: ./src/components/Knowledge/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var Option = es_select["default"].Option;
|
|
|
var Knowledge = function Knowledge(_ref) {
|
|
|
var subId = _ref.subId,
|
|
|
value = _ref.value,
|
|
|
selectvalues = _ref.selectvalues,
|
|
|
disabled = _ref.disabled,
|
|
|
_ref$knowledgeOptions = _ref.knowledgeOptions,
|
|
|
knowledgeOptions = _ref$knowledgeOptions === void 0 ? [] : _ref$knowledgeOptions,
|
|
|
_ref$onChange = _ref.onChange,
|
|
|
onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
|
|
|
_ref$onAddKnowledgeFi = _ref.onAddKnowledgeFinish,
|
|
|
onAddKnowledgeFinish = _ref$onAddKnowledgeFi === void 0 ? function () {} : _ref$onAddKnowledgeFi;
|
|
|
var addValue = (0,_react_17_0_2_react.useRef)();
|
|
|
var _useState = (0,_react_17_0_2_react.useState)([]),
|
|
|
_useState2 = slicedToArray_default()(_useState, 2),
|
|
|
values = _useState2[0],
|
|
|
setValues = _useState2[1];
|
|
|
value = value || [];
|
|
|
var handleChange = function handleChange(e, valuesmap) {
|
|
|
if (e) {
|
|
|
//获取选中的数据
|
|
|
setValues([valuesmap.key]);
|
|
|
onChange([valuesmap.key]);
|
|
|
} else {
|
|
|
//获取选中的数据
|
|
|
setValues([]);
|
|
|
onChange([]);
|
|
|
}
|
|
|
};
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
if ((selectvalues === null || selectvalues === void 0 ? void 0 : selectvalues.length) > 0) {
|
|
|
setValues(toConsumableArray_default()(selectvalues));
|
|
|
onChange(toConsumableArray_default()(selectvalues));
|
|
|
}
|
|
|
}, [knowledgeOptions]);
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
var _value;
|
|
|
if (((_value = value) === null || _value === void 0 ? void 0 : _value.length) > 0) {
|
|
|
onChange(toConsumableArray_default()(value));
|
|
|
}
|
|
|
}, [knowledgeOptions]);
|
|
|
var handleAdd = function handleAdd(e) {
|
|
|
e.preventDefault();
|
|
|
addValue.current = '';
|
|
|
modal/* default */.Z.confirm({
|
|
|
centered: true,
|
|
|
width: 640,
|
|
|
okText: '确定',
|
|
|
cancelText: '取消',
|
|
|
icon: null,
|
|
|
title: '新建知识点',
|
|
|
className: 'custom-modal-divider',
|
|
|
content: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
className: "font14",
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
|
|
|
className: "mb20",
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(ExclamationCircleOutlined/* default */.Z, {
|
|
|
style: {
|
|
|
color: '#FF8C29'
|
|
|
}
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, {
|
|
|
className: "ml10 ".concat(Knowledgemodules.mainText),
|
|
|
children: ["\u65B0\u5EFA\u7684\u77E5\u8BC6\u70B9\u4EC5\u672C\u4EBA\u53EF\u89C1\uFF0C\u5E73\u53F0\u5BA1\u6838\u5217\u5165\u516C\u5F00\u77E5\u8BC6\u70B9\u540E\uFF0C\u5BF9\u6240\u6709\u7528\u6237\u53EF\u89C1\u3002", /*#__PURE__*/(0,jsx_runtime.jsx)("br", {}), "\u5E73\u53F0\u6709\u6743\u5220\u9664\u4E0D\u5408\u9002\u7684\u77E5\u8BC6\u70B9\uFF0C\u8BF7\u8BA4\u771F\u586B\u5199\u77E5\u8BC6\u70B9\u540D\u79F0\u3002"]
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, {
|
|
|
maxLength: 20,
|
|
|
size: 'middle',
|
|
|
showCount: true,
|
|
|
placeholder: "\u8BF7\u8F93\u5165\u77E5\u8BC6\u70B9\u540D\u79F0",
|
|
|
defaultValue: addValue.current,
|
|
|
onChange: function onChange(e) {
|
|
|
addValue.current = e.target.value;
|
|
|
}
|
|
|
})]
|
|
|
}),
|
|
|
onOk: function onOk() {
|
|
|
return new Promise( /*#__PURE__*/function () {
|
|
|
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee(resolve, reject) {
|
|
|
var res, _value2;
|
|
|
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
|
|
|
while (1) switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
if (addValue.current) {
|
|
|
_context.next = 3;
|
|
|
break;
|
|
|
}
|
|
|
message/* default */.ZP.warning("请输入知识点名称");
|
|
|
return _context.abrupt("return", reject());
|
|
|
case 3:
|
|
|
if (!(addValue.current.length > 20)) {
|
|
|
_context.next = 6;
|
|
|
break;
|
|
|
}
|
|
|
message/* default */.ZP.warning("请输入不超过20字的知识点名称");
|
|
|
return _context.abrupt("return", reject());
|
|
|
case 6:
|
|
|
_context.next = 8;
|
|
|
return (0,fetch/* default */.ZP)("/api/tag_disciplines.json", {
|
|
|
method: 'post',
|
|
|
body: {
|
|
|
name: addValue.current,
|
|
|
sub_discipline_id: subId
|
|
|
}
|
|
|
});
|
|
|
case 8:
|
|
|
res = _context.sent;
|
|
|
if ((res === null || res === void 0 ? void 0 : res.status) === 0) {
|
|
|
onAddKnowledgeFinish({
|
|
|
id: res.tag_discipline_id,
|
|
|
name: addValue.current,
|
|
|
type: 'personal'
|
|
|
});
|
|
|
// values.push(res.tag_discipline_id)
|
|
|
// value.push(res.tag_discipline_id)
|
|
|
_value2 = [];
|
|
|
_value2.push(res.tag_discipline_id);
|
|
|
onChange([].concat(_value2));
|
|
|
setValues([res.tag_discipline_id]);
|
|
|
onChange([].concat(_value2));
|
|
|
}
|
|
|
return _context.abrupt("return", resolve());
|
|
|
case 11:
|
|
|
case "end":
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}, _callee);
|
|
|
}));
|
|
|
return function (_x, _x2) {
|
|
|
return _ref2.apply(this, arguments);
|
|
|
};
|
|
|
}());
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
|
|
|
wrap: false,
|
|
|
align: "middle",
|
|
|
className: Knowledgemodules.wrap,
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(es_select["default"], {
|
|
|
disabled: !subId || disabled,
|
|
|
className: Knowledgemodules.selectWrapper,
|
|
|
placeholder: "\u8BF7\u9009\u62E9\u77E5\u8BC6\u70B9",
|
|
|
onChange: handleChange,
|
|
|
style: {
|
|
|
width: 490
|
|
|
},
|
|
|
showSearch: true,
|
|
|
allowClear: true,
|
|
|
value: knowledgeOptions === null || knowledgeOptions === void 0 ? void 0 : knowledgeOptions.filter(function (item) {
|
|
|
return (values === null || values === void 0 ? void 0 : values.includes(item === null || item === void 0 ? void 0 : item.id)) || (values === null || values === void 0 ? void 0 : values.includes((item === null || item === void 0 ? void 0 : item.id) + ''));
|
|
|
}).map(function (item) {
|
|
|
return item.name;
|
|
|
}),
|
|
|
children: knowledgeOptions === null || knowledgeOptions === void 0 ? void 0 : knowledgeOptions.map(function (item) {
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(Option, {
|
|
|
value: item.name,
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
style: {
|
|
|
display: 'flex',
|
|
|
justifyContent: 'space-between'
|
|
|
},
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
|
style: {
|
|
|
overflow: "hidden",
|
|
|
whiteSpace: "nowrap",
|
|
|
textOverflow: "ellipsis"
|
|
|
},
|
|
|
children: item.name
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
|
children: item.type === 'personal' ? '(自用)' : ''
|
|
|
})]
|
|
|
})
|
|
|
}, item.id);
|
|
|
})
|
|
|
})
|
|
|
}), subId && /*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, {
|
|
|
className: "ml20",
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
|
className: Knowledgemodules.tips,
|
|
|
children: "\u6CA1\u6709\u5408\u9002\u7684\u77E5\u8BC6\u70B9\uFF1F"
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
|
className: Knowledgemodules.linkBtn,
|
|
|
onClick: handleAdd,
|
|
|
children: "\u65B0\u5EFA\u77E5\u8BC6\u70B9"
|
|
|
})]
|
|
|
})]
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 68006:
|
|
|
/*!**********************************************************!*\
|
|
|
!*** ./src/components/QuestionEditor/MdEditorInForm.tsx ***!
|
|
|
\**********************************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
|
/* harmony export */ h: function() { return /* binding */ MdEditorInForm; },
|
|
|
/* harmony export */ x: function() { return /* binding */ RegularInput; }
|
|
|
/* harmony export */ });
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectSpread2.js */ 26801);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectWithoutProperties_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectWithoutProperties.js */ 27161);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectWithoutProperties_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectWithoutProperties_js__WEBPACK_IMPORTED_MODULE_1__);
|
|
|
/* harmony import */ var _components_markdown_editor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/components/markdown-editor */ 38874);
|
|
|
/* harmony import */ var _index_less_modules__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./index.less?modules */ 34566);
|
|
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react */ 59301);
|
|
|
/* harmony import */ var _components_RenderHtml__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/components/RenderHtml */ 80416);
|
|
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ 37712);
|
|
|
|
|
|
|
|
|
var _excluded = ["value", "onChange", "scrollId"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var MdEditorInForm = function MdEditorInForm(_ref) {
|
|
|
var value = _ref.value,
|
|
|
_onChange = _ref.onChange,
|
|
|
scrollId = _ref.scrollId,
|
|
|
props = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectWithoutProperties_js__WEBPACK_IMPORTED_MODULE_1___default()(_ref, _excluded);
|
|
|
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("div", {
|
|
|
id: scrollId || '',
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_markdown_editor__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()({}, props), {}, {
|
|
|
defaultValue: value,
|
|
|
onChange: function onChange(a, b) {
|
|
|
console.log("a:", a, b);
|
|
|
if (!!(b !== null && b !== void 0 && b.length)) _onChange(a, b);else _onChange(a);
|
|
|
}
|
|
|
}))
|
|
|
});
|
|
|
};
|
|
|
var RegularInput = function RegularInput(_ref2) {
|
|
|
var value = _ref2.value,
|
|
|
onChange = _ref2.onChange,
|
|
|
placeholder = _ref2.placeholder,
|
|
|
_ref2$height = _ref2.height,
|
|
|
height = _ref2$height === void 0 ? 140 : _ref2$height,
|
|
|
isEdit = _ref2.isEdit;
|
|
|
return isEdit ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_markdown_editor__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, {
|
|
|
watch: true,
|
|
|
isFocus: true,
|
|
|
height: height,
|
|
|
placeholder: placeholder,
|
|
|
defaultValue: value,
|
|
|
onChange: onChange
|
|
|
}) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("div", {
|
|
|
style: {
|
|
|
cursor: 'pointer'
|
|
|
},
|
|
|
children: value ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components_RenderHtml__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z, {
|
|
|
className: _index_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.inputBorder,
|
|
|
value: value
|
|
|
}) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("div", {
|
|
|
className: "".concat(_index_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.inputBorder, " ").concat(_index_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.placeholder),
|
|
|
children: placeholder
|
|
|
})
|
|
|
});
|
|
|
};
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 80416:
|
|
|
/*!*********************************************************!*\
|
|
|
!*** ./src/components/RenderHtml/index.tsx + 1 modules ***!
|
|
|
\*********************************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
|
// EXPORTS
|
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
|
Z: function() { return /* binding */ RenderHtml; }
|
|
|
});
|
|
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectSpread2.js
|
|
|
var objectSpread2 = __webpack_require__(26801);
|
|
|
var objectSpread2_default = /*#__PURE__*/__webpack_require__.n(objectSpread2);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/toConsumableArray.js
|
|
|
var toConsumableArray = __webpack_require__(93923);
|
|
|
var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/createForOfIteratorHelper.js
|
|
|
var createForOfIteratorHelper = __webpack_require__(98190);
|
|
|
var createForOfIteratorHelper_default = /*#__PURE__*/__webpack_require__.n(createForOfIteratorHelper);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/slicedToArray.js
|
|
|
var slicedToArray = __webpack_require__(11006);
|
|
|
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
|
|
|
var _react_17_0_2_react = __webpack_require__(59301);
|
|
|
// EXTERNAL MODULE: ./node_modules/_katex@0.11.1@katex/dist/katex.min.css
|
|
|
var katex_min = __webpack_require__(31020);
|
|
|
// EXTERNAL MODULE: ./node_modules/_marked@2.0.7@marked/lib/marked.js
|
|
|
var marked = __webpack_require__(32834);
|
|
|
var marked_default = /*#__PURE__*/__webpack_require__.n(marked);
|
|
|
// EXTERNAL MODULE: ./node_modules/_marked@2.0.7@marked/src/helpers.js
|
|
|
var helpers = __webpack_require__(11690);
|
|
|
;// CONCATENATED MODULE: ./src/utils/marked.ts
|
|
|
|
|
|
|
|
|
|
|
|
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 = slicedToArray_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_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,helpers.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,helpers.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_default().setOptions({
|
|
|
silent: true,
|
|
|
gfm: true,
|
|
|
pedantic: false
|
|
|
});
|
|
|
marked_default().use({
|
|
|
tokenizer: tokenizer,
|
|
|
renderer: renderer
|
|
|
});
|
|
|
/* harmony default export */ var utils_marked = ((marked_default()));
|
|
|
// EXTERNAL MODULE: ./node_modules/_code-prettify@0.1.0@code-prettify/src/prettify.js
|
|
|
var prettify = __webpack_require__(64018);
|
|
|
// EXTERNAL MODULE: ./node_modules/_hls.js@1.4.14@hls.js/dist/hls.mjs
|
|
|
var dist_hls = __webpack_require__(76980);
|
|
|
// EXTERNAL MODULE: ./src/utils/env.ts + 1 modules
|
|
|
var env = __webpack_require__(67871);
|
|
|
// EXTERNAL MODULE: ./node_modules/_katex@0.11.1@katex/dist/katex.js
|
|
|
var katex = __webpack_require__(15342);
|
|
|
// EXTERNAL MODULE: ./node_modules/_uuid@8.3.0@uuid/dist/esm-browser/v4.js + 4 modules
|
|
|
var v4 = __webpack_require__(1012);
|
|
|
// EXTERNAL MODULE: ./src/components/PreviewAll/index.tsx + 1 modules
|
|
|
var PreviewAll = __webpack_require__(78075);
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/jsx-runtime.js
|
|
|
var jsx_runtime = __webpack_require__(37712);
|
|
|
;// CONCATENATED MODULE: ./src/components/RenderHtml/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 */ var RenderHtml = (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_17_0_2_react.useState)(""),
|
|
|
_useState2 = slicedToArray_default()(_useState, 2),
|
|
|
data = _useState2[0],
|
|
|
setData = _useState2[1];
|
|
|
var _useState3 = (0,_react_17_0_2_react.useState)("office"),
|
|
|
_useState4 = slicedToArray_default()(_useState3, 2),
|
|
|
type = _useState4[0],
|
|
|
setType = _useState4[1];
|
|
|
var _useState5 = (0,_react_17_0_2_react.useState)([]),
|
|
|
_useState6 = slicedToArray_default()(_useState5, 2),
|
|
|
projectValue = _useState6[0],
|
|
|
setProjectValue = _useState6[1];
|
|
|
var classNamesRef = (0,_react_17_0_2_react.useRef)("a" + (0,v4/* 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_17_0_2_react.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, "(" + env/* default */.Z.API_SERVER + "/api/attachments/").replace(reg2, '"' + env/* default */.Z.API_SERVER + "/api/attachments/").replace(reg3, '"' + env/* 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 = utils_marked(str);
|
|
|
rs = formatMD(rs);
|
|
|
var math_expressions = getMathExpressions();
|
|
|
if (str.match(/\[TOC\]/)) {
|
|
|
rs = rs.replace('<p>[TOC]</p>', getTocContent());
|
|
|
cleanToc();
|
|
|
}
|
|
|
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.renderToString)(_unescape(expression) || '', {
|
|
|
displayMode: type === 'block',
|
|
|
throwOnError: false,
|
|
|
output: 'html'
|
|
|
});
|
|
|
});
|
|
|
rs = rs.replace(/▁/g, '▁▁▁');
|
|
|
resetMathExpressions();
|
|
|
// 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_17_0_2_react.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_17_0_2_react.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 = createForOfIteratorHelper_default()(dom.entries()),
|
|
|
_step;
|
|
|
try {
|
|
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
|
var _programFillValue$k;
|
|
|
var _step$value = slicedToArray_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 = createForOfIteratorHelper_default()(scoreDom.entries()),
|
|
|
_step2;
|
|
|
try {
|
|
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
|
var _programFillValue$_k, _programFillValue$_k2;
|
|
|
var _step2$value = slicedToArray_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(toConsumableArray_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(toConsumableArray_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_17_0_2_react.useRef)();
|
|
|
lines['WebkitLineClamp'] = showLines;
|
|
|
if (showLines) {
|
|
|
style = objectSpread2_default()(objectSpread2_default()({}, style), lines);
|
|
|
}
|
|
|
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 (dist_hls/* default */.Z.isSupported()) {
|
|
|
var hls = new dist_hls/* default */.Z();
|
|
|
hls.loadSource(item.src);
|
|
|
hls.attachMedia(item);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
(0,_react_17_0_2_react.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);
|
|
|
resetMathExpressions();
|
|
|
cleanToc();
|
|
|
};
|
|
|
}
|
|
|
}, [html, el.current, onAncherHandler]);
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
|
|
|
children: [showTextOnly && /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
ref: el,
|
|
|
children: html
|
|
|
}), !showTextOnly && /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
ref: el,
|
|
|
style: objectSpread2_default()({}, style),
|
|
|
className: "".concat(className ? className : '', " ").concat(disabledFill ? "disabled-fill" : "", " markdown-body ").concat(classNamesRef.current),
|
|
|
dangerouslySetInnerHTML: {
|
|
|
__html: html
|
|
|
}
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(PreviewAll/* default */.Z, {
|
|
|
close: true,
|
|
|
data: data,
|
|
|
type: !!(data !== null && data !== void 0 && data.length) ? type : "",
|
|
|
style: objectSpread2_default()({}, stylesPrev),
|
|
|
onClose: function onClose() {
|
|
|
return setData("");
|
|
|
}
|
|
|
})]
|
|
|
});
|
|
|
});
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 3254:
|
|
|
/*!*************************************************************!*\
|
|
|
!*** ./src/components/SplitContainer/index.tsx + 1 modules ***!
|
|
|
\*************************************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
|
// EXPORTS
|
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
|
Z: function() { return /* binding */ SplitContainer; }
|
|
|
});
|
|
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/slicedToArray.js
|
|
|
var slicedToArray = __webpack_require__(11006);
|
|
|
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
|
|
|
var _react_17_0_2_react = __webpack_require__(59301);
|
|
|
;// CONCATENATED MODULE: ./src/components/SplitContainer/index.less
|
|
|
// extracted by mini-css-extract-plugin
|
|
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/jsx-runtime.js
|
|
|
var jsx_runtime = __webpack_require__(37712);
|
|
|
;// CONCATENATED MODULE: ./src/components/SplitContainer/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* harmony default export */ var SplitContainer = (function (_ref) {
|
|
|
var _ref$defaultX = _ref.defaultX,
|
|
|
defaultX = _ref$defaultX === void 0 ? '40%' : _ref$defaultX,
|
|
|
leftChild = _ref.leftChild,
|
|
|
rightChild = _ref.rightChild,
|
|
|
className = _ref.className,
|
|
|
_ref$hideResize = _ref.hideResize,
|
|
|
hideResize = _ref$hideResize === void 0 ? false : _ref$hideResize;
|
|
|
var _useState = (0,_react_17_0_2_react.useState)(defaultX),
|
|
|
_useState2 = slicedToArray_default()(_useState, 2),
|
|
|
moveX = _useState2[0],
|
|
|
setMoveX = _useState2[1];
|
|
|
var resizeXFlag = (0,_react_17_0_2_react.useRef)();
|
|
|
function onResizeStart() {
|
|
|
resizeXFlag.current = true;
|
|
|
}
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
function onMove(e) {
|
|
|
if (resizeXFlag.current) {
|
|
|
setMoveX(e.pageX);
|
|
|
}
|
|
|
}
|
|
|
function onMouseUp() {
|
|
|
resizeXFlag.current = false;
|
|
|
}
|
|
|
window.addEventListener('mousemove', onMove);
|
|
|
window.addEventListener('mouseup', onMouseUp);
|
|
|
return function () {
|
|
|
window.removeEventListener('mousemove', onMove);
|
|
|
window.removeEventListener('mouseup', onMouseUp);
|
|
|
};
|
|
|
}, []);
|
|
|
var leftPanelWidth = typeof moveX === 'number' && moveX !== 0.01 ? "".concat(moveX, "px") : defaultX;
|
|
|
var rightPanelWidth = "calc(100% - ".concat(hideResize ? "0px" : "4px", " - ").concat(leftPanelWidth, ")");
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
className: "split-panel-container ".concat(className),
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("section", {
|
|
|
style: {
|
|
|
width: leftPanelWidth,
|
|
|
display: moveX === 0.01 ? 'none' : ''
|
|
|
},
|
|
|
children: leftChild
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("section", {
|
|
|
className: "resize-x-bar",
|
|
|
onMouseDown: onResizeStart,
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("a", {
|
|
|
className: "btn-resize",
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("svg", {
|
|
|
width: "16",
|
|
|
height: "13",
|
|
|
viewBox: "0 0 16 13",
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("path", {
|
|
|
d: "M12.245 7.53H5.647v1.882h6.598v2.823L16 8.471l-3.755-3.765V7.53zM10.353 4.706H3.755v2.823L0 3.765 3.755 0v2.824h6.598v1.882z"
|
|
|
})
|
|
|
})
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("section", {
|
|
|
style: {
|
|
|
width: rightPanelWidth
|
|
|
},
|
|
|
children: rightChild
|
|
|
})]
|
|
|
});
|
|
|
});
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 74921:
|
|
|
/*!*************************************************************!*\
|
|
|
!*** ./src/components/markdown-editor/code-block/index.tsx ***!
|
|
|
\*************************************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
|
/* harmony export */ h: function() { return /* binding */ MyCodeMirror; }
|
|
|
/* harmony export */ });
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectSpread2.js */ 26801);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/slicedToArray.js */ 11006);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_1__);
|
|
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ 59301);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! antd */ 57809);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! antd */ 78241);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! antd */ 3113);
|
|
|
/* harmony import */ var codemirror__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! codemirror */ 89780);
|
|
|
/* harmony import */ var codemirror__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(codemirror__WEBPACK_IMPORTED_MODULE_3__);
|
|
|
/* harmony import */ var codemirror_lib_codemirror_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! codemirror/lib/codemirror.css */ 83164);
|
|
|
/* harmony import */ var codemirror_theme_blackboard_css__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! codemirror/theme/blackboard.css */ 45215);
|
|
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ 37712);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var Option = antd__WEBPACK_IMPORTED_MODULE_7__["default"].Option;
|
|
|
|
|
|
//https://github.com/codemirror/CodeMirror/issues/4838
|
|
|
var formItemLayout = {
|
|
|
labelCol: {
|
|
|
span: 4
|
|
|
},
|
|
|
wrapperCol: {
|
|
|
span: 20
|
|
|
}
|
|
|
};
|
|
|
var LanguageDesc = {
|
|
|
asp: ['ASP', 'vbscript'],
|
|
|
actionscript: ['ActionScript(3.0)/Flash/Flex', 'clike'],
|
|
|
bash: ['Bash/Bat', 'shell'],
|
|
|
css: ['CSS', 'css'],
|
|
|
c: ['C', 'clike'],
|
|
|
cpp: ['C++', 'clike'],
|
|
|
csharp: ['C#', 'clike'],
|
|
|
coffeescript: ['CoffeeScript', 'coffeescript'],
|
|
|
d: ['D', 'd'],
|
|
|
dart: ['Dart', 'dart'],
|
|
|
delphi: ['Delphi/Pascal', 'pascal'],
|
|
|
erlang: ['Erlang', 'erlang'],
|
|
|
go: ['Golang', 'go'],
|
|
|
groovy: ['Groovy', 'groovy'],
|
|
|
html: ['HTML', 'text/html'],
|
|
|
java: ['Java', 'clike'],
|
|
|
json: ['JSON', 'text/json'],
|
|
|
javascript: ['Javascript', 'javascript'],
|
|
|
lua: ['Lua', 'lua'],
|
|
|
less: ['LESS', 'css'],
|
|
|
markdown: ['Markdown', 'gfm'],
|
|
|
'objective-c': ['Objective-C', 'clike'],
|
|
|
php: ['PHP', 'php'],
|
|
|
perl: ['Perl', 'perl'],
|
|
|
python: ['Python', 'python'],
|
|
|
r: ['R', 'r'],
|
|
|
rst: ['reStructedText', 'rst'],
|
|
|
ruby: ['Ruby', 'ruby'],
|
|
|
sql: ['SQL', 'sql'],
|
|
|
sass: ['SASS/SCSS', 'sass'],
|
|
|
shell: ['Shell', 'shell'],
|
|
|
scala: ['Scala', 'clike'],
|
|
|
swift: ['Swift', 'clike'],
|
|
|
vb: ['VB/VBScript', 'vb'],
|
|
|
xml: ['XML', 'text/xml'],
|
|
|
yaml: ['YAML', 'yaml']
|
|
|
};
|
|
|
/* harmony default export */ __webpack_exports__.Z = (function (_ref) {
|
|
|
var callback = _ref.callback,
|
|
|
onCancel = _ref.onCancel;
|
|
|
var _useState = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)('python'),
|
|
|
_useState2 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_1___default()(_useState, 2),
|
|
|
mode = _useState2[0],
|
|
|
setMode = _useState2[1];
|
|
|
function onSetMode(value) {
|
|
|
setMode(LanguageDesc[value][1]);
|
|
|
}
|
|
|
function onSubmit(values) {
|
|
|
callback(values);
|
|
|
}
|
|
|
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(antd__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z, _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()({}, formItemLayout), {}, {
|
|
|
className: "code-block-panel",
|
|
|
initialValues: {
|
|
|
language: 'python',
|
|
|
content: ''
|
|
|
},
|
|
|
onFinish: onSubmit,
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(antd__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z.Item, {
|
|
|
label: "\u4EE3\u7801\u8BED\u8A00",
|
|
|
name: "language",
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(antd__WEBPACK_IMPORTED_MODULE_7__["default"], {
|
|
|
getPopupContainer: function getPopupContainer(trigger) {
|
|
|
return trigger.parentNode;
|
|
|
},
|
|
|
onChange: onSetMode,
|
|
|
children: Object.keys(LanguageDesc).map(function (item) {
|
|
|
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(Option, {
|
|
|
value: item,
|
|
|
children: LanguageDesc[item][0]
|
|
|
}, item);
|
|
|
})
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(antd__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z.Item, {
|
|
|
label: "\u4EE3\u7801\u5185\u5BB9",
|
|
|
name: "content",
|
|
|
rules: [{
|
|
|
required: true,
|
|
|
message: '请输入代码内容'
|
|
|
}],
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(MyCodeMirror, {
|
|
|
mode: mode
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)("div", {
|
|
|
className: "flex-container flex-end",
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .ZP, {
|
|
|
type: "primary",
|
|
|
htmlType: "submit",
|
|
|
style: {
|
|
|
marginRight: 10
|
|
|
},
|
|
|
children: "\u786E\u5B9A"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .ZP, {
|
|
|
type: "ghost",
|
|
|
onClick: onCancel,
|
|
|
children: "\u53D6\u6D88"
|
|
|
})]
|
|
|
})]
|
|
|
}));
|
|
|
});
|
|
|
function MyCodeMirror(_ref2) {
|
|
|
var value = _ref2.value,
|
|
|
onChange = _ref2.onChange,
|
|
|
mode = _ref2.mode,
|
|
|
_ref2$options = _ref2.options,
|
|
|
options = _ref2$options === void 0 ? {} : _ref2$options;
|
|
|
var el = (0,react__WEBPACK_IMPORTED_MODULE_2__.useRef)();
|
|
|
var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)(),
|
|
|
_useState4 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_1___default()(_useState3, 2),
|
|
|
cm = _useState4[0],
|
|
|
setCm = _useState4[1];
|
|
|
(0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(function () {
|
|
|
if (cm) {
|
|
|
var onChangeHandler = function onChangeHandler(cm) {
|
|
|
var content = cm.getValue();
|
|
|
onChange && onChange(content);
|
|
|
};
|
|
|
cm.on('change', onChangeHandler);
|
|
|
return function () {
|
|
|
cm.off('change', onChangeHandler);
|
|
|
};
|
|
|
}
|
|
|
}, [cm, onChange]);
|
|
|
(0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(function () {
|
|
|
if (cm) {
|
|
|
cm.setOption('mode', mode);
|
|
|
}
|
|
|
}, [cm, mode]);
|
|
|
(0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(function () {
|
|
|
if (cm) {
|
|
|
if (value !== cm.getValue() || value === '') {
|
|
|
setTimeout(function () {
|
|
|
cm.setValue(value || '');
|
|
|
}, 300);
|
|
|
}
|
|
|
}
|
|
|
}, [cm, value]);
|
|
|
(0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(function () {
|
|
|
if (el.current && !cm) {
|
|
|
var instance = codemirror__WEBPACK_IMPORTED_MODULE_3___default().fromTextArea(el.current, _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()({
|
|
|
mode: mode,
|
|
|
lineNumbers: true,
|
|
|
lineWrapping: true,
|
|
|
autoCloseBrackets: true,
|
|
|
tabSize: 4,
|
|
|
autofocus: true,
|
|
|
autoCloseTags: true,
|
|
|
matchBrackets: true,
|
|
|
styleActiveLine: true
|
|
|
}, options));
|
|
|
setCm(instance);
|
|
|
}
|
|
|
}, [el.current, cm]);
|
|
|
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("div", {
|
|
|
className: "my-codemirror-container",
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("textarea", {
|
|
|
ref: el
|
|
|
})
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 38874:
|
|
|
/*!***************************************************************!*\
|
|
|
!*** ./src/components/markdown-editor/index.tsx + 14 modules ***!
|
|
|
\***************************************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
|
// EXPORTS
|
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
|
Z: function() { return /* binding */ markdown_editor; }
|
|
|
});
|
|
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/createForOfIteratorHelper.js
|
|
|
var createForOfIteratorHelper = __webpack_require__(98190);
|
|
|
var createForOfIteratorHelper_default = /*#__PURE__*/__webpack_require__.n(createForOfIteratorHelper);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/slicedToArray.js
|
|
|
var slicedToArray = __webpack_require__(11006);
|
|
|
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/defineProperty.js
|
|
|
var defineProperty = __webpack_require__(22060);
|
|
|
var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty);
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
|
|
|
var _react_17_0_2_react = __webpack_require__(59301);
|
|
|
// EXTERNAL MODULE: ./node_modules/_codemirror@5.58.2@codemirror/lib/codemirror.js
|
|
|
var codemirror = __webpack_require__(89780);
|
|
|
var codemirror_default = /*#__PURE__*/__webpack_require__.n(codemirror);
|
|
|
// EXTERNAL MODULE: ./node_modules/_resize-observer-polyfill@1.5.1@resize-observer-polyfill/dist/ResizeObserver.es.js
|
|
|
var ResizeObserver_es = __webpack_require__(76374);
|
|
|
// EXTERNAL MODULE: ./node_modules/_codemirror@5.58.2@codemirror/lib/codemirror.css
|
|
|
var lib_codemirror = __webpack_require__(83164);
|
|
|
// EXTERNAL MODULE: ./node_modules/_codemirror@5.58.2@codemirror/addon/edit/closetag.js
|
|
|
var closetag = __webpack_require__(6313);
|
|
|
// EXTERNAL MODULE: ./node_modules/_codemirror@5.58.2@codemirror/addon/edit/closebrackets.js
|
|
|
var closebrackets = __webpack_require__(25717);
|
|
|
// EXTERNAL MODULE: ./node_modules/_codemirror@5.58.2@codemirror/addon/display/placeholder.js
|
|
|
var placeholder = __webpack_require__(99498);
|
|
|
// EXTERNAL MODULE: ./node_modules/_codemirror@5.58.2@codemirror/mode/markdown/markdown.js
|
|
|
var markdown = __webpack_require__(25419);
|
|
|
// EXTERNAL MODULE: ./node_modules/_codemirror@5.58.2@codemirror/mode/stex/stex.js
|
|
|
var stex = __webpack_require__(67549);
|
|
|
;// CONCATENATED MODULE: ./src/components/markdown-editor/index.less
|
|
|
// extracted by mini-css-extract-plugin
|
|
|
|
|
|
// EXTERNAL MODULE: ./src/components/RenderHtml/index.tsx + 1 modules
|
|
|
var RenderHtml = __webpack_require__(80416);
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/jsx-runtime.js
|
|
|
var jsx_runtime = __webpack_require__(37712);
|
|
|
;// CONCATENATED MODULE: ./src/components/RenderHtml/stex.tsx
|
|
|
|
|
|
// const latexjs = require('latex-l.js/dist/latex.js');
|
|
|
// import "latex-l.js/dist/css/base.css"
|
|
|
|
|
|
|
|
|
/* harmony default export */ var RenderHtml_stex = (function (_ref) {
|
|
|
var _ref$value = _ref.value,
|
|
|
value = _ref$value === void 0 ? '' : _ref$value,
|
|
|
className = _ref.className,
|
|
|
showTextOnly = _ref.showTextOnly,
|
|
|
showLines = _ref.showLines,
|
|
|
_ref$style = _ref.style,
|
|
|
style = _ref$style === void 0 ? {} : _ref$style;
|
|
|
var html = (0,_react_17_0_2_react.useMemo)(function () {
|
|
|
// try {
|
|
|
// const latex = value || 'This is some text';
|
|
|
// let generator = new latexjs.default.HtmlGenerator({ hyphenate: true })
|
|
|
// let doc = latexjs.default.parse(latex, { generator: generator }).htmlDocument()
|
|
|
// return doc.body.innerHTML
|
|
|
// }catch(e){
|
|
|
// console.log("e:",e)
|
|
|
// return "错误的latex语法,请检查"
|
|
|
// }
|
|
|
return "";
|
|
|
}, [value]);
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment, {
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
dangerouslySetInnerHTML: {
|
|
|
__html: html
|
|
|
}
|
|
|
})
|
|
|
});
|
|
|
});
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectSpread2.js
|
|
|
var objectSpread2 = __webpack_require__(26801);
|
|
|
var objectSpread2_default = /*#__PURE__*/__webpack_require__.n(objectSpread2);
|
|
|
;// CONCATENATED MODULE: ./src/components/markdown-editor/toolbar/index.less
|
|
|
// extracted by mini-css-extract-plugin
|
|
|
|
|
|
;// CONCATENATED MODULE: ./src/components/markdown-editor/css/iconfont.css
|
|
|
// extracted by mini-css-extract-plugin
|
|
|
|
|
|
;// CONCATENATED MODULE: ./src/components/markdown-editor/toolbar/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var DEFAULTICONS = [{
|
|
|
title: '粗体',
|
|
|
icon: 'md-iconfont icon-bold',
|
|
|
actionName: 'bold'
|
|
|
}, {
|
|
|
title: '斜体',
|
|
|
icon: 'md-iconfont icon-italic',
|
|
|
actionName: 'italic'
|
|
|
}, '|', {
|
|
|
title: '无序列表',
|
|
|
icon: 'md-iconfont icon-unorder-list',
|
|
|
actionName: 'list-ul'
|
|
|
}, {
|
|
|
title: '有序列表',
|
|
|
icon: 'md-iconfont icon-order-list',
|
|
|
actionName: 'list-ol'
|
|
|
}, '|', {
|
|
|
title: '行内代码',
|
|
|
icon: 'md-iconfont icon-code',
|
|
|
actionName: 'code'
|
|
|
}, {
|
|
|
title: '代码块(多语言风格)',
|
|
|
icon: 'md-iconfont icon-file-code',
|
|
|
actionName: 'code-block'
|
|
|
}, {
|
|
|
title: '链接',
|
|
|
icon: 'md-iconfont icon-link',
|
|
|
actionName: 'link'
|
|
|
}, '|', {
|
|
|
title: '行内公式',
|
|
|
icon: 'md-iconfont icon-sum',
|
|
|
actionName: 'inline-latex'
|
|
|
}, {
|
|
|
title: '多行公式',
|
|
|
icon: 'md-iconfont icon-formula',
|
|
|
actionName: 'latex'
|
|
|
}, '|', {
|
|
|
title: '添加图片',
|
|
|
icon: 'md-iconfont icon-picture',
|
|
|
actionName: 'upload-image'
|
|
|
}, {
|
|
|
title: '插入画图',
|
|
|
icon: 'iconfont icon-sheji',
|
|
|
actionName: 'draw-image'
|
|
|
}, {
|
|
|
title: '插入流程图',
|
|
|
icon: 'iconfont icon-liucheng',
|
|
|
actionName: 'add-flowchart'
|
|
|
}, {
|
|
|
title: '表格',
|
|
|
icon: 'md-iconfont icon-table',
|
|
|
actionName: 'add-table'
|
|
|
}, '|', {
|
|
|
title: '换行',
|
|
|
icon: 'md-iconfont icon-minus',
|
|
|
actionName: 'line-break'
|
|
|
}, {
|
|
|
title: '清空',
|
|
|
icon: 'md-iconfont icon-eraser',
|
|
|
actionName: 'eraser'
|
|
|
}];
|
|
|
function AButton(_ref) {
|
|
|
var onActionCallback = _ref.onActionCallback,
|
|
|
title = _ref.title,
|
|
|
icon = _ref.icon,
|
|
|
actionName = _ref.actionName,
|
|
|
_ref$className = _ref.className,
|
|
|
className = _ref$className === void 0 ? '' : _ref$className,
|
|
|
children = _ref.children;
|
|
|
function onAction() {
|
|
|
onActionCallback(actionName);
|
|
|
}
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("a", {
|
|
|
title: title,
|
|
|
className: className,
|
|
|
onClick: onAction,
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("i", {
|
|
|
className: "".concat(icon)
|
|
|
}), children]
|
|
|
});
|
|
|
}
|
|
|
/* harmony default export */ var toolbar = (function (_ref2) {
|
|
|
var watch = _ref2.watch,
|
|
|
showNullButton = _ref2.showNullButton,
|
|
|
showNullProgramButton = _ref2.showNullProgramButton,
|
|
|
onActionCallback = _ref2.onActionCallback,
|
|
|
fullScreen = _ref2.fullScreen,
|
|
|
insertTemp = _ref2.insertTemp,
|
|
|
hidetoolBar = _ref2.hidetoolBar,
|
|
|
extraUse = _ref2.extraUse;
|
|
|
var icons = [].concat(DEFAULTICONS, [{
|
|
|
title: "".concat(watch ? '关闭实时预览' : '开启实时预览'),
|
|
|
icon: "".concat(watch ? 'md-iconfont icon-eye-slash' : 'md-iconfont icon-eye'),
|
|
|
actionName: 'trigger-watch'
|
|
|
}]);
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("ul", {
|
|
|
className: "markdown-toolbar-container",
|
|
|
children: [!hidetoolBar && icons.map(function (item, index) {
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)("li", {
|
|
|
children: item.actionName ? /*#__PURE__*/(0,jsx_runtime.jsx)(AButton, objectSpread2_default()(objectSpread2_default()({}, item), {}, {
|
|
|
onActionCallback: onActionCallback
|
|
|
})) : /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
|
className: "v-line"
|
|
|
})
|
|
|
}, index);
|
|
|
}), showNullButton ? /*#__PURE__*/(0,jsx_runtime.jsx)("li", {
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(AButton, {
|
|
|
icon: "md-iconfont icon-edit insert-blank",
|
|
|
className: "btn-null",
|
|
|
title: "\u589E\u52A0\u586B\u7A7A",
|
|
|
actionName: "add-null-ch",
|
|
|
onActionCallback: onActionCallback,
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
|
className: "fill-tip",
|
|
|
children: "\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"
|
|
|
})
|
|
|
})
|
|
|
}) : null, showNullProgramButton ? /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("li", {
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(AButton, {
|
|
|
icon: "md-iconfont icon-edit insert-blank",
|
|
|
className: "btn-null",
|
|
|
title: "\u589E\u52A0\u586B\u7A7A",
|
|
|
actionName: "add-signal",
|
|
|
onActionCallback: onActionCallback,
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
|
className: "fill-tip",
|
|
|
children: "\u6DFB\u52A0\u5355\u884C\u586B\u7A7A\u9879"
|
|
|
})
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("li", {
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(AButton, {
|
|
|
icon: "md-iconfont icon-uniE900 insert-blank",
|
|
|
className: "btn-null",
|
|
|
title: "\u589E\u52A0\u586B\u7A7A",
|
|
|
actionName: "add-multiple",
|
|
|
onActionCallback: onActionCallback,
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
|
className: "fill-tip",
|
|
|
children: "\u6DFB\u52A0\u591A\u884C\u586B\u7A7A\u9879"
|
|
|
})
|
|
|
})
|
|
|
})]
|
|
|
}) : null, insertTemp && /*#__PURE__*/(0,jsx_runtime.jsx)("li", {
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(AButton, {
|
|
|
icon: "md-iconfont icon-edit",
|
|
|
className: "btn-null",
|
|
|
title: "\u63D2\u5165\u6A21\u677F",
|
|
|
actionName: "inster-template-".concat(insertTemp),
|
|
|
onActionCallback: onActionCallback,
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
|
className: "fill-tip",
|
|
|
children: "\u63D2\u5165\u6A21\u677F"
|
|
|
})
|
|
|
})
|
|
|
}), extraUse && /*#__PURE__*/(0,jsx_runtime.jsx)("li", {
|
|
|
children: extraUse
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("li", {
|
|
|
className: "btn-full-screen",
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(AButton, {
|
|
|
icon: "".concat(fullScreen ? 'md-iconfont icon-shrink' : 'md-iconfont icon-enlarge'),
|
|
|
title: fullScreen ? '关闭全屏' : '开启全屏',
|
|
|
actionName: "trigger-full-screen",
|
|
|
onActionCallback: onActionCallback
|
|
|
})
|
|
|
})]
|
|
|
});
|
|
|
});
|
|
|
// EXTERNAL MODULE: ./src/components/modal.tsx
|
|
|
var modal = __webpack_require__(90463);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/form/index.js + 19 modules
|
|
|
var es_form = __webpack_require__(78241);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/input/index.js + 5 modules
|
|
|
var input = __webpack_require__(1056);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/button/index.js
|
|
|
var es_button = __webpack_require__(3113);
|
|
|
;// CONCATENATED MODULE: ./src/components/markdown-editor/link/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var formItemLayout = {
|
|
|
labelCol: {
|
|
|
span: 4
|
|
|
},
|
|
|
wrapperCol: {
|
|
|
span: 20
|
|
|
}
|
|
|
};
|
|
|
/* harmony default export */ var markdown_editor_link = (function (_ref) {
|
|
|
var callback = _ref.callback,
|
|
|
onCancel = _ref.onCancel;
|
|
|
function onSubmit(values) {
|
|
|
callback(values);
|
|
|
}
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)(es_form/* default */.Z, objectSpread2_default()(objectSpread2_default()({}, formItemLayout), {}, {
|
|
|
initialValues: {
|
|
|
link: 'http://',
|
|
|
title: ''
|
|
|
},
|
|
|
className: "link-panel",
|
|
|
onFinish: onSubmit,
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
|
|
|
label: "\u94FE\u63A5\u5730\u5740",
|
|
|
name: "link",
|
|
|
rules: [{
|
|
|
required: true,
|
|
|
message: '请输入链接地址'
|
|
|
}],
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, {})
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
|
|
|
label: "\u94FE\u63A5\u6807\u9898",
|
|
|
name: "title",
|
|
|
rules: [{
|
|
|
required: true,
|
|
|
message: '请输入链接标题'
|
|
|
}],
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, {})
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
className: "flex-container flex-end",
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
|
type: "primary",
|
|
|
htmlType: "submit",
|
|
|
style: {
|
|
|
marginRight: 10
|
|
|
},
|
|
|
children: "\u786E\u5B9A"
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
|
type: "ghost",
|
|
|
onClick: onCancel,
|
|
|
children: "\u53D6\u6D88"
|
|
|
})]
|
|
|
})]
|
|
|
}));
|
|
|
});
|
|
|
// EXTERNAL MODULE: ./src/components/markdown-editor/code-block/index.tsx
|
|
|
var code_block = __webpack_require__(74921);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/message/index.js + 4 modules
|
|
|
var message = __webpack_require__(8591);
|
|
|
;// CONCATENATED MODULE: ./src/components/markdown-editor/upload-image/index.less
|
|
|
// extracted by mini-css-extract-plugin
|
|
|
|
|
|
// EXTERNAL MODULE: ./src/pages/tasks/util.js
|
|
|
var util = __webpack_require__(51811);
|
|
|
;// CONCATENATED MODULE: ./src/components/markdown-editor/upload-image/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var useForm = es_form/* default */.Z.useForm;
|
|
|
var style = {
|
|
|
width: 280,
|
|
|
marginRight: 10
|
|
|
};
|
|
|
var upload_image_formItemLayout = {
|
|
|
labelCol: {
|
|
|
span: 5
|
|
|
},
|
|
|
wrapperCol: {
|
|
|
span: 19
|
|
|
}
|
|
|
};
|
|
|
/* harmony default export */ var upload_image = (function (_ref) {
|
|
|
var callback = _ref.callback,
|
|
|
onCancel = _ref.onCancel;
|
|
|
var _useForm = useForm(),
|
|
|
_useForm2 = slicedToArray_default()(_useForm, 1),
|
|
|
form = _useForm2[0];
|
|
|
function onSubmit(values) {
|
|
|
callback(values);
|
|
|
}
|
|
|
function onAddUrl(data, file) {
|
|
|
if (data.status === -1) {
|
|
|
message/* default */.ZP.error(data.message);
|
|
|
return;
|
|
|
}
|
|
|
form.setFieldsValue({
|
|
|
src: "/api/attachments/".concat(data.id),
|
|
|
type: file.type
|
|
|
});
|
|
|
}
|
|
|
function onFileChange(e) {
|
|
|
var file = e.target.files[0];
|
|
|
uploadImage(file, onAddUrl);
|
|
|
}
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)(es_form/* default */.Z, objectSpread2_default()(objectSpread2_default()({
|
|
|
form: form
|
|
|
}, upload_image_formItemLayout), {}, {
|
|
|
className: "upload-image-panel",
|
|
|
onFinish: onSubmit,
|
|
|
style: {
|
|
|
width: 470,
|
|
|
overflow: "hidden"
|
|
|
},
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
|
|
|
label: "\u56FE\u7247\u5730\u5740",
|
|
|
required: true,
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
className: "flex-container",
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
|
|
|
noStyle: true,
|
|
|
name: "src",
|
|
|
rules: [{
|
|
|
required: true,
|
|
|
message: '请输入图片地址'
|
|
|
}],
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, {
|
|
|
style: style
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(UploadButton, {
|
|
|
onFileChange: onFileChange
|
|
|
})]
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
|
|
|
label: "\u56FE\u7247\u63CF\u8FF0",
|
|
|
name: "alt"
|
|
|
// rules={[{ required: true, message: '请输入图片描述' }]}
|
|
|
,
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, {
|
|
|
style: {
|
|
|
width: 264
|
|
|
}
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(es_form/* default */.Z.Item, {
|
|
|
style: {
|
|
|
textAlign: "right"
|
|
|
},
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
|
type: "primary",
|
|
|
htmlType: "submit",
|
|
|
style: {
|
|
|
marginRight: 10
|
|
|
},
|
|
|
children: "\u786E\u5B9A"
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
|
type: "default",
|
|
|
onClick: onCancel,
|
|
|
children: "\u53D6\u6D88"
|
|
|
})]
|
|
|
})]
|
|
|
}));
|
|
|
});
|
|
|
function UploadButton(_ref2) {
|
|
|
var onFileChange = _ref2.onFileChange;
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("label", {
|
|
|
className: "upload-button",
|
|
|
style: {
|
|
|
cursor: "pointer"
|
|
|
},
|
|
|
children: ["\u672C\u5730\u4E0A\u4F20", /*#__PURE__*/(0,jsx_runtime.jsx)("input", {
|
|
|
type: "file",
|
|
|
onChange: onFileChange
|
|
|
})]
|
|
|
});
|
|
|
}
|
|
|
function uploadImage(file, callback) {
|
|
|
if (!file) {
|
|
|
throw new String('没有文件');
|
|
|
return;
|
|
|
}
|
|
|
var formData = new FormData();
|
|
|
formData.append('editormd-image-file', file);
|
|
|
formData.append('file_param_name', 'editormd-image-file');
|
|
|
formData.append('byxhr', 'true');
|
|
|
var xhr = new window.XMLHttpRequest();
|
|
|
xhr.withCredentials = true;
|
|
|
xhr.addEventListener('load', function (response) {
|
|
|
callback(JSON.parse(response.target.responseText), file);
|
|
|
}, false);
|
|
|
xhr.addEventListener('error', function (error) {
|
|
|
console.error(error);
|
|
|
}, false);
|
|
|
xhr.open('POST', "".concat(util/* apiPref */.KI, "/api/attachments.json"));
|
|
|
xhr.send(formData);
|
|
|
}
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/row/index.js
|
|
|
var row = __webpack_require__(95237);
|
|
|
// EXTERNAL MODULE: ./src/components/ImageDimensions/index.tsx + 1 modules
|
|
|
var ImageDimensions = __webpack_require__(11681);
|
|
|
;// CONCATENATED MODULE: ./src/components/markdown-editor/draw-image/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* harmony default export */ var draw_image = (function (_ref) {
|
|
|
var callback = _ref.callback,
|
|
|
onCancel = _ref.onCancel;
|
|
|
var canvas = document.createElement('canvas');
|
|
|
var context = canvas.getContext('2d');
|
|
|
canvas.width = 1000;
|
|
|
canvas.height = 800;
|
|
|
context.fillStyle = '#ffffff';
|
|
|
context.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
var base64Image = canvas.toDataURL('image/png');
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(row/* default */.Z, {
|
|
|
style: {
|
|
|
height: "100vh"
|
|
|
},
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(ImageDimensions/* default */.Z, {
|
|
|
fullWidth: true,
|
|
|
noAssociationId: true,
|
|
|
showFullTools: true,
|
|
|
data: {
|
|
|
src: base64Image,
|
|
|
visible: true,
|
|
|
title: String(Date.now())
|
|
|
},
|
|
|
onOk: function onOk(data) {
|
|
|
callback({
|
|
|
src: data.url
|
|
|
});
|
|
|
},
|
|
|
onClose: onCancel
|
|
|
})
|
|
|
});
|
|
|
});
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/regeneratorRuntime.js
|
|
|
var regeneratorRuntime = __webpack_require__(10574);
|
|
|
var regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(regeneratorRuntime);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/asyncToGenerator.js
|
|
|
var asyncToGenerator = __webpack_require__(39343);
|
|
|
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/toConsumableArray.js
|
|
|
var toConsumableArray = __webpack_require__(93923);
|
|
|
var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray);
|
|
|
// EXTERNAL MODULE: ./node_modules/_gojs3@2.3.10@gojs3/release/go-module.js
|
|
|
var go_module = __webpack_require__(12378);
|
|
|
;// CONCATENATED MODULE: ./public/js/go/DrawCommandHandler.js
|
|
|
|
|
|
|
|
|
/*
|
|
|
* Copyright (C) 1998-2023 by Northwoods Software Corporation. All Rights Reserved.
|
|
|
*/
|
|
|
|
|
|
/*
|
|
|
* This is an extension and not part of the main GoJS library.
|
|
|
* Note that the API for this class may change with any version, even point releases.
|
|
|
* If you intend to use an extension in production, you should copy the code to your own source directory.
|
|
|
* Extensions can be found in the GoJS kit under the extensions or extensionsJSM folders.
|
|
|
* See the Extensions intro page (https://gojs.net/latest/intro/extensions.html) for more information.
|
|
|
*/
|
|
|
|
|
|
/**
|
|
|
* @constructor
|
|
|
* @extends CommandHandler
|
|
|
* @class
|
|
|
* This CommandHandler class allows the user to position selected Parts in a diagram
|
|
|
* relative to the first part selected, in addition to overriding the doKeyDown method
|
|
|
* of the CommandHandler for handling the arrow keys in additional manners.
|
|
|
* <p>
|
|
|
* Typical usage:
|
|
|
* <pre>
|
|
|
* new go.Diagram("myDiagramDiv",
|
|
|
* {
|
|
|
* commandHandler: $(DrawCommandHandler),
|
|
|
* . . .
|
|
|
* }
|
|
|
* )
|
|
|
* </pre>
|
|
|
* or:
|
|
|
* <pre>
|
|
|
* myDiagram.commandHandler = new DrawCommandHandler();
|
|
|
* </pre>
|
|
|
*/
|
|
|
function DrawCommandHandler() {
|
|
|
go.CommandHandler.call(this);
|
|
|
this._arrowKeyBehavior = "move";
|
|
|
this._pasteOffset = new go.Point(10, 10);
|
|
|
this._lastPasteOffset = new go.Point(0, 0);
|
|
|
}
|
|
|
go.Diagram.inherit(DrawCommandHandler, go.CommandHandler);
|
|
|
|
|
|
/**
|
|
|
* This controls whether or not the user can invoke the {@link #alignLeft}, {@link #alignRight},
|
|
|
* {@link #alignTop}, {@link #alignBottom}, {@link #alignCenterX}, {@link #alignCenterY} commands.
|
|
|
* @this {DrawCommandHandler}
|
|
|
* @return {boolean}
|
|
|
* This returns true:
|
|
|
* if the diagram is not {@link Diagram#isReadOnly},
|
|
|
* if the model is not {@link Model#isReadOnly}, and
|
|
|
* if there are at least two selected {@link Part}s.
|
|
|
*/
|
|
|
DrawCommandHandler.prototype.canAlignSelection = function () {
|
|
|
var diagram = this.diagram;
|
|
|
if (diagram === null || diagram.isReadOnly || diagram.isModelReadOnly) return false;
|
|
|
if (diagram.selection.count < 2) return false;
|
|
|
return true;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Aligns selected parts along the left-most edge of the left-most part.
|
|
|
* @this {DrawCommandHandler}
|
|
|
*/
|
|
|
DrawCommandHandler.prototype.alignLeft = function () {
|
|
|
var diagram = this.diagram;
|
|
|
diagram.startTransaction("aligning left");
|
|
|
var minPosition = Infinity;
|
|
|
diagram.selection.each(function (current) {
|
|
|
if (current instanceof go.Link) return; // skips over go.Link
|
|
|
minPosition = Math.min(current.position.x, minPosition);
|
|
|
});
|
|
|
diagram.selection.each(function (current) {
|
|
|
if (current instanceof go.Link) return; // skips over go.Link
|
|
|
current.move(new go.Point(minPosition, current.position.y));
|
|
|
});
|
|
|
diagram.commitTransaction("aligning left");
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Aligns selected parts at the right-most edge of the right-most part.
|
|
|
* @this {DrawCommandHandler}
|
|
|
*/
|
|
|
DrawCommandHandler.prototype.alignRight = function () {
|
|
|
var diagram = this.diagram;
|
|
|
diagram.startTransaction("aligning right");
|
|
|
var maxPosition = -Infinity;
|
|
|
diagram.selection.each(function (current) {
|
|
|
if (current instanceof go.Link) return; // skips over go.Link
|
|
|
var rightSideLoc = current.actualBounds.x + current.actualBounds.width;
|
|
|
maxPosition = Math.max(rightSideLoc, maxPosition);
|
|
|
});
|
|
|
diagram.selection.each(function (current) {
|
|
|
if (current instanceof go.Link) return; // skips over go.Link
|
|
|
current.move(new go.Point(maxPosition - current.actualBounds.width, current.position.y));
|
|
|
});
|
|
|
diagram.commitTransaction("aligning right");
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Aligns selected parts at the top-most edge of the top-most part.
|
|
|
* @this {DrawCommandHandler}
|
|
|
*/
|
|
|
DrawCommandHandler.prototype.alignTop = function () {
|
|
|
var diagram = this.diagram;
|
|
|
diagram.startTransaction("alignTop");
|
|
|
var minPosition = Infinity;
|
|
|
diagram.selection.each(function (current) {
|
|
|
if (current instanceof go.Link) return; // skips over go.Link
|
|
|
minPosition = Math.min(current.position.y, minPosition);
|
|
|
});
|
|
|
diagram.selection.each(function (current) {
|
|
|
if (current instanceof go.Link) return; // skips over go.Link
|
|
|
current.move(new go.Point(current.position.x, minPosition));
|
|
|
});
|
|
|
diagram.commitTransaction("alignTop");
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Aligns selected parts at the bottom-most edge of the bottom-most part.
|
|
|
* @this {DrawCommandHandler}
|
|
|
*/
|
|
|
DrawCommandHandler.prototype.alignBottom = function () {
|
|
|
var diagram = this.diagram;
|
|
|
diagram.startTransaction("aligning bottom");
|
|
|
var maxPosition = -Infinity;
|
|
|
diagram.selection.each(function (current) {
|
|
|
if (current instanceof go.Link) return; // skips over go.Link
|
|
|
var bottomSideLoc = current.actualBounds.y + current.actualBounds.height;
|
|
|
maxPosition = Math.max(bottomSideLoc, maxPosition);
|
|
|
});
|
|
|
diagram.selection.each(function (current) {
|
|
|
if (current instanceof go.Link) return; // skips over go.Link
|
|
|
current.move(new go.Point(current.actualBounds.x, maxPosition - current.actualBounds.height));
|
|
|
});
|
|
|
diagram.commitTransaction("aligning bottom");
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Aligns selected parts at the x-value of the center point of the first selected part.
|
|
|
* @this {DrawCommandHandler}
|
|
|
*/
|
|
|
DrawCommandHandler.prototype.alignCenterX = function () {
|
|
|
var diagram = this.diagram;
|
|
|
var firstSelection = diagram.selection.first();
|
|
|
if (!firstSelection) return;
|
|
|
diagram.startTransaction("aligning Center X");
|
|
|
var centerX = firstSelection.actualBounds.x + firstSelection.actualBounds.width / 2;
|
|
|
diagram.selection.each(function (current) {
|
|
|
if (current instanceof go.Link) return; // skips over go.Link
|
|
|
current.move(new go.Point(centerX - current.actualBounds.width / 2, current.actualBounds.y));
|
|
|
});
|
|
|
diagram.commitTransaction("aligning Center X");
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Aligns selected parts at the y-value of the center point of the first selected part.
|
|
|
* @this {DrawCommandHandler}
|
|
|
*/
|
|
|
DrawCommandHandler.prototype.alignCenterY = function () {
|
|
|
var diagram = this.diagram;
|
|
|
var firstSelection = diagram.selection.first();
|
|
|
if (!firstSelection) return;
|
|
|
diagram.startTransaction("aligning Center Y");
|
|
|
var centerY = firstSelection.actualBounds.y + firstSelection.actualBounds.height / 2;
|
|
|
diagram.selection.each(function (current) {
|
|
|
if (current instanceof go.Link) return; // skips over go.Link
|
|
|
current.move(new go.Point(current.actualBounds.x, centerY - current.actualBounds.height / 2));
|
|
|
});
|
|
|
diagram.commitTransaction("aligning Center Y");
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Aligns selected parts top-to-bottom in order of the order selected.
|
|
|
* Distance between parts can be specified. Default distance is 0.
|
|
|
* @this {DrawCommandHandler}
|
|
|
* @param {number} distance
|
|
|
*/
|
|
|
DrawCommandHandler.prototype.alignColumn = function (distance) {
|
|
|
var diagram = this.diagram;
|
|
|
diagram.startTransaction("align Column");
|
|
|
if (distance === undefined) distance = 0; // for aligning edge to edge
|
|
|
distance = parseFloat(distance);
|
|
|
var selectedParts = new Array();
|
|
|
diagram.selection.each(function (current) {
|
|
|
if (current instanceof go.Link) return; // skips over go.Link
|
|
|
selectedParts.push(current);
|
|
|
});
|
|
|
for (var i = 0; i < selectedParts.length - 1; i++) {
|
|
|
var current = selectedParts[i];
|
|
|
// adds distance specified between parts
|
|
|
var curBottomSideLoc = current.actualBounds.y + current.actualBounds.height + distance;
|
|
|
var next = selectedParts[i + 1];
|
|
|
next.move(new go.Point(current.actualBounds.x, curBottomSideLoc));
|
|
|
}
|
|
|
diagram.commitTransaction("align Column");
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Aligns selected parts left-to-right in order of the order selected.
|
|
|
* Distance between parts can be specified. Default distance is 0.
|
|
|
* @this {DrawCommandHandler}
|
|
|
* @param {number} distance
|
|
|
*/
|
|
|
DrawCommandHandler.prototype.alignRow = function (distance) {
|
|
|
if (distance === undefined) distance = 0; // for aligning edge to edge
|
|
|
distance = parseFloat(distance);
|
|
|
var diagram = this.diagram;
|
|
|
diagram.startTransaction("align Row");
|
|
|
var selectedParts = new Array();
|
|
|
diagram.selection.each(function (current) {
|
|
|
if (current instanceof go.Link) return; // skips over go.Link
|
|
|
selectedParts.push(current);
|
|
|
});
|
|
|
for (var i = 0; i < selectedParts.length - 1; i++) {
|
|
|
var current = selectedParts[i];
|
|
|
// adds distance specified between parts
|
|
|
var curRightSideLoc = current.actualBounds.x + current.actualBounds.width + distance;
|
|
|
var next = selectedParts[i + 1];
|
|
|
next.move(new go.Point(curRightSideLoc, current.actualBounds.y));
|
|
|
}
|
|
|
diagram.commitTransaction("align Row");
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* This controls whether or not the user can invoke the {@link #rotate} command.
|
|
|
* @this {DrawCommandHandler}
|
|
|
* @param {number=} angle the positive (clockwise) or negative (counter-clockwise) change in the rotation angle of each Part, in degrees.
|
|
|
* @return {boolean}
|
|
|
* This returns true:
|
|
|
* if the diagram is not {@link Diagram#isReadOnly},
|
|
|
* if the model is not {@link Model#isReadOnly}, and
|
|
|
* if there is at least one selected {@link Part}.
|
|
|
*/
|
|
|
DrawCommandHandler.prototype.canRotate = function (number) {
|
|
|
var diagram = this.diagram;
|
|
|
if (diagram === null || diagram.isReadOnly || diagram.isModelReadOnly) return false;
|
|
|
if (diagram.selection.count < 1) return false;
|
|
|
return true;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Change the angle of the parts connected with the given part. This is in the command handler
|
|
|
* so it can be easily accessed for the purpose of creating commands that change the rotation of a part.
|
|
|
* @this {DrawCommandHandler}
|
|
|
* @param {number=} angle the positive (clockwise) or negative (counter-clockwise) change in the rotation angle of each Part, in degrees.
|
|
|
*/
|
|
|
DrawCommandHandler.prototype.rotate = function (angle) {
|
|
|
if (angle === undefined) angle = 90;
|
|
|
var diagram = this.diagram;
|
|
|
diagram.startTransaction("rotate " + angle.toString());
|
|
|
var diagram = this.diagram;
|
|
|
diagram.selection.each(function (current) {
|
|
|
if (current instanceof go.Link || current instanceof go.Group) return; // skips over Links and Groups
|
|
|
current.angle += angle;
|
|
|
});
|
|
|
diagram.commitTransaction("rotate " + angle.toString());
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Change the z-ordering of selected parts to pull them forward, in front of all other parts
|
|
|
* in their respective layers.
|
|
|
* All unselected parts in each layer with a selected Part with a non-numeric {@link Part#zOrder} will get a zOrder of zero.
|
|
|
* @this {DrawCommandHandler}
|
|
|
*/
|
|
|
DrawCommandHandler.prototype.pullToFront = function () {
|
|
|
var diagram = this.diagram;
|
|
|
diagram.startTransaction("pullToFront");
|
|
|
// find the affected Layers
|
|
|
var layers = new go.Map();
|
|
|
diagram.selection.each(function (part) {
|
|
|
layers.set(part.layer, 0);
|
|
|
});
|
|
|
// find the maximum zOrder in each Layer
|
|
|
layers.iteratorKeys.each(function (layer) {
|
|
|
var max = 0;
|
|
|
layer.parts.each(function (part) {
|
|
|
if (part.isSelected) return;
|
|
|
var z = part.zOrder;
|
|
|
if (isNaN(z)) {
|
|
|
part.zOrder = 0;
|
|
|
} else {
|
|
|
max = Math.max(max, z);
|
|
|
}
|
|
|
});
|
|
|
layers.set(layer, max);
|
|
|
});
|
|
|
// assign each selected Part.zOrder to the computed value for each Layer
|
|
|
diagram.selection.each(function (part) {
|
|
|
DrawCommandHandler._assignZOrder(part, layers.get(part.layer) + 1);
|
|
|
});
|
|
|
diagram.commitTransaction("pullToFront");
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Change the z-ordering of selected parts to push them backward, behind of all other parts
|
|
|
* in their respective layers.
|
|
|
* All unselected parts in each layer with a selected Part with a non-numeric {@link Part#zOrder} will get a zOrder of zero.
|
|
|
* @this {DrawCommandHandler}
|
|
|
*/
|
|
|
DrawCommandHandler.prototype.pushToBack = function () {
|
|
|
var diagram = this.diagram;
|
|
|
diagram.startTransaction("pushToBack");
|
|
|
// find the affected Layers
|
|
|
var layers = new go.Map();
|
|
|
diagram.selection.each(function (part) {
|
|
|
layers.set(part.layer, 0);
|
|
|
});
|
|
|
// find the minimum zOrder in each Layer
|
|
|
layers.iteratorKeys.each(function (layer) {
|
|
|
var min = 0;
|
|
|
layer.parts.each(function (part) {
|
|
|
if (part.isSelected) return;
|
|
|
var z = part.zOrder;
|
|
|
if (isNaN(z)) {
|
|
|
part.zOrder = 0;
|
|
|
} else {
|
|
|
min = Math.min(min, z);
|
|
|
}
|
|
|
});
|
|
|
layers.set(layer, min);
|
|
|
});
|
|
|
// assign each selected Part.zOrder to the computed value for each Layer
|
|
|
diagram.selection.each(function (part) {
|
|
|
DrawCommandHandler._assignZOrder(part,
|
|
|
// make sure a group's nested nodes are also behind everything else
|
|
|
layers.get(part.layer) - 1 - DrawCommandHandler._findGroupDepth(part));
|
|
|
});
|
|
|
diagram.commitTransaction("pushToBack");
|
|
|
};
|
|
|
DrawCommandHandler._assignZOrder = function (part, z, root) {
|
|
|
if (root === undefined) root = part;
|
|
|
if (part.layer === root.layer) part.zOrder = z;
|
|
|
if (part instanceof go.Group) {
|
|
|
part.memberParts.each(function (m) {
|
|
|
DrawCommandHandler._assignZOrder(m, z + 1, root);
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
DrawCommandHandler._findGroupDepth = function (part) {
|
|
|
if (part instanceof go.Group) {
|
|
|
var d = 0;
|
|
|
part.memberParts.each(function (m) {
|
|
|
d = Math.max(d, DrawCommandHandler._findGroupDepth(m));
|
|
|
});
|
|
|
return d + 1;
|
|
|
} else {
|
|
|
return 0;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* This implements custom behaviors for arrow key keyboard events.
|
|
|
* Set {@link #arrowKeyBehavior} to "select", "move" (the default), "scroll" (the standard behavior), or "none"
|
|
|
* to affect the behavior when the user types an arrow key.
|
|
|
* @this {DrawCommandHandler}*/
|
|
|
DrawCommandHandler.prototype.doKeyDown = function () {
|
|
|
var diagram = this.diagram;
|
|
|
if (diagram === null) return;
|
|
|
var e = diagram.lastInput;
|
|
|
|
|
|
// determines the function of the arrow keys
|
|
|
if (e.key === "Up" || e.key === "Down" || e.key === "Left" || e.key === "Right") {
|
|
|
var behavior = this.arrowKeyBehavior;
|
|
|
if (behavior === "none") {
|
|
|
// no-op
|
|
|
return;
|
|
|
} else if (behavior === "select") {
|
|
|
this._arrowKeySelect();
|
|
|
return;
|
|
|
} else if (behavior === "move") {
|
|
|
this._arrowKeyMove();
|
|
|
return;
|
|
|
} else if (behavior === "tree") {
|
|
|
this._arrowKeyTree();
|
|
|
return;
|
|
|
}
|
|
|
// otherwise drop through to get the default scrolling behavior
|
|
|
}
|
|
|
|
|
|
// otherwise still does all standard commands
|
|
|
go.CommandHandler.prototype.doKeyDown.call(this);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Collects in an Array all of the non-Link Parts currently in the Diagram.
|
|
|
* @this {DrawCommandHandler}
|
|
|
* @return {Array}
|
|
|
*/
|
|
|
DrawCommandHandler.prototype._getAllParts = function () {
|
|
|
var allParts = new Array();
|
|
|
this.diagram.nodes.each(function (node) {
|
|
|
allParts.push(node);
|
|
|
});
|
|
|
this.diagram.parts.each(function (part) {
|
|
|
allParts.push(part);
|
|
|
});
|
|
|
// note that this ignores Links
|
|
|
return allParts;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* To be called when arrow keys should move the Diagram.selection.
|
|
|
* @this {DrawCommandHandler}
|
|
|
*/
|
|
|
DrawCommandHandler.prototype._arrowKeyMove = function () {
|
|
|
var diagram = this.diagram;
|
|
|
var e = diagram.lastInput;
|
|
|
// moves all selected parts in the specified direction
|
|
|
var vdistance = 0;
|
|
|
var hdistance = 0;
|
|
|
// if control is being held down, move pixel by pixel. Else, moves by grid cell size
|
|
|
if (e.control || e.meta) {
|
|
|
vdistance = 1;
|
|
|
hdistance = 1;
|
|
|
} else if (diagram.grid !== null) {
|
|
|
var cellsize = diagram.grid.gridCellSize;
|
|
|
hdistance = cellsize.width;
|
|
|
vdistance = cellsize.height;
|
|
|
}
|
|
|
diagram.startTransaction("arrowKeyMove");
|
|
|
diagram.selection.each(function (part) {
|
|
|
if (e.key === "Up") {
|
|
|
part.move(new go.Point(part.actualBounds.x, part.actualBounds.y - vdistance));
|
|
|
} else if (e.key === "Down") {
|
|
|
part.move(new go.Point(part.actualBounds.x, part.actualBounds.y + vdistance));
|
|
|
} else if (e.key === "Left") {
|
|
|
part.move(new go.Point(part.actualBounds.x - hdistance, part.actualBounds.y));
|
|
|
} else if (e.key === "Right") {
|
|
|
part.move(new go.Point(part.actualBounds.x + hdistance, part.actualBounds.y));
|
|
|
}
|
|
|
});
|
|
|
diagram.commitTransaction("arrowKeyMove");
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* To be called when arrow keys should change selection.
|
|
|
* @this {DrawCommandHandler}
|
|
|
*/
|
|
|
DrawCommandHandler.prototype._arrowKeySelect = function () {
|
|
|
var diagram = this.diagram;
|
|
|
var e = diagram.lastInput;
|
|
|
// with a part selected, arrow keys change the selection
|
|
|
// arrow keys + shift selects the additional part in the specified direction
|
|
|
// arrow keys + control toggles the selection of the additional part
|
|
|
var nextPart = null;
|
|
|
if (e.key === "Up") {
|
|
|
nextPart = this._findNearestPartTowards(270);
|
|
|
} else if (e.key === "Down") {
|
|
|
nextPart = this._findNearestPartTowards(90);
|
|
|
} else if (e.key === "Left") {
|
|
|
nextPart = this._findNearestPartTowards(180);
|
|
|
} else if (e.key === "Right") {
|
|
|
nextPart = this._findNearestPartTowards(0);
|
|
|
}
|
|
|
if (nextPart !== null) {
|
|
|
if (e.shift) {
|
|
|
nextPart.isSelected = true;
|
|
|
} else if (e.control || e.meta) {
|
|
|
nextPart.isSelected = !nextPart.isSelected;
|
|
|
} else {
|
|
|
diagram.select(nextPart);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Finds the nearest selectable Part in the specified direction, based on their center points.
|
|
|
* if it doesn't find anything, it just returns the current Part.
|
|
|
* @this {DrawCommandHandler}
|
|
|
* @param {number} dir the direction, in degrees
|
|
|
* @return {Part} the closest Part found in the given direction
|
|
|
*/
|
|
|
DrawCommandHandler.prototype._findNearestPartTowards = function (dir) {
|
|
|
var originalPart = this.diagram.selection.first();
|
|
|
if (originalPart === null) return null;
|
|
|
var originalPoint = originalPart.actualBounds.center;
|
|
|
var allParts = this._getAllParts();
|
|
|
var closestDistance = Infinity;
|
|
|
var closest = originalPart; // if no parts meet the criteria, the same part remains selected
|
|
|
|
|
|
for (var i = 0; i < allParts.length; i++) {
|
|
|
var nextPart = allParts[i];
|
|
|
if (nextPart === originalPart) continue; // skips over currently selected part
|
|
|
if (!nextPart.canSelect()) continue;
|
|
|
var nextPoint = nextPart.actualBounds.center;
|
|
|
var angle = originalPoint.directionPoint(nextPoint);
|
|
|
var anglediff = this._angleCloseness(angle, dir);
|
|
|
if (anglediff <= 45) {
|
|
|
// if this part's center is within the desired direction's sector,
|
|
|
var distance = originalPoint.distanceSquaredPoint(nextPoint);
|
|
|
distance *= 1 + Math.sin(anglediff * Math.PI / 180); // the more different from the intended angle, the further it is
|
|
|
if (distance < closestDistance) {
|
|
|
// and if it's closer than any other part,
|
|
|
closestDistance = distance; // remember it as a better choice
|
|
|
closest = nextPart;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return closest;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* @this {DrawCommandHandler}
|
|
|
* @param {number} a
|
|
|
* @param {number} dir
|
|
|
* @return {number}
|
|
|
*/
|
|
|
DrawCommandHandler.prototype._angleCloseness = function (a, dir) {
|
|
|
return Math.min(Math.abs(dir - a), Math.min(Math.abs(dir + 360 - a), Math.abs(dir - 360 - a)));
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* To be called when arrow keys should change the selected node in a tree and expand or collapse subtrees.
|
|
|
* @this {DrawCommandHandler}
|
|
|
*/
|
|
|
DrawCommandHandler.prototype._arrowKeyTree = function () {
|
|
|
var diagram = this.diagram;
|
|
|
var selected = diagram.selection.first();
|
|
|
if (!(selected instanceof go.Node)) return;
|
|
|
var e = diagram.lastInput;
|
|
|
if (e.key === "Right") {
|
|
|
if (selected.isTreeLeaf) {
|
|
|
// no-op
|
|
|
} else if (!selected.isTreeExpanded) {
|
|
|
if (diagram.commandHandler.canExpandTree(selected)) {
|
|
|
diagram.commandHandler.expandTree(selected); // expands the tree
|
|
|
}
|
|
|
} else {
|
|
|
// already expanded -- select the first child node
|
|
|
var first = this._sortTreeChildrenByY(selected).first();
|
|
|
if (first !== null) diagram.select(first);
|
|
|
}
|
|
|
} else if (e.key === "Left") {
|
|
|
if (!selected.isTreeLeaf && selected.isTreeExpanded) {
|
|
|
if (diagram.commandHandler.canCollapseTree(selected)) {
|
|
|
diagram.commandHandler.collapseTree(selected); // collapses the tree
|
|
|
}
|
|
|
} else {
|
|
|
// either a leaf or is already collapsed -- select the parent node
|
|
|
var parent = selected.findTreeParentNode();
|
|
|
if (parent !== null) diagram.select(parent);
|
|
|
}
|
|
|
} else if (e.key === "Up") {
|
|
|
var parent = selected.findTreeParentNode();
|
|
|
if (parent !== null) {
|
|
|
var list = this._sortTreeChildrenByY(parent);
|
|
|
var idx = list.indexOf(selected);
|
|
|
if (idx > 0) {
|
|
|
// if there is a previous sibling
|
|
|
var prev = list.elt(idx - 1);
|
|
|
// keep looking at the last child until it's a leaf or collapsed
|
|
|
while (prev !== null && prev.isTreeExpanded && !prev.isTreeLeaf) {
|
|
|
var children = this._sortTreeChildrenByY(prev);
|
|
|
prev = children.last();
|
|
|
}
|
|
|
if (prev !== null) diagram.select(prev);
|
|
|
} else {
|
|
|
// no previous sibling -- select parent
|
|
|
diagram.select(parent);
|
|
|
}
|
|
|
}
|
|
|
} else if (e.key === "Down") {
|
|
|
// if at an expanded parent, select the first child
|
|
|
if (selected.isTreeExpanded && !selected.isTreeLeaf) {
|
|
|
var first = this._sortTreeChildrenByY(selected).first();
|
|
|
if (first !== null) diagram.select(first);
|
|
|
} else {
|
|
|
while (selected !== null) {
|
|
|
var parent = selected.findTreeParentNode();
|
|
|
if (parent === null) break;
|
|
|
var list = this._sortTreeChildrenByY(parent);
|
|
|
var idx = list.indexOf(selected);
|
|
|
if (idx < list.length - 1) {
|
|
|
// select next lower node
|
|
|
diagram.select(list.elt(idx + 1));
|
|
|
break;
|
|
|
} else {
|
|
|
// already at bottom of list of children
|
|
|
selected = parent;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// make sure the selection is now in the viewport, but not necessarily centered
|
|
|
var sel = diagram.selection.first();
|
|
|
if (sel !== null) diagram.scrollToRect(sel.actualBounds);
|
|
|
};
|
|
|
DrawCommandHandler.prototype._sortTreeChildrenByY = function (node) {
|
|
|
var list = new go.List().addAll(node.findTreeChildrenNodes());
|
|
|
list.sort(function (a, b) {
|
|
|
var aloc = a.location;
|
|
|
var bloc = b.location;
|
|
|
if (aloc.y < bloc.y) return -1;
|
|
|
if (aloc.y > bloc.y) return 1;
|
|
|
if (aloc.x < bloc.x) return -1;
|
|
|
if (aloc.x > bloc.x) return 1;
|
|
|
return 0;
|
|
|
});
|
|
|
return list;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Reset the last offset for pasting.
|
|
|
* @this {DrawCommandHandler}
|
|
|
* @param {Iterable.<Part>} coll a collection of {@link Part}s.
|
|
|
*/
|
|
|
DrawCommandHandler.prototype.copyToClipboard = function (coll) {
|
|
|
go.CommandHandler.prototype.copyToClipboard.call(this, coll);
|
|
|
this._lastPasteOffset.set(this.pasteOffset);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Paste from the clipboard with an offset incremented on each paste, and reset when copied.
|
|
|
* @this {DrawCommandHandler}
|
|
|
* @return {Set.<Part>} a collection of newly pasted {@link Part}s
|
|
|
*/
|
|
|
DrawCommandHandler.prototype.pasteFromClipboard = function () {
|
|
|
var coll = go.CommandHandler.prototype.pasteFromClipboard.call(this);
|
|
|
this.diagram.moveParts(coll, this._lastPasteOffset);
|
|
|
this._lastPasteOffset.add(this.pasteOffset);
|
|
|
return coll;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Gets or sets the arrow key behavior. Possible values are "move", "select", "scroll", and "tree".
|
|
|
* The default value is "move".
|
|
|
* @name DrawCommandHandler#arrowKeyBehavior
|
|
|
|
|
|
* @return {string}
|
|
|
*/
|
|
|
Object.defineProperty(DrawCommandHandler.prototype, "arrowKeyBehavior", {
|
|
|
get: function get() {
|
|
|
return this._arrowKeyBehavior;
|
|
|
},
|
|
|
set: function set(val) {
|
|
|
if (val !== "move" && val !== "select" && val !== "scroll" && val !== "tree" && val !== "none") {
|
|
|
throw new Error("DrawCommandHandler.arrowKeyBehavior must be either \"move\", \"select\", \"scroll\", \"tree\", or \"none\", not: " + val);
|
|
|
}
|
|
|
this._arrowKeyBehavior = val;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* Gets or sets the offset at which each repeated pasteSelection() puts the new copied parts from the clipboard.
|
|
|
* The default value is (10,10).
|
|
|
* @name DrawCommandHandler#pasteOffset
|
|
|
|
|
|
* @return {Point}
|
|
|
*/
|
|
|
Object.defineProperty(DrawCommandHandler.prototype, "pasteOffset", {
|
|
|
get: function get() {
|
|
|
return this._pasteOffset;
|
|
|
},
|
|
|
set: function set(val) {
|
|
|
if (!(val instanceof go.Point)) throw new Error("DrawCommandHandler.pasteOffset must be a Point, not: " + val);
|
|
|
this._pasteOffset.set(val);
|
|
|
}
|
|
|
});
|
|
|
/* harmony default export */ var go_DrawCommandHandler = (DrawCommandHandler);
|
|
|
// EXTERNAL MODULE: ./public/js/go/Figures.js
|
|
|
var Figures = __webpack_require__(42878);
|
|
|
// EXTERNAL MODULE: ./node_modules/_gojs-react@1.1.2@gojs-react/lib/esm/gojsreact.js + 1 modules
|
|
|
var gojsreact = __webpack_require__(85160);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/modal/index.js + 16 modules
|
|
|
var es_modal = __webpack_require__(43418);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/col/index.js
|
|
|
var col = __webpack_require__(43604);
|
|
|
// EXTERNAL MODULE: ./src/utils/fetch.ts
|
|
|
var fetch = __webpack_require__(15830);
|
|
|
;// CONCATENATED MODULE: ./src/components/markdown-editor/flow-chart/index.less?modules
|
|
|
// extracted by mini-css-extract-plugin
|
|
|
/* harmony default export */ var flow_chartmodules = ({"myPaletteDiv":"myPaletteDiv___Xjz2I","maxH60":"maxH60___Pd4Re"});
|
|
|
;// CONCATENATED MODULE: ./src/components/markdown-editor/flow-chart/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window.go = go_module;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function FlowChart(_ref) {
|
|
|
var onCancel = _ref.onCancel,
|
|
|
callback = _ref.callback;
|
|
|
var myDiagram = (0,_react_17_0_2_react.useRef)();
|
|
|
var myDiagramDivRef = (0,_react_17_0_2_react.useRef)();
|
|
|
var myPaletteDivRef = (0,_react_17_0_2_react.useRef)();
|
|
|
var hidedenContentRef = (0,_react_17_0_2_react.useRef)(false);
|
|
|
var modalRef = (0,_react_17_0_2_react.useRef)(false);
|
|
|
var _useState = (0,_react_17_0_2_react.useState)(0),
|
|
|
_useState2 = slicedToArray_default()(_useState, 2),
|
|
|
updateModal = _useState2[0],
|
|
|
setUpdateModal = _useState2[1];
|
|
|
function initDiagram() {
|
|
|
var $ = go_module.GraphObject.make;
|
|
|
var colors = {
|
|
|
red: "#ff3333",
|
|
|
blue: "#3358ff",
|
|
|
green: "#25ad23",
|
|
|
magenta: "#d533ff",
|
|
|
purple: "#7d33ff",
|
|
|
orange: "#ff6233",
|
|
|
brown: "#8e571e",
|
|
|
white: "#ffffff",
|
|
|
black: "#000000",
|
|
|
beige: "#fffcd5",
|
|
|
extralightblue: "#d5ebff",
|
|
|
extralightred: "#f2dfe0",
|
|
|
lightblue: "#a5d2fa",
|
|
|
lightgray: "#cccccc",
|
|
|
lightgreen: "#b3e6b3",
|
|
|
lightred: "#fcbbbd"
|
|
|
};
|
|
|
myDiagram.current = new go_module.Diagram(myDiagramDivRef.current, {
|
|
|
padding: 20,
|
|
|
// extra space when scrolled all the way
|
|
|
grid: $(go_module.Panel, "Grid",
|
|
|
// a simple 10x10 grid
|
|
|
$(go_module.Shape, "LineH", {
|
|
|
stroke: "lightgray",
|
|
|
strokeWidth: 0.5
|
|
|
}), $(go_module.Shape, "LineV", {
|
|
|
stroke: "lightgray",
|
|
|
strokeWidth: 0.5
|
|
|
})),
|
|
|
"draggingTool.isGridSnapEnabled": true,
|
|
|
handlesDragDropForTopLevelParts: true,
|
|
|
mouseDrop: function mouseDrop(e) {
|
|
|
var ok = e.diagram.commandHandler.addTopLevelParts(e.diagram.selection, true);
|
|
|
if (!ok) e.diagram.currentTool.doCancel();
|
|
|
},
|
|
|
commandHandler: $(go_DrawCommandHandler),
|
|
|
// support offset copy-and-paste
|
|
|
"clickCreatingTool.archetypeNodeData": {
|
|
|
text: "未命名",
|
|
|
fill: null,
|
|
|
stroke: null,
|
|
|
borderColor: "rgba(0,0,0,0)"
|
|
|
},
|
|
|
// create a new node by double-clicking in background
|
|
|
"PartCreated": function PartCreated(e) {
|
|
|
var node = e.subject; // the newly inserted Node -- now need to snap its location to the grid
|
|
|
node.location = node.location.copy().snapToGridPoint(e.diagram.grid.gridOrigin, e.diagram.grid.gridCellSize);
|
|
|
setTimeout(function () {
|
|
|
// and have the user start editing its text
|
|
|
e.diagram.commandHandler.editTextBlock();
|
|
|
}, 20);
|
|
|
},
|
|
|
"commandHandler.archetypeGroupData": {
|
|
|
isGroup: true,
|
|
|
text: "NEW GROUP"
|
|
|
},
|
|
|
"SelectionGrouped": function SelectionGrouped(e) {
|
|
|
var group = e.subject;
|
|
|
setTimeout(function () {
|
|
|
// and have the user start editing its text
|
|
|
e.diagram.commandHandler.editTextBlock();
|
|
|
});
|
|
|
},
|
|
|
"LinkRelinked": function LinkRelinked(e) {
|
|
|
// re-spread the connections of other links connected with both old and new nodes
|
|
|
var oldnode = e.parameter.part;
|
|
|
oldnode.invalidateConnectedLinks();
|
|
|
var link = e.subject;
|
|
|
if (e.diagram.toolManager.linkingTool.isForwards) {
|
|
|
link.toNode.invalidateConnectedLinks();
|
|
|
} else {
|
|
|
link.fromNode.invalidateConnectedLinks();
|
|
|
}
|
|
|
},
|
|
|
"undoManager.isEnabled": true
|
|
|
});
|
|
|
|
|
|
// Node template
|
|
|
|
|
|
myDiagram.current.nodeTemplate = $(go_module.Node, "Auto", {
|
|
|
locationSpot: go_module.Spot.Center,
|
|
|
locationObjectName: "SHAPE",
|
|
|
desiredSize: new go_module.Size(120, 60),
|
|
|
minSize: new go_module.Size(40, 40),
|
|
|
resizable: true,
|
|
|
resizeCellSize: new go_module.Size(10, 10),
|
|
|
rotatable: true
|
|
|
// rotateObjectName: "SHAPE", // rotate the Shape without rotating the label
|
|
|
},
|
|
|
// these Bindings are TwoWay because the DraggingTool and ResizingTool modify the target properties
|
|
|
new go_module.Binding("location", "loc", go_module.Point.parse).makeTwoWay(go_module.Point.stringify), new go_module.Binding("desiredSize", "size", go_module.Size.parse).makeTwoWay(go_module.Size.stringify), $(go_module.Shape, {
|
|
|
// the border
|
|
|
name: "SHAPE",
|
|
|
fill: colors.white,
|
|
|
cursor: "pointer",
|
|
|
portId: "",
|
|
|
fromLinkable: true,
|
|
|
toLinkable: true,
|
|
|
fromLinkableDuplicates: true,
|
|
|
toLinkableDuplicates: true,
|
|
|
fromSpot: go_module.Spot.AllSides,
|
|
|
toSpot: go_module.Spot.AllSides
|
|
|
}, new go_module.Binding("figure"), new go_module.Binding("fill"), new go_module.Binding("stroke", "borderColor"), new go_module.Binding("strokeWidth", "thickness"), new go_module.Binding("strokeDashArray", "dash")),
|
|
|
// this Shape prevents mouse events from reaching the middle of the port
|
|
|
$(go_module.Shape, {
|
|
|
width: 100,
|
|
|
height: 20,
|
|
|
strokeWidth: 0,
|
|
|
fill: "transparent"
|
|
|
}), $(go_module.TextBlock, {
|
|
|
margin: 1,
|
|
|
textAlign: "center",
|
|
|
overflow: go_module.TextBlock.OverflowEllipsis,
|
|
|
editable: true
|
|
|
},
|
|
|
// this Binding is TwoWay due to the user editing the text with the TextEditingTool
|
|
|
new go_module.Binding("text").makeTwoWay(), new go_module.Binding("stroke", "color")));
|
|
|
myDiagram.current.nodeTemplate.toolTip = $("ToolTip",
|
|
|
// show some detailed information
|
|
|
$(go_module.Panel, "Vertical", {
|
|
|
maxSize: new go_module.Size(200, NaN)
|
|
|
},
|
|
|
// limit width but not height
|
|
|
$(go_module.TextBlock, {
|
|
|
font: "bold 10pt sans-serif",
|
|
|
textAlign: "center"
|
|
|
}, new go_module.Binding("text")), $(go_module.TextBlock, {
|
|
|
font: "10pt sans-serif",
|
|
|
textAlign: "center"
|
|
|
}, new go_module.Binding("text", "details"))));
|
|
|
|
|
|
// Node selection adornment
|
|
|
// Include four large triangular buttons so that the user can easily make a copy
|
|
|
// of the node, move it to be in that direction relative to the original node,
|
|
|
// and add a link to the new node.
|
|
|
|
|
|
function makeArrowButton(spot, fig) {
|
|
|
var maker = function maker(e, shape) {
|
|
|
e.handled = true;
|
|
|
e.diagram.model.commit(function (m) {
|
|
|
var selnode = shape.part.adornedPart;
|
|
|
// create a new node in the direction of the spot
|
|
|
var p = new go_module.Point().setRectSpot(selnode.actualBounds, spot);
|
|
|
p.subtract(selnode.location);
|
|
|
p.scale(2, 2);
|
|
|
p.x += Math.sign(p.x) * 130;
|
|
|
p.y += Math.sign(p.y) * 130;
|
|
|
p.add(selnode.location);
|
|
|
p.snapToGridPoint(e.diagram.grid.gridOrigin, e.diagram.grid.gridCellSize);
|
|
|
// make the new node a copy of the selected node
|
|
|
var nodedata = m.copyNodeData(selnode.data);
|
|
|
// add to same group as selected node
|
|
|
m.setGroupKeyForNodeData(nodedata, m.getGroupKeyForNodeData(selnode.data));
|
|
|
m.addNodeData(nodedata); // add to model
|
|
|
// create a link from the selected node to the new node
|
|
|
var linkdata = {
|
|
|
from: selnode.key,
|
|
|
to: m.getKeyForNodeData(nodedata)
|
|
|
};
|
|
|
m.addLinkData(linkdata); // add to model
|
|
|
// move the new node to the computed location, select it, and start to edit it
|
|
|
var newnode = e.diagram.findNodeForData(nodedata);
|
|
|
newnode.location = p;
|
|
|
e.diagram.select(newnode);
|
|
|
setTimeout(function () {
|
|
|
e.diagram.commandHandler.editTextBlock();
|
|
|
}, 20);
|
|
|
});
|
|
|
};
|
|
|
return $(go_module.Shape, {
|
|
|
figure: fig,
|
|
|
alignment: spot,
|
|
|
alignmentFocus: spot.opposite(),
|
|
|
width: spot.equals(go_module.Spot.Top) || spot.equals(go_module.Spot.Bottom) ? 25 : 18,
|
|
|
height: spot.equals(go_module.Spot.Top) || spot.equals(go_module.Spot.Bottom) ? 18 : 25,
|
|
|
fill: "orange",
|
|
|
stroke: colors.white,
|
|
|
strokeWidth: 4,
|
|
|
mouseEnter: function mouseEnter(e, shape) {
|
|
|
return shape.fill = "dodgerblue";
|
|
|
},
|
|
|
mouseLeave: function mouseLeave(e, shape) {
|
|
|
return shape.fill = "orange";
|
|
|
},
|
|
|
isActionable: true,
|
|
|
// needed because it's in an Adornment
|
|
|
click: maker,
|
|
|
contextClick: maker
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// create a button that brings up the context menu
|
|
|
function CMButton(options) {
|
|
|
return $(go_module.Shape, {
|
|
|
fill: "orange",
|
|
|
stroke: "rgba(0, 0, 0, 0)",
|
|
|
strokeWidth: 15,
|
|
|
background: "transparent",
|
|
|
geometryString: "F1 M0 0 b 0 360 -4 0 4 z M10 0 b 0 360 -4 0 4 z M20 0 b 0 360 -4 0 4",
|
|
|
// M10 0 A2 2 0 1 0 14 10 M20 0 A2 2 0 1 0 24 10,
|
|
|
isActionable: true,
|
|
|
cursor: "context-menu",
|
|
|
mouseEnter: function mouseEnter(e, shape) {
|
|
|
return shape.fill = "dodgerblue";
|
|
|
},
|
|
|
mouseLeave: function mouseLeave(e, shape) {
|
|
|
return shape.fill = "orange";
|
|
|
},
|
|
|
click: function click(e, shape) {
|
|
|
e.diagram.commandHandler.showContextMenu(shape.part.adornedPart);
|
|
|
}
|
|
|
}, options || {});
|
|
|
}
|
|
|
myDiagram.current.nodeTemplate.selectionAdornmentTemplate = $(go_module.Adornment, "Spot", $(go_module.Placeholder, {
|
|
|
padding: 10
|
|
|
}), makeArrowButton(go_module.Spot.Top, "TriangleUp"), makeArrowButton(go_module.Spot.Left, "TriangleLeft"), makeArrowButton(go_module.Spot.Right, "TriangleRight"), makeArrowButton(go_module.Spot.Bottom, "TriangleDown"), CMButton({
|
|
|
alignment: new go_module.Spot(0.75, 0)
|
|
|
}));
|
|
|
|
|
|
// Common context menu button definitions
|
|
|
|
|
|
// All buttons in context menu work on both click and contextClick,
|
|
|
// in case the user context-clicks on the button.
|
|
|
// All buttons modify the node data, not the Node, so the Bindings need not be TwoWay.
|
|
|
|
|
|
// A button-defining helper function that returns a click event handler.
|
|
|
// PROPNAME is the name of the data property that should be set to the given VALUE.
|
|
|
function ClickFunction(propname, value) {
|
|
|
return function (e, obj) {
|
|
|
e.handled = true; // don't let the click bubble up
|
|
|
e.diagram.model.commit(function (m) {
|
|
|
m.set(obj.part.adornedPart.data, propname, value);
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// Create a context menu button for setting a data property with a color value.
|
|
|
function ColorButton(color, propname) {
|
|
|
if (!propname) propname = "color";
|
|
|
return $(go_module.Shape, {
|
|
|
width: 16,
|
|
|
height: 16,
|
|
|
stroke: "lightgray",
|
|
|
fill: color,
|
|
|
margin: 1,
|
|
|
background: "transparent",
|
|
|
mouseEnter: function mouseEnter(e, shape) {
|
|
|
return shape.stroke = "dodgerblue";
|
|
|
},
|
|
|
mouseLeave: function mouseLeave(e, shape) {
|
|
|
return shape.stroke = "lightgray";
|
|
|
},
|
|
|
click: ClickFunction(propname, color),
|
|
|
contextClick: ClickFunction(propname, color)
|
|
|
});
|
|
|
}
|
|
|
function LightFillButtons() {
|
|
|
// used by multiple context menus
|
|
|
return [$("ContextMenuButton", $(go_module.Panel, "Horizontal", ColorButton(colors.white, "fill"), ColorButton(colors.beige, "fill"), ColorButton(colors.extralightblue, "fill"), ColorButton(colors.extralightred, "fill"))), $("ContextMenuButton", $(go_module.Panel, "Horizontal", ColorButton(colors.lightgray, "fill"), ColorButton(colors.lightgreen, "fill"), ColorButton(colors.lightblue, "fill"), ColorButton(colors.lightred, "fill")))];
|
|
|
}
|
|
|
function DarkColorButtons() {
|
|
|
// used by multiple context menus
|
|
|
return [$("ContextMenuButton", $(go_module.Panel, "Horizontal", ColorButton(colors.black), ColorButton(colors.green), ColorButton(colors.blue), ColorButton(colors.red))), $("ContextMenuButton", $(go_module.Panel, "Horizontal", ColorButton(colors.white), ColorButton(colors.magenta), ColorButton(colors.purple), ColorButton(colors.orange)))];
|
|
|
}
|
|
|
|
|
|
// Create a context menu button for setting a data property with a stroke width value.
|
|
|
function ThicknessButton(sw, propname) {
|
|
|
if (!propname) propname = "thickness";
|
|
|
return $(go_module.Shape, "LineH", {
|
|
|
width: 16,
|
|
|
height: 16,
|
|
|
strokeWidth: sw,
|
|
|
margin: 1,
|
|
|
background: "transparent",
|
|
|
mouseEnter: function mouseEnter(e, shape) {
|
|
|
return shape.background = "dodgerblue";
|
|
|
},
|
|
|
mouseLeave: function mouseLeave(e, shape) {
|
|
|
return shape.background = "transparent";
|
|
|
},
|
|
|
click: ClickFunction(propname, sw),
|
|
|
contextClick: ClickFunction(propname, sw)
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// Create a context menu button for setting a data property with a stroke dash Array value.
|
|
|
function DashButton(dash, propname) {
|
|
|
if (!propname) propname = "dash";
|
|
|
return $(go_module.Shape, "LineH", {
|
|
|
width: 24,
|
|
|
height: 16,
|
|
|
strokeWidth: 2,
|
|
|
strokeDashArray: dash,
|
|
|
margin: 1,
|
|
|
background: "transparent",
|
|
|
mouseEnter: function mouseEnter(e, shape) {
|
|
|
return shape.background = "dodgerblue";
|
|
|
},
|
|
|
mouseLeave: function mouseLeave(e, shape) {
|
|
|
return shape.background = "transparent";
|
|
|
},
|
|
|
click: ClickFunction(propname, dash),
|
|
|
contextClick: ClickFunction(propname, dash)
|
|
|
});
|
|
|
}
|
|
|
function StrokeOptionsButtons() {
|
|
|
// used by multiple context menus
|
|
|
return [$("ContextMenuButton", $(go_module.Panel, "Horizontal", ThicknessButton(1), ThicknessButton(2), ThicknessButton(3), ThicknessButton(4))), $("ContextMenuButton", $(go_module.Panel, "Horizontal", DashButton(null), DashButton([2, 4]), DashButton([4, 4])))];
|
|
|
}
|
|
|
|
|
|
// Node context menu
|
|
|
|
|
|
function FigureButton(fig, propname) {
|
|
|
if (!propname) propname = "figure";
|
|
|
return $(go_module.Shape, {
|
|
|
width: 32,
|
|
|
height: 32,
|
|
|
scale: 0.5,
|
|
|
fill: "lightgray",
|
|
|
figure: fig,
|
|
|
margin: 1,
|
|
|
background: "transparent",
|
|
|
mouseEnter: function mouseEnter(e, shape) {
|
|
|
return shape.fill = "dodgerblue";
|
|
|
},
|
|
|
mouseLeave: function mouseLeave(e, shape) {
|
|
|
return shape.fill = "lightgray";
|
|
|
},
|
|
|
click: ClickFunction(propname, fig),
|
|
|
contextClick: ClickFunction(propname, fig)
|
|
|
});
|
|
|
}
|
|
|
myDiagram.current.nodeTemplate.contextMenu = $("ContextMenu",
|
|
|
// $("ContextMenuButton",
|
|
|
// $(go.TextBlock, 'Move Up', {
|
|
|
// // Associate the custom command to move the node up
|
|
|
// click: (e, obj) => {
|
|
|
// const node = obj.part.adornedPart;
|
|
|
// myDiagram.current.commandHandler['MoveNodeUp'].execute(myDiagram.current);
|
|
|
// }
|
|
|
// })
|
|
|
// ),
|
|
|
// $("ContextMenuButton",
|
|
|
// $(go.TextBlock, 'Move Up', {
|
|
|
// // Associate the custom command to move the node up
|
|
|
// click: (e, obj) => {
|
|
|
// const node = obj.part.adornedPart;
|
|
|
// myDiagram.current.commandHandler['moveNodeUpCommand'].execute(myDiagram.current);
|
|
|
// }
|
|
|
// })
|
|
|
// ),
|
|
|
$("ContextMenuButton", $(go_module.Panel, "Horizontal", FigureButton("Rectangle"), FigureButton("RoundedRectangle"), FigureButton("Ellipse"), FigureButton("Diamond"))), $("ContextMenuButton", $(go_module.Panel, "Horizontal", FigureButton("Parallelogram2"), FigureButton("ManualOperation"), FigureButton("Procedure"), FigureButton("Cylinder1"))), $("ContextMenuButton", $(go_module.Panel, "Horizontal", FigureButton("Terminator"), FigureButton("CreateRequest"), FigureButton("Document"), FigureButton("TriangleDown"))), LightFillButtons(), DarkColorButtons(), StrokeOptionsButtons());
|
|
|
|
|
|
// Group template
|
|
|
|
|
|
myDiagram.current.groupTemplate = $(go_module.Group, "Spot", {
|
|
|
layerName: "Background",
|
|
|
ungroupable: true,
|
|
|
locationSpot: go_module.Spot.Center,
|
|
|
selectionObjectName: "BODY",
|
|
|
computesBoundsAfterDrag: true,
|
|
|
// allow dragging out of a Group that uses a Placeholder
|
|
|
handlesDragDropForMembers: true,
|
|
|
// don't need to define handlers on Nodes and Links
|
|
|
mouseDrop: function mouseDrop(e, grp) {
|
|
|
// add dropped nodes as members of the group
|
|
|
var ok = grp.addMembers(grp.diagram.selection, true);
|
|
|
if (!ok) grp.diagram.currentTool.doCancel();
|
|
|
},
|
|
|
avoidable: false
|
|
|
}, new go_module.Binding("location", "loc", go_module.Point.parse).makeTwoWay(go_module.Point.stringify), $(go_module.Panel, "Auto", {
|
|
|
name: "BODY"
|
|
|
}, $(go_module.Shape, {
|
|
|
parameter1: 10,
|
|
|
fill: colors.white,
|
|
|
strokeWidth: 2,
|
|
|
cursor: "pointer",
|
|
|
fromLinkable: true,
|
|
|
toLinkable: true,
|
|
|
fromLinkableDuplicates: true,
|
|
|
toLinkableDuplicates: true,
|
|
|
fromSpot: go_module.Spot.AllSides,
|
|
|
toSpot: go_module.Spot.AllSides
|
|
|
}, new go_module.Binding("fill"), new go_module.Binding("stroke", "color"), new go_module.Binding("strokeWidth", "thickness"), new go_module.Binding("strokeDashArray", "dash")), $(go_module.Placeholder, {
|
|
|
background: "transparent",
|
|
|
margin: 20
|
|
|
})), $(go_module.TextBlock, {
|
|
|
alignment: go_module.Spot.Top,
|
|
|
alignmentFocus: go_module.Spot.Bottom,
|
|
|
font: "bold 12pt sans-serif",
|
|
|
editable: true
|
|
|
}, new go_module.Binding("text"), new go_module.Binding("stroke", "color")));
|
|
|
myDiagram.current.groupTemplate.selectionAdornmentTemplate = $(go_module.Adornment, "Spot", $(go_module.Panel, "Auto", $(go_module.Shape, {
|
|
|
fill: null,
|
|
|
stroke: "dodgerblue",
|
|
|
strokeWidth: 3
|
|
|
}), $(go_module.Placeholder, {
|
|
|
margin: 1.5
|
|
|
})), CMButton({
|
|
|
alignment: go_module.Spot.TopRight,
|
|
|
alignmentFocus: go_module.Spot.BottomRight
|
|
|
}));
|
|
|
|
|
|
// 右键
|
|
|
myDiagram.current.groupTemplate.contextMenu = $("ContextMenu", LightFillButtons(), DarkColorButtons(), StrokeOptionsButtons());
|
|
|
|
|
|
// Link template
|
|
|
|
|
|
myDiagram.current.linkTemplate = $(go_module.Link, {
|
|
|
layerName: "Foreground",
|
|
|
routing: go_module.Link.AvoidsNodes,
|
|
|
corner: 10,
|
|
|
fromShortLength: 10,
|
|
|
toShortLength: 15,
|
|
|
// assume arrowhead at "to" end, need to avoid bad appearance when path is thick
|
|
|
relinkableFrom: true,
|
|
|
relinkableTo: true,
|
|
|
reshapable: true,
|
|
|
resegmentable: true
|
|
|
}, new go_module.Binding("fromSpot", "fromSpot", go_module.Spot.parse), new go_module.Binding("toSpot", "toSpot", go_module.Spot.parse), new go_module.Binding("fromShortLength", "dir", function (dir) {
|
|
|
return dir >= 1 ? 10 : 0;
|
|
|
}), new go_module.Binding("toShortLength", "dir", function (dir) {
|
|
|
return dir >= 1 ? 10 : 0;
|
|
|
}), new go_module.Binding("points").makeTwoWay(),
|
|
|
// TwoWay due to user reshaping with LinkReshapingTool
|
|
|
|
|
|
$(go_module.Shape, {
|
|
|
strokeWidth: 2
|
|
|
}, new go_module.Binding("stroke", "color"), new go_module.Binding("strokeWidth", "thickness"), new go_module.Binding("strokeDashArray", "dash")), $(go_module.Shape,
|
|
|
// custom arrowheads to create the lifted effect
|
|
|
{
|
|
|
segmentIndex: 0,
|
|
|
segmentOffset: new go_module.Point(15, 0),
|
|
|
segmentOrientation: go_module.Link.OrientAlong,
|
|
|
alignmentFocus: go_module.Spot.Right,
|
|
|
figure: "circle",
|
|
|
width: 10,
|
|
|
strokeWidth: 0
|
|
|
}, new go_module.Binding("fill", "color"), new go_module.Binding("visible", "dir", function (dir) {
|
|
|
return dir === 1;
|
|
|
})), $(go_module.Shape, {
|
|
|
segmentIndex: -1,
|
|
|
segmentOffset: new go_module.Point(-10, 6),
|
|
|
segmentOrientation: go_module.Link.OrientPlus90,
|
|
|
alignmentFocus: go_module.Spot.Right,
|
|
|
figure: "triangle",
|
|
|
width: 12,
|
|
|
height: 12,
|
|
|
strokeWidth: 0
|
|
|
}, new go_module.Binding("fill", "color"), new go_module.Binding("visible", "dir", function (dir) {
|
|
|
return dir >= 1;
|
|
|
}), new go_module.Binding("width", "thickness", function (t) {
|
|
|
return 7 + 3 * t;
|
|
|
}),
|
|
|
// custom arrowhead must scale with the size of the while
|
|
|
new go_module.Binding("height", "thickness", function (t) {
|
|
|
return 7 + 3 * t;
|
|
|
}),
|
|
|
// while remaining centered on line
|
|
|
new go_module.Binding("segmentOffset", "thickness", function (t) {
|
|
|
return new go_module.Point(-15, 4 + 1.5 * t);
|
|
|
})), $(go_module.Shape, {
|
|
|
segmentIndex: 0,
|
|
|
segmentOffset: new go_module.Point(15, -6),
|
|
|
segmentOrientation: go_module.Link.OrientMinus90,
|
|
|
alignmentFocus: go_module.Spot.Right,
|
|
|
figure: "triangle",
|
|
|
width: 12,
|
|
|
height: 12,
|
|
|
strokeWidth: 0
|
|
|
}, new go_module.Binding("fill", "color"), new go_module.Binding("visible", "dir", function (dir) {
|
|
|
return dir === 2;
|
|
|
}), new go_module.Binding("width", "thickness", function (t) {
|
|
|
return 7 + 3 * t;
|
|
|
}), new go_module.Binding("height", "thickness", function (t) {
|
|
|
return 7 + 3 * t;
|
|
|
}), new go_module.Binding("segmentOffset", "thickness", function (t) {
|
|
|
return new go_module.Point(-15, 4 + 1.5 * t);
|
|
|
})), $(go_module.TextBlock, {
|
|
|
alignmentFocus: new go_module.Spot(0, 1, -4, 0),
|
|
|
editable: true
|
|
|
}, new go_module.Binding("text").makeTwoWay(),
|
|
|
// TwoWay due to user editing with TextEditingTool
|
|
|
new go_module.Binding("stroke", "color")));
|
|
|
myDiagram.current.linkTemplate.selectionAdornmentTemplate = $(go_module.Adornment,
|
|
|
// use a special selection Adornment that does not obscure the link path itself
|
|
|
$(go_module.Shape, {
|
|
|
// this uses a pathPattern with a gap in it, in order to avoid drawing on top of the link path Shape
|
|
|
isPanelMain: true,
|
|
|
stroke: "transparent",
|
|
|
strokeWidth: 6,
|
|
|
pathPattern: makeAdornmentPathPattern(2) // == thickness or strokeWidth
|
|
|
}, new go_module.Binding("pathPattern", "thickness", makeAdornmentPathPattern)), CMButton({
|
|
|
alignmentFocus: new go_module.Spot(0, 0, -6, -4)
|
|
|
}));
|
|
|
function makeAdornmentPathPattern(w) {
|
|
|
return $(go_module.Shape, {
|
|
|
stroke: "dodgerblue",
|
|
|
strokeWidth: 2,
|
|
|
strokeCap: "square",
|
|
|
geometryString: "M0 0 M4 2 H3 M4 " + (w + 4).toString() + " H3"
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// Link context menu
|
|
|
// All buttons in context menu work on both click and contextClick,
|
|
|
// in case the user context-clicks on the button.
|
|
|
// All buttons modify the link data, not the Link, so the Bindings need not be TwoWay.
|
|
|
|
|
|
function ArrowButton(num) {
|
|
|
var geo = "M0 0 M8 16 M0 8 L16 8 M12 11 L16 8 L12 5";
|
|
|
if (num === 0) {
|
|
|
geo = "M0 0 M16 16 M0 8 L16 8";
|
|
|
} else if (num === 2) {
|
|
|
geo = "M0 0 M16 16 M0 8 L16 8 M12 11 L16 8 L12 5 M4 11 L0 8 L4 5";
|
|
|
}
|
|
|
return $(go_module.Shape, {
|
|
|
geometryString: geo,
|
|
|
margin: 2,
|
|
|
background: "transparent",
|
|
|
mouseEnter: function mouseEnter(e, shape) {
|
|
|
return shape.background = "dodgerblue";
|
|
|
},
|
|
|
mouseLeave: function mouseLeave(e, shape) {
|
|
|
return shape.background = "transparent";
|
|
|
},
|
|
|
click: ClickFunction("dir", num),
|
|
|
contextClick: ClickFunction("dir", num)
|
|
|
});
|
|
|
}
|
|
|
function AllSidesButton(to) {
|
|
|
var setter = function setter(e, shape) {
|
|
|
e.handled = true;
|
|
|
e.diagram.model.commit(function (m) {
|
|
|
var link = shape.part.adornedPart;
|
|
|
m.set(link.data, to ? "toSpot" : "fromSpot", go_module.Spot.stringify(go_module.Spot.AllSides));
|
|
|
// re-spread the connections of other links connected with the node
|
|
|
(to ? link.toNode : link.fromNode).invalidateConnectedLinks();
|
|
|
});
|
|
|
};
|
|
|
return $(go_module.Shape, {
|
|
|
width: 12,
|
|
|
height: 12,
|
|
|
fill: "transparent",
|
|
|
mouseEnter: function mouseEnter(e, shape) {
|
|
|
return shape.background = "dodgerblue";
|
|
|
},
|
|
|
mouseLeave: function mouseLeave(e, shape) {
|
|
|
return shape.background = "transparent";
|
|
|
},
|
|
|
click: setter,
|
|
|
contextClick: setter
|
|
|
});
|
|
|
}
|
|
|
function SpotButton(spot, to) {
|
|
|
var ang = 0;
|
|
|
var side = go_module.Spot.RightSide;
|
|
|
if (spot.equals(go_module.Spot.Top)) {
|
|
|
ang = 270;
|
|
|
side = go_module.Spot.TopSide;
|
|
|
} else if (spot.equals(go_module.Spot.Left)) {
|
|
|
ang = 180;
|
|
|
side = go_module.Spot.LeftSide;
|
|
|
} else if (spot.equals(go_module.Spot.Bottom)) {
|
|
|
ang = 90;
|
|
|
side = go_module.Spot.BottomSide;
|
|
|
}
|
|
|
if (!to) ang -= 180;
|
|
|
var setter = function setter(e, shape) {
|
|
|
e.handled = true;
|
|
|
e.diagram.model.commit(function (m) {
|
|
|
var link = shape.part.adornedPart;
|
|
|
m.set(link.data, to ? "toSpot" : "fromSpot", go_module.Spot.stringify(side));
|
|
|
// re-spread the connections of other links connected with the node
|
|
|
(to ? link.toNode : link.fromNode).invalidateConnectedLinks();
|
|
|
});
|
|
|
};
|
|
|
return $(go_module.Shape, {
|
|
|
alignment: spot,
|
|
|
alignmentFocus: spot.opposite(),
|
|
|
geometryString: "M0 0 M12 12 M12 6 L1 6 L4 4 M1 6 L4 8",
|
|
|
angle: ang,
|
|
|
background: "transparent",
|
|
|
mouseEnter: function mouseEnter(e, shape) {
|
|
|
return shape.background = "dodgerblue";
|
|
|
},
|
|
|
mouseLeave: function mouseLeave(e, shape) {
|
|
|
return shape.background = "transparent";
|
|
|
},
|
|
|
click: setter,
|
|
|
contextClick: setter
|
|
|
});
|
|
|
}
|
|
|
myDiagram.current.linkTemplate.contextMenu = $("ContextMenu", DarkColorButtons(), StrokeOptionsButtons(), $("ContextMenuButton", $(go_module.Panel, "Horizontal", ArrowButton(0), ArrowButton(1), ArrowButton(2))), $("ContextMenuButton", $(go_module.Panel, "Horizontal", $(go_module.Panel, "Spot", AllSidesButton(false), SpotButton(go_module.Spot.Top, false), SpotButton(go_module.Spot.Left, false), SpotButton(go_module.Spot.Right, false), SpotButton(go_module.Spot.Bottom, false)), $(go_module.Panel, "Spot", {
|
|
|
margin: new go_module.Margin(0, 0, 0, 2)
|
|
|
}, AllSidesButton(true), SpotButton(go_module.Spot.Top, true), SpotButton(go_module.Spot.Left, true), SpotButton(go_module.Spot.Right, true), SpotButton(go_module.Spot.Bottom, true)))));
|
|
|
var initData = "{ \"class\": \"GraphLinksModel\",\n \"nodeDataArray\": [\n{\"text\":\"Find Problem\",\"key\":-9,\"loc\":\"-20 -140\",\"color\":\"#3358ff\",\"fill\":\"white\",\"figure\":\"Procedure\",\"thickness\":3},\n{\"text\":\"What do we want?\",\"key\":-10,\"loc\":\"-65 -324.305\",\"group\":-16,\"figure\":\"Ellipse\",\"fill\":\"white\"},\n{\"text\":\"What do our users want?\",\"key\":-11,\"loc\":\"105 -334.305\",\"group\":-20,\"figure\":\"Ellipse\",\"fill\":\"#ffffff\",\"color\":\"black\"},\n{\"text\":\"Meetings\",\"key\":-12,\"loc\":\"-65 -444.305\",\"group\":-16,\"figure\":\"TriangleDown\",\"fill\":\"#ffffff\"},\n{\"text\":\"Reviews\",\"key\":-13,\"loc\":\"105 -454.305\",\"group\":-20,\"figure\":\"TriangleDown\",\"fill\":\"#ffffff\",\"color\":\"black\"},\n{\"text\":\"Can we solve it?\",\"key\":-14,\"loc\":\"190 -140\",\"color\":\"#7d33ff\",\"fill\":\"#ffffff\",\"figure\":\"Diamond\",\"size\":\"140 80\",\"thickness\":3},\n{\"isGroup\":true,\"text\":\"Internal\",\"key\":-16,\"loc\":\"-65 -384.305\",\"fill\":\"#d5ebff\",\"dash\":null,\"thickness\":1,\"group\":-22},\n{\"isGroup\":true,\"text\":\"External\",\"key\":-20,\"loc\":\"105 -394.305\",\"fill\":\"#d5ebff\",\"dash\":null,\"thickness\":1,\"group\":-22},\n{\"isGroup\":true,\"text\":\"Sources\",\"key\":-22,\"loc\":\"20 -400\",\"fill\":\"#a5d2fa\",\"dash\":[4,4],\"color\":\"#3358ff\"}\n],\n \"linkDataArray\": [\n{\"from\":-12,\"to\":-10,\"points\":[-65,-414.305,-65,-404.305,-65,-384.305,-65,-384.305,-65,-364.305,-65,-354.305],\"dash\":null,\"dir\":1},\n{\"from\":-13,\"to\":-11,\"points\":[105,-424.305,105,-414.305,105,-394.305,105,-394.305,105,-374.305,105,-364.305],\"dash\":null,\"color\":\"#000000\",\"dir\":1},\n{\"from\":-10,\"to\":-9,\"points\":[-65,-294.305,-65,-284.305,-65,-232.1525,-40,-232.1525,-40,-180,-40,-170],\"dir\":2,\"dash\":[4,4]},\n{\"from\":-11,\"to\":-9,\"points\":[105,-304.305,105,-294.305,105,-237.1525,0,-237.1525,0,-180,0,-170],\"dash\":[4,4],\"dir\":2},\n{\"from\":-9,\"to\":-14,\"points\":[40,-150,58,-150,80,-150,80,-153.33333333333331,102,-153.33333333333331,120,-153.33333333333331],\"dir\":1,\"color\":\"#3358ff\"},\n{\"from\":-14,\"to\":-9,\"points\":[190,-100,190,-90,-20,-90,-20,-95,-20,-100,-20,-110],\"fromSpot\":\"BottomSide\",\"toSpot\":\"BottomSide\",\"text\":\"No\",\"color\":\"#ff3333\",\"thickness\":2,\"dir\":1},\n{\"from\":-9,\"to\":-14,\"points\":[40,-130,58,-130,80,-130,80,-126.66666666666666,102,-126.66666666666666,120,-126.66666666666666]}\n]}";
|
|
|
// myDiagram.current.model = go.Model.fromJson(initData);
|
|
|
|
|
|
// start
|
|
|
var builtIn = ["Rectangle", "Square", "RoundedRectangle", "Border", "Ellipse", "Circle", "TriangleRight", "TriangleDown", "TriangleLeft", "TriangleUp", "Triangle", "Diamond", "LineH", "LineV", "None", "BarH", "BarV", "MinusLine", "PlusLine", "XLine", "LineRight", "LineDown", "LineLeft", "LineUp"];
|
|
|
function isBuiltIn(shapeName) {
|
|
|
console.log("shapeName:", shapeName);
|
|
|
return builtIn.indexOf(shapeName) >= 0;
|
|
|
}
|
|
|
var myPalette = new go_module.Palette(myPaletteDivRef.current,
|
|
|
// must name or refer to the DIV HTML element
|
|
|
{
|
|
|
maxSelectionCount: 1,
|
|
|
// nodeTemplateMap: myDiagram.current.nodeTemplateMap, // share the templates used by myDiagram.current
|
|
|
linkTemplate:
|
|
|
// simplify the link template, just in this Palette
|
|
|
$(go_module.Link, {
|
|
|
// because the GridLayout.alignment is Location and the nodes have locationSpot == Spot.Center,
|
|
|
// to line up the Link in the same manner we have to pretend the Link has the same location spot
|
|
|
locationSpot: go_module.Spot.Center,
|
|
|
selectionAdornmentTemplate: $(go_module.Adornment, "Link", {
|
|
|
locationSpot: go_module.Spot.Center
|
|
|
}, $(go_module.Shape, {
|
|
|
isPanelMain: true,
|
|
|
fill: null,
|
|
|
stroke: "deepskyblue",
|
|
|
strokeWidth: 0
|
|
|
}), $(go_module.Shape,
|
|
|
// the arrowhead
|
|
|
{
|
|
|
toArrow: "Standard",
|
|
|
stroke: null
|
|
|
}))
|
|
|
}, {
|
|
|
routing: go_module.Link.AvoidsNodes,
|
|
|
curve: go_module.Link.JumpOver,
|
|
|
corner: 5,
|
|
|
toShortLength: 4
|
|
|
}, new go_module.Binding("points"), $(go_module.Shape,
|
|
|
// the link path shape
|
|
|
{
|
|
|
isPanelMain: true,
|
|
|
strokeWidth: 2
|
|
|
}), $(go_module.Shape,
|
|
|
// the arrowhead
|
|
|
{
|
|
|
toArrow: "Standard",
|
|
|
stroke: null
|
|
|
})),
|
|
|
model: new go_module.GraphLinksModel([
|
|
|
// specify the contents of the Palette
|
|
|
{
|
|
|
text: "未命名",
|
|
|
"size": "100 100",
|
|
|
fill: null,
|
|
|
stroke: "#000"
|
|
|
}].concat(toConsumableArray_default()(go_module.Shape.getFigureGenerators().toArray().map(function (item) {
|
|
|
return {
|
|
|
text: "未命名",
|
|
|
"size": "100 100",
|
|
|
figure: item.key,
|
|
|
fill: "white",
|
|
|
stroke: "#666",
|
|
|
borderColor: "#000"
|
|
|
};
|
|
|
})))) // [
|
|
|
// // the Palette also has a disconnected Link, which the user can drag-and-drop
|
|
|
// { points: new go.List(/*go.Point*/).addAll([new go.Point(0, 0), new go.Point(30, 0), new go.Point(30, 40), new go.Point(60, 40)]) }
|
|
|
// ]
|
|
|
});
|
|
|
|
|
|
// $("ContextMenuButton",
|
|
|
// $(go.Panel, "Horizontal",
|
|
|
// FigureButton("Rectangle"), FigureButton("RoundedRectangle"), FigureButton("Ellipse"), FigureButton("Diamond")
|
|
|
// )
|
|
|
// ),
|
|
|
// $("ContextMenuButton",
|
|
|
// $(go.Panel, "Horizontal",
|
|
|
// FigureButton("Parallelogram2"), FigureButton("ManualOperation"), FigureButton("Procedure"), FigureButton("Cylinder1")
|
|
|
// )
|
|
|
// ),
|
|
|
// $("ContextMenuButton",
|
|
|
// $(go.Panel, "Horizontal",
|
|
|
// FigureButton("Terminator"), FigureButton("CreateRequest"), FigureButton("Document"), FigureButton("TriangleDown")
|
|
|
// )
|
|
|
// ),
|
|
|
|
|
|
myPalette.nodeTemplate = $(go_module.Node, "Auto", {
|
|
|
locationSpot: go_module.Spot.Center
|
|
|
}, new go_module.Binding("location", "location", go_module.Point.parse).makeTwoWay(go_module.Point.stringify), $(go_module.Shape, "Circle", {
|
|
|
fill: "white",
|
|
|
stroke: "gray",
|
|
|
strokeWidth: 2,
|
|
|
width: 20,
|
|
|
height: 20,
|
|
|
portId: "",
|
|
|
fromLinkable: true,
|
|
|
toLinkable: true,
|
|
|
fromLinkableDuplicates: true,
|
|
|
toLinkableDuplicates: true,
|
|
|
fromLinkableSelfNode: true,
|
|
|
toLinkableSelfNode: true
|
|
|
}, new go_module.Binding("stroke").makeTwoWay(), new go_module.Binding("fill").makeTwoWay(), new go_module.Binding("figure")), $(go_module.TextBlock, {
|
|
|
margin: new go_module.Margin(5, 5, 3, 5),
|
|
|
font: "10pt sans-serif",
|
|
|
minSize: new go_module.Size(16, 16),
|
|
|
maxSize: new go_module.Size(10, NaN),
|
|
|
textAlign: "center",
|
|
|
editable: true
|
|
|
}, new go_module.Binding("key").makeTwoWay()));
|
|
|
// end
|
|
|
|
|
|
setTimeout(function () {
|
|
|
myDiagram.current.grid = $(go_module.Panel, "Grid", $(go_module.Shape, "LineH", {
|
|
|
stroke: "lightgray",
|
|
|
strokeWidth: 0.5
|
|
|
}), $(go_module.Shape, "LineV", {
|
|
|
stroke: "lightgray",
|
|
|
strokeWidth: 0.5
|
|
|
}));
|
|
|
myDiagram.current.grid.visible = true; // 隐藏网格
|
|
|
myDiagram.current.grid.gridCellStroke = "darkgray"; // 设置网格线的颜色
|
|
|
myDiagram.current.grid.gridCellStrokeWidth = 1; // 设置网格线的粗细
|
|
|
}, 300);
|
|
|
window.myDiagrams = myDiagram.current;
|
|
|
return myDiagram.current;
|
|
|
}
|
|
|
var save = /*#__PURE__*/function () {
|
|
|
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() {
|
|
|
var imgs, res;
|
|
|
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
|
|
|
while (1) switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
// console.log(JSON.stringify(myDiagram.current.model.toJson()))
|
|
|
imgs = myDiagram.current.makeImage();
|
|
|
_context.next = 3;
|
|
|
return (0,fetch/* default */.ZP)('/api/attachments.json', {
|
|
|
method: 'post',
|
|
|
body: {
|
|
|
file_type: 'base64',
|
|
|
original_filename: Date.now(),
|
|
|
file: imgs.src
|
|
|
}
|
|
|
});
|
|
|
case 3:
|
|
|
res = _context.sent;
|
|
|
callback({
|
|
|
src: res.url
|
|
|
});
|
|
|
case 5:
|
|
|
case "end":
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}, _callee);
|
|
|
}));
|
|
|
return function save() {
|
|
|
return _ref2.apply(this, arguments);
|
|
|
};
|
|
|
}();
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
setUpdateModal(updateModal + 1);
|
|
|
}, []);
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
ref: modalRef,
|
|
|
className: hidedenContentRef.current ? "".concat(flow_chartmodules.maxH60, " body-overflow-initial") : "body-overflow-initial",
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(es_modal/* default */.Z, {
|
|
|
width: 1200,
|
|
|
icon: null,
|
|
|
footer: null,
|
|
|
closable: true,
|
|
|
visible: !!updateModal,
|
|
|
destroyOnClose: true,
|
|
|
maskClosable: false,
|
|
|
getContainer: modalRef.current,
|
|
|
title: /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
|
flex: 1,
|
|
|
children: "\u63D2\u5165\u6D41\u7A0B\u56FE"
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
|
onClick: function onClick() {
|
|
|
hidedenContentRef.current = !hidedenContentRef.current;
|
|
|
setUpdateModal(updateModal + 1);
|
|
|
},
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
|
className: "current c-blue mr30",
|
|
|
style: {
|
|
|
fontWeight: 400
|
|
|
},
|
|
|
children: "\u5C55\u5F00/\u6536\u8D77"
|
|
|
})
|
|
|
})]
|
|
|
}),
|
|
|
onCancel: onCancel,
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
style: {
|
|
|
width: "100%",
|
|
|
height: "80vh",
|
|
|
overflow: "hidden",
|
|
|
position: "relative"
|
|
|
},
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
style: {
|
|
|
display: "flex",
|
|
|
height: "100%"
|
|
|
},
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
style: {
|
|
|
width: "300px",
|
|
|
height: "100%"
|
|
|
},
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
style: {
|
|
|
background: "#fff",
|
|
|
position: "relative",
|
|
|
zIndex: 12,
|
|
|
fontSize: 16,
|
|
|
color: "#3061d0"
|
|
|
},
|
|
|
children: "\u56FE\u5F62\u5E93"
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
style: {
|
|
|
height: "calc(100% - 50px)"
|
|
|
},
|
|
|
className: flow_chartmodules.myPaletteDiv,
|
|
|
ref: myPaletteDivRef
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
style: {
|
|
|
flex: 1,
|
|
|
position: "relative"
|
|
|
},
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(gojsreact/* ReactDiagram */.FI, {
|
|
|
initDiagram: initDiagram,
|
|
|
divClassName: "diagram-component",
|
|
|
style: {
|
|
|
height: "80vh"
|
|
|
}
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
ref: myDiagramDivRef
|
|
|
})]
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
className: "tr",
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
|
size: "large",
|
|
|
onClick: save,
|
|
|
style: {
|
|
|
position: "absolute",
|
|
|
right: 0,
|
|
|
bottom: 0,
|
|
|
zIndex: 8
|
|
|
},
|
|
|
type: "primary",
|
|
|
children: "\u4FDD\u5B58\u5230\u7F16\u8F91\u5668"
|
|
|
})
|
|
|
})]
|
|
|
})
|
|
|
})
|
|
|
});
|
|
|
}
|
|
|
/* harmony default export */ var flow_chart = (FlowChart);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/radio/index.js + 5 modules
|
|
|
var es_radio = __webpack_require__(5112);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/input-number/index.js + 14 modules
|
|
|
var input_number = __webpack_require__(85731);
|
|
|
;// CONCATENATED MODULE: ./src/components/markdown-editor/add-table-panel/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var RadioGroup = es_radio/* default.Group */.ZP.Group;
|
|
|
var add_table_panel_style = {
|
|
|
margin: '0 8px'
|
|
|
};
|
|
|
/* harmony default export */ var add_table_panel = (function (_ref) {
|
|
|
var callback = _ref.callback,
|
|
|
onCancel = _ref.onCancel;
|
|
|
function onSubmit(values) {
|
|
|
callback(values);
|
|
|
}
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)(es_form/* default */.Z, {
|
|
|
className: "add-table-panel",
|
|
|
initialValues: {
|
|
|
row: 3,
|
|
|
col: 2,
|
|
|
align: 'default'
|
|
|
},
|
|
|
onFinish: onSubmit,
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
className: "flex-container",
|
|
|
style: {
|
|
|
alignItems: "baseline"
|
|
|
},
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
|
style: add_table_panel_style,
|
|
|
children: "\u5355\u5143\u683C\u6570\uFF1A"
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
|
style: add_table_panel_style,
|
|
|
children: "\u884C\u6570"
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
|
|
|
name: "row",
|
|
|
rules: [{
|
|
|
required: true,
|
|
|
message: '请输入行数'
|
|
|
}],
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, {})
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
|
style: add_table_panel_style,
|
|
|
children: "\u5217\u6570"
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
|
|
|
name: "col",
|
|
|
rules: [{
|
|
|
required: true,
|
|
|
message: '请输入列数'
|
|
|
}],
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, {})
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
className: "flex-container",
|
|
|
style: {
|
|
|
marginTop: 12,
|
|
|
alignItems: "baseline"
|
|
|
},
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
|
style: add_table_panel_style,
|
|
|
children: "\u5BF9\u9F50\u65B9\u5F0F\uFF1A"
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
|
|
|
name: "align",
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)(RadioGroup, {
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default */.ZP, {
|
|
|
value: "default",
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
|
|
|
className: "fa fa-align-justify"
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default */.ZP, {
|
|
|
value: "left",
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
|
|
|
className: "fa fa-align-left"
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default */.ZP, {
|
|
|
value: "center",
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
|
|
|
className: "fa fa-align-center"
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default */.ZP, {
|
|
|
value: "right",
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
|
|
|
className: "fa fa-align-right"
|
|
|
})
|
|
|
})]
|
|
|
})
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
className: "flex-container flex-end",
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
|
type: "primary",
|
|
|
htmlType: "submit",
|
|
|
style: {
|
|
|
marginRight: 10
|
|
|
},
|
|
|
children: "\u786E\u5B9A"
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
|
type: "ghost",
|
|
|
onClick: onCancel,
|
|
|
children: "\u53D6\u6D88"
|
|
|
})]
|
|
|
})]
|
|
|
});
|
|
|
});
|
|
|
// EXTERNAL MODULE: ./src/utils/env.ts + 1 modules
|
|
|
var env = __webpack_require__(67871);
|
|
|
;// CONCATENATED MODULE: ./src/components/markdown-editor/constant.ts
|
|
|
var LINK = 'link';
|
|
|
var UPLOAD_IMAGE = 'upload-image';
|
|
|
var ADD_FLOWCHART = 'add-flowchart';
|
|
|
var DRAW_IMAGE = 'draw-image';
|
|
|
var FLOW_CHART = 'add-flowchart';
|
|
|
var CODE_BLOCK = 'code-block';
|
|
|
var ADD_TABLE = 'add-table';
|
|
|
var HRLINE = '------------';
|
|
|
var ALIGNSIGN = {
|
|
|
"default": HRLINE,
|
|
|
left: ":".concat(HRLINE),
|
|
|
center: ":".concat(HRLINE, ":"),
|
|
|
right: "".concat(HRLINE, ":")
|
|
|
};
|
|
|
// EXTERNAL MODULE: ./src/components/useInterval.tsx
|
|
|
var useInterval = __webpack_require__(86219);
|
|
|
;// CONCATENATED MODULE: ./src/components/markdown-editor/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
var _DEFAULTKEYMAP, _TitleDesc;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function noop() {}
|
|
|
var pending = 0;
|
|
|
var StorageTimeTicket = 10000;
|
|
|
var NULL_CH = '▁';
|
|
|
var ADD_MULTI = '@▁▁@';
|
|
|
var ADD_SINGLE = '@▁@';
|
|
|
var TEMP1 = '\n**模板标题**\n模板正文内容,可输入文本内容和粘贴图片等操作'; //课程须知模板
|
|
|
function processSize(size) {
|
|
|
return !/^\d+$/.test(size) ? size : "".concat(size, "px");
|
|
|
}
|
|
|
var isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
|
|
var key = isMac ? 'Cmd' : 'Ctrl';
|
|
|
var DEFAULTKEYMAP = (_DEFAULTKEYMAP = {}, defineProperty_default()(_DEFAULTKEYMAP, key + '-B', 'bold'), defineProperty_default()(_DEFAULTKEYMAP, key + '-I', 'italic'), _DEFAULTKEYMAP);
|
|
|
var TitleDesc = (_TitleDesc = {}, defineProperty_default()(_TitleDesc, LINK, '添加链接'), defineProperty_default()(_TitleDesc, CODE_BLOCK, '添加代码块'), defineProperty_default()(_TitleDesc, UPLOAD_IMAGE, '添加图片'), defineProperty_default()(_TitleDesc, DRAW_IMAGE, '添加画图'), defineProperty_default()(_TitleDesc, ADD_FLOWCHART, '插入流程图'), defineProperty_default()(_TitleDesc, ADD_TABLE, '添加表格'), _TitleDesc);
|
|
|
|
|
|
//https://codemirror.net/demo
|
|
|
//The height can be set through CSS (by giving the .CodeMirror class a height property), or by calling the cm's setSize method.
|
|
|
/* harmony default export */ var markdown_editor = (function (_ref) {
|
|
|
var _ref$defaultValue = _ref.defaultValue,
|
|
|
defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue,
|
|
|
onChange = _ref.onChange,
|
|
|
_ref$width = _ref.width,
|
|
|
width = _ref$width === void 0 ? '100%' : _ref$width,
|
|
|
_ref$height = _ref.height,
|
|
|
height = _ref$height === void 0 ? 400 : _ref$height,
|
|
|
_ref$miniToolbar = _ref.miniToolbar,
|
|
|
miniToolbar = _ref$miniToolbar === void 0 ? false : _ref$miniToolbar,
|
|
|
_ref$isFocus = _ref.isFocus,
|
|
|
isFocus = _ref$isFocus === void 0 ? false : _ref$isFocus,
|
|
|
watch = _ref.watch,
|
|
|
insertTemp = _ref.insertTemp,
|
|
|
_ref$mode = _ref.mode,
|
|
|
mode = _ref$mode === void 0 ? "markdown" : _ref$mode,
|
|
|
_ref$id = _ref.id,
|
|
|
id = _ref$id === void 0 ? 'markdown-editor-id' : _ref$id,
|
|
|
_ref$showResizeBar = _ref.showResizeBar,
|
|
|
showResizeBar = _ref$showResizeBar === void 0 ? false : _ref$showResizeBar,
|
|
|
_ref$noStorage = _ref.noStorage,
|
|
|
noStorage = _ref$noStorage === void 0 ? false : _ref$noStorage,
|
|
|
_ref$showNullButton = _ref.showNullButton,
|
|
|
showNullButton = _ref$showNullButton === void 0 ? false : _ref$showNullButton,
|
|
|
_ref$showNullProgramB = _ref.showNullProgramButton,
|
|
|
showNullProgramButton = _ref$showNullProgramB === void 0 ? false : _ref$showNullProgramB,
|
|
|
_ref$hidetoolBar = _ref.hidetoolBar,
|
|
|
hidetoolBar = _ref$hidetoolBar === void 0 ? false : _ref$hidetoolBar,
|
|
|
_ref$fullScreen = _ref.fullScreen,
|
|
|
fullScreen = _ref$fullScreen === void 0 ? false : _ref$fullScreen,
|
|
|
onBlur = _ref.onBlur,
|
|
|
onCMBeforeChange = _ref.onCMBeforeChange,
|
|
|
onFullScreen = _ref.onFullScreen,
|
|
|
_ref$className = _ref.className,
|
|
|
className = _ref$className === void 0 ? '' : _ref$className,
|
|
|
_ref$disablePaste = _ref.disablePaste,
|
|
|
disablePaste = _ref$disablePaste === void 0 ? false : _ref$disablePaste,
|
|
|
_ref$disabled = _ref.disabled,
|
|
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
|
_ref$disabledFill = _ref.disabledFill,
|
|
|
disabledFill = _ref$disabledFill === void 0 ? false : _ref$disabledFill,
|
|
|
_ref$placeholder = _ref.placeholder,
|
|
|
placeholder = _ref$placeholder === void 0 ? '' : _ref$placeholder,
|
|
|
_ref$values = _ref.values,
|
|
|
values = _ref$values === void 0 ? '' : _ref$values,
|
|
|
extraUse = _ref.extraUse;
|
|
|
var _useState = (0,_react_17_0_2_react.useState)(null),
|
|
|
_useState2 = slicedToArray_default()(_useState, 2),
|
|
|
cm = _useState2[0],
|
|
|
setCm = _useState2[1];
|
|
|
var _useState3 = (0,_react_17_0_2_react.useState)(defaultValue),
|
|
|
_useState4 = slicedToArray_default()(_useState3, 2),
|
|
|
value = _useState4[0],
|
|
|
setValue = _useState4[1];
|
|
|
var _useState5 = (0,_react_17_0_2_react.useState)(watch),
|
|
|
_useState6 = slicedToArray_default()(_useState5, 2),
|
|
|
preview = _useState6[0],
|
|
|
setPreview = _useState6[1];
|
|
|
var _useState7 = (0,_react_17_0_2_react.useState)(fullScreen),
|
|
|
_useState8 = slicedToArray_default()(_useState7, 2),
|
|
|
isFull = _useState8[0],
|
|
|
setIsFull = _useState8[1];
|
|
|
var _useState9 = (0,_react_17_0_2_react.useState)(''),
|
|
|
_useState10 = slicedToArray_default()(_useState9, 2),
|
|
|
action = _useState10[0],
|
|
|
setAction = _useState10[1];
|
|
|
var _useState11 = (0,_react_17_0_2_react.useState)(0),
|
|
|
_useState12 = slicedToArray_default()(_useState11, 2),
|
|
|
lastedUpdateTime = _useState12[0],
|
|
|
setLastedUpdateTime = _useState12[1];
|
|
|
var _useState13 = (0,_react_17_0_2_react.useState)(height),
|
|
|
_useState14 = slicedToArray_default()(_useState13, 2),
|
|
|
h = _useState14[0],
|
|
|
setH = _useState14[1];
|
|
|
var _useState15 = (0,_react_17_0_2_react.useState)(false),
|
|
|
_useState16 = slicedToArray_default()(_useState15, 2),
|
|
|
tip = _useState16[0],
|
|
|
setTip = _useState16[1];
|
|
|
var cmEl = (0,_react_17_0_2_react.useRef)();
|
|
|
var containerEl = (0,_react_17_0_2_react.useRef)();
|
|
|
var resizeBarEl = (0,_react_17_0_2_react.useRef)();
|
|
|
var previewEl = (0,_react_17_0_2_react.useRef)();
|
|
|
|
|
|
// useEffect(() => {
|
|
|
// setValue(defaultValue)
|
|
|
// cm?.setValue(defaultValue)
|
|
|
// },[])
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
var scrollTop = window.scrollY || window.pageYOffset;
|
|
|
setValue(values);
|
|
|
cm === null || cm === void 0 || cm.setValue(values);
|
|
|
window.scrollTo(0, scrollTop);
|
|
|
}, [values]);
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
onFullScreen === null || onFullScreen === void 0 || onFullScreen(isFull);
|
|
|
}, [isFull]);
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
if (cmEl.current) {
|
|
|
var onPaste = function onPaste(_, e) {
|
|
|
if (disablePaste) {
|
|
|
e.preventDefault();
|
|
|
return;
|
|
|
}
|
|
|
var clipboardData = e.clipboardData;
|
|
|
if (clipboardData) {
|
|
|
var types = clipboardData.types.toString();
|
|
|
var items = clipboardData.items;
|
|
|
var officeSix = ["pptm", "pptx", "ppt", "pot", "pps", "ppa", "potx", "ppsx", "ppam", "pptm", "potm", "ppsm", "doc", "docx", "dot", "dotx", "docm", "dotm", "xls", "xlsx", "csv", "xlt", "xla", "xltx", "xlsm", "xltm", "xlam", "xlsb"];
|
|
|
if (types === 'Files' || clipboardData.types.indexOf("Files") > -1) {
|
|
|
e.preventDefault();
|
|
|
if (mode == "stex") return;
|
|
|
try {
|
|
|
var _items$;
|
|
|
var item = items[1];
|
|
|
if (((_items$ = items[0]) === null || _items$ === void 0 ? void 0 : _items$.kind) === 'file') {
|
|
|
item = items[0];
|
|
|
}
|
|
|
var file = item.getAsFile();
|
|
|
var fileSix = file.name.split(".").pop();
|
|
|
// console.log("item:", item, file, item?.type?.match(/^video\//i))
|
|
|
uploadImage(file, function (data) {
|
|
|
if (data.id) {
|
|
|
var _file$type, _file$type2, _file$type3;
|
|
|
if ((file === null || file === void 0 || (_file$type = file.type) === null || _file$type === void 0 ? void 0 : _file$type.indexOf("image")) > -1) {
|
|
|
instance.replaceSelection(".concat(data.content_type, ")"));
|
|
|
} else if ((file === null || file === void 0 || (_file$type2 = file.type) === null || _file$type2 === void 0 ? void 0 : _file$type2.indexOf("video")) > -1) {
|
|
|
instance.replaceSelection("<video width=\"100%\" controls src=\"".concat(env/* default */.Z.API_SERVER, "/api/attachments/").concat(data.id, "\"></video>"));
|
|
|
} else if ((file === null || file === void 0 || (_file$type3 = file.type) === null || _file$type3 === void 0 ? void 0 : _file$type3.indexOf("pdf")) > -1) {
|
|
|
instance.replaceSelection("<a href=\"".concat(env/* default */.Z.API_SERVER, "/api/attachments/").concat(data.id, "?type=").concat(file.type, "&disposition=inline\" target=\"_blank\">").concat(file.name, "</a>"));
|
|
|
} else if (officeSix.includes(fileSix)) {
|
|
|
instance.replaceSelection("<a href=\"".concat(env/* default */.Z.API_SERVER, "/api/attachments/").concat(data.id, "?type=office&disposition=inline\" target=\"_blank\">").concat(file.name, "</a>"));
|
|
|
} else {
|
|
|
instance.replaceSelection("[".concat(file.name, "](").concat(env/* default */.Z.API_SERVER, "/api/attachments/").concat(data.id, "?type=").concat(data.content_type, ")"));
|
|
|
}
|
|
|
} else {
|
|
|
if ((data === null || data === void 0 ? void 0 : data.status) === 401) document.location.href = '/user/login';
|
|
|
}
|
|
|
});
|
|
|
} catch (e) {
|
|
|
message/* default */.ZP.warning("请使用chrome浏览器粘贴");
|
|
|
}
|
|
|
return true;
|
|
|
} else {
|
|
|
//toMarkdown ?
|
|
|
// let html = clipboardData.getData('text/html')
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
var instance = codemirror_default().fromTextArea(cmEl.current, {
|
|
|
mode: mode,
|
|
|
// inputStyle: 'contenteditable',
|
|
|
lineNumbers: miniToolbar ? false : true,
|
|
|
lineWrapping: true,
|
|
|
value: defaultValue,
|
|
|
autoCloseTags: true,
|
|
|
autoCloseBrackets: true
|
|
|
});
|
|
|
instance.on("keyup", function (cm, event) {
|
|
|
if (event.keyCode === 8) {
|
|
|
if (cm.getValue() == "") {
|
|
|
instance.setOption("placeholder", placeholder);
|
|
|
} else {
|
|
|
instance.setOption("placeholder", null);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
instance.on("keydown", function (cm, event) {
|
|
|
if (event.keyCode === 8) {
|
|
|
var pos = deleteAtSymbol(cm);
|
|
|
if (pos) {
|
|
|
event.preventDefault();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
isFocus && instance.focus();
|
|
|
instance.on('paste', onPaste);
|
|
|
if (disabled) {
|
|
|
instance.on("beforeChange", function (instances, change) {
|
|
|
if (change.origin === "paste" || change.origin === "+input") {
|
|
|
change.cancel();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
setCm(instance);
|
|
|
return function () {
|
|
|
instance.off('paste', onPaste);
|
|
|
};
|
|
|
}
|
|
|
}, []);
|
|
|
var resizeEditorBodyHeight = (0,_react_17_0_2_react.useCallback)(function () {
|
|
|
if (containerEl.current) {
|
|
|
try {
|
|
|
// let toolH = containerEl.current.getElementsByClassName('markdown-toolbar-container')[0].offsetHeight
|
|
|
// let mdBody = containerEl.current.getElementsByClassName('markdown-editor-body')[0]
|
|
|
// if (!isFull) {
|
|
|
// mdBody.style.height = `${h - toolH}px`
|
|
|
// } else {
|
|
|
// mdBody.style.height = `calc(100vh - ${toolH}px)`
|
|
|
// }
|
|
|
} catch (error) {
|
|
|
console.log(error, '---- to set md editor body height');
|
|
|
}
|
|
|
}
|
|
|
}, [h, containerEl, isFull]);
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
function onLayout() {
|
|
|
var ro = new ResizeObserver_es/* default */.Z(function (entries) {
|
|
|
var _iterator = createForOfIteratorHelper_default()(entries),
|
|
|
_step;
|
|
|
try {
|
|
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
|
var entry = _step.value;
|
|
|
if (entry.target.offsetHeight > 0 || entry.target.offsetWidth > 0) {
|
|
|
resizeEditorBodyHeight();
|
|
|
cm.setSize('100%', '100%');
|
|
|
cm.refresh();
|
|
|
}
|
|
|
}
|
|
|
} catch (err) {
|
|
|
_iterator.e(err);
|
|
|
} finally {
|
|
|
_iterator.f();
|
|
|
}
|
|
|
});
|
|
|
ro.observe(cmEl.current.parentElement);
|
|
|
return ro;
|
|
|
}
|
|
|
if (cm) {
|
|
|
var ro = onLayout();
|
|
|
return function () {
|
|
|
var _cmEl$current, _cmEl$current2;
|
|
|
if ((_cmEl$current = cmEl.current) !== null && _cmEl$current !== void 0 && _cmEl$current.parentElement) ro.unobserve((_cmEl$current2 = cmEl.current) === null || _cmEl$current2 === void 0 ? void 0 : _cmEl$current2.parentElement);
|
|
|
};
|
|
|
}
|
|
|
}, [cm, resizeEditorBodyHeight]);
|
|
|
|
|
|
//keymap
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
if (cm) {
|
|
|
var keymap = [];
|
|
|
var _loop = function _loop() {
|
|
|
var _Object$entries$_i = slicedToArray_default()(_Object$entries[_i], 2),
|
|
|
k = _Object$entries$_i[0],
|
|
|
value = _Object$entries$_i[1];
|
|
|
var map = defineProperty_default()({}, k, function () {
|
|
|
onActionCallback(value);
|
|
|
});
|
|
|
keymap.push(map);
|
|
|
cm.addKeyMap(map);
|
|
|
};
|
|
|
for (var _i = 0, _Object$entries = Object.entries(DEFAULTKEYMAP); _i < _Object$entries.length; _i++) {
|
|
|
_loop();
|
|
|
}
|
|
|
return function () {
|
|
|
for (var _i2 = 0, _keymap = keymap; _i2 < _keymap.length; _i2++) {
|
|
|
var m = _keymap[_i2];
|
|
|
cm.removeKeyMap(m);
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
}, [cm]);
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
if (fullScreen !== isFull) {
|
|
|
setIsFull(fullScreen);
|
|
|
}
|
|
|
}, [fullScreen]);
|
|
|
(0,useInterval/* default */.Z)(function () {
|
|
|
if (!noStorage && lastedUpdateTime > 0) {
|
|
|
var currentTime = new Date().getTime();
|
|
|
var lastedValue = window.sessionStorage.getItem(id);
|
|
|
if (currentTime >= lastedUpdateTime + StorageTimeTicket && (!lastedValue || lastedValue !== value)) {
|
|
|
window.sessionStorage.setItem(id, value);
|
|
|
setTip(true);
|
|
|
}
|
|
|
}
|
|
|
}, StorageTimeTicket);
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
setPreview(watch);
|
|
|
}, [cm, watch]);
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
if (cm) {
|
|
|
isFocus && cm.focus();
|
|
|
}
|
|
|
}, [cm, isFocus]);
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
if (preview && cm) {
|
|
|
var syncScroll = function syncScroll(e) {
|
|
|
var target = e.target;
|
|
|
if (previewEl.current) {
|
|
|
var ratio = target.scrollTop / target.scrollHeight;
|
|
|
previewEl.current.scrollTop = previewEl.current.scrollHeight * ratio;
|
|
|
}
|
|
|
};
|
|
|
var scrollEl = cm.getScrollerElement();
|
|
|
scrollEl.addEventListener('scroll', syncScroll);
|
|
|
return function () {
|
|
|
scrollEl.removeEventListener('scroll', syncScroll);
|
|
|
};
|
|
|
}
|
|
|
}, [cm, preview]);
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
if (cm && onCMBeforeChange) {
|
|
|
var onChangeHandler = function onChangeHandler(cm, change) {
|
|
|
onCMBeforeChange(cm, change);
|
|
|
};
|
|
|
cm.on('beforeChange', onChangeHandler);
|
|
|
return function () {
|
|
|
cm.off('beforeChange', onChangeHandler);
|
|
|
};
|
|
|
}
|
|
|
}, [cm, onCMBeforeChange]);
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
if (cm && onBlur) {
|
|
|
var onBlurHandler = function onBlurHandler() {
|
|
|
onBlur(cm.getValue());
|
|
|
};
|
|
|
cm.on('blur', onBlurHandler);
|
|
|
return function () {
|
|
|
cm.off('blur', onBlurHandler);
|
|
|
};
|
|
|
}
|
|
|
}, [cm, onBlur]);
|
|
|
function deleteAtSymbol(cm, change) {
|
|
|
var doc = cm.getDoc();
|
|
|
var cursor = doc.getCursor();
|
|
|
var line = doc.getLine(cursor.line);
|
|
|
var ch = line.charAt(cursor.ch - 1);
|
|
|
var p1 = line.lastIndexOf("@▁@", cursor.ch);
|
|
|
var p2 = line.lastIndexOf("@▁▁@", cursor.ch);
|
|
|
var posStart = p1 > p2 ? p1 : p2;
|
|
|
var n = p1 > p2 ? 3 : 4;
|
|
|
if (ADD_MULTI.indexOf(ch) === -1) return null;
|
|
|
console.log("change1:", change, cm, line, cursor, posStart, p1, p2, ch);
|
|
|
if (posStart >= 0 && cursor.ch - posStart < 5) {
|
|
|
var posEnd = posStart + n;
|
|
|
doc.replaceRange("", {
|
|
|
line: cursor.line,
|
|
|
ch: posStart
|
|
|
}, {
|
|
|
line: cursor.line,
|
|
|
ch: posEnd
|
|
|
});
|
|
|
return {
|
|
|
line: cursor.line,
|
|
|
ch: posEnd
|
|
|
};
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
if (cm) {
|
|
|
var onChangeHandler = function onChangeHandler(cm, change) {
|
|
|
var content = cm.getValue();
|
|
|
setValue(content);
|
|
|
setLastedUpdateTime(new Date().getTime());
|
|
|
cm.getScrollerElement().dispatchEvent(new CustomEvent('scroll'));
|
|
|
if (onChange) {
|
|
|
if (showNullProgramButton) {
|
|
|
onChange(content, formatProgramFill(content));
|
|
|
} else {
|
|
|
onChange(content);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
cm.on('change', onChangeHandler);
|
|
|
return function () {
|
|
|
cm.off('change', onChangeHandler);
|
|
|
};
|
|
|
}
|
|
|
}, [cm, onChange]);
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
if (cm) {
|
|
|
// isFocus && cm.focus()
|
|
|
if (defaultValue === null || defaultValue === undefined) {
|
|
|
cm.setValue('');
|
|
|
setValue('');
|
|
|
} else {
|
|
|
var scrollTop = window.scrollY || window.pageYOffset;
|
|
|
if (defaultValue !== cm.getValue()) {
|
|
|
cm.setValue(defaultValue);
|
|
|
setValue(defaultValue);
|
|
|
cm.setCursor(disabled ? 1 : cm.lineCount(), 0);
|
|
|
window.scrollTo(0, scrollTop);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}, [cm, defaultValue]);
|
|
|
var onActionCallback = (0,_react_17_0_2_react.useCallback)(function (actionName) {
|
|
|
var cursor = cm.getCursor();
|
|
|
var selection = cm.getSelection();
|
|
|
var selectionText = selection.split('\n');
|
|
|
switch (actionName) {
|
|
|
case 'bold':
|
|
|
cm.replaceSelection('**' + selection + '**');
|
|
|
if (selection === '') {
|
|
|
cm.setCursor(cursor.line, cursor.ch + 2);
|
|
|
}
|
|
|
return cm.focus();
|
|
|
case 'italic':
|
|
|
cm.replaceSelection('*' + selection + '*');
|
|
|
if (selection === '') {
|
|
|
cm.setCursor(cursor.line, cursor.ch + 1);
|
|
|
}
|
|
|
return cm.focus();
|
|
|
case 'code':
|
|
|
cm.replaceSelection('`' + selection + '`');
|
|
|
if (selection === '') {
|
|
|
cm.setCursor(cursor.line, cursor.ch + 1);
|
|
|
}
|
|
|
return cm.focus();
|
|
|
case 'inline-latex':
|
|
|
cm.replaceSelection('`$$' + selection + '$$`');
|
|
|
if (selection === '') {
|
|
|
cm.setCursor(cursor.line, cursor.ch + 3);
|
|
|
}
|
|
|
return cm.focus();
|
|
|
case 'latex':
|
|
|
cm.replaceSelection("```latex\n" + selection + "\n```");
|
|
|
cm.setCursor(cursor.line + 1, selection.length + 1);
|
|
|
return cm.focus();
|
|
|
case 'line-break':
|
|
|
cm.replaceSelection('<br/>\n');
|
|
|
return cm.focus();
|
|
|
case 'list-ul':
|
|
|
if (selection === '') {
|
|
|
cm.replaceSelection('- ' + selection);
|
|
|
} else {
|
|
|
cm.replaceSelection(selectionText.map(function (item) {
|
|
|
return item === '' ? '' : "- ".concat(item);
|
|
|
}).join('\n'));
|
|
|
}
|
|
|
return cm.focus();
|
|
|
case 'list-ol':
|
|
|
if (selection === '') {
|
|
|
cm.replaceSelection('1. ' + selection);
|
|
|
} else {
|
|
|
cm.replaceSelection(selectionText.map(function (item, index) {
|
|
|
return item === '' ? '' : "".concat(index + 1, ". ").concat(item);
|
|
|
}).join('\n'));
|
|
|
}
|
|
|
return cm.focus();
|
|
|
case 'add-null-ch':
|
|
|
if (selection === '') {
|
|
|
cm.setCursor(cursor.line, cursor.ch);
|
|
|
}
|
|
|
cm.replaceSelection(NULL_CH);
|
|
|
return cm.focus();
|
|
|
case 'add-signal':
|
|
|
if (selection === '') {
|
|
|
cm.setCursor(cursor.line, cursor.ch);
|
|
|
}
|
|
|
cm.replaceSelection(ADD_SINGLE);
|
|
|
return cm.focus();
|
|
|
case 'add-multiple':
|
|
|
if (selection === '') {
|
|
|
cm.setCursor(cursor.line, cursor.ch);
|
|
|
}
|
|
|
cm.replaceSelection(ADD_MULTI);
|
|
|
return cm.focus();
|
|
|
case 'inster-template-1':
|
|
|
if (selection === '') {
|
|
|
cm.setCursor(cursor.line, cursor.ch);
|
|
|
}
|
|
|
cm.replaceSelection(TEMP1);
|
|
|
return cm.focus();
|
|
|
case 'eraser':
|
|
|
cm.setValue('');
|
|
|
return cm.focus();
|
|
|
case 'trigger-watch':
|
|
|
setPreview(!preview);
|
|
|
return cm.focus();
|
|
|
case 'trigger-full-screen':
|
|
|
setIsFull(!isFull);
|
|
|
return cm.focus();
|
|
|
case LINK:
|
|
|
setAction(LINK);
|
|
|
return;
|
|
|
case CODE_BLOCK:
|
|
|
setAction(CODE_BLOCK);
|
|
|
return;
|
|
|
case UPLOAD_IMAGE:
|
|
|
setAction(UPLOAD_IMAGE);
|
|
|
return;
|
|
|
case DRAW_IMAGE:
|
|
|
setAction(DRAW_IMAGE);
|
|
|
return;
|
|
|
case ADD_FLOWCHART:
|
|
|
setAction(ADD_FLOWCHART);
|
|
|
return;
|
|
|
case ADD_TABLE:
|
|
|
setAction(ADD_TABLE);
|
|
|
return;
|
|
|
default:
|
|
|
throw new Error();
|
|
|
}
|
|
|
}, [cm, preview, isFull]);
|
|
|
var ExecutePluginAction = (0,_react_17_0_2_react.useCallback)(function (values) {
|
|
|
setAction('');
|
|
|
switch (action) {
|
|
|
case LINK:
|
|
|
var title = values.title,
|
|
|
link = values.link;
|
|
|
cm.replaceSelection("[".concat(title, "](").concat(link, ")"));
|
|
|
return cm.focus();
|
|
|
case CODE_BLOCK:
|
|
|
var language = values.language,
|
|
|
content = values.content;
|
|
|
cm.replaceSelection(['```' + language, content, '```'].join('\n'));
|
|
|
return cm.focus();
|
|
|
case UPLOAD_IMAGE:
|
|
|
case DRAW_IMAGE:
|
|
|
case FLOW_CHART:
|
|
|
var src = values.src,
|
|
|
alt = values.alt;
|
|
|
if (alt) {
|
|
|
cm.replaceSelection(".concat(src, " \"").concat(alt, "\" )"));
|
|
|
} else {
|
|
|
cm.replaceSelection(""));
|
|
|
}
|
|
|
return cm.focus();
|
|
|
case ADD_TABLE:
|
|
|
var row = values.row,
|
|
|
col = values.col,
|
|
|
align = values.align;
|
|
|
var table = '\n';
|
|
|
for (var r = 0; r < row; r++) {
|
|
|
var rows = [];
|
|
|
var heads = [];
|
|
|
for (var c = 0; c < col; c++) {
|
|
|
if (r === 1) {
|
|
|
heads.push(ALIGNSIGN[align]);
|
|
|
}
|
|
|
rows.push(' ');
|
|
|
}
|
|
|
if (r === 1) {
|
|
|
table += "| ".concat(heads.join(' | '), " |\n");
|
|
|
}
|
|
|
table += "| ".concat(rows.join(col === 1 ? '' : ' | '), " |\n");
|
|
|
}
|
|
|
cm.replaceSelection(table + '\n');
|
|
|
return cm.focus();
|
|
|
default:
|
|
|
throw new Error();
|
|
|
}
|
|
|
}, [cm, action]);
|
|
|
var PluginEl = (0,_react_17_0_2_react.useMemo)(function () {
|
|
|
switch (action) {
|
|
|
case LINK:
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor_link, {
|
|
|
callback: ExecutePluginAction,
|
|
|
onCancel: onCancel
|
|
|
});
|
|
|
case CODE_BLOCK:
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(code_block/* default */.Z, {
|
|
|
callback: ExecutePluginAction,
|
|
|
onCancel: onCancel
|
|
|
});
|
|
|
case UPLOAD_IMAGE:
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(upload_image, {
|
|
|
callback: ExecutePluginAction,
|
|
|
onCancel: onCancel
|
|
|
});
|
|
|
case ADD_FLOWCHART:
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(flow_chart, {
|
|
|
callback: ExecutePluginAction,
|
|
|
onCancel: onCancel
|
|
|
})
|
|
|
// <iframe src='/knowledgegraph/blockEditor.html' style={{width:"80vw",height:"80vh"}} frameBorder={0} />
|
|
|
;
|
|
|
|
|
|
case ADD_TABLE:
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(add_table_panel, {
|
|
|
callback: ExecutePluginAction,
|
|
|
onCancel: onCancel
|
|
|
});
|
|
|
default:
|
|
|
return null;
|
|
|
}
|
|
|
}, [action]);
|
|
|
function onCancel() {
|
|
|
setAction('');
|
|
|
}
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
if (resizeBarEl.current) {
|
|
|
var onMouseDown = function onMouseDown(e) {
|
|
|
dragging = true;
|
|
|
startY = e.pageY;
|
|
|
};
|
|
|
var onMouseUp = function onMouseUp() {
|
|
|
dragging = false;
|
|
|
};
|
|
|
var onMouseMove = function onMouseMove(e) {
|
|
|
if (dragging) {
|
|
|
var delta = e.pageY - startY;
|
|
|
if (delta < 0) {
|
|
|
delta = 0;
|
|
|
}
|
|
|
if (delta > 300) {
|
|
|
delta = 300;
|
|
|
}
|
|
|
var resizeH = height + delta + 'px';
|
|
|
setH(resizeH);
|
|
|
}
|
|
|
};
|
|
|
var resizeBar = resizeBarEl.current;
|
|
|
var dragging = false;
|
|
|
var startY = 0;
|
|
|
resizeBar.addEventListener('mousedown', onMouseDown);
|
|
|
document.addEventListener('mousemove', onMouseMove);
|
|
|
document.addEventListener('mouseup', onMouseUp);
|
|
|
return function () {
|
|
|
resizeBar.removeEventListener('mousedown', onMouseDown);
|
|
|
document.removeEventListener('mousemove', onMouseMove);
|
|
|
document.removeEventListener('mouseup', onMouseUp);
|
|
|
};
|
|
|
}
|
|
|
}, [cm, resizeBarEl]);
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
setH(height);
|
|
|
}, [height]);
|
|
|
var fixedWidth = processSize(width);
|
|
|
var fixedHeight = processSize(h);
|
|
|
var style = {
|
|
|
width: fixedWidth,
|
|
|
height: fixedHeight
|
|
|
};
|
|
|
var saveTime = (0,_react_17_0_2_react.useMemo)(function () {
|
|
|
if (lastedUpdateTime) {
|
|
|
var d = new Date(lastedUpdateTime);
|
|
|
var _h = d.getHours();
|
|
|
var m = d.getMinutes();
|
|
|
var s = d.getSeconds();
|
|
|
_h = _h < 10 ? '0' + _h : _h;
|
|
|
m = m < 10 ? '0' + m : m;
|
|
|
s = s < 10 ? '0' + s : s;
|
|
|
return "".concat(_h, ":").concat(m, ":").concat(s);
|
|
|
}
|
|
|
return 0;
|
|
|
}, [lastedUpdateTime]);
|
|
|
var formatProgramFill = function formatProgramFill(str) {
|
|
|
var arr = [];
|
|
|
if (showNullProgramButton) {
|
|
|
var num = -1;
|
|
|
str = str.replace(/(@▁▁@|@▁@)/g, function (a, b, c) {
|
|
|
arr.push({
|
|
|
multiLine: !(a === ADD_SINGLE)
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
return arr;
|
|
|
};
|
|
|
function onCancelStorage() {
|
|
|
window.sessionStorage.removeItem(id);
|
|
|
setTip(false);
|
|
|
setLastedUpdateTime(0);
|
|
|
}
|
|
|
function onReset() {
|
|
|
setTip(false);
|
|
|
setLastedUpdateTime(0);
|
|
|
cm.setValue(window.sessionStorage.getItem(id));
|
|
|
}
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)(_react_17_0_2_react.Fragment, {
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
className: "markdown-editor-wrapper",
|
|
|
ref: containerEl,
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
className: "markdown-editor-container ".concat(className, " ").concat(preview ? 'on-preview' : '', " ").concat(miniToolbar ? 'mini' : '', " ").concat(isFull ? 'full-screen' : ''),
|
|
|
style: style,
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(toolbar, {
|
|
|
insertTemp: insertTemp,
|
|
|
watch: preview,
|
|
|
fullScreen: isFull,
|
|
|
showNullButton: showNullButton,
|
|
|
showNullProgramButton: showNullProgramButton,
|
|
|
onActionCallback: onActionCallback,
|
|
|
hidetoolBar: hidetoolBar,
|
|
|
extraUse: extraUse
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
className: "markdown-editor-body",
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
className: "codemirror-container",
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("textarea", {
|
|
|
ref: cmEl,
|
|
|
placeholder: placeholder
|
|
|
})
|
|
|
}), preview ? /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
ref: previewEl,
|
|
|
className: "preview-container",
|
|
|
children: [mode === "stex" && /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml_stex, {
|
|
|
value: value
|
|
|
}), mode !== "stex" && /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, {
|
|
|
disabledFill: disabledFill,
|
|
|
showProgramFill: showNullProgramButton,
|
|
|
value: value
|
|
|
})]
|
|
|
}) : null]
|
|
|
})]
|
|
|
})
|
|
|
}), showResizeBar ? /*#__PURE__*/(0,jsx_runtime.jsx)("a", {
|
|
|
ref: resizeBarEl,
|
|
|
className: "editor-resize"
|
|
|
}) : null, action === DRAW_IMAGE && /*#__PURE__*/(0,jsx_runtime.jsx)(draw_image, {
|
|
|
callback: ExecutePluginAction,
|
|
|
onCancel: onCancel
|
|
|
}), action === ADD_FLOWCHART && /*#__PURE__*/(0,jsx_runtime.jsx)(flow_chart, {
|
|
|
callback: ExecutePluginAction,
|
|
|
onCancel: onCancel
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(modal/* default */.Z, {
|
|
|
children: TitleDesc[action] && action !== DRAW_IMAGE && action !== ADD_FLOWCHART ? /*#__PURE__*/(0,jsx_runtime.jsx)(es_modal/* default */.Z, {
|
|
|
centered: true,
|
|
|
title: TitleDesc[action],
|
|
|
open: true,
|
|
|
onCancel: onCancel,
|
|
|
footer: null,
|
|
|
destroyOnClose: true,
|
|
|
width: action === ADD_FLOWCHART ? "1200px" : 520,
|
|
|
height: action === ADD_FLOWCHART ? "80vh" : null,
|
|
|
className: "markdown-popup-form",
|
|
|
children: PluginEl
|
|
|
}) : null
|
|
|
})]
|
|
|
});
|
|
|
});
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 90463:
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/components/modal.tsx ***!
|
|
|
\**********************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
|
/* harmony export */ Z: function() { return /* binding */ Dialog; }
|
|
|
/* harmony export */ });
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_classCallCheck_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/classCallCheck.js */ 94312);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_classCallCheck_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_classCallCheck_js__WEBPACK_IMPORTED_MODULE_0__);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createClass_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/createClass.js */ 24127);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createClass_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createClass_js__WEBPACK_IMPORTED_MODULE_1__);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_inherits_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/inherits.js */ 93242);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_inherits_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_inherits_js__WEBPACK_IMPORTED_MODULE_2__);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createSuper_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/createSuper.js */ 10564);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createSuper_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createSuper_js__WEBPACK_IMPORTED_MODULE_3__);
|
|
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react */ 59301);
|
|
|
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react-dom */ 4676);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var Dialog = /*#__PURE__*/function (_React$Component) {
|
|
|
_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_inherits_js__WEBPACK_IMPORTED_MODULE_2___default()(Dialog, _React$Component);
|
|
|
var _super = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createSuper_js__WEBPACK_IMPORTED_MODULE_3___default()(Dialog);
|
|
|
function Dialog(props) {
|
|
|
var _this;
|
|
|
_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_classCallCheck_js__WEBPACK_IMPORTED_MODULE_0___default()(this, Dialog);
|
|
|
_this = _super.call(this, props);
|
|
|
var doc = window.document;
|
|
|
_this.node = doc.createElement('div');
|
|
|
doc.body.appendChild(_this.node);
|
|
|
return _this;
|
|
|
}
|
|
|
_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createClass_js__WEBPACK_IMPORTED_MODULE_1___default()(Dialog, [{
|
|
|
key: "render",
|
|
|
value: function render() {
|
|
|
var children = this.props.children;
|
|
|
return /*#__PURE__*/(0,react_dom__WEBPACK_IMPORTED_MODULE_5__.createPortal)(children, this.node);
|
|
|
}
|
|
|
}, {
|
|
|
key: "componentWillUnmount",
|
|
|
value: function componentWillUnmount() {
|
|
|
window.document.body.removeChild(this.node);
|
|
|
}
|
|
|
}]);
|
|
|
return Dialog;
|
|
|
}(react__WEBPACK_IMPORTED_MODULE_4__.Component);
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 35110:
|
|
|
/*!*********************************************************!*\
|
|
|
!*** ./src/components/tpi-code-setting/CodeSetting.tsx ***!
|
|
|
\*********************************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ 59301);
|
|
|
/* harmony import */ var _index_less__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./index.less */ 30345);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! antd */ 57809);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! antd */ 78673);
|
|
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react/jsx-runtime */ 37712);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var Option = antd__WEBPACK_IMPORTED_MODULE_3__["default"].Option;
|
|
|
/* harmony default export */ __webpack_exports__.Z = (function (_ref) {
|
|
|
var isTheoretical = _ref.isTheoretical,
|
|
|
onFontSizeChange = _ref.onFontSizeChange,
|
|
|
cmFontSize = _ref.cmFontSize,
|
|
|
cmCodeMode = _ref.cmCodeMode,
|
|
|
autoFormat = _ref.autoFormat,
|
|
|
onCodeModeChange = _ref.onCodeModeChange,
|
|
|
onTabToSpace = _ref.onTabToSpace,
|
|
|
onAutoFormat = _ref.onAutoFormat,
|
|
|
formatDocument = _ref.formatDocument,
|
|
|
_ref$className = _ref.className,
|
|
|
className = _ref$className === void 0 ? '' : _ref$className,
|
|
|
tabToSpace = _ref.tabToSpace,
|
|
|
children = _ref.children;
|
|
|
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", {
|
|
|
className: "tpi-code-setting ".concat(className),
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("h3", {
|
|
|
children: "\u4EE3\u7801\u683C\u5F0F"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("section", {
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", {
|
|
|
className: "file-item",
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("b", {
|
|
|
children: "\u663E\u793A\u6A21\u5F0F"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)(antd__WEBPACK_IMPORTED_MODULE_3__["default"], {
|
|
|
bordered: false,
|
|
|
size: "small",
|
|
|
value: cmCodeMode,
|
|
|
onChange: onCodeModeChange,
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(Option, {
|
|
|
value: 'vs',
|
|
|
children: "\u767D\u8272\u80CC\u666F"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(Option, {
|
|
|
value: 'vs-dark',
|
|
|
children: "\u9ED1\u8272\u80CC\u666F"
|
|
|
})]
|
|
|
})]
|
|
|
}), !isTheoretical && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.Fragment, {
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", {
|
|
|
className: "file-item",
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("b", {
|
|
|
children: "\u5B57\u4F53\u5927\u5C0F"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)(antd__WEBPACK_IMPORTED_MODULE_3__["default"], {
|
|
|
bordered: false,
|
|
|
size: "small",
|
|
|
value: cmFontSize,
|
|
|
onChange: onFontSizeChange,
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(Option, {
|
|
|
value: 12,
|
|
|
children: "12px"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(Option, {
|
|
|
value: 14,
|
|
|
children: "14px"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(Option, {
|
|
|
value: 16,
|
|
|
children: "16px"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(Option, {
|
|
|
value: 18,
|
|
|
children: "18px"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(Option, {
|
|
|
value: 20,
|
|
|
children: "20px"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(Option, {
|
|
|
value: 22,
|
|
|
children: "22px"
|
|
|
})]
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", {
|
|
|
className: "file-item",
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("b", {
|
|
|
children: "Tab\u8F6C\u6362"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(antd__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {
|
|
|
checked: tabToSpace,
|
|
|
onChange: onTabToSpace
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("div", {
|
|
|
className: "file-item",
|
|
|
onClick: formatDocument,
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("b", {
|
|
|
style: {
|
|
|
cursor: "pointer"
|
|
|
},
|
|
|
children: "\u683C\u5F0F\u5316\u4EE3\u7801"
|
|
|
})
|
|
|
})]
|
|
|
})]
|
|
|
}), !isTheoretical && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.Fragment, {
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("h3", {
|
|
|
children: "\u5FEB\u6377\u952E"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("section", {
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", {
|
|
|
className: "file-item",
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("b", {
|
|
|
children: "\u4FDD\u5B58\u4EE3\u7801"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("span", {
|
|
|
children: "Ctrl + S"
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", {
|
|
|
className: "file-item",
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("b", {
|
|
|
children: "\u5524\u51FA\u5FEB\u6377\u952E\u5217\u8868"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("span", {
|
|
|
children: "F1 / Alt + F1"
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", {
|
|
|
className: "file-item",
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("b", {
|
|
|
children: "\u5DE6\u53F3\u7F29\u8FDB"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("span", {
|
|
|
children: "Ctrl + ]/["
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", {
|
|
|
className: "file-item",
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("b", {
|
|
|
children: "\u8DF3\u5230\u5339\u914D\u7684\u62EC\u53F7"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("span", {
|
|
|
children: "Ctrl + Shift + \\"
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", {
|
|
|
className: "file-item",
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("b", {
|
|
|
children: "\u8F6C\u5230\u884C\u9996"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("span", {
|
|
|
children: "Home"
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", {
|
|
|
className: "file-item",
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("b", {
|
|
|
children: "\u8F6C\u5230\u884C\u5C3E"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("span", {
|
|
|
children: "End"
|
|
|
})]
|
|
|
})]
|
|
|
}), children]
|
|
|
})]
|
|
|
});
|
|
|
});
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 86219:
|
|
|
/*!****************************************!*\
|
|
|
!*** ./src/components/useInterval.tsx ***!
|
|
|
\****************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
|
/* harmony export */ Z: function() { return /* binding */ useInterval; }
|
|
|
/* harmony export */ });
|
|
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ 59301);
|
|
|
|
|
|
function useInterval(callback, delay) {
|
|
|
var savedCallback = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
|
|
|
|
|
|
// 保存新回调
|
|
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
|
savedCallback.current = callback;
|
|
|
});
|
|
|
|
|
|
// 建立 interval
|
|
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
|
|
|
function tick() {
|
|
|
savedCallback.current();
|
|
|
}
|
|
|
if (delay !== null) {
|
|
|
var id = setInterval(tick, delay);
|
|
|
return function () {
|
|
|
return clearInterval(id);
|
|
|
};
|
|
|
}
|
|
|
}, [delay]);
|
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 95384:
|
|
|
/*!*******************************************************************!*\
|
|
|
!*** ./src/pages/Problems/OjForm/CodePanel/index.tsx + 1 modules ***!
|
|
|
\*******************************************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
|
// EXPORTS
|
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
|
Z: function() { return /* binding */ CodePanel; }
|
|
|
});
|
|
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/slicedToArray.js
|
|
|
var slicedToArray = __webpack_require__(11006);
|
|
|
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectSpread2.js
|
|
|
var objectSpread2 = __webpack_require__(26801);
|
|
|
var objectSpread2_default = /*#__PURE__*/__webpack_require__.n(objectSpread2);
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
|
|
|
var _react_17_0_2_react = __webpack_require__(59301);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/drawer/index.js + 9 modules
|
|
|
var drawer = __webpack_require__(43428);
|
|
|
// EXTERNAL MODULE: ./src/components/monaco-editor/index.jsx + 4 modules
|
|
|
var monaco_editor = __webpack_require__(58570);
|
|
|
// EXTERNAL MODULE: ./src/components/tpi-code-setting/CodeSetting.tsx
|
|
|
var CodeSetting = __webpack_require__(35110);
|
|
|
// EXTERNAL MODULE: ./src/components/modal.tsx
|
|
|
var modal = __webpack_require__(90463);
|
|
|
// EXTERNAL MODULE: ./src/utils/urlTool.ts
|
|
|
var urlTool = __webpack_require__(22358);
|
|
|
;// CONCATENATED MODULE: ./src/pages/Problems/OjForm/CodePanel/index.less
|
|
|
// extracted by mini-css-extract-plugin
|
|
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/jsx-runtime.js
|
|
|
var jsx_runtime = __webpack_require__(37712);
|
|
|
;// CONCATENATED MODULE: ./src/pages/Problems/OjForm/CodePanel/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//@ts-ignore
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var initialState = {
|
|
|
theme: (0,urlTool/* fromStore */.G)('cmCodeMode', 'vs-dark'),
|
|
|
fontSize: (0,urlTool/* fromStore */.G)('cmFontSize', 14),
|
|
|
showEditorSetting: false,
|
|
|
tabToSpace: (0,urlTool/* fromStore */.G)('cmTabToSpace', true)
|
|
|
};
|
|
|
var Types = /*#__PURE__*/function (Types) {
|
|
|
Types[Types["set_font_size"] = 0] = "set_font_size";
|
|
|
Types[Types["set_theme"] = 1] = "set_theme";
|
|
|
Types[Types["on_tab_to_space"] = 2] = "on_tab_to_space";
|
|
|
Types[Types["set_show_editor_setting"] = 3] = "set_show_editor_setting";
|
|
|
return Types;
|
|
|
}(Types || {});
|
|
|
function reducer(state, action) {
|
|
|
switch (action.type) {
|
|
|
case Types.set_show_editor_setting:
|
|
|
return objectSpread2_default()(objectSpread2_default()({}, state), {}, {
|
|
|
showEditorSetting: action.payload
|
|
|
});
|
|
|
case Types.set_theme:
|
|
|
return objectSpread2_default()(objectSpread2_default()({}, state), {}, {
|
|
|
theme: action.payload
|
|
|
});
|
|
|
case Types.set_font_size:
|
|
|
return objectSpread2_default()(objectSpread2_default()({}, state), {}, {
|
|
|
fontSize: action.payload
|
|
|
});
|
|
|
case Types.on_tab_to_space:
|
|
|
return objectSpread2_default()(objectSpread2_default()({}, state), {}, {
|
|
|
tabToSpace: action.payload
|
|
|
});
|
|
|
default:
|
|
|
throw new Error();
|
|
|
}
|
|
|
}
|
|
|
/* harmony default export */ var CodePanel = (function (_ref) {
|
|
|
var isLoading = _ref.isLoading,
|
|
|
value = _ref.value,
|
|
|
_onChange = _ref.onChange,
|
|
|
language = _ref.language,
|
|
|
onUpdateCode = _ref.onUpdateCode,
|
|
|
_ref$ActionBarRender = _ref.ActionBarRender,
|
|
|
ActionBarRender = _ref$ActionBarRender === void 0 ? function (onShowCodeSetting) {
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(DefaultActionBar, {
|
|
|
onShowCodeSetting: onShowCodeSetting
|
|
|
});
|
|
|
} : _ref$ActionBarRender;
|
|
|
var _useReducer = (0,_react_17_0_2_react.useReducer)(reducer, initialState),
|
|
|
_useReducer2 = slicedToArray_default()(_useReducer, 2),
|
|
|
state = _useReducer2[0],
|
|
|
dispatch = _useReducer2[1];
|
|
|
var theme = state.theme,
|
|
|
fontSize = state.fontSize,
|
|
|
showEditorSetting = state.showEditorSetting,
|
|
|
tabToSpace = state.tabToSpace;
|
|
|
var timeRef = (0,_react_17_0_2_react.useRef)();
|
|
|
var valueRef = (0,_react_17_0_2_react.useRef)();
|
|
|
var codeSettingOption = {
|
|
|
onFontSizeChange: function onFontSizeChange(val) {
|
|
|
dispatch({
|
|
|
type: Types.set_font_size,
|
|
|
payload: val
|
|
|
});
|
|
|
(0,urlTool/* toStore */.t)('cmFontSize', val);
|
|
|
},
|
|
|
tabToSpace: tabToSpace,
|
|
|
cmFontSize: fontSize,
|
|
|
className: 'oj',
|
|
|
cmCodeMode: theme,
|
|
|
onTabToSpace: function onTabToSpace(checked) {
|
|
|
dispatch({
|
|
|
type: Types.on_tab_to_space,
|
|
|
payload: checked
|
|
|
});
|
|
|
(0,urlTool/* toStore */.t)('cmTabToSpace', checked);
|
|
|
},
|
|
|
onCodeModeChange: function onCodeModeChange(val) {
|
|
|
dispatch({
|
|
|
type: Types.set_theme,
|
|
|
payload: val
|
|
|
});
|
|
|
(0,urlTool/* toStore */.t)('cmCodeMode', val);
|
|
|
}
|
|
|
};
|
|
|
function onHideCodeSetting() {
|
|
|
dispatch({
|
|
|
type: Types.set_show_editor_setting,
|
|
|
payload: false
|
|
|
});
|
|
|
}
|
|
|
function onShowCodeSetting() {
|
|
|
dispatch({
|
|
|
type: Types.set_show_editor_setting,
|
|
|
payload: true
|
|
|
});
|
|
|
}
|
|
|
var editorOption = {
|
|
|
value: value,
|
|
|
language: language,
|
|
|
// onChange,
|
|
|
theme: theme,
|
|
|
height: 'calc(100% - 56px)',
|
|
|
options: {
|
|
|
fontSize: fontSize,
|
|
|
insertSpaces: tabToSpace
|
|
|
},
|
|
|
onChange: function onChange(value) {
|
|
|
_onChange(value);
|
|
|
valueRef.current = value;
|
|
|
clearTimeout(timeRef.current);
|
|
|
timeRef.current = setTimeout(function () {
|
|
|
onUpdateCode(valueRef.current);
|
|
|
}, 10000);
|
|
|
},
|
|
|
onEditBlur: function onEditBlur(value) {
|
|
|
if (!!valueRef.current) onUpdateCode(valueRef.current);
|
|
|
}
|
|
|
};
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)(_react_17_0_2_react.Fragment, {
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
className: "code-panel-container",
|
|
|
children: [ActionBarRender(onShowCodeSetting), !isLoading && /*#__PURE__*/(0,jsx_runtime.jsx)(monaco_editor/* default */.ZP, objectSpread2_default()({}, editorOption))]
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(modal/* default */.Z, {
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(drawer/* default */.Z, {
|
|
|
rootClassName: "oj",
|
|
|
title: null,
|
|
|
placement: "right",
|
|
|
closable: false,
|
|
|
open: showEditorSetting,
|
|
|
onClose: onHideCodeSetting,
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(CodeSetting/* default */.Z, objectSpread2_default()({}, codeSettingOption))
|
|
|
})
|
|
|
})]
|
|
|
});
|
|
|
});
|
|
|
function DefaultActionBar(_ref2) {
|
|
|
var onShowCodeSetting = _ref2.onShowCodeSetting;
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
className: "action-bar",
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
|
children: "\u5B66\u5458\u521D\u59CB\u4EE3\u7801\u6587\u4EF6"
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("a", {
|
|
|
onClick: onShowCodeSetting,
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
|
|
|
className: "iconfont icon-shezhi"
|
|
|
})
|
|
|
})]
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 65135:
|
|
|
/*!**************************************************************************!*\
|
|
|
!*** ./src/pages/Problems/OjForm/CodeProgramPanel/index.tsx + 1 modules ***!
|
|
|
\**************************************************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
|
// EXPORTS
|
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
|
Z: function() { return /* binding */ CodeProgramPanel; }
|
|
|
});
|
|
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/slicedToArray.js
|
|
|
var slicedToArray = __webpack_require__(11006);
|
|
|
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectSpread2.js
|
|
|
var objectSpread2 = __webpack_require__(26801);
|
|
|
var objectSpread2_default = /*#__PURE__*/__webpack_require__.n(objectSpread2);
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
|
|
|
var _react_17_0_2_react = __webpack_require__(59301);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/drawer/index.js + 9 modules
|
|
|
var drawer = __webpack_require__(43428);
|
|
|
// EXTERNAL MODULE: ./src/components/monaco-editor/index.jsx + 4 modules
|
|
|
var monaco_editor = __webpack_require__(58570);
|
|
|
// EXTERNAL MODULE: ./src/components/tpi-code-setting/CodeSetting.tsx
|
|
|
var CodeSetting = __webpack_require__(35110);
|
|
|
// EXTERNAL MODULE: ./src/components/modal.tsx
|
|
|
var modal = __webpack_require__(90463);
|
|
|
// EXTERNAL MODULE: ./src/utils/urlTool.ts
|
|
|
var urlTool = __webpack_require__(22358);
|
|
|
;// CONCATENATED MODULE: ./src/pages/Problems/OjForm/CodeProgramPanel/index.less?modules
|
|
|
// extracted by mini-css-extract-plugin
|
|
|
/* harmony default export */ var CodeProgramPanelmodules = ({"code-panel-container":"code-panel-container___RFtv_","action-oj-bar":"action-oj-bar___ByFmZ","active":"active___s9gT5"});
|
|
|
// EXTERNAL MODULE: ./node_modules/_lodash@4.17.21@lodash/lodash.js
|
|
|
var lodash = __webpack_require__(89392);
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/jsx-runtime.js
|
|
|
var jsx_runtime = __webpack_require__(37712);
|
|
|
;// CONCATENATED MODULE: ./src/pages/Problems/OjForm/CodeProgramPanel/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//@ts-ignore
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var initialState = {
|
|
|
theme: (0,urlTool/* fromStore */.G)('cmCodeMode', 'vs-dark'),
|
|
|
fontSize: (0,urlTool/* fromStore */.G)('cmFontSize', 14),
|
|
|
showEditorSetting: false,
|
|
|
tabToSpace: (0,urlTool/* fromStore */.G)('cmTabToSpace', true)
|
|
|
};
|
|
|
var Types = /*#__PURE__*/function (Types) {
|
|
|
Types[Types["set_font_size"] = 0] = "set_font_size";
|
|
|
Types[Types["set_theme"] = 1] = "set_theme";
|
|
|
Types[Types["on_tab_to_space"] = 2] = "on_tab_to_space";
|
|
|
Types[Types["set_show_editor_setting"] = 3] = "set_show_editor_setting";
|
|
|
return Types;
|
|
|
}(Types || {});
|
|
|
function reducer(state, action) {
|
|
|
switch (action.type) {
|
|
|
case Types.set_show_editor_setting:
|
|
|
return objectSpread2_default()(objectSpread2_default()({}, state), {}, {
|
|
|
showEditorSetting: action.payload
|
|
|
});
|
|
|
case Types.set_theme:
|
|
|
return objectSpread2_default()(objectSpread2_default()({}, state), {}, {
|
|
|
theme: action.payload
|
|
|
});
|
|
|
case Types.set_font_size:
|
|
|
return objectSpread2_default()(objectSpread2_default()({}, state), {}, {
|
|
|
fontSize: action.payload
|
|
|
});
|
|
|
case Types.on_tab_to_space:
|
|
|
return objectSpread2_default()(objectSpread2_default()({}, state), {}, {
|
|
|
tabToSpace: action.payload
|
|
|
});
|
|
|
default:
|
|
|
throw new Error();
|
|
|
}
|
|
|
}
|
|
|
/* harmony default export */ var CodeProgramPanel = (function (_ref) {
|
|
|
var _value$find;
|
|
|
var isLoading = _ref.isLoading,
|
|
|
_ref$value = _ref.value,
|
|
|
value = _ref$value === void 0 ? [] : _ref$value,
|
|
|
onChange = _ref.onChange;
|
|
|
var _useReducer = (0,_react_17_0_2_react.useReducer)(reducer, initialState),
|
|
|
_useReducer2 = slicedToArray_default()(_useReducer, 2),
|
|
|
state = _useReducer2[0],
|
|
|
dispatch = _useReducer2[1];
|
|
|
var theme = state.theme,
|
|
|
fontSize = state.fontSize,
|
|
|
showEditorSetting = state.showEditorSetting,
|
|
|
tabToSpace = state.tabToSpace;
|
|
|
var _useState = (0,_react_17_0_2_react.useState)('c'),
|
|
|
_useState2 = slicedToArray_default()(_useState, 2),
|
|
|
language = _useState2[0],
|
|
|
setLanguage = _useState2[1];
|
|
|
var saveLanguageItems = (0,_react_17_0_2_react.useRef)([]);
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
if (!!(value !== null && value !== void 0 && value.length)) {
|
|
|
saveLanguageItems.current = (0,lodash.cloneDeep)(value);
|
|
|
}
|
|
|
}, [value]);
|
|
|
var codeSettingOption = {
|
|
|
onFontSizeChange: function onFontSizeChange(val) {
|
|
|
dispatch({
|
|
|
type: Types.set_font_size,
|
|
|
payload: val
|
|
|
});
|
|
|
(0,urlTool/* toStore */.t)('cmFontSize', val);
|
|
|
},
|
|
|
tabToSpace: tabToSpace,
|
|
|
cmFontSize: fontSize,
|
|
|
className: 'oj',
|
|
|
cmCodeMode: theme,
|
|
|
onTabToSpace: function onTabToSpace(checked) {
|
|
|
dispatch({
|
|
|
type: Types.on_tab_to_space,
|
|
|
payload: checked
|
|
|
});
|
|
|
(0,urlTool/* toStore */.t)('cmTabToSpace', checked);
|
|
|
},
|
|
|
onCodeModeChange: function onCodeModeChange(val) {
|
|
|
dispatch({
|
|
|
type: Types.set_theme,
|
|
|
payload: val
|
|
|
});
|
|
|
(0,urlTool/* toStore */.t)('cmCodeMode', val);
|
|
|
}
|
|
|
};
|
|
|
function onHideCodeSetting() {
|
|
|
dispatch({
|
|
|
type: Types.set_show_editor_setting,
|
|
|
payload: false
|
|
|
});
|
|
|
}
|
|
|
function onShowCodeSetting() {
|
|
|
dispatch({
|
|
|
type: Types.set_show_editor_setting,
|
|
|
payload: true
|
|
|
});
|
|
|
}
|
|
|
function onCodeChange(v) {
|
|
|
var _saveLanguageItems$cu;
|
|
|
var item = (_saveLanguageItems$cu = saveLanguageItems.current) === null || _saveLanguageItems$cu === void 0 ? void 0 : _saveLanguageItems$cu.map(function (e) {
|
|
|
if (e.language === language) {
|
|
|
e.code = v;
|
|
|
return e;
|
|
|
}
|
|
|
return e;
|
|
|
});
|
|
|
saveLanguageItems.current = (0,lodash.cloneDeep)(item);
|
|
|
onChange(item);
|
|
|
}
|
|
|
var editorOption = {
|
|
|
key: language,
|
|
|
value: value === null || value === void 0 || (_value$find = value.find(function (e) {
|
|
|
return e.language === language;
|
|
|
})) === null || _value$find === void 0 ? void 0 : _value$find.code,
|
|
|
language: language,
|
|
|
onChange: onCodeChange,
|
|
|
theme: theme,
|
|
|
height: 'calc(100% - 56px)',
|
|
|
options: {
|
|
|
fontSize: fontSize,
|
|
|
insertSpaces: tabToSpace
|
|
|
}
|
|
|
};
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)(_react_17_0_2_react.Fragment, {
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
className: CodeProgramPanelmodules["code-panel-container"],
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(DefaultActionBar, {
|
|
|
languageItems: value,
|
|
|
onLanguage: function onLanguage(v) {
|
|
|
return setLanguage(v);
|
|
|
},
|
|
|
language: language,
|
|
|
onShowCodeSetting: onShowCodeSetting
|
|
|
}), !isLoading && /*#__PURE__*/(0,jsx_runtime.jsx)(monaco_editor/* default */.ZP, objectSpread2_default()({}, editorOption))]
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(modal/* default */.Z, {
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(drawer/* default */.Z, {
|
|
|
rootClassName: "oj",
|
|
|
title: null,
|
|
|
placement: "right",
|
|
|
closable: false,
|
|
|
open: showEditorSetting,
|
|
|
onClose: onHideCodeSetting,
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(CodeSetting/* default */.Z, objectSpread2_default()({}, codeSettingOption))
|
|
|
})
|
|
|
})]
|
|
|
});
|
|
|
});
|
|
|
function DefaultActionBar(_ref2) {
|
|
|
var languageItems = _ref2.languageItems,
|
|
|
language = _ref2.language,
|
|
|
onShowCodeSetting = _ref2.onShowCodeSetting,
|
|
|
onLanguage = _ref2.onLanguage;
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
className: CodeProgramPanelmodules["action-oj-bar"],
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
|
children: "\u5B66\u5458\u521D\u59CB\u4EE3\u7801\u6587\u4EF6"
|
|
|
}), languageItems === null || languageItems === void 0 ? void 0 : languageItems.map(function (e) {
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
className: language === (e === null || e === void 0 ? void 0 : e.language) ? CodeProgramPanelmodules.active : '',
|
|
|
onClick: function onClick() {
|
|
|
return onLanguage(e === null || e === void 0 ? void 0 : e.language);
|
|
|
},
|
|
|
children: e === null || e === void 0 ? void 0 : e.language
|
|
|
}, e === null || e === void 0 ? void 0 : e.language);
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("a", {
|
|
|
onClick: onShowCodeSetting,
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
|
|
|
className: "iconfont icon-shezhi"
|
|
|
})
|
|
|
})]
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 83721:
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./src/pages/Problems/OjForm/index.tsx ***!
|
|
|
\*********************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
|
/* harmony export */ Types: function() { return /* binding */ Types; }
|
|
|
/* harmony export */ });
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectDestructuringEmpty_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectDestructuringEmpty.js */ 27223);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectDestructuringEmpty_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectDestructuringEmpty_js__WEBPACK_IMPORTED_MODULE_0__);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createForOfIteratorHelper_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/createForOfIteratorHelper.js */ 98190);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createForOfIteratorHelper_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createForOfIteratorHelper_js__WEBPACK_IMPORTED_MODULE_1__);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/toConsumableArray.js */ 93923);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_2__);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/regeneratorRuntime.js */ 10574);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_3__);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/asyncToGenerator.js */ 39343);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_4__);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/slicedToArray.js */ 11006);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_5__);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectSpread2.js */ 26801);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6__);
|
|
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react */ 59301);
|
|
|
/* harmony import */ var _index_less_modules__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./index.less?modules */ 63390);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! antd */ 1056);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! antd */ 43418);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! antd */ 74997);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! antd */ 78241);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! antd */ 8591);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! antd */ 71418);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! antd */ 3113);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! antd */ 57809);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! antd */ 19842);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! antd */ 85731);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! antd */ 24905);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! antd */ 5112);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! antd */ 81327);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(/*! antd */ 14478);
|
|
|
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./util */ 55654);
|
|
|
/* harmony import */ var umi__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! umi */ 38670);
|
|
|
/* harmony import */ var js_base64__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! js-base64 */ 24334);
|
|
|
/* harmony import */ var js_base64__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(js_base64__WEBPACK_IMPORTED_MODULE_11__);
|
|
|
/* harmony import */ var _ant_design_icons__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! @ant-design/icons */ 22321);
|
|
|
/* harmony import */ var _ant_design_icons__WEBPACK_IMPORTED_MODULE_43__ = __webpack_require__(/*! @ant-design/icons */ 47104);
|
|
|
/* harmony import */ var _components_markdown_editor__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @/components/markdown-editor */ 38874);
|
|
|
/* harmony import */ var _service__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./service */ 77900);
|
|
|
/* harmony import */ var _service_exercise__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! @/service/exercise */ 86018);
|
|
|
/* harmony import */ var _components_SplitContainer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! @/components/SplitContainer */ 3254);
|
|
|
/* harmony import */ var _CodePanel__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./CodePanel */ 95384);
|
|
|
/* harmony import */ var _CodeProgramPanel__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./CodeProgramPanel */ 65135);
|
|
|
/* harmony import */ var _utils_fetch__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! @/utils/fetch */ 15830);
|
|
|
/* harmony import */ var _utils_util__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! @/utils/util */ 85578);
|
|
|
/* harmony import */ var _utils_env__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! @/utils/env */ 67871);
|
|
|
/* harmony import */ var _components_Knowledge__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! @/components/Knowledge */ 53108);
|
|
|
/* harmony import */ var _components_CustomTree__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! @/components/CustomTree */ 99947);
|
|
|
/* harmony import */ var _pages_Shixuns_Edit_body_Level_Challenges_components_UploadFile__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! @/pages/Shixuns/Edit/body/Level/Challenges/components/UploadFile */ 7572);
|
|
|
/* harmony import */ var _service_paperlibrary__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! @/service/paperlibrary */ 74251);
|
|
|
/* harmony import */ var _utils_enum__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! @/utils/enum */ 42939);
|
|
|
/* harmony import */ var _components_QuestionEditor_MdEditorInForm__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! @/components/QuestionEditor/MdEditorInForm */ 68006);
|
|
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! react/jsx-runtime */ 37712);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//@ts-ignore
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var TextArea = antd__WEBPACK_IMPORTED_MODULE_28__/* ["default"] */ .Z.TextArea;
|
|
|
var confirm = antd__WEBPACK_IMPORTED_MODULE_29__/* ["default"] */ .Z.confirm;
|
|
|
var Panel = antd__WEBPACK_IMPORTED_MODULE_30__/* ["default"] */ .Z.Panel;
|
|
|
function getTimeStamp() {
|
|
|
return new Date().getTime();
|
|
|
}
|
|
|
var initialState = {
|
|
|
loading: true,
|
|
|
user: null,
|
|
|
disciplines: [],
|
|
|
dicts: null,
|
|
|
status: 0,
|
|
|
data: undefined,
|
|
|
lastedUpdateTime: 0
|
|
|
};
|
|
|
var Types = /*#__PURE__*/function (Types) {
|
|
|
Types[Types["SET_INITAL_DATA"] = 0] = "SET_INITAL_DATA";
|
|
|
Types[Types["SET_LOADING"] = 1] = "SET_LOADING";
|
|
|
Types[Types["SET_STATUS"] = 2] = "SET_STATUS";
|
|
|
return Types;
|
|
|
}({});
|
|
|
function reducer(state, action) {
|
|
|
switch (action.type) {
|
|
|
case Types.SET_INITAL_DATA:
|
|
|
return _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, state), action.payload);
|
|
|
case Types.SET_LOADING:
|
|
|
return _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, state), {}, {
|
|
|
loading: action.payload
|
|
|
});
|
|
|
case Types.SET_STATUS:
|
|
|
return _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, state), {}, {
|
|
|
status: action.payload
|
|
|
});
|
|
|
default:
|
|
|
throw new Error();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//problems/new?difficult=3&sub_discipline_id=95&tag_discipline_id=105&newoj=1&pages=1
|
|
|
///problems/p2mblri6/edit
|
|
|
//* 从课堂试卷编辑入口进来 http://localhost:8000/problems/i4b5wuhn/edit?type=exercises&express_id=2510&callback_url=/classrooms/1309/exercise/2510/edit
|
|
|
/* harmony default export */ __webpack_exports__["default"] = (function () {
|
|
|
var _data$hack, _data$hack4;
|
|
|
var _useSearchParams = (0,umi__WEBPACK_IMPORTED_MODULE_10__.useSearchParams)(),
|
|
|
_useSearchParams2 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_5___default()(_useSearchParams, 1),
|
|
|
searchParams = _useSearchParams2[0];
|
|
|
var location = (0,umi__WEBPACK_IMPORTED_MODULE_10__.useLocation)();
|
|
|
var _useParams = (0,umi__WEBPACK_IMPORTED_MODULE_10__.useParams)(),
|
|
|
id = _useParams.id;
|
|
|
var _Form$useForm = antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.useForm(),
|
|
|
_Form$useForm2 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_5___default()(_Form$useForm, 1),
|
|
|
form = _Form$useForm2[0];
|
|
|
var _useState = (0,react__WEBPACK_IMPORTED_MODULE_7__.useState)(),
|
|
|
_useState2 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_5___default()(_useState, 2),
|
|
|
formValue = _useState2[0],
|
|
|
setFormValue = _useState2[1];
|
|
|
var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_7__.useState)([]),
|
|
|
_useState4 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_5___default()(_useState3, 2),
|
|
|
knowledgeOptions = _useState4[0],
|
|
|
setKnowledgeOptions = _useState4[1];
|
|
|
var _useState5 = (0,react__WEBPACK_IMPORTED_MODULE_7__.useState)([]),
|
|
|
_useState6 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_5___default()(_useState5, 2),
|
|
|
uploadData = _useState6[0],
|
|
|
setUploadData = _useState6[1];
|
|
|
var _useReducer = (0,react__WEBPACK_IMPORTED_MODULE_7__.useReducer)(reducer, initialState),
|
|
|
_useReducer2 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_5___default()(_useReducer, 2),
|
|
|
state = _useReducer2[0],
|
|
|
dispatch = _useReducer2[1];
|
|
|
var loading = state.loading,
|
|
|
data = state.data,
|
|
|
user = state.user,
|
|
|
disciplines = state.disciplines,
|
|
|
dicts = state.dicts,
|
|
|
status = state.status;
|
|
|
var hack_sets = data === null || data === void 0 ? void 0 : data.hack_sets;
|
|
|
var test_set_average = data === null || data === void 0 || (_data$hack = data.hack) === null || _data$hack === void 0 ? void 0 : _data$hack.test_set_average;
|
|
|
var _getJsonFromUrl = (0,_utils_util__WEBPACK_IMPORTED_MODULE_19__/* .getJsonFromUrl */ .oP)(),
|
|
|
callback_url = _getJsonFromUrl.callback_url,
|
|
|
express_id = _getJsonFromUrl.express_id,
|
|
|
score = _getJsonFromUrl.score,
|
|
|
question_id = _getJsonFromUrl.question_id,
|
|
|
type = _getJsonFromUrl.type;
|
|
|
var _useState7 = (0,react__WEBPACK_IMPORTED_MODULE_7__.useState)([]),
|
|
|
_useState8 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_5___default()(_useState7, 2),
|
|
|
MyGroup = _useState8[0],
|
|
|
setMyGroup = _useState8[1];
|
|
|
var _useState9 = (0,react__WEBPACK_IMPORTED_MODULE_7__.useState)(false),
|
|
|
_useState10 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_5___default()(_useState9, 2),
|
|
|
ischecked = _useState10[0],
|
|
|
setischecked = _useState10[1];
|
|
|
var _useState11 = (0,react__WEBPACK_IMPORTED_MODULE_7__.useState)(false),
|
|
|
_useState12 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_5___default()(_useState11, 2),
|
|
|
isshows = _useState12[0],
|
|
|
setisshows = _useState12[1];
|
|
|
var isProgram = type === '1';
|
|
|
var categorys = (0,react__WEBPACK_IMPORTED_MODULE_7__.useMemo)(function () {
|
|
|
var rs = [];
|
|
|
if (disciplines) {
|
|
|
(0,_util__WEBPACK_IMPORTED_MODULE_9__/* .getDisciplineOptions */ .D0)(disciplines, rs);
|
|
|
}
|
|
|
return rs;
|
|
|
}, [disciplines]);
|
|
|
var initData = (0,react__WEBPACK_IMPORTED_MODULE_7__.useCallback)( /*#__PURE__*/_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_4___default()( /*#__PURE__*/_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_3___default()().mark(function _callee() {
|
|
|
var timeStamp,
|
|
|
discips,
|
|
|
response,
|
|
|
rs,
|
|
|
res,
|
|
|
category,
|
|
|
_user,
|
|
|
code,
|
|
|
language,
|
|
|
_hack_sets,
|
|
|
description,
|
|
|
difficult,
|
|
|
name,
|
|
|
open_or_not,
|
|
|
sub_discipline_id,
|
|
|
tag_discipline_id,
|
|
|
analysis,
|
|
|
time_limit,
|
|
|
_test_set_average,
|
|
|
test_set_score,
|
|
|
_status,
|
|
|
tag_discipline_ids,
|
|
|
item_banks_group_id,
|
|
|
_res$is_file,
|
|
|
is_file,
|
|
|
hide_actual_output,
|
|
|
code_compile_score,
|
|
|
languages,
|
|
|
is_my,
|
|
|
codes,
|
|
|
submit_rule,
|
|
|
_getDisciplineIds,
|
|
|
_getDisciplineIds2,
|
|
|
ids,
|
|
|
dictData,
|
|
|
new_hack_sets,
|
|
|
_getJsonFromUrl2,
|
|
|
lastedUpdateTime,
|
|
|
newCodes,
|
|
|
_tagIds$split,
|
|
|
_tagIds$split2,
|
|
|
_yield$getUser,
|
|
|
_user2,
|
|
|
_getJsonFromUrl3,
|
|
|
_difficult,
|
|
|
_sub_discipline_id,
|
|
|
_tag_discipline_id,
|
|
|
tagIds,
|
|
|
banksIds,
|
|
|
_getDisciplineIds3,
|
|
|
_getDisciplineIds4,
|
|
|
_ids,
|
|
|
_dictData,
|
|
|
bankstime,
|
|
|
_args = arguments;
|
|
|
return _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_3___default()().wrap(function _callee$(_context) {
|
|
|
while (1) switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
timeStamp = _args.length > 0 && _args[0] !== undefined ? _args[0] : 0;
|
|
|
discips = disciplines;
|
|
|
if (!(discips.length === 0)) {
|
|
|
_context.next = 7;
|
|
|
break;
|
|
|
}
|
|
|
_context.next = 5;
|
|
|
return (0,_service__WEBPACK_IMPORTED_MODULE_13__/* .getDisciplines */ .d1)('new_question');
|
|
|
case 5:
|
|
|
response = _context.sent;
|
|
|
discips = response.disciplines;
|
|
|
case 7:
|
|
|
if (!id) {
|
|
|
_context.next = 15;
|
|
|
break;
|
|
|
}
|
|
|
rs = {
|
|
|
disciplines: discips
|
|
|
};
|
|
|
_context.next = 11;
|
|
|
return (0,_service__WEBPACK_IMPORTED_MODULE_13__/* .getProgrammingTopic */ .fu)(id);
|
|
|
case 11:
|
|
|
res = _context.sent;
|
|
|
if (res.message) {
|
|
|
if (res.status === '401') {
|
|
|
// history.push('/user/login')
|
|
|
document.location.href = '/user/login';
|
|
|
}
|
|
|
} else {
|
|
|
// console.log(res.hack_sets, 'response1')
|
|
|
category = res.category, _user = res.user, code = res.code, language = res.language, _hack_sets = res.hack_sets, description = res.description, difficult = res.difficult, name = res.name, open_or_not = res.open_or_not, sub_discipline_id = res.sub_discipline_id, tag_discipline_id = res.tag_discipline_id, analysis = res.analysis, time_limit = res.time_limit, _test_set_average = res.test_set_average, test_set_score = res.test_set_score, _status = res.status, tag_discipline_ids = res.tag_discipline_ids, item_banks_group_id = res.item_banks_group_id, _res$is_file = res.is_file, is_file = _res$is_file === void 0 ? false : _res$is_file, hide_actual_output = res.hide_actual_output, code_compile_score = res.code_compile_score, languages = res.languages, is_my = res.is_my, codes = res.codes, submit_rule = res.submit_rule; //
|
|
|
_getDisciplineIds = (0,_util__WEBPACK_IMPORTED_MODULE_9__/* .getDisciplineIds */ .y3)(discips, sub_discipline_id), _getDisciplineIds2 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_5___default()(_getDisciplineIds, 2), ids = _getDisciplineIds2[0], dictData = _getDisciplineIds2[1];
|
|
|
setischecked(hide_actual_output);
|
|
|
// console.log('----',hack_sets);
|
|
|
new_hack_sets = is_file ? [{
|
|
|
input: '',
|
|
|
output: '',
|
|
|
score: 100,
|
|
|
position: 1
|
|
|
}] : _hack_sets;
|
|
|
if (is_file) {
|
|
|
setUploadData(_hack_sets);
|
|
|
form.setFieldsValue({
|
|
|
'hack_sets': new_hack_sets
|
|
|
});
|
|
|
} else {
|
|
|
setUploadData([]);
|
|
|
}
|
|
|
|
|
|
//@ts-ignore
|
|
|
_getJsonFromUrl2 = (0,_utils_util__WEBPACK_IMPORTED_MODULE_19__/* .getJsonFromUrl */ .oP)(), lastedUpdateTime = _getJsonFromUrl2.lastedUpdateTime;
|
|
|
newCodes = codes === null || codes === void 0 ? void 0 : codes.map(function (e) {
|
|
|
return _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, e), {}, {
|
|
|
code: js_base64__WEBPACK_IMPORTED_MODULE_11__.Base64.decode(e === null || e === void 0 ? void 0 : e.code)
|
|
|
});
|
|
|
});
|
|
|
rs = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, rs), {}, {
|
|
|
loading: false,
|
|
|
user: _user,
|
|
|
dicts: dictData,
|
|
|
status: _status,
|
|
|
lastedUpdateTime: timeStamp ? timeStamp : lastedUpdateTime ? lastedUpdateTime : 0,
|
|
|
data: {
|
|
|
hack_codes: {
|
|
|
language: language,
|
|
|
code: js_base64__WEBPACK_IMPORTED_MODULE_11__.Base64.decode(code)
|
|
|
},
|
|
|
hack: {
|
|
|
category: category,
|
|
|
difficult: difficult,
|
|
|
name: name,
|
|
|
description: description,
|
|
|
open_or_not: open_or_not,
|
|
|
time_limit: time_limit,
|
|
|
test_set_average: _test_set_average,
|
|
|
test_set_score: test_set_score,
|
|
|
sub_discipline_id: ids,
|
|
|
tag_discipline_ids: tag_discipline_ids,
|
|
|
languages: languages,
|
|
|
score: score || 1,
|
|
|
item_banks_group_ids: item_banks_group_id,
|
|
|
is_file: is_file,
|
|
|
is_my: is_my,
|
|
|
code_compile_score: code_compile_score,
|
|
|
analysis: analysis,
|
|
|
submit_rule: submit_rule
|
|
|
},
|
|
|
hack_sets: new_hack_sets,
|
|
|
tags: tag_discipline_ids,
|
|
|
codes: newCodes
|
|
|
}
|
|
|
});
|
|
|
if (parseInt(code_compile_score) > 0) {
|
|
|
setisshows(true);
|
|
|
}
|
|
|
dispatch({
|
|
|
type: Types.SET_INITAL_DATA,
|
|
|
payload: rs
|
|
|
});
|
|
|
setFormValue({
|
|
|
hack: {
|
|
|
category: category,
|
|
|
difficult: difficult,
|
|
|
name: name,
|
|
|
description: description,
|
|
|
open_or_not: open_or_not,
|
|
|
time_limit: time_limit,
|
|
|
test_set_average: _test_set_average,
|
|
|
test_set_score: test_set_score,
|
|
|
sub_discipline_id: ids,
|
|
|
tag_discipline_ids: tag_discipline_ids,
|
|
|
score: score || 1,
|
|
|
item_banks_group_ids: item_banks_group_id,
|
|
|
is_file: is_file,
|
|
|
analysis: analysis
|
|
|
},
|
|
|
codes: newCodes
|
|
|
});
|
|
|
handleSetKnowledge(ids === null || ids === void 0 ? void 0 : ids[0], ids === null || ids === void 0 ? void 0 : ids[1], discips);
|
|
|
}
|
|
|
_context.next = 25;
|
|
|
break;
|
|
|
case 15:
|
|
|
_context.next = 17;
|
|
|
return (0,_service__WEBPACK_IMPORTED_MODULE_13__/* .getUser */ .PR)();
|
|
|
case 17:
|
|
|
_yield$getUser = _context.sent;
|
|
|
_user2 = _yield$getUser.user;
|
|
|
//@ts-ignore
|
|
|
_getJsonFromUrl3 = (0,_utils_util__WEBPACK_IMPORTED_MODULE_19__/* .getJsonFromUrl */ .oP)(), _difficult = _getJsonFromUrl3.difficult, _sub_discipline_id = _getJsonFromUrl3.sub_discipline_id, _tag_discipline_id = _getJsonFromUrl3.tag_discipline_id, tagIds = _getJsonFromUrl3.tagIds, banksIds = _getJsonFromUrl3.banksIds;
|
|
|
_getDisciplineIds3 = (0,_util__WEBPACK_IMPORTED_MODULE_9__/* .getDisciplineIds */ .y3)(discips, parseInt(_sub_discipline_id, 10)), _getDisciplineIds4 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_5___default()(_getDisciplineIds3, 2), _ids = _getDisciplineIds4[0], _dictData = _getDisciplineIds4[1];
|
|
|
bankstime = [Number(banksIds)];
|
|
|
dispatch({
|
|
|
type: Types.SET_INITAL_DATA,
|
|
|
payload: {
|
|
|
loading: false,
|
|
|
user: _user2,
|
|
|
disciplines: discips,
|
|
|
status: 0,
|
|
|
dicts: _dictData,
|
|
|
data: {
|
|
|
hack_codes: {
|
|
|
language: 'C',
|
|
|
code: ''
|
|
|
},
|
|
|
hack: {
|
|
|
category: null,
|
|
|
difficult: parseInt(_difficult, 10),
|
|
|
time_limit: 3,
|
|
|
description: '',
|
|
|
test_set_score: true,
|
|
|
test_set_average: true,
|
|
|
open_or_not: true,
|
|
|
sub_discipline_id: _ids,
|
|
|
tag_discipline_id: tagIds && (tagIds === null || tagIds === void 0 || (_tagIds$split = tagIds.split(',')) === null || _tagIds$split === void 0 ? void 0 : _tagIds$split.map(function (x) {
|
|
|
return Number(x);
|
|
|
})),
|
|
|
name: '',
|
|
|
item_banks_group_ids: bankstime,
|
|
|
is_file: false
|
|
|
},
|
|
|
tags: _tag_discipline_id ? _tag_discipline_id === null || _tag_discipline_id === void 0 ? void 0 : _tag_discipline_id.split(',').map(function (t) {
|
|
|
return parseInt(t, 10);
|
|
|
}) : [],
|
|
|
hack_sets: [{
|
|
|
input: '',
|
|
|
output: '',
|
|
|
score: 100,
|
|
|
position: 1
|
|
|
}]
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
setFormValue({
|
|
|
hack: {
|
|
|
category: null,
|
|
|
difficult: parseInt(_difficult, 10),
|
|
|
time_limit: 3,
|
|
|
description: '',
|
|
|
test_set_average: true,
|
|
|
open_or_not: true,
|
|
|
sub_discipline_id: _ids,
|
|
|
tag_discipline_id: tagIds && (tagIds === null || tagIds === void 0 || (_tagIds$split2 = tagIds.split(',')) === null || _tagIds$split2 === void 0 ? void 0 : _tagIds$split2.map(function (x) {
|
|
|
return Number(x);
|
|
|
})),
|
|
|
name: '',
|
|
|
item_banks_group_id: bankstime,
|
|
|
is_file: false
|
|
|
}
|
|
|
});
|
|
|
handleSetKnowledge(_ids === null || _ids === void 0 ? void 0 : _ids[0], _ids === null || _ids === void 0 ? void 0 : _ids[1], discips);
|
|
|
case 25:
|
|
|
case "end":
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}, _callee);
|
|
|
})), [id, disciplines]);
|
|
|
(0,react__WEBPACK_IMPORTED_MODULE_7__.useEffect)(function () {
|
|
|
try {
|
|
|
initData();
|
|
|
} catch (error) {
|
|
|
console.log(error, '----');
|
|
|
// history.replace('/user/login', { from: location.pathname })
|
|
|
}
|
|
|
}, []);
|
|
|
(0,react__WEBPACK_IMPORTED_MODULE_7__.useEffect)(function () {
|
|
|
//获取我的分组信息
|
|
|
function init() {
|
|
|
return _init.apply(this, arguments);
|
|
|
}
|
|
|
function _init() {
|
|
|
_init = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_4___default()( /*#__PURE__*/_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_3___default()().mark(function _callee2() {
|
|
|
var data;
|
|
|
return _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_3___default()().wrap(function _callee2$(_context2) {
|
|
|
while (1) switch (_context2.prev = _context2.next) {
|
|
|
case 0:
|
|
|
_context2.next = 2;
|
|
|
return (0,_utils_fetch__WEBPACK_IMPORTED_MODULE_18__/* .get */ .U2)('item_banks_groups/mine.json');
|
|
|
case 2:
|
|
|
data = _context2.sent;
|
|
|
setMyGroup(data);
|
|
|
case 4:
|
|
|
case "end":
|
|
|
return _context2.stop();
|
|
|
}
|
|
|
}, _callee2);
|
|
|
}));
|
|
|
return _init.apply(this, arguments);
|
|
|
}
|
|
|
init();
|
|
|
}, []);
|
|
|
var handleSetKnowledge = function handleSetKnowledge(id, subId, discips) {
|
|
|
var _discips$find;
|
|
|
var options = discips === null || discips === void 0 || (_discips$find = discips.find(function (item) {
|
|
|
return item.id === id;
|
|
|
})) === null || _discips$find === void 0 || (_discips$find = _discips$find.sub_disciplines) === null || _discips$find === void 0 || (_discips$find = _discips$find.find(function (subItem) {
|
|
|
return subItem.id === subId;
|
|
|
})) === null || _discips$find === void 0 ? void 0 : _discips$find.tag_disciplines;
|
|
|
|
|
|
// setKnowledgeOptions(options || []);
|
|
|
};
|
|
|
function onSubmit(_x, _x2, _x3) {
|
|
|
return _onSubmit.apply(this, arguments);
|
|
|
}
|
|
|
function _onSubmit() {
|
|
|
_onSubmit = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_4___default()( /*#__PURE__*/_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_3___default()().mark(function _callee5(values, type, is_cover) {
|
|
|
var _values, hack_sets, hack_codes, hack, tags, codes, update_hack_sets, new_hack_sets, sumScore, new_list, _iterator, _step, item, newCodes, res, _yield$updateExercise, _status2, _yield$addProgramming, identifier, exam_identifier, _res, _yield$addExerciseQue, _status3;
|
|
|
return _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_3___default()().wrap(function _callee5$(_context5) {
|
|
|
while (1) switch (_context5.prev = _context5.next) {
|
|
|
case 0:
|
|
|
_values = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, values), hack_sets = _values.hack_sets, hack_codes = _values.hack_codes, hack = _values.hack, tags = _values.tags, codes = _values.codes;
|
|
|
hack.hide_actual_output = ischecked;
|
|
|
update_hack_sets = [];
|
|
|
new_hack_sets = [];
|
|
|
sumScore = 0;
|
|
|
new_list = hack !== null && hack !== void 0 && hack.is_file ? uploadData.map(function (e, i) {
|
|
|
return _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, e), {}, {
|
|
|
position: i + 1
|
|
|
});
|
|
|
}) : hack_sets.map(function (e) {
|
|
|
return _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, e), {}, {
|
|
|
is_file: false
|
|
|
});
|
|
|
});
|
|
|
_iterator = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_createForOfIteratorHelper_js__WEBPACK_IMPORTED_MODULE_1___default()(new_list);
|
|
|
try {
|
|
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
|
item = _step.value;
|
|
|
sumScore += item.score;
|
|
|
if (item.id && item.id >= 0) {
|
|
|
update_hack_sets.push(item);
|
|
|
} else {
|
|
|
new_hack_sets.push(item);
|
|
|
}
|
|
|
}
|
|
|
} catch (err) {
|
|
|
_iterator.e(err);
|
|
|
} finally {
|
|
|
_iterator.f();
|
|
|
}
|
|
|
if (new_list !== null && new_list !== void 0 && new_list.length) {
|
|
|
_context5.next = 11;
|
|
|
break;
|
|
|
}
|
|
|
antd__WEBPACK_IMPORTED_MODULE_32__/* ["default"] */ .ZP.error('测试集不能为空');
|
|
|
return _context5.abrupt("return");
|
|
|
case 11:
|
|
|
sumScore += parseInt(hack.code_compile_score || 0);
|
|
|
if (!(sumScore !== 100 && !hack.test_set_score)) {
|
|
|
_context5.next = 15;
|
|
|
break;
|
|
|
}
|
|
|
antd__WEBPACK_IMPORTED_MODULE_32__/* ["default"] */ .ZP.error('测试集的评分占比之和必须等于100');
|
|
|
return _context5.abrupt("return");
|
|
|
case 15:
|
|
|
if (!(new_list !== null && new_list !== void 0 && new_list.some(function (e) {
|
|
|
return !e.output;
|
|
|
}))) {
|
|
|
_context5.next = 18;
|
|
|
break;
|
|
|
}
|
|
|
antd__WEBPACK_IMPORTED_MODULE_32__/* ["default"] */ .ZP.error('测试集输出不能为空');
|
|
|
return _context5.abrupt("return");
|
|
|
case 18:
|
|
|
newCodes = {};
|
|
|
if (isProgram) {
|
|
|
codes === null || codes === void 0 || codes.forEach(function (e) {
|
|
|
newCodes[e.language] = e !== null && e !== void 0 && e.code ? js_base64__WEBPACK_IMPORTED_MODULE_11__.Base64.encode(e === null || e === void 0 ? void 0 : e.code) : '';
|
|
|
});
|
|
|
} else {
|
|
|
hack_codes.code = js_base64__WEBPACK_IMPORTED_MODULE_11__.Base64.encode(hack_codes === null || hack_codes === void 0 ? void 0 : hack_codes.code);
|
|
|
}
|
|
|
hack.sub_discipline_id = hack.sub_discipline_id[1];
|
|
|
dispatch({
|
|
|
type: Types.SET_LOADING,
|
|
|
payload: true
|
|
|
});
|
|
|
if (!callback_url) {
|
|
|
hack.score = hack.difficult * 100;
|
|
|
}
|
|
|
//编辑
|
|
|
if (!id) {
|
|
|
_context5.next = 50;
|
|
|
break;
|
|
|
}
|
|
|
_context5.next = 26;
|
|
|
return (0,_service__WEBPACK_IMPORTED_MODULE_13__/* .updateProgrammingTopic */ .l_)(id, {
|
|
|
hack: hack,
|
|
|
hack_codes: hack_codes,
|
|
|
hack_sets: new_hack_sets,
|
|
|
update_hack_sets: update_hack_sets,
|
|
|
tags: tags,
|
|
|
is_cover: is_cover,
|
|
|
languages: hack.languages,
|
|
|
codes: newCodes
|
|
|
});
|
|
|
case 26:
|
|
|
if (!callback_url) {
|
|
|
_context5.next = 45;
|
|
|
break;
|
|
|
}
|
|
|
_context5.next = 29;
|
|
|
return (0,_service__WEBPACK_IMPORTED_MODULE_13__/* .publishProgrammingTopic */ .j2)(id);
|
|
|
case 29:
|
|
|
if (!callback_url.includes('paperlibrary')) {
|
|
|
_context5.next = 35;
|
|
|
break;
|
|
|
}
|
|
|
_context5.next = 32;
|
|
|
return (0,_service_paperlibrary__WEBPACK_IMPORTED_MODULE_24__/* .createOrModifyQuestion */ .oF)({
|
|
|
id: express_id,
|
|
|
question_id: question_id,
|
|
|
item_type: _utils_enum__WEBPACK_IMPORTED_MODULE_25__/* .QuestionType */ .c.Program,
|
|
|
name: hack.name,
|
|
|
question_score: hack.score,
|
|
|
difficulty: hack.difficult,
|
|
|
sub_discipline_id: hack.sub_discipline_id,
|
|
|
tag_discipline_ids: hack.tag_discipline_ids,
|
|
|
item_banks_group_ids: hack.item_banks_group_ids,
|
|
|
analysis: hack.analysis
|
|
|
|
|
|
// identifier: id
|
|
|
});
|
|
|
case 32:
|
|
|
res = _context5.sent;
|
|
|
if (res.status === 0) {
|
|
|
umi__WEBPACK_IMPORTED_MODULE_10__.history.replace(callback_url);
|
|
|
}
|
|
|
return _context5.abrupt("return");
|
|
|
case 35:
|
|
|
_context5.next = 37;
|
|
|
return (0,_service__WEBPACK_IMPORTED_MODULE_13__/* .updateExerciseQuestion */ .GM)(question_id, {
|
|
|
question_type: 6,
|
|
|
question_score: hack.score,
|
|
|
question_title: hack.name,
|
|
|
description: hack.description,
|
|
|
sub_discipline_id: hack.sub_discipline_id,
|
|
|
tag_discipline_ids: hack.tag_discipline_ids,
|
|
|
item_banks_group_ids: hack.item_banks_group_ids,
|
|
|
identifier: id,
|
|
|
analysis: hack.analysis
|
|
|
});
|
|
|
case 37:
|
|
|
_yield$updateExercise = _context5.sent;
|
|
|
_status2 = _yield$updateExercise.status;
|
|
|
if (!(_status2 === 0)) {
|
|
|
_context5.next = 43;
|
|
|
break;
|
|
|
}
|
|
|
if (!(type === 'start')) {
|
|
|
_context5.next = 42;
|
|
|
break;
|
|
|
}
|
|
|
return _context5.abrupt("return");
|
|
|
case 42:
|
|
|
umi__WEBPACK_IMPORTED_MODULE_10__.history.replace(callback_url);
|
|
|
case 43:
|
|
|
_context5.next = 47;
|
|
|
break;
|
|
|
case 45:
|
|
|
// window.location.reload()
|
|
|
antd__WEBPACK_IMPORTED_MODULE_32__/* ["default"] */ .ZP.success('保存成功');
|
|
|
initData(getTimeStamp());
|
|
|
case 47:
|
|
|
dispatch({
|
|
|
type: Types.SET_LOADING,
|
|
|
payload: false
|
|
|
});
|
|
|
_context5.next = 80;
|
|
|
break;
|
|
|
case 50:
|
|
|
_context5.next = 52;
|
|
|
return (0,_service__WEBPACK_IMPORTED_MODULE_13__/* .addProgrammingTopic */ .zQ)({
|
|
|
hack: hack,
|
|
|
hack_codes: hack_codes,
|
|
|
hack_sets: new_list,
|
|
|
tags: tags,
|
|
|
examination_bank_id: express_id || null
|
|
|
});
|
|
|
case 52:
|
|
|
_yield$addProgramming = _context5.sent;
|
|
|
identifier = _yield$addProgramming.identifier;
|
|
|
exam_identifier = _yield$addProgramming.exam_identifier;
|
|
|
dispatch({
|
|
|
type: Types.SET_LOADING,
|
|
|
payload: false
|
|
|
});
|
|
|
if (!(type === 'start')) {
|
|
|
_context5.next = 58;
|
|
|
break;
|
|
|
}
|
|
|
return _context5.abrupt("return");
|
|
|
case 58:
|
|
|
if (!identifier) {
|
|
|
_context5.next = 80;
|
|
|
break;
|
|
|
}
|
|
|
if (callback_url) {
|
|
|
_context5.next = 63;
|
|
|
break;
|
|
|
}
|
|
|
umi__WEBPACK_IMPORTED_MODULE_10__.history.replace("/problems/".concat(identifier, "/edit?lastedUpdateTime=").concat(getTimeStamp()));
|
|
|
_context5.next = 80;
|
|
|
break;
|
|
|
case 63:
|
|
|
_context5.next = 65;
|
|
|
return (0,_service__WEBPACK_IMPORTED_MODULE_13__/* .publishProgrammingTopic */ .j2)(identifier);
|
|
|
case 65:
|
|
|
if (id) {
|
|
|
_context5.next = 79;
|
|
|
break;
|
|
|
}
|
|
|
if (!callback_url.includes('paperlibrary')) {
|
|
|
_context5.next = 72;
|
|
|
break;
|
|
|
}
|
|
|
_context5.next = 69;
|
|
|
return (0,_service_paperlibrary__WEBPACK_IMPORTED_MODULE_24__/* .createOrModifyQuestion */ .oF)({
|
|
|
id: express_id,
|
|
|
item_type: _utils_enum__WEBPACK_IMPORTED_MODULE_25__/* .QuestionType */ .c.Program,
|
|
|
name: hack.name,
|
|
|
question_score: hack.score,
|
|
|
difficulty: hack.difficult,
|
|
|
sub_discipline_id: hack.sub_discipline_id,
|
|
|
tag_discipline_ids: hack.tag_discipline_ids,
|
|
|
identifier: exam_identifier,
|
|
|
analysis: hack.analysis
|
|
|
});
|
|
|
case 69:
|
|
|
_res = _context5.sent;
|
|
|
if (_res.status === 0) {
|
|
|
umi__WEBPACK_IMPORTED_MODULE_10__.history.replace(callback_url);
|
|
|
}
|
|
|
return _context5.abrupt("return");
|
|
|
case 72:
|
|
|
_context5.next = 74;
|
|
|
return (0,_service__WEBPACK_IMPORTED_MODULE_13__/* .addExerciseQuestion */ .MK)(parseInt(express_id, 10), {
|
|
|
question_type: 6,
|
|
|
question_score: hack.score,
|
|
|
question_title: hack.name,
|
|
|
identifier: identifier,
|
|
|
tag_discipline_ids: hack.tag_discipline_ids,
|
|
|
analysis: hack.analysis
|
|
|
});
|
|
|
case 74:
|
|
|
_yield$addExerciseQue = _context5.sent;
|
|
|
_status3 = _yield$addExerciseQue.status;
|
|
|
if (_status3 === 0) {
|
|
|
umi__WEBPACK_IMPORTED_MODULE_10__.history.replace(callback_url);
|
|
|
}
|
|
|
_context5.next = 80;
|
|
|
break;
|
|
|
case 79:
|
|
|
umi__WEBPACK_IMPORTED_MODULE_10__.history.replace(callback_url);
|
|
|
case 80:
|
|
|
case "end":
|
|
|
return _context5.stop();
|
|
|
}
|
|
|
}, _callee5);
|
|
|
}));
|
|
|
return _onSubmit.apply(this, arguments);
|
|
|
}
|
|
|
function onPublish() {
|
|
|
form.submit();
|
|
|
setTimeout( /*#__PURE__*/_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_4___default()( /*#__PURE__*/_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_3___default()().mark(function _callee3() {
|
|
|
var response;
|
|
|
return _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_3___default()().wrap(function _callee3$(_context3) {
|
|
|
while (1) switch (_context3.prev = _context3.next) {
|
|
|
case 0:
|
|
|
_context3.next = 2;
|
|
|
return (0,_service__WEBPACK_IMPORTED_MODULE_13__/* .publishProgrammingTopic */ .j2)(id);
|
|
|
case 2:
|
|
|
response = _context3.sent;
|
|
|
if (response.status === 0) {
|
|
|
antd__WEBPACK_IMPORTED_MODULE_32__/* ["default"] */ .ZP.success('发布成功');
|
|
|
dispatch({
|
|
|
type: Types.SET_STATUS,
|
|
|
payload: 1
|
|
|
});
|
|
|
} else {
|
|
|
antd__WEBPACK_IMPORTED_MODULE_32__/* ["default"] */ .ZP.info(response.message);
|
|
|
}
|
|
|
case 4:
|
|
|
case "end":
|
|
|
return _context3.stop();
|
|
|
}
|
|
|
}, _callee3);
|
|
|
})), 400);
|
|
|
}
|
|
|
function onCancelPublish() {
|
|
|
return _onCancelPublish.apply(this, arguments);
|
|
|
}
|
|
|
function _onCancelPublish() {
|
|
|
_onCancelPublish = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_4___default()( /*#__PURE__*/_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_3___default()().mark(function _callee6() {
|
|
|
var response;
|
|
|
return _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_3___default()().wrap(function _callee6$(_context6) {
|
|
|
while (1) switch (_context6.prev = _context6.next) {
|
|
|
case 0:
|
|
|
_context6.next = 2;
|
|
|
return (0,_service__WEBPACK_IMPORTED_MODULE_13__/* .cancelPublishProgrammingTopic */ .ZS)(id);
|
|
|
case 2:
|
|
|
response = _context6.sent;
|
|
|
if (response.status === 0) {
|
|
|
antd__WEBPACK_IMPORTED_MODULE_32__/* ["default"] */ .ZP.success('撤销发布成功');
|
|
|
dispatch({
|
|
|
type: Types.SET_STATUS,
|
|
|
payload: 0
|
|
|
});
|
|
|
} else {
|
|
|
antd__WEBPACK_IMPORTED_MODULE_32__/* ["default"] */ .ZP.info(response.message);
|
|
|
}
|
|
|
case 4:
|
|
|
case "end":
|
|
|
return _context6.stop();
|
|
|
}
|
|
|
}, _callee6);
|
|
|
}));
|
|
|
return _onCancelPublish.apply(this, arguments);
|
|
|
}
|
|
|
function onTriggerPublish() {
|
|
|
//立即发布
|
|
|
if (status === 0) {
|
|
|
confirm({
|
|
|
title: '提示',
|
|
|
content: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)(react__WEBPACK_IMPORTED_MODULE_7__.Fragment, {
|
|
|
children: [" ", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)("div", {
|
|
|
children: "\u53D1\u5E03\u540E\u5373\u53EF\u5E94\u7528\u5230\u81EA\u5DF1\u7BA1\u7406\u7684\u8BFE\u5802"
|
|
|
}), " ", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)("div", {
|
|
|
children: " \u662F\u5426\u786E\u8BA4\u53D1\u5E03?"
|
|
|
}), " "]
|
|
|
}),
|
|
|
okText: '确定',
|
|
|
cancelText: '取消',
|
|
|
onOk: function onOk() {
|
|
|
onPublish();
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
confirm({
|
|
|
title: '提示',
|
|
|
content: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)("p", {
|
|
|
children: "\u662F\u5426\u786E\u8BA4\u64A4\u9500\u53D1\u5E03\uFF1F"
|
|
|
}),
|
|
|
okText: '确定',
|
|
|
cancelText: '取消',
|
|
|
onOk: function onOk() {
|
|
|
onCancelPublish();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
function onChallenge() {
|
|
|
return _onChallenge.apply(this, arguments);
|
|
|
}
|
|
|
function _onChallenge() {
|
|
|
_onChallenge = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_4___default()( /*#__PURE__*/_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_3___default()().mark(function _callee8() {
|
|
|
return _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_3___default()().wrap(function _callee8$(_context8) {
|
|
|
while (1) switch (_context8.prev = _context8.next) {
|
|
|
case 0:
|
|
|
_context8.t0 = onSubmit;
|
|
|
_context8.next = 3;
|
|
|
return form.getFieldValue();
|
|
|
case 3:
|
|
|
_context8.t1 = _context8.sent;
|
|
|
(0, _context8.t0)(_context8.t1, 'start');
|
|
|
setTimeout( /*#__PURE__*/_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_4___default()( /*#__PURE__*/_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_3___default()().mark(function _callee7() {
|
|
|
var _yield$startChallenge, identifier;
|
|
|
return _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_3___default()().wrap(function _callee7$(_context7) {
|
|
|
while (1) switch (_context7.prev = _context7.next) {
|
|
|
case 0:
|
|
|
_context7.next = 2;
|
|
|
return (0,_service__WEBPACK_IMPORTED_MODULE_13__/* .startChallenge */ .uE)(id);
|
|
|
case 2:
|
|
|
_yield$startChallenge = _context7.sent;
|
|
|
identifier = _yield$startChallenge.identifier;
|
|
|
if (isProgram) {
|
|
|
window.location.href = "/myproblems/".concat(identifier, "?type=1");
|
|
|
} else {
|
|
|
window.location.href = "/myproblems/".concat(identifier);
|
|
|
}
|
|
|
case 5:
|
|
|
case "end":
|
|
|
return _context7.stop();
|
|
|
}
|
|
|
}, _callee7);
|
|
|
})), 400);
|
|
|
case 6:
|
|
|
case "end":
|
|
|
return _context8.stop();
|
|
|
}
|
|
|
}, _callee8);
|
|
|
}));
|
|
|
return _onChallenge.apply(this, arguments);
|
|
|
}
|
|
|
function onBack() {
|
|
|
if (callback_url) {
|
|
|
umi__WEBPACK_IMPORTED_MODULE_10__.history.replace(callback_url);
|
|
|
} else {
|
|
|
if (isProgram) {
|
|
|
var _localStorage$getItem;
|
|
|
var item = (_localStorage$getItem = localStorage.getItem('program_homework')) === null || _localStorage$getItem === void 0 ? void 0 : _localStorage$getItem.split(',');
|
|
|
umi__WEBPACK_IMPORTED_MODULE_10__.history.push("/classrooms/".concat(item === null || item === void 0 ? void 0 : item[0], "/program_homework/").concat(item === null || item === void 0 ? void 0 : item[1], "/detail"));
|
|
|
} else {
|
|
|
umi__WEBPACK_IMPORTED_MODULE_10__.history.replace("/problemset");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
var handleUploadRatio = function handleUploadRatio(testSetData) {
|
|
|
var code_compile_score = parseInt(form.getFieldValue('hack').code_compile_score) || 0;
|
|
|
var score = Math.floor((100 - code_compile_score) / testSetData.length);
|
|
|
var lastScore = score + (100 - code_compile_score) % testSetData.length;
|
|
|
// const score = Math.floor(100 / testSetData.length)
|
|
|
// const lastScore = score + 100 % testSetData.length
|
|
|
|
|
|
testSetData = testSetData.map(function (item, index) {
|
|
|
if (index === testSetData.length - 1) {
|
|
|
return _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, item), {}, {
|
|
|
score: lastScore
|
|
|
});
|
|
|
}
|
|
|
return _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, item), {}, {
|
|
|
score: score
|
|
|
});
|
|
|
});
|
|
|
setUploadData(testSetData);
|
|
|
};
|
|
|
function onChangeScore(e) {
|
|
|
if (!e.target.value) {
|
|
|
handleUploadRatio(uploadData);
|
|
|
}
|
|
|
dispatch({
|
|
|
type: Types.SET_INITAL_DATA,
|
|
|
payload: {
|
|
|
data: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, data), {}, {
|
|
|
hack: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, data.hack), {}, {
|
|
|
test_set_score: e.target.value
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
function onChangeFile(e) {
|
|
|
dispatch({
|
|
|
type: Types.SET_INITAL_DATA,
|
|
|
payload: {
|
|
|
data: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, data), {}, {
|
|
|
hack: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, data.hack), {}, {
|
|
|
is_file: e.target.value
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
function onChangehide(e) {
|
|
|
setischecked(e.target.checked);
|
|
|
}
|
|
|
function onChangeAverage(e) {
|
|
|
var value = e.target.value;
|
|
|
if (value) {
|
|
|
handleUploadRatio(uploadData);
|
|
|
}
|
|
|
dispatch({
|
|
|
type: Types.SET_INITAL_DATA,
|
|
|
payload: {
|
|
|
data: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, data), {}, {
|
|
|
hack: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, data.hack), {}, {
|
|
|
test_set_average: value
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
function onAddTestCase() {
|
|
|
var rs = form.getFieldValue('hack_sets');
|
|
|
var by = parseInt(form.getFieldValue('hack').code_compile_score) || 0;
|
|
|
var len = rs.length + 1;
|
|
|
var averageMark = Math.floor((100 - by) / len);
|
|
|
var remainder = (100 - by) % len;
|
|
|
rs.map(function (item, index) {
|
|
|
if (test_set_average) {
|
|
|
item.score = averageMark;
|
|
|
}
|
|
|
item.position = index + 1;
|
|
|
return item;
|
|
|
});
|
|
|
rs.push({
|
|
|
input: '',
|
|
|
output: '',
|
|
|
position: len,
|
|
|
score: test_set_average ? averageMark + remainder : 0
|
|
|
});
|
|
|
form.setFieldsValue({
|
|
|
'hack_sets': rs
|
|
|
});
|
|
|
dispatch({
|
|
|
type: Types.SET_INITAL_DATA,
|
|
|
payload: {
|
|
|
data: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, data), {}, {
|
|
|
hack_sets: rs
|
|
|
})
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
function onAddTestCases() {
|
|
|
var rs = form.getFieldValue('hack_sets');
|
|
|
var by = parseInt(form.getFieldValue('hack').code_compile_score) || 0;
|
|
|
var len = rs.length;
|
|
|
var averageMark = Math.floor((100 - by) / len);
|
|
|
var remainder = (100 - by) % len;
|
|
|
rs.map(function (item, index) {
|
|
|
if (test_set_average) {
|
|
|
item.score = averageMark;
|
|
|
if (index === rs.length - 1) {
|
|
|
item.score = averageMark + remainder;
|
|
|
}
|
|
|
}
|
|
|
item.position = index + 1;
|
|
|
return item;
|
|
|
});
|
|
|
form.setFieldsValue({
|
|
|
'hack_sets': rs
|
|
|
});
|
|
|
dispatch({
|
|
|
type: Types.SET_INITAL_DATA,
|
|
|
payload: {
|
|
|
data: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, data), {}, {
|
|
|
hack_sets: rs
|
|
|
})
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
(0,react__WEBPACK_IMPORTED_MODULE_7__.useEffect)(function () {
|
|
|
if (test_set_average) {
|
|
|
var by = parseInt(form.getFieldValue('hack').code_compile_score) || 0;
|
|
|
var len = hack_sets === null || hack_sets === void 0 ? void 0 : hack_sets.length;
|
|
|
var averageMark = Math.floor((100 - by) / len);
|
|
|
var remainder = (100 - by) % len;
|
|
|
hack_sets === null || hack_sets === void 0 || hack_sets.map(function (item, index) {
|
|
|
item.score = averageMark;
|
|
|
item.position = index + 1;
|
|
|
if (index === len - 1) {
|
|
|
item.score = averageMark + remainder;
|
|
|
}
|
|
|
return item;
|
|
|
});
|
|
|
dispatch({
|
|
|
type: Types.SET_INITAL_DATA,
|
|
|
payload: {
|
|
|
data: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, data), {}, {
|
|
|
hack_sets: hack_sets
|
|
|
})
|
|
|
}
|
|
|
});
|
|
|
form.setFieldsValue({
|
|
|
'hack_sets': hack_sets
|
|
|
});
|
|
|
}
|
|
|
}, [test_set_average]);
|
|
|
function onRemoveTestCase(index) {
|
|
|
var sets = form.getFieldValue('hack_sets');
|
|
|
var by = parseInt(form.getFieldValue('hack').code_compile_score) || 0;
|
|
|
var len = (sets === null || sets === void 0 ? void 0 : sets.length) - 1;
|
|
|
var averageMark = Math.floor((100 - by) / len);
|
|
|
var remainder = (100 - by) % len;
|
|
|
sets.splice(index, 1);
|
|
|
sets === null || sets === void 0 || sets.map(function (item, index) {
|
|
|
if (test_set_average) {
|
|
|
item.score = averageMark;
|
|
|
if (index === len - 1) {
|
|
|
item.score = averageMark + remainder;
|
|
|
}
|
|
|
}
|
|
|
item.position = index + 1;
|
|
|
return item;
|
|
|
});
|
|
|
dispatch({
|
|
|
type: Types.SET_INITAL_DATA,
|
|
|
payload: {
|
|
|
data: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, data), {}, {
|
|
|
hack_sets: sets
|
|
|
})
|
|
|
}
|
|
|
});
|
|
|
form.setFieldsValue({
|
|
|
'hack_sets': sets
|
|
|
});
|
|
|
}
|
|
|
function onChangeLanguage(language) {
|
|
|
dispatch({
|
|
|
type: Types.SET_INITAL_DATA,
|
|
|
payload: {
|
|
|
data: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, data), {}, {
|
|
|
hack_codes: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, data.hack_codes), {}, {
|
|
|
language: language
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
var handleValuesChange = function handleValuesChange(changedValues) {
|
|
|
var _changedValues$hack;
|
|
|
if (changedValues !== null && changedValues !== void 0 && (_changedValues$hack = changedValues.hack) !== null && _changedValues$hack !== void 0 && _changedValues$hack.sub_discipline_id) {
|
|
|
var _changedValues$hack2, _disciplines$find, _form$getFieldsValue;
|
|
|
var _changedValues$hack$s = changedValues === null || changedValues === void 0 || (_changedValues$hack2 = changedValues.hack) === null || _changedValues$hack2 === void 0 ? void 0 : _changedValues$hack2.sub_discipline_id,
|
|
|
_changedValues$hack$s2 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_5___default()(_changedValues$hack$s, 2),
|
|
|
_id = _changedValues$hack$s2[0],
|
|
|
subId = _changedValues$hack$s2[1];
|
|
|
var options = disciplines === null || disciplines === void 0 || (_disciplines$find = disciplines.find(function (item) {
|
|
|
return item.id === _id;
|
|
|
})) === null || _disciplines$find === void 0 || (_disciplines$find = _disciplines$find.sub_disciplines) === null || _disciplines$find === void 0 || (_disciplines$find = _disciplines$find.find(function (subItem) {
|
|
|
return subItem.id === subId;
|
|
|
})) === null || _disciplines$find === void 0 ? void 0 : _disciplines$find.tag_disciplines;
|
|
|
|
|
|
// setKnowledgeOptions(options);
|
|
|
var fieldData = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, form.getFieldsValue()), {}, {
|
|
|
hack: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, (_form$getFieldsValue = form.getFieldsValue()) === null || _form$getFieldsValue === void 0 ? void 0 : _form$getFieldsValue.hack), {}, {
|
|
|
tag_discipline_ids: []
|
|
|
})
|
|
|
});
|
|
|
form.setFieldsValue(fieldData);
|
|
|
setFormValue(fieldData);
|
|
|
} else {
|
|
|
setFormValue(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, form.getFieldsValue()));
|
|
|
}
|
|
|
};
|
|
|
var handleAddKnowledgeFinish = function handleAddKnowledgeFinish(item) {
|
|
|
setKnowledgeOptions([].concat(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_2___default()(knowledgeOptions), [_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, item)]));
|
|
|
};
|
|
|
(0,react__WEBPACK_IMPORTED_MODULE_7__.useEffect)(function () {
|
|
|
var _data$hack2;
|
|
|
if (data !== null && data !== void 0 && (_data$hack2 = data.hack) !== null && _data$hack2 !== void 0 && (_data$hack2 = _data$hack2.sub_discipline_id) !== null && _data$hack2 !== void 0 && _data$hack2[1]) {
|
|
|
var _data$hack3;
|
|
|
getTagData(data === null || data === void 0 || (_data$hack3 = data.hack) === null || _data$hack3 === void 0 || (_data$hack3 = _data$hack3.sub_discipline_id) === null || _data$hack3 === void 0 ? void 0 : _data$hack3[1]);
|
|
|
}
|
|
|
}, [data === null || data === void 0 || (_data$hack4 = data.hack) === null || _data$hack4 === void 0 ? void 0 : _data$hack4.sub_discipline_id]);
|
|
|
//进来的时候 取一次值
|
|
|
var getTagData = /*#__PURE__*/function () {
|
|
|
var _ref3 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_4___default()( /*#__PURE__*/_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_3___default()().mark(function _callee4(id) {
|
|
|
var res;
|
|
|
return _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_3___default()().wrap(function _callee4$(_context4) {
|
|
|
while (1) switch (_context4.prev = _context4.next) {
|
|
|
case 0:
|
|
|
_context4.next = 2;
|
|
|
return (0,_service_exercise__WEBPACK_IMPORTED_MODULE_14__/* .getTagDiscipline */ .YY)({
|
|
|
sub_discipline_id: id
|
|
|
});
|
|
|
case 2:
|
|
|
res = _context4.sent;
|
|
|
setKnowledgeOptions(res.tag_disciplines);
|
|
|
case 4:
|
|
|
case "end":
|
|
|
return _context4.stop();
|
|
|
}
|
|
|
}, _callee4);
|
|
|
}));
|
|
|
return function getTagData(_x4) {
|
|
|
return _ref3.apply(this, arguments);
|
|
|
};
|
|
|
}();
|
|
|
//调用接口 获取knowledgeOptions
|
|
|
function onChangeSubDiscipline(values) {
|
|
|
// getTagData(values?.[1])
|
|
|
var subId = values[1];
|
|
|
var _getDisciplineIds5 = (0,_util__WEBPACK_IMPORTED_MODULE_9__/* .getDisciplineIds */ .y3)(disciplines, subId),
|
|
|
_getDisciplineIds6 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_5___default()(_getDisciplineIds5, 2),
|
|
|
dictData = _getDisciplineIds6[1];
|
|
|
form.setFieldsValue({
|
|
|
tags: []
|
|
|
});
|
|
|
dispatch({
|
|
|
type: Types.SET_INITAL_DATA,
|
|
|
payload: {
|
|
|
dicts: dictData,
|
|
|
data: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, data), {}, {
|
|
|
hack: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, data.hack), {}, {
|
|
|
sub_discipline_id: values
|
|
|
}),
|
|
|
tags: []
|
|
|
})
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
var addUploadFnc = function addUploadFnc(files) {
|
|
|
var _form$getFieldValue;
|
|
|
var isFuc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
|
if (isFuc) {
|
|
|
return function () {
|
|
|
dispatch({
|
|
|
type: Types.SET_INITAL_DATA,
|
|
|
payload: {
|
|
|
data: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, data), {}, {
|
|
|
hack: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, data.hack), {}, {
|
|
|
is_file: true
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
});
|
|
|
form.setFieldsValue({
|
|
|
hack: {
|
|
|
is_file: true
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
var newFiles = files === null || files === void 0 ? void 0 : files.map(function (e) {
|
|
|
return {
|
|
|
input: e.input,
|
|
|
output: e.output,
|
|
|
score: 0,
|
|
|
position: 1
|
|
|
};
|
|
|
});
|
|
|
var sets = (_form$getFieldValue = form.getFieldValue('hack_sets')) === null || _form$getFieldValue === void 0 || (_form$getFieldValue = _form$getFieldValue.filter(function (e) {
|
|
|
return e.input || e.output;
|
|
|
})) === null || _form$getFieldValue === void 0 ? void 0 : _form$getFieldValue.concat(newFiles);
|
|
|
var by = parseInt(form.getFieldValue('hack').code_compile_score) || 0;
|
|
|
var len = sets === null || sets === void 0 ? void 0 : sets.length;
|
|
|
var averageMark = Math.floor((100 - by) / len);
|
|
|
var remainder = (100 - by) % len;
|
|
|
sets === null || sets === void 0 || sets.map(function (item, index) {
|
|
|
if (test_set_average) {
|
|
|
item.score = averageMark;
|
|
|
if (index === len - 1) {
|
|
|
item.score = averageMark + remainder;
|
|
|
}
|
|
|
}
|
|
|
item.position = index + 1;
|
|
|
return item;
|
|
|
});
|
|
|
dispatch({
|
|
|
type: Types.SET_INITAL_DATA,
|
|
|
payload: {
|
|
|
data: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, data), {}, {
|
|
|
hack_sets: sets,
|
|
|
hack: _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, data.hack), {}, {
|
|
|
is_file: false
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
});
|
|
|
form.setFieldsValue({
|
|
|
'hack_sets': sets,
|
|
|
hack: {
|
|
|
is_file: false
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_33__/* ["default"] */ .Z, {
|
|
|
spinning: loading,
|
|
|
delay: 500,
|
|
|
children: !data ? null : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)(react__WEBPACK_IMPORTED_MODULE_7__.Fragment, {
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)("header", {
|
|
|
className: _index_less_modules__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z.header,
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)("div", {
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)("img", {
|
|
|
src: "".concat(_utils_env__WEBPACK_IMPORTED_MODULE_20__/* ["default"] */ .Z.IMG_SERVER, "/images/").concat(user === null || user === void 0 ? void 0 : user.image_url),
|
|
|
alt: "user",
|
|
|
width: 30
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)("span", {
|
|
|
children: user === null || user === void 0 ? void 0 : user.name
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)("h2", {
|
|
|
children: [" ", data === null || data === void 0 ? void 0 : data.hack.name, " "]
|
|
|
}), id ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)("a", {
|
|
|
className: _index_less_modules__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z.btn_back,
|
|
|
onClick: onBack,
|
|
|
children: [" ", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(_ant_design_icons__WEBPACK_IMPORTED_MODULE_34__/* ["default"] */ .Z, {}), "\u9000\u51FA"]
|
|
|
}) : null]
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z, {
|
|
|
form: form,
|
|
|
initialValues: data,
|
|
|
layout: "vertical",
|
|
|
className: _index_less_modules__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z["oj-form-container"],
|
|
|
onValuesChange: handleValuesChange,
|
|
|
onFinish: function onFinish(v, s) {
|
|
|
if (searchParams.get("exercise") && !callback_url.includes('paperlibrary')) {
|
|
|
antd__WEBPACK_IMPORTED_MODULE_29__/* ["default"] */ .Z.confirm({
|
|
|
title: '保存提示',
|
|
|
content: '此题目已存在试题库中,是否将修改后的试题覆盖试题库的原题?',
|
|
|
okText: '覆盖原题',
|
|
|
cancelText: '不覆盖',
|
|
|
onOk: function onOk() {
|
|
|
return onSubmit(v, s, 1);
|
|
|
},
|
|
|
onCancel: function onCancel() {
|
|
|
return onSubmit(v, s, 0);
|
|
|
}
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// if (data?.hack?.is_my) {
|
|
|
// Modal.confirm({
|
|
|
// title: '保存提示',
|
|
|
// content: '此题目已存在试题库中,是否将修改后的试题覆盖试题库的原题?',
|
|
|
// okText: '确认',
|
|
|
// cancelText: '取消',
|
|
|
// onOk: () => onSubmit(v, s,1),
|
|
|
// onCancel:()=>onSubmit(v, s,0),
|
|
|
// })
|
|
|
// return
|
|
|
// }
|
|
|
onSubmit(v, s);
|
|
|
},
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(_components_SplitContainer__WEBPACK_IMPORTED_MODULE_15__/* ["default"] */ .Z, {
|
|
|
leftChild: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(LeftPanel, {
|
|
|
onAddTestCases: onAddTestCases,
|
|
|
form: form,
|
|
|
handleAddKnowledgeFinish: handleAddKnowledgeFinish,
|
|
|
MyGroup: MyGroup,
|
|
|
formValue: formValue,
|
|
|
knowledgeOptions: knowledgeOptions,
|
|
|
onChangeLanguage: onChangeLanguage,
|
|
|
onChangeSubDiscipline: onChangeSubDiscipline,
|
|
|
onRemoveTestCase: onRemoveTestCase,
|
|
|
onAddTestCase: onAddTestCase,
|
|
|
dicts: dicts,
|
|
|
categorys: categorys,
|
|
|
callback_url: callback_url,
|
|
|
hack: data.hack,
|
|
|
onChangeScore: onChangeScore,
|
|
|
onChangehide: onChangehide,
|
|
|
onChangeAverage: onChangeAverage,
|
|
|
onChangeFile: onChangeFile,
|
|
|
uploadData: uploadData,
|
|
|
setUploadData: setUploadData,
|
|
|
handleUploadRatio: handleUploadRatio,
|
|
|
ischecked: ischecked,
|
|
|
isshows: isshows,
|
|
|
isProgram: isProgram,
|
|
|
addUploadFnc: addUploadFnc
|
|
|
}),
|
|
|
rightChild: isProgram ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.Item, {
|
|
|
name: "codes",
|
|
|
style: {
|
|
|
marginBottom: 0
|
|
|
},
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(_CodeProgramPanel__WEBPACK_IMPORTED_MODULE_17__/* ["default"] */ .Z, {})
|
|
|
}) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.Item, {
|
|
|
name: ['hack_codes', 'code'],
|
|
|
style: {
|
|
|
marginBottom: 0
|
|
|
},
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(_CodePanel__WEBPACK_IMPORTED_MODULE_16__/* ["default"] */ .Z, {
|
|
|
language: data.hack_codes.language
|
|
|
})
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)("div", {
|
|
|
className: _index_less_modules__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z["footer"],
|
|
|
children: !id ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)(react__WEBPACK_IMPORTED_MODULE_7__.Fragment, {
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_35__/* ["default"] */ .ZP, {
|
|
|
onClick: onBack,
|
|
|
children: "\u53D6\u6D88"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_35__/* ["default"] */ .ZP, {
|
|
|
loading: loading,
|
|
|
type: "primary",
|
|
|
htmlType: "submit",
|
|
|
children: "\u4FDD\u5B58"
|
|
|
})]
|
|
|
}) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)(react__WEBPACK_IMPORTED_MODULE_7__.Fragment, {
|
|
|
children: [isProgram && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_35__/* ["default"] */ .ZP, {
|
|
|
onClick: onBack,
|
|
|
type: "primary",
|
|
|
ghost: true,
|
|
|
children: "\u9000\u51FA\u7F16\u8F91"
|
|
|
}), callback_url ? null : isProgram ? null : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_35__/* ["default"] */ .ZP, {
|
|
|
type: status ? 'default' : 'primary',
|
|
|
onClick: onTriggerPublish,
|
|
|
children: status ? '撤销发布' : '立即发布'
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_35__/* ["default"] */ .ZP, {
|
|
|
loading: loading,
|
|
|
type: "primary",
|
|
|
htmlType: "submit",
|
|
|
children: "\u4FDD\u5B58"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_35__/* ["default"] */ .ZP, {
|
|
|
type: "primary",
|
|
|
onClick: onChallenge,
|
|
|
children: status ? '开始挑战' : '模拟挑战'
|
|
|
})]
|
|
|
})
|
|
|
})]
|
|
|
})]
|
|
|
})
|
|
|
});
|
|
|
});
|
|
|
function LeftPanel(_ref5) {
|
|
|
var _location, _formValue$hack;
|
|
|
var form = _ref5.form,
|
|
|
onAddTestCases = _ref5.onAddTestCases,
|
|
|
handleAddKnowledgeFinish = _ref5.handleAddKnowledgeFinish,
|
|
|
ischecked = _ref5.ischecked,
|
|
|
MyGroup = _ref5.MyGroup,
|
|
|
formValue = _ref5.formValue,
|
|
|
knowledgeOptions = _ref5.knowledgeOptions,
|
|
|
categorys = _ref5.categorys,
|
|
|
hack = _ref5.hack,
|
|
|
callback_url = _ref5.callback_url,
|
|
|
onChangeAverage = _ref5.onChangeAverage,
|
|
|
onChangeScore = _ref5.onChangeScore,
|
|
|
onChangehide = _ref5.onChangehide,
|
|
|
onChangeFile = _ref5.onChangeFile,
|
|
|
onAddTestCase = _ref5.onAddTestCase,
|
|
|
onRemoveTestCase = _ref5.onRemoveTestCase,
|
|
|
onChangeSubDiscipline = _ref5.onChangeSubDiscipline,
|
|
|
onChangeLanguage = _ref5.onChangeLanguage,
|
|
|
uploadData = _ref5.uploadData,
|
|
|
setUploadData = _ref5.setUploadData,
|
|
|
handleUploadRatio = _ref5.handleUploadRatio,
|
|
|
isshows = _ref5.isshows,
|
|
|
isProgram = _ref5.isProgram,
|
|
|
addUploadFnc = _ref5.addUploadFnc;
|
|
|
var is_random = ((_location = location) === null || _location === void 0 || (_location = _location.search) === null || _location === void 0 ? void 0 : _location.includes('select')) || false;
|
|
|
var _useState13 = (0,react__WEBPACK_IMPORTED_MODULE_7__.useState)(isshows),
|
|
|
_useState14 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_5___default()(_useState13, 2),
|
|
|
isshow = _useState14[0],
|
|
|
setisshow = _useState14[1];
|
|
|
var _useState15 = (0,react__WEBPACK_IMPORTED_MODULE_7__.useState)(false),
|
|
|
_useState16 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_5___default()(_useState15, 2),
|
|
|
editAnalysis = _useState16[0],
|
|
|
setEditAnalysis = _useState16[1];
|
|
|
var test_set_average = hack.test_set_average,
|
|
|
test_set_score = hack.test_set_score;
|
|
|
var _useState17 = (0,react__WEBPACK_IMPORTED_MODULE_7__.useState)(false),
|
|
|
_useState18 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_5___default()(_useState17, 2),
|
|
|
showUploadFile = _useState18[0],
|
|
|
setShowUploadFile = _useState18[1];
|
|
|
var handleRemove = function handleRemove(item, key) {
|
|
|
var newList = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_2___default()(uploadData);
|
|
|
newList.splice(key, 1);
|
|
|
if (test_set_average) {
|
|
|
handleUploadRatio(newList);
|
|
|
} else {
|
|
|
setUploadData(newList);
|
|
|
}
|
|
|
};
|
|
|
var handleInputChange = function handleInputChange(e, key) {
|
|
|
console.log(e, key);
|
|
|
var testData = uploadData.map(function (test, testIndex) {
|
|
|
if (testIndex === key) {
|
|
|
return _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_6___default()({}, test), {}, {
|
|
|
score: e.target.value ? Number(e.target.value) : 0
|
|
|
});
|
|
|
}
|
|
|
return test;
|
|
|
});
|
|
|
setUploadData(testData);
|
|
|
};
|
|
|
var addUploadData = function addUploadData(files) {
|
|
|
if (!(files !== null && files !== void 0 && files.length)) return;
|
|
|
|
|
|
//文件
|
|
|
if (files !== null && files !== void 0 && files[0].is_file) {
|
|
|
addUploadFnc(files, true)();
|
|
|
var newList = uploadData.concat(files);
|
|
|
if (hack.test_set_average) {
|
|
|
handleUploadRatio(newList);
|
|
|
} else {
|
|
|
setUploadData(newList);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//文本
|
|
|
if (!(files !== null && files !== void 0 && files[0].is_file)) {
|
|
|
addUploadFnc(files);
|
|
|
}
|
|
|
};
|
|
|
function onStopPropagation(e) {
|
|
|
e.stopPropagation();
|
|
|
}
|
|
|
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)("div", {
|
|
|
className: _index_less_modules__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z["oj-left-panel"],
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)("div", {
|
|
|
className: _index_less_modules__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z["oj-form-info"],
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)("div", {
|
|
|
className: _index_less_modules__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z.field,
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.Item, {
|
|
|
label: "\u96BE\u6613\u5EA6",
|
|
|
name: ['hack', 'difficult'],
|
|
|
rules: [{
|
|
|
required: true,
|
|
|
message: '请选择难易度'
|
|
|
}],
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_36__["default"], {
|
|
|
disabled: is_random,
|
|
|
children: (0,_util__WEBPACK_IMPORTED_MODULE_9__/* .getSelectOptions */ .jw)(_util__WEBPACK_IMPORTED_MODULE_9__/* .Keys */ .R8.difficult)
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.Item, {
|
|
|
label: "\u8BFE\u7A0B(\u5408\u7406\u7684\u8BFE\u7A0B\u5206\u7C7B\u6709\u5229\u4E8E\u5FEB\u901F\u68C0\u7D22)",
|
|
|
name: ['hack', 'sub_discipline_id'],
|
|
|
rules: [{
|
|
|
required: true,
|
|
|
message: '请选择课程'
|
|
|
}],
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_37__/* ["default"] */ .Z, {
|
|
|
disabled: is_random,
|
|
|
allowClear: false,
|
|
|
options: categorys,
|
|
|
placeholder: "\u8BF7\u9009\u62E9",
|
|
|
onChange: onChangeSubDiscipline
|
|
|
})
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)("div", {
|
|
|
className: _index_less_modules__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z.field,
|
|
|
children: [callback_url && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.Item, {
|
|
|
label: "\u5206\u6570",
|
|
|
name: ['hack', 'score'],
|
|
|
rules: [{
|
|
|
required: true,
|
|
|
message: '请输入分数'
|
|
|
}],
|
|
|
extra: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)("span", {
|
|
|
style: {
|
|
|
position: "absolute",
|
|
|
left: 100,
|
|
|
top: 5
|
|
|
},
|
|
|
children: "\u5206"
|
|
|
}),
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_38__/* ["default"] */ .Z, {
|
|
|
disabled: is_random,
|
|
|
min: 1,
|
|
|
max: 100
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.Item, {
|
|
|
label: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)("div", {
|
|
|
children: "\u5355\u4E2A\u6D4B\u8BD5\u96C6\u8BC4\u6D4B\u65F6\u957F\u9650\u5236 "
|
|
|
}),
|
|
|
name: ['hack', 'time_limit'],
|
|
|
rules: [{
|
|
|
required: true,
|
|
|
message: '请输入单个测试集评测时长限制'
|
|
|
}, {
|
|
|
type: 'number',
|
|
|
min: 3,
|
|
|
message: '最小限制时间是3秒'
|
|
|
}],
|
|
|
extra: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)("span", {
|
|
|
style: {
|
|
|
position: "absolute",
|
|
|
left: 100,
|
|
|
top: 5
|
|
|
},
|
|
|
children: "\u79D2"
|
|
|
}),
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_38__/* ["default"] */ .Z, {
|
|
|
min: 3
|
|
|
})
|
|
|
}), isProgram ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.Item, {
|
|
|
label: "\u7F16\u7A0B\u8BED\u8A00",
|
|
|
style: {
|
|
|
paddingBottom: 16
|
|
|
},
|
|
|
name: ['hack', 'languages'],
|
|
|
rules: [{
|
|
|
required: true,
|
|
|
message: '请选择编程语言'
|
|
|
}],
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)(antd__WEBPACK_IMPORTED_MODULE_39__/* ["default"] */ .Z.Group, {
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_39__/* ["default"] */ .Z, {
|
|
|
value: 'C',
|
|
|
children: "C"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_39__/* ["default"] */ .Z, {
|
|
|
value: 'C++',
|
|
|
children: "C++"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_39__/* ["default"] */ .Z, {
|
|
|
value: 'Java',
|
|
|
children: "Java"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_39__/* ["default"] */ .Z, {
|
|
|
value: 'Python',
|
|
|
children: "Python"
|
|
|
})]
|
|
|
})
|
|
|
}) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.Item, {
|
|
|
label: "\u7F16\u7A0B\u8BED\u8A00",
|
|
|
name: ['hack_codes', 'language'],
|
|
|
style: {
|
|
|
paddingBottom: 16
|
|
|
},
|
|
|
rules: [{
|
|
|
required: true,
|
|
|
message: '请选择编程语言'
|
|
|
}],
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_36__["default"], {
|
|
|
onChange: onChangeLanguage,
|
|
|
children: (0,_util__WEBPACK_IMPORTED_MODULE_9__/* .getSelectOptions */ .jw)(_util__WEBPACK_IMPORTED_MODULE_9__/* .Keys */ .R8.language)
|
|
|
})
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.Item, {
|
|
|
label: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)("span", {
|
|
|
children: ["\u77E5\u8BC6\u70B9\uFF1A", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)("span", {
|
|
|
className: "c-grey-999",
|
|
|
children: "\uFF08\u6240\u6709\u81EA\u5EFA\u77E5\u8BC6\u70B9\u4EC5\u672C\u4EBA\u53EF\u89C1\uFF0C\u88ABEduCoder\u5E73\u53F0\u5BA1\u6838\u901A\u8FC7\u4E3A\u5B98\u65B9\u77E5\u8BC6\u70B9\u540E\u6240\u6709\u7528\u6237\u53EF\u89C1\uFF09"
|
|
|
})]
|
|
|
}),
|
|
|
name: ['hack', 'tag_discipline_ids']
|
|
|
// rules={[{ message: '请选择知识点' }]}
|
|
|
,
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(_components_Knowledge__WEBPACK_IMPORTED_MODULE_21__/* .Knowledge */ .N, {
|
|
|
selectvalues: (hack === null || hack === void 0 ? void 0 : hack.tag_discipline_id) || (hack === null || hack === void 0 ? void 0 : hack.tag_discipline_ids)
|
|
|
// value={[]}
|
|
|
,
|
|
|
disabled: is_random,
|
|
|
subId: formValue === null || formValue === void 0 || (_formValue$hack = formValue.hack) === null || _formValue$hack === void 0 || (_formValue$hack = _formValue$hack.sub_discipline_id) === null || _formValue$hack === void 0 ? void 0 : _formValue$hack[1],
|
|
|
knowledgeOptions: knowledgeOptions,
|
|
|
onAddKnowledgeFinish: handleAddKnowledgeFinish
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.Item, {
|
|
|
label: '加入文件夹目录',
|
|
|
name: ['hack', 'item_banks_group_ids'],
|
|
|
labelCol: {
|
|
|
span: 24
|
|
|
},
|
|
|
wrapperCol: {
|
|
|
span: 24
|
|
|
},
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(_components_CustomTree__WEBPACK_IMPORTED_MODULE_22__/* ["default"] */ .Z, {
|
|
|
disabled: is_random
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.Item, {
|
|
|
label: "\u4EFB\u52A1\u540D\u79F0",
|
|
|
name: ['hack', 'name'],
|
|
|
rules: [{
|
|
|
required: true,
|
|
|
message: '请输入任务名称'
|
|
|
}],
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_28__/* ["default"] */ .Z, {
|
|
|
maxLength: 60,
|
|
|
placeholder: "\u8BF7\u8F93\u5165\u4EFB\u52A1\u540D\u79F0",
|
|
|
suffix: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)("span", {
|
|
|
children: 60 - hack.name.length
|
|
|
})
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.Item, {
|
|
|
name: ['hack', "description"],
|
|
|
valuePropName: "defaultValue",
|
|
|
rules: [{
|
|
|
required: true,
|
|
|
message: '请输入描述内容'
|
|
|
}],
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(_components_markdown_editor__WEBPACK_IMPORTED_MODULE_12__/* ["default"] */ .Z, {
|
|
|
miniToolbar: true,
|
|
|
id: "moop_cases_content",
|
|
|
noStorage: true,
|
|
|
height: 200
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)("div", {
|
|
|
onClick: function onClick() {
|
|
|
return setEditAnalysis(true);
|
|
|
},
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.Item, {
|
|
|
label: "\u9898\u76EE\u89E3\u6790",
|
|
|
name: ["hack", 'analysis'],
|
|
|
className: "".concat(_index_less_modules__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z.baseLineHeight),
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(_components_QuestionEditor_MdEditorInForm__WEBPACK_IMPORTED_MODULE_26__/* .RegularInput */ .x, {
|
|
|
placeholder: "\u8BF7\u7F16\u8F91\u9898\u76EE\u89E3\u6790\uFF08\u975E\u5FC5\u586B\uFF09",
|
|
|
isEdit: editAnalysis
|
|
|
})
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)("div", {
|
|
|
className: "tst-case-info",
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)("h3", {
|
|
|
className: "flex-container",
|
|
|
style: {
|
|
|
justifyContent: 'space-between'
|
|
|
},
|
|
|
children: [" \u6D4B\u8BD5\u7528\u4F8B\u4E0E\u7CFB\u7EDF\u8BC4\u5206\u89C4\u5219", !hack.is_file && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_35__/* ["default"] */ .ZP, {
|
|
|
type: "primary",
|
|
|
ghost: true,
|
|
|
onClick: onAddTestCase,
|
|
|
children: "\u6DFB\u52A0\u6D4B\u8BD5\u7528\u4F8B"
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.Item, {
|
|
|
name: ['hack', 'test_set_score'],
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)(antd__WEBPACK_IMPORTED_MODULE_40__/* ["default"].Group */ .ZP.Group, {
|
|
|
onChange: onChangeScore,
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)(antd__WEBPACK_IMPORTED_MODULE_40__/* ["default"] */ .ZP, {
|
|
|
value: true,
|
|
|
children: ["\u901A\u8FC7\u5168\u90E8\u6D4B\u8BD5\u96C6", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)("span", {
|
|
|
className: "tip",
|
|
|
children: " \uFF08\u5B66\u5458\u8BC4\u6D4B\uFF0C\u4EC5\u5F53\u6240\u6709\u6D4B\u8BD5\u96C6\u90FD\u6B63\u786E\u65F6\uFF0C\u624D\u83B7\u5F97\u4E00\u6B21\u6027\u5956\u52B1\uFF09"
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)(antd__WEBPACK_IMPORTED_MODULE_40__/* ["default"] */ .ZP, {
|
|
|
value: false,
|
|
|
children: ["\u901A\u8FC7\u90E8\u5206\u6D4B\u8BD5\u96C6", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)("span", {
|
|
|
className: "tip",
|
|
|
children: " \uFF08\u5B66\u5458\u8BC4\u6D4B\uFF0C\u901A\u8FC7\u6D4B\u8BD5\u96C6\u5373\u53EF\u83B7\u5F97\u5BF9\u5E94\u5956\u52B1\uFF09"
|
|
|
})]
|
|
|
})]
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_39__/* ["default"] */ .Z, {
|
|
|
style: {
|
|
|
marginBottom: '5px'
|
|
|
},
|
|
|
checked: ischecked,
|
|
|
onChange: onChangehide,
|
|
|
children: "\u9690\u85CF\u5B9E\u9645\u8F93\u51FA \uFF08\u9009\u4E2D\uFF0C\u5219\u5728\u5B66\u751F\u8003\u8BD5\u8FC7\u7A0B\u4E2D\u65E0\u6CD5\u770B\u5230\u5B9E\u9645\u8F93\u51FA\u7ED3\u679C\uFF0C\u4EC5\u5C55\u793A\u662F\u5426\u8BC4\u6D4B\u662F\u5426\u901A\u8FC7\uFF09"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.Item, {
|
|
|
className: _index_less_modules__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z.testJi,
|
|
|
name: ['hack', 'is_file'],
|
|
|
label: "\u7528\u4F8B\u7C7B\u578B:",
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_40__/* ["default"].Group */ .ZP.Group, {
|
|
|
onChange: onChangeFile,
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)(antd__WEBPACK_IMPORTED_MODULE_41__/* ["default"] */ .Z, {
|
|
|
direction: "horizontal",
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_40__/* ["default"] */ .ZP, {
|
|
|
value: false,
|
|
|
children: "\u6587\u672C"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_40__/* ["default"] */ .ZP, {
|
|
|
value: true,
|
|
|
children: "\u6587\u4EF6"
|
|
|
})]
|
|
|
})
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.Item, {
|
|
|
label: "\u8BC4\u6D4B\u65F6\u7A7A\u683C\u5904\u7406",
|
|
|
name: ['hack', 'submit_rule']
|
|
|
// labelCol={{ span: 24 }}
|
|
|
,
|
|
|
rules: [{
|
|
|
required: true
|
|
|
}],
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)(antd__WEBPACK_IMPORTED_MODULE_40__/* ["default"].Group */ .ZP.Group, {
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_40__/* ["default"] */ .ZP, {
|
|
|
value: 0,
|
|
|
children: "\u4E0D\u5FFD\u7565\u7A7A\u683C"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_40__/* ["default"] */ .ZP, {
|
|
|
value: 1,
|
|
|
children: "\u5FFD\u7565\u9996\u5C3E\u7A7A\u683C"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_40__/* ["default"] */ .ZP, {
|
|
|
value: 2,
|
|
|
children: "\u5FFD\u7565\u6240\u6709\u7A7A\u683C"
|
|
|
})]
|
|
|
})
|
|
|
}), !hack.test_set_score && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.Item, {
|
|
|
name: ['hack', 'test_set_average'],
|
|
|
label: "\u7CFB\u7EDF\u8BC4\u5206\u5360\u6BD4",
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)(antd__WEBPACK_IMPORTED_MODULE_40__/* ["default"].Group */ .ZP.Group, {
|
|
|
onChange: onChangeAverage,
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_40__/* ["default"] */ .ZP, {
|
|
|
value: true,
|
|
|
children: "\u5747\u5206\u6BD4\u4F8B"
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_40__/* ["default"] */ .ZP, {
|
|
|
value: false,
|
|
|
children: "\u81EA\u5B9A\u4E49\u6BD4\u4F8B"
|
|
|
})]
|
|
|
})
|
|
|
}), !hack.test_set_score && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)("div", {
|
|
|
style: {
|
|
|
marginBottom: '20px',
|
|
|
marginTop: '-10px'
|
|
|
},
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)("div", {
|
|
|
style: {
|
|
|
display: 'flex',
|
|
|
height: '30px',
|
|
|
marginBottom: '10px'
|
|
|
},
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_39__/* ["default"] */ .Z, {
|
|
|
checked: isshow,
|
|
|
style: {
|
|
|
display: 'flex',
|
|
|
alignItems: 'center'
|
|
|
},
|
|
|
className: _index_less_modules__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z.checkboxs,
|
|
|
onChange: function onChange(e) {
|
|
|
setisshow(e.target.checked);
|
|
|
form.setFieldsValue({
|
|
|
hack: {
|
|
|
code_compile_score: 0
|
|
|
}
|
|
|
});
|
|
|
if (hack.test_set_average) {
|
|
|
if (hack.is_file) {
|
|
|
handleUploadRatio(uploadData);
|
|
|
} else {
|
|
|
onAddTestCases();
|
|
|
// handleShareRatio(testSetList)
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
children: "\u542F\u7528\u7F16\u8BD1\u901A\u8FC7\u5373\u53EF\u5F97\u5206"
|
|
|
}), isshow && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)("span", {
|
|
|
style: {
|
|
|
display: 'flex'
|
|
|
},
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.Item, {
|
|
|
rules: [{
|
|
|
required: true,
|
|
|
message: '请输入编译得分'
|
|
|
}],
|
|
|
name: ['hack', 'code_compile_score'],
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_38__/* ["default"] */ .Z, {
|
|
|
onChange: function onChange() {
|
|
|
if (hack.test_set_average) {
|
|
|
if (hack.is_file) {
|
|
|
handleUploadRatio(uploadData);
|
|
|
} else {
|
|
|
onAddTestCases();
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
parser: function parser(e) {
|
|
|
return isNaN(parseInt(e)) ? '' : parseInt(e);
|
|
|
},
|
|
|
min: 0,
|
|
|
max: 100,
|
|
|
style: {
|
|
|
width: '90px',
|
|
|
margin: '5px 0px'
|
|
|
}
|
|
|
})
|
|
|
}), " ", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)("span", {
|
|
|
style: {
|
|
|
display: 'flex',
|
|
|
alignItems: 'center',
|
|
|
marginLeft: '5px'
|
|
|
},
|
|
|
children: "%"
|
|
|
})]
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)("span", {
|
|
|
style: {
|
|
|
color: '#999',
|
|
|
fontSize: '12px',
|
|
|
marginLeft: '-8px'
|
|
|
},
|
|
|
children: "\uFF08\u8BF7\u6CE8\u610F\u8BE5\u5B9E\u8BAD\u9898\u662F\u5426\u6709\u7F16\u8BD1\u8FC7\u7A0B\uFF0C\u82E5\u6CA1\u6709\u5219\u65E0\u6CD5\u83B7\u5F97\u7F16\u8BD1\u5F97\u5206\uFF09"
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)("div", {
|
|
|
className: _index_less_modules__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z.upBtn,
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_35__/* ["default"] */ .ZP, {
|
|
|
ghost: true,
|
|
|
type: "primary",
|
|
|
className: "mb20",
|
|
|
onClick: function onClick() {
|
|
|
return setShowUploadFile(true);
|
|
|
},
|
|
|
children: "\u6279\u91CF\u4E0A\u4F20\u6D4B\u8BD5\u7528\u4F8B"
|
|
|
}), (hack === null || hack === void 0 ? void 0 : hack.is_file) && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(_pages_Shixuns_Edit_body_Level_Challenges_components_UploadFile__WEBPACK_IMPORTED_MODULE_23__/* .UploadTable */ .Y2, {
|
|
|
disabled: hack === null || hack === void 0 ? void 0 : hack.test_set_average,
|
|
|
inputChange: handleInputChange,
|
|
|
showScore: !hack.test_set_score,
|
|
|
data: uploadData,
|
|
|
onRemove: handleRemove
|
|
|
})]
|
|
|
}), !hack.is_file && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.List, {
|
|
|
name: "hack_sets",
|
|
|
children: function children(fields, _ref6) {
|
|
|
_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_objectDestructuringEmpty_js__WEBPACK_IMPORTED_MODULE_0___default()(_ref6);
|
|
|
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_30__/* ["default"] */ .Z, {
|
|
|
accordion: true,
|
|
|
className: _index_less_modules__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z.collapse,
|
|
|
children: fields.map(function (field, index) {
|
|
|
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)(Panel, {
|
|
|
header: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)("a", {
|
|
|
className: _index_less_modules__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z["test-case-name"],
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)("span", {
|
|
|
children: ["\u6D4B\u8BD5\u7528\u4F8B", index + 1]
|
|
|
}), !test_set_score ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.Fragment, {
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.Item, {
|
|
|
name: [field.name, 'score'],
|
|
|
style: {
|
|
|
marginBottom: 0
|
|
|
},
|
|
|
fieldKey: [field.fieldKey, 'score'],
|
|
|
rules: [{
|
|
|
required: true,
|
|
|
message: "\u8BF7\u8F93\u5165\u6D4B\u8BD5\u96C6".concat(index + 1, "\u8BC4\u5206")
|
|
|
}],
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_38__/* ["default"] */ .Z, {
|
|
|
onClick: onStopPropagation,
|
|
|
min: 0,
|
|
|
max: 100,
|
|
|
disabled: test_set_average
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)("span", {
|
|
|
children: "%"
|
|
|
})]
|
|
|
}) : null]
|
|
|
}),
|
|
|
extra: index > 0 ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)("div", {
|
|
|
onClick: onStopPropagation,
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_42__/* ["default"] */ .Z, {
|
|
|
okText: "\u786E\u5B9A",
|
|
|
cancelText: "\u53D6\u6D88",
|
|
|
title: '确定删除测试集' + (index + 1),
|
|
|
onConfirm: function onConfirm() {
|
|
|
onRemoveTestCase(index);
|
|
|
},
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(_ant_design_icons__WEBPACK_IMPORTED_MODULE_43__/* ["default"] */ .Z, {
|
|
|
className: _index_less_modules__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z['btn-remove-case']
|
|
|
})
|
|
|
})
|
|
|
}) : null,
|
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.Item, {
|
|
|
label: "\u8F93\u5165",
|
|
|
name: [field.name, 'input'],
|
|
|
fieldKey: [field.fieldKey, 'input'],
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(TextArea, {})
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(antd__WEBPACK_IMPORTED_MODULE_31__/* ["default"] */ .Z.Item, {
|
|
|
label: "\u8F93\u51FA",
|
|
|
name: [field.name, 'output'],
|
|
|
fieldKey: [field.fieldKey, 'output'],
|
|
|
rules: [{
|
|
|
required: true,
|
|
|
message: '请输入输出内容'
|
|
|
}],
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(TextArea, {})
|
|
|
})]
|
|
|
}, "".concat(field.key, "--").concat(index));
|
|
|
})
|
|
|
});
|
|
|
}
|
|
|
})]
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_27__.jsx)(_pages_Shixuns_Edit_body_Level_Challenges_components_UploadFile__WEBPACK_IMPORTED_MODULE_23__/* ["default"] */ .ZP, {
|
|
|
rootIdentifier: null,
|
|
|
visible: showUploadFile,
|
|
|
onClose: function onClose() {
|
|
|
return setShowUploadFile(false);
|
|
|
},
|
|
|
onOK: addUploadData,
|
|
|
multiple: true,
|
|
|
defaultMultipleValue: hack === null || hack === void 0 ? void 0 : hack.is_file
|
|
|
})]
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 77900:
|
|
|
/*!**********************************************!*\
|
|
|
!*** ./src/pages/Problems/OjForm/service.ts ***!
|
|
|
\**********************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
|
/* harmony export */ GM: function() { return /* binding */ updateExerciseQuestion; },
|
|
|
/* harmony export */ MK: function() { return /* binding */ addExerciseQuestion; },
|
|
|
/* harmony export */ PR: function() { return /* binding */ getUser; },
|
|
|
/* harmony export */ ZS: function() { return /* binding */ cancelPublishProgrammingTopic; },
|
|
|
/* harmony export */ d1: function() { return /* binding */ getDisciplines; },
|
|
|
/* harmony export */ fu: function() { return /* binding */ getProgrammingTopic; },
|
|
|
/* harmony export */ j2: function() { return /* binding */ publishProgrammingTopic; },
|
|
|
/* harmony export */ l_: function() { return /* binding */ updateProgrammingTopic; },
|
|
|
/* harmony export */ uE: function() { return /* binding */ startChallenge; },
|
|
|
/* harmony export */ zQ: function() { return /* binding */ addProgrammingTopic; }
|
|
|
/* harmony export */ });
|
|
|
/* unused harmony export addTag */
|
|
|
/* harmony import */ var _utils_fetch_ts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/utils/fetch.ts */ 15830);
|
|
|
|
|
|
function getUser() {
|
|
|
return (0,_utils_fetch_ts__WEBPACK_IMPORTED_MODULE_0__/* .get */ .U2)('problems/new.json');
|
|
|
}
|
|
|
function getDisciplines() {
|
|
|
var source = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'question';
|
|
|
return (0,_utils_fetch_ts__WEBPACK_IMPORTED_MODULE_0__/* .get */ .U2)("disciplines.json", {
|
|
|
source: source
|
|
|
});
|
|
|
}
|
|
|
function getProgrammingTopic(id) {
|
|
|
return (0,_utils_fetch_ts__WEBPACK_IMPORTED_MODULE_0__/* .get */ .U2)("problems/".concat(id, "/edit.json"));
|
|
|
}
|
|
|
function updateProgrammingTopic(id, params) {
|
|
|
return (0,_utils_fetch_ts__WEBPACK_IMPORTED_MODULE_0__/* .put */ .gz)("problems/".concat(id, ".json"), params);
|
|
|
}
|
|
|
function addProgrammingTopic(params) {
|
|
|
return (0,_utils_fetch_ts__WEBPACK_IMPORTED_MODULE_0__/* .post */ .v_)("problems.json", params);
|
|
|
}
|
|
|
function addExerciseQuestion(exerciseId, params) {
|
|
|
return (0,_utils_fetch_ts__WEBPACK_IMPORTED_MODULE_0__/* .post */ .v_)("exercises/".concat(exerciseId, "/exercise_questions.json"), params);
|
|
|
}
|
|
|
function updateExerciseQuestion(id, params) {
|
|
|
return (0,_utils_fetch_ts__WEBPACK_IMPORTED_MODULE_0__/* .put */ .gz)("exercise_questions/".concat(id, ".json"), params);
|
|
|
}
|
|
|
function publishProgrammingTopic(id) {
|
|
|
return (0,_utils_fetch_ts__WEBPACK_IMPORTED_MODULE_0__/* .post */ .v_)("problems/".concat(id, "/publish.json"));
|
|
|
}
|
|
|
function cancelPublishProgrammingTopic(id) {
|
|
|
return (0,_utils_fetch_ts__WEBPACK_IMPORTED_MODULE_0__/* .post */ .v_)("problems/".concat(id, "/cancel_publish.json"));
|
|
|
}
|
|
|
function startChallenge(id) {
|
|
|
return (0,_utils_fetch_ts__WEBPACK_IMPORTED_MODULE_0__/* .get */ .U2)("problems/".concat(id, "/start.json"));
|
|
|
}
|
|
|
function addTag(sub_discipline_id, name) {
|
|
|
return post("tag_disciplines.json", {
|
|
|
name: name,
|
|
|
sub_discipline_id: sub_discipline_id
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 55654:
|
|
|
/*!********************************************!*\
|
|
|
!*** ./src/pages/Problems/OjForm/util.tsx ***!
|
|
|
\********************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
|
/* harmony export */ D0: function() { return /* binding */ getDisciplineOptions; },
|
|
|
/* harmony export */ R8: function() { return /* binding */ Keys; },
|
|
|
/* harmony export */ jw: function() { return /* binding */ getSelectOptions; },
|
|
|
/* harmony export */ y3: function() { return /* binding */ getDisciplineIds; }
|
|
|
/* harmony export */ });
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_defineProperty_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/defineProperty.js */ 22060);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_defineProperty_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_defineProperty_js__WEBPACK_IMPORTED_MODULE_0__);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! antd */ 57809);
|
|
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ 59301);
|
|
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react/jsx-runtime */ 37712);
|
|
|
|
|
|
var _Options;
|
|
|
|
|
|
|
|
|
|
|
|
var Option = antd__WEBPACK_IMPORTED_MODULE_3__["default"].Option;
|
|
|
var Keys = /*#__PURE__*/function (Keys) {
|
|
|
Keys[Keys["language"] = 0] = "language";
|
|
|
Keys[Keys["difficult"] = 1] = "difficult";
|
|
|
Keys[Keys["category"] = 2] = "category";
|
|
|
Keys[Keys["openOrNot"] = 3] = "openOrNot";
|
|
|
return Keys;
|
|
|
}({});
|
|
|
var Options = (_Options = {}, _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_defineProperty_js__WEBPACK_IMPORTED_MODULE_0___default()(_Options, Keys.language, [{
|
|
|
title: 'C',
|
|
|
key: 'C'
|
|
|
}, {
|
|
|
title: 'C++',
|
|
|
key: 'C++'
|
|
|
}, {
|
|
|
title: 'Python',
|
|
|
key: 'Python'
|
|
|
}, {
|
|
|
title: 'Java',
|
|
|
key: 'Java'
|
|
|
}, {
|
|
|
title: 'JavaScript',
|
|
|
key: 'JavaScript'
|
|
|
}, {
|
|
|
title: 'Ruby',
|
|
|
key: 'Ruby'
|
|
|
}]), _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_defineProperty_js__WEBPACK_IMPORTED_MODULE_0___default()(_Options, Keys.difficult, [{
|
|
|
title: '简单',
|
|
|
key: 1
|
|
|
}, {
|
|
|
title: '中等',
|
|
|
key: 2
|
|
|
}, {
|
|
|
title: '困难',
|
|
|
key: 3
|
|
|
}]), _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_defineProperty_js__WEBPACK_IMPORTED_MODULE_0___default()(_Options, Keys.category, [{
|
|
|
title: '程序设计',
|
|
|
key: 1
|
|
|
}, {
|
|
|
title: '算法',
|
|
|
key: 2
|
|
|
}]), _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_2_babel_runtime_helpers_defineProperty_js__WEBPACK_IMPORTED_MODULE_0___default()(_Options, Keys.openOrNot, [{
|
|
|
title: '公开',
|
|
|
key: 1
|
|
|
}, {
|
|
|
title: '私有',
|
|
|
key: 0
|
|
|
}]), _Options);
|
|
|
function getSelectOptions(name) {
|
|
|
return Options[name].map(function (item) {
|
|
|
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)(Option, {
|
|
|
value: item.key,
|
|
|
children: [" ", item.title, " "]
|
|
|
}, item.title);
|
|
|
});
|
|
|
}
|
|
|
function getDisciplineOptions(data, result) {
|
|
|
data.map(function (value) {
|
|
|
var id = value.id,
|
|
|
name = value.name,
|
|
|
sub_disciplines = value.sub_disciplines;
|
|
|
var item = {
|
|
|
value: id,
|
|
|
label: name
|
|
|
};
|
|
|
result.push(item);
|
|
|
if (sub_disciplines && sub_disciplines.length > 0) {
|
|
|
item.children = [];
|
|
|
getDisciplineOptions(sub_disciplines, item.children);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
function getDisciplineIds(data, sub_disciplines_id) {
|
|
|
var rs = [];
|
|
|
for (var index = 0; index < data.length; index++) {
|
|
|
var _value$sub_discipline;
|
|
|
var value = data[index];
|
|
|
if (((_value$sub_discipline = value.sub_disciplines) === null || _value$sub_discipline === void 0 ? void 0 : _value$sub_discipline.length) > 0) {
|
|
|
rs[0] = value.id;
|
|
|
for (var j = 0; j < value.sub_disciplines.length; j++) {
|
|
|
var item = value.sub_disciplines[j];
|
|
|
if (item.id === sub_disciplines_id) {
|
|
|
rs[1] = item.id;
|
|
|
return [rs, item.tag_disciplines || item.sub_disciplines || []];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return [rs, []];
|
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 42939:
|
|
|
/*!***************************!*\
|
|
|
!*** ./src/utils/enum.ts ***!
|
|
|
\***************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
|
/* harmony export */ c: function() { return /* binding */ QuestionType; }
|
|
|
/* harmony export */ });
|
|
|
/* unused harmony export PageType */
|
|
|
var PageType = /*#__PURE__*/function (PageType) {
|
|
|
PageType["FirstPage"] = "firstPage";
|
|
|
PageType["PrevPage"] = "prevPage";
|
|
|
PageType["NextPage"] = "nextPage";
|
|
|
return PageType;
|
|
|
}({});
|
|
|
var QuestionType = /*#__PURE__*/function (QuestionType) {
|
|
|
QuestionType[QuestionType["Single"] = 0] = "Single";
|
|
|
QuestionType[QuestionType["Multiple"] = 1] = "Multiple";
|
|
|
QuestionType[QuestionType["Judge"] = 2] = "Judge";
|
|
|
QuestionType[QuestionType["Fill"] = 3] = "Fill";
|
|
|
QuestionType[QuestionType["Subjective"] = 4] = "Subjective";
|
|
|
QuestionType[QuestionType["Shixun"] = 5] = "Shixun";
|
|
|
QuestionType[QuestionType["Program"] = 6] = "Program";
|
|
|
QuestionType[QuestionType["Combine"] = 7] = "Combine";
|
|
|
return QuestionType;
|
|
|
}({});
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 22358:
|
|
|
/*!******************************!*\
|
|
|
!*** ./src/utils/urlTool.ts ***!
|
|
|
\******************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
|
/* harmony export */ G: function() { return /* binding */ fromStore; },
|
|
|
/* harmony export */ t: function() { return /* binding */ toStore; }
|
|
|
/* harmony export */ });
|
|
|
/* harmony import */ var store__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! store */ 7062);
|
|
|
/* harmony import */ var store__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(store__WEBPACK_IMPORTED_MODULE_0__);
|
|
|
var isDev = (/* unused pure expression or super */ null && ("production" === 'development'));
|
|
|
|
|
|
function toStore(key, val) {
|
|
|
var _config = store__WEBPACK_IMPORTED_MODULE_0___default().get('__ec');
|
|
|
if (!_config) _config = {};
|
|
|
_config[key] = val;
|
|
|
store__WEBPACK_IMPORTED_MODULE_0___default().set('__ec', _config);
|
|
|
}
|
|
|
function fromStore(key, defaultVal) {
|
|
|
var _config = store__WEBPACK_IMPORTED_MODULE_0___default().get('__ec');
|
|
|
if (!_config) return defaultVal;
|
|
|
return _config[key] === undefined ? defaultVal : _config[key];
|
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 34566:
|
|
|
/*!**********************************************************!*\
|
|
|
!*** ./src/components/QuestionEditor/index.less?modules ***!
|
|
|
\**********************************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__) {
|
|
|
|
|
|
// extracted by mini-css-extract-plugin
|
|
|
/* harmony default export */ __webpack_exports__.Z = ({"wrap":"wrap___ilWvf","deleteIcon":"deleteIcon___JBDG8","keywordTag":"keywordTag___iieCb","questionTitleEditorWrap":"questionTitleEditorWrap___MHB5s","choiceWrap":"choiceWrap___QFkTc","choiceIndex":"choiceIndex___Mr2YO","judgementIndex":"judgementIndex___fUVWK","setAnswerBtn":"setAnswerBtn___Whox5","activeAnswer":"activeAnswer___fGU6Y","activeJudgementAnswer":"activeJudgementAnswer___wJv8P","actionWrapper":"actionWrapper___ERQ7k","addIcon":"addIcon___L9TE0","inputBorder":"inputBorder___Q5tRE","placeholder":"placeholder___p9sFY","blankWrapper":"blankWrapper___nC45e","blankInput":"blankInput___pEHsx","blankInputNumberWrapper":"blankInputNumberWrapper___uEHb0","addBtn":"addBtn___WR5ZI","blankIndex":"blankIndex___x9Pny","baseInputWrapper":"baseInputWrapper___eVsG7","collapseWrapper":"collapseWrapper___ZTysU","panelHeader":"panelHeader___QSN9g","open":"open___B6FU9","close":"close___QX19r","hide":"hide___mn25n"});
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 63390:
|
|
|
/*!******************************************************!*\
|
|
|
!*** ./src/pages/Problems/OjForm/index.less?modules ***!
|
|
|
\******************************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__) {
|
|
|
|
|
|
// extracted by mini-css-extract-plugin
|
|
|
/* harmony default export */ __webpack_exports__.Z = ({"header":"header___HqHSe","checkboxs":"checkboxs___ObBnD","field":"field___w_sM6","oj-form-container":"oj-form-container____odYP","oj-left-panel":"oj-left-panel___emEB2","oj-form-info":"oj-form-info___m00Ag","footer":"footer___O4iSJ","collapse":"collapse___Ltfkj","test-case-name":"test-case-name___miZcb","btn-remove-case":"btn-remove-case___cHap2","icon-tag":"icon-tag___gmyTb","btn_back":"btn_back___tNmX3","testJi":"testJi___L3fHb","upBtn":"upBtn___RGH6X"});
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 30345:
|
|
|
/*!****************************************************!*\
|
|
|
!*** ./src/components/tpi-code-setting/index.less ***!
|
|
|
\****************************************************/
|
|
|
/***/ (function() {
|
|
|
|
|
|
// extracted by mini-css-extract-plugin
|
|
|
|
|
|
|
|
|
/***/ })
|
|
|
|
|
|
}]); |