You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
683 lines
31 KiB
683 lines
31 KiB
"use strict";
|
|
(self["webpackChunk"] = self["webpackChunk"] || []).push([[2936],{
|
|
|
|
/***/ 46948:
|
|
/*!*****************************************!*\
|
|
!*** ./src/components/NoData/index.tsx ***!
|
|
\*****************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ 59301);
|
|
/* harmony import */ var _assets_images_icons_nodata_png__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/assets/images/icons/nodata.png */ 93314);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! antd */ 3113);
|
|
var __defProp = Object.defineProperty;
|
|
var __defProps = Object.defineProperties;
|
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
var __spreadValues = (a, b) => {
|
|
for (var prop in b || (b = {}))
|
|
if (__hasOwnProp.call(b, prop))
|
|
__defNormalProp(a, prop, b[prop]);
|
|
if (__getOwnPropSymbols)
|
|
for (var prop of __getOwnPropSymbols(b)) {
|
|
if (__propIsEnum.call(b, prop))
|
|
__defNormalProp(a, prop, b[prop]);
|
|
}
|
|
return a;
|
|
};
|
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
|
|
|
|
|
const noData = ({
|
|
img,
|
|
buttonProps = {},
|
|
styles = {},
|
|
customText,
|
|
ButtonText,
|
|
ButtonClick,
|
|
Buttonclass,
|
|
ButtonTwo,
|
|
imgStyles,
|
|
loading = false
|
|
}) => {
|
|
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(
|
|
"section",
|
|
{
|
|
className: "tc animated fadeIn",
|
|
style: __spreadValues(__spreadValues({}, { color: "#999", margin: "100px auto", visibility: loading ? "hidden" : "visible" }), styles)
|
|
},
|
|
/* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("img", { src: img || _assets_images_icons_nodata_png__WEBPACK_IMPORTED_MODULE_1__, style: __spreadProps(__spreadValues({}, imgStyles), { pointerEvents: "none", userSelect: "none" }) }),
|
|
/* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("p", { className: "mt20 font14" }, customText || "\u6682\u65F6\u8FD8\u6CA1\u6709\u76F8\u5173\u6570\u636E\u54E6!"),
|
|
ButtonText && /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .ZP, __spreadValues({ className: Buttonclass, onClick: ButtonClick }, buttonProps), ButtonText),
|
|
ButtonTwo && ButtonTwo
|
|
);
|
|
};
|
|
/* harmony default export */ __webpack_exports__.Z = (noData);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 95391:
|
|
/*!*********************************************************!*\
|
|
!*** ./src/components/PreviewAll/index.tsx + 1 modules ***!
|
|
\*********************************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
// EXPORTS
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
Z: function() { return /* binding */ PreviewAll; }
|
|
});
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
|
|
var _react_17_0_2_react = __webpack_require__(59301);
|
|
;// CONCATENATED MODULE: ./src/components/PreviewAll/index.less?modules
|
|
// extracted by mini-css-extract-plugin
|
|
/* harmony default export */ var PreviewAllmodules = ({"wrp":"wrp___dq7YK","bgBlack":"bgBlack___ARIUV","monaco":"monaco___VnZC3","darkBlue":"darkBlue___UprA9","close":"close___LKoWu","embed":"embed___hvpEJ"});
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/button/index.js
|
|
var es_button = __webpack_require__(3113);
|
|
// EXTERNAL MODULE: ./node_modules/_@ant-design_icons@5.3.1@@ant-design/icons/es/icons/ArrowDownOutlined.js + 1 modules
|
|
var ArrowDownOutlined = __webpack_require__(59658);
|
|
// EXTERNAL MODULE: ./src/components/monaco-editor/index.jsx + 4 modules
|
|
var monaco_editor = __webpack_require__(16162);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/tooltip/index.js + 3 modules
|
|
var tooltip = __webpack_require__(6848);
|
|
// EXTERNAL MODULE: ./src/utils/util.tsx
|
|
var util = __webpack_require__(75798);
|
|
// EXTERNAL MODULE: ./src/service/exercise.ts
|
|
var exercise = __webpack_require__(53669);
|
|
// EXTERNAL MODULE: ./src/components/NoData/index.tsx
|
|
var NoData = __webpack_require__(46948);
|
|
// EXTERNAL MODULE: ./src/utils/env.ts + 1 modules
|
|
var env = __webpack_require__(19351);
|
|
;// CONCATENATED MODULE: ./src/components/PreviewAll/index.tsx
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
var __spreadValues = (a, b) => {
|
|
for (var prop in b || (b = {}))
|
|
if (__hasOwnProp.call(b, prop))
|
|
__defNormalProp(a, prop, b[prop]);
|
|
if (__getOwnPropSymbols)
|
|
for (var prop of __getOwnPropSymbols(b)) {
|
|
if (__propIsEnum.call(b, prop))
|
|
__defNormalProp(a, prop, b[prop]);
|
|
}
|
|
return a;
|
|
};
|
|
var __async = (__this, __arguments, generator) => {
|
|
return new Promise((resolve, reject) => {
|
|
var fulfilled = (value) => {
|
|
try {
|
|
step(generator.next(value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
};
|
|
var rejected = (value) => {
|
|
try {
|
|
step(generator.throw(value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
};
|
|
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
});
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* harmony default export */ var PreviewAll = (({ editOffice = "view", data, theme, type, filename, monacoEditor, className, style, close, onClose, hasMask, disabledDownload, onImgDimensions, showNodata }) => {
|
|
const [src, setSrc] = (0,_react_17_0_2_react.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt");
|
|
const [token, setToken] = (0,_react_17_0_2_react.useState)("");
|
|
const [officeData, setOfficeData] = (0,_react_17_0_2_react.useState)();
|
|
const officePath = window.ENV === "build" ? "/react/build" : "";
|
|
const apiServer = location.host.startsWith("localhost") ? env/* default */.Z.PROXY_SERVER : env/* default */.Z.API_SERVER;
|
|
const unit = 1024 * 1024;
|
|
const maxSize = 10 * unit;
|
|
const closeRef = (0,_react_17_0_2_react.useRef)();
|
|
if ((data == null ? void 0 : data.startsWith("/api")) && type !== "txt") {
|
|
data = env/* default */.Z.API_SERVER + data;
|
|
}
|
|
const getFileExtension = (url) => {
|
|
const filename2 = url.substring(url.lastIndexOf("/") + 1);
|
|
const extension = filename2.split(".").pop();
|
|
return extension;
|
|
};
|
|
if (filename)
|
|
monacoEditor.filename = filename;
|
|
(0,_react_17_0_2_react.useEffect)(() => {
|
|
var _a, _b;
|
|
const cookies = (_b = (_a = document.cookie) == null ? void 0 : _a.replace(/\s/g, "")) == null ? void 0 : _b.split(";");
|
|
cookies == null ? void 0 : cookies.map((item) => {
|
|
let i = item.split("=");
|
|
if (i[0] === "_educoder_session") {
|
|
setToken(i[1]);
|
|
}
|
|
});
|
|
}, []);
|
|
(0,_react_17_0_2_react.useEffect)(() => {
|
|
if (type === "office") {
|
|
if (data.indexOf("bigfilescdn.") > -1) {
|
|
setOfficeData({
|
|
url: data,
|
|
fileType: getFileExtension(data),
|
|
model: data.indexOf("model=edit") ? "edit" : "view"
|
|
});
|
|
} else {
|
|
getData();
|
|
}
|
|
}
|
|
}, [type, data]);
|
|
const getData = () => __async(void 0, null, function* () {
|
|
console.log("data:", data);
|
|
let _url = data;
|
|
if (!data.startsWith("http")) {
|
|
_url = location.origin + _url;
|
|
}
|
|
let _id = new URL(_url).pathname.split("/").pop();
|
|
const res = yield (0,exercise/* setEcsAttachment */.gJ)({ attachment_id: _id });
|
|
res.url = apiServer + res.url;
|
|
setOfficeData(res);
|
|
});
|
|
const handleClick = () => {
|
|
if (data.startsWith("http") || data.startsWith("blob:")) {
|
|
handleDown();
|
|
return;
|
|
}
|
|
(0,util/* downloadFile */.Sv)(filename || "educoder", data, filename);
|
|
};
|
|
const handleDown = () => {
|
|
(0,util/* downLoadLink */.Nd)(filename || "educoder", decodeURIComponent(data));
|
|
};
|
|
return /* @__PURE__ */ _react_17_0_2_react.createElement("div", { style: __spreadValues({}, style || {}), className: `${hasMask && PreviewAllmodules.bgBlack} ${!!type ? PreviewAllmodules.wrp : "hide"}` }, close && /* @__PURE__ */ _react_17_0_2_react.createElement("div", { className: PreviewAllmodules.close, ref: closeRef }, !!onImgDimensions && /* @__PURE__ */ _react_17_0_2_react.createElement(tooltip/* default */.Z, { title: "\u70B9\u51FB\u5BF9\u56FE\u7247\u8FDB\u884C\u6279\u6CE8", getPopupContainer: () => closeRef.current }, /* @__PURE__ */ _react_17_0_2_react.createElement("span", { onClick: () => {
|
|
onClose();
|
|
onImgDimensions();
|
|
} }, /* @__PURE__ */ _react_17_0_2_react.createElement("i", { className: "icon-yulanpizhu" }))), !disabledDownload && /* @__PURE__ */ _react_17_0_2_react.createElement(tooltip/* default */.Z, { title: "\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6", getPopupContainer: () => closeRef.current }, /* @__PURE__ */ _react_17_0_2_react.createElement("span", { onClick: handleDown }, /* @__PURE__ */ _react_17_0_2_react.createElement("i", { className: "icon-quxiaozhiding" }))), /* @__PURE__ */ _react_17_0_2_react.createElement(tooltip/* default */.Z, { title: "\u5173\u95ED", getPopupContainer: () => closeRef.current }, /* @__PURE__ */ _react_17_0_2_react.createElement("span", { className: "", onClick: onClose }, /* @__PURE__ */ _react_17_0_2_react.createElement("i", { className: "icon-guanbi1" })))), /* @__PURE__ */ _react_17_0_2_react.createElement("div", { className: `${PreviewAllmodules[className]} ${className} ${PreviewAllmodules.monaco} ${type === "txt" ? "show" : "hide"}` }, type === "txt" && /* @__PURE__ */ _react_17_0_2_react.createElement(_react_17_0_2_react.Fragment, null, /* @__PURE__ */ _react_17_0_2_react.createElement(
|
|
monaco_editor/* default */.ZP,
|
|
__spreadValues({}, monacoEditor)
|
|
))), type === "audio" && /* @__PURE__ */ _react_17_0_2_react.createElement("audio", { src: `${(data == null ? void 0 : data.indexOf("http://")) > -1 || (data == null ? void 0 : data.indexOf("https://")) > -1 ? "" : "data:audio/mp3;base64,"}${data}`, autoPlay: true }), type === "video" && /* @__PURE__ */ _react_17_0_2_react.createElement(_react_17_0_2_react.Fragment, null, (data == null ? void 0 : data.indexOf("http")) > -1 ? /* @__PURE__ */ _react_17_0_2_react.createElement("video", { controls: true, src: `${data}`, autoPlay: true }) : /* @__PURE__ */ _react_17_0_2_react.createElement("video", { controls: true, src: `data:video/mp4;base64,${data}`, autoPlay: true })), type === "office" && officeData && /* @__PURE__ */ _react_17_0_2_react.createElement("iframe", { src: `${officePath}/office.html?key=${officeData.key}&url=${btoa(officeData.url)}&callbackUrl=${apiServer + officeData.callbackUrl}&fileType=${officeData.fileType}&title=${officeData.title}&model=${editOffice}&officeServer=${env/* default */.Z.ONLYOFFICE}&disabledDownload=${!!disabledDownload}` }), type === "html" && /* @__PURE__ */ _react_17_0_2_react.createElement("iframe", { src: data + "&disposition=inline" }), type === "pdf" && /* @__PURE__ */ _react_17_0_2_react.createElement("iframe", { src: `${officePath}/js/pdfview/index.html?url=${data}&disabledDownload=${!!disabledDownload}` }), type === "image" && /* @__PURE__ */ _react_17_0_2_react.createElement("img", { src: `${(data == null ? void 0 : data.indexOf("http://")) > -1 || (data == null ? void 0 : data.indexOf("https://")) > -1 ? "" : "data:image/png;base64,"}${data}` }), (type === "other" || type === "download") && /* @__PURE__ */ _react_17_0_2_react.createElement(_react_17_0_2_react.Fragment, null, showNodata ? /* @__PURE__ */ _react_17_0_2_react.createElement(NoData/* default */.Z, { customText: "\u5F53\u524D\u6587\u4EF6\u4E0D\u652F\u6301\u9884\u89C8\uFF0C\u53EF\u70B9\u51FB\u4E0B\u8F7D\u67E5\u770B", ButtonTwo: /* @__PURE__ */ _react_17_0_2_react.createElement(es_button/* default */.ZP, { icon: /* @__PURE__ */ _react_17_0_2_react.createElement("i", { className: "iconfont icon-xiazai4 font14" }), type: "primary", size: "middle", onClick: handleClick }, "\u4E0B\u8F7D") }) : /* @__PURE__ */ _react_17_0_2_react.createElement(es_button/* default */.ZP, { type: "primary", size: "middle", onClick: handleClick }, /* @__PURE__ */ _react_17_0_2_react.createElement(ArrowDownOutlined/* default */.Z, null), "\u70B9\u51FB\u4E0B\u8F7D")));
|
|
});
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 92936:
|
|
/*!*********************************************!*\
|
|
!*** ./src/components/RenderHtml/index.tsx ***!
|
|
\*********************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ 59301);
|
|
/* harmony import */ var katex_dist_katex_min_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! katex/dist/katex.min.css */ 97762);
|
|
/* harmony import */ var _utils_marked__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/utils/marked */ 5596);
|
|
/* harmony import */ var code_prettify__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! code-prettify */ 64018);
|
|
/* harmony import */ var code_prettify__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(code_prettify__WEBPACK_IMPORTED_MODULE_3__);
|
|
/* harmony import */ var hls_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! hls.js */ 70169);
|
|
/* harmony import */ var _utils_env__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/utils/env */ 19351);
|
|
/* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! katex */ 15342);
|
|
/* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(katex__WEBPACK_IMPORTED_MODULE_6__);
|
|
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! uuid */ 1012);
|
|
/* harmony import */ var _components_PreviewAll__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/components/PreviewAll */ 95391);
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
var __spreadValues = (a, b) => {
|
|
for (var prop in b || (b = {}))
|
|
if (__hasOwnProp.call(b, prop))
|
|
__defNormalProp(a, prop, b[prop]);
|
|
if (__getOwnPropSymbols)
|
|
for (var prop of __getOwnPropSymbols(b)) {
|
|
if (__propIsEnum.call(b, prop))
|
|
__defNormalProp(a, prop, b[prop]);
|
|
}
|
|
return a;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ADD_MULTI = "@\u2581\u2581@";
|
|
const ADD_SINGLE = "@\u2581@";
|
|
const preRegex = /<pre[^>]*>/g;
|
|
function _unescape(str) {
|
|
let div = document.createElement("div");
|
|
div.innerHTML = str;
|
|
return div.childNodes.length === 0 ? "" : div.childNodes[0].nodeValue;
|
|
}
|
|
/* harmony default export */ __webpack_exports__.Z = (({
|
|
value = "",
|
|
className,
|
|
showTextOnly,
|
|
showLines,
|
|
style = {},
|
|
stylesPrev = {},
|
|
highlightKeywords,
|
|
showProgramFill,
|
|
isProgramFill,
|
|
disabledFill = false,
|
|
programFillValue,
|
|
onFillChange = (value2) => {
|
|
},
|
|
onFillBlur = () => {
|
|
}
|
|
}) => {
|
|
let str = String(value);
|
|
const [data, setData] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)("");
|
|
const [type, setType] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)("office");
|
|
const [projectValue, setProjectValue] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]);
|
|
const classNamesRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)("a" + (0,uuid__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z)());
|
|
const formObj = {};
|
|
const createInput = (a, num) => {
|
|
const 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 = "\u8BF7\u8F93\u5165";
|
|
input.dataset.id = num;
|
|
const key = Object.keys(formObj).length;
|
|
formObj[key] = input;
|
|
return `<span class="edu-program-fill-wrap ${a === ADD_SINGLE ? "" : "show"}" style="width:${a === ADD_SINGLE ? "200px" : "100%"}"><span>${input.outerHTML}<span class="edu-program-fill-score"></span></span></span>`;
|
|
};
|
|
const formatMD = (rs) => {
|
|
return rs.replace(/<style.*?>([\s\S]+?)<\/style>/gim, function(_, css) {
|
|
let _css = css.replace(/(\n|\r)/g, "").split("}");
|
|
let arr = [];
|
|
_css.map((item) => {
|
|
if (item != "") {
|
|
arr.push(`.${classNamesRef.current} ${item}`);
|
|
}
|
|
});
|
|
return `<style>${arr.join("}")}</style>`;
|
|
});
|
|
};
|
|
const html = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => {
|
|
try {
|
|
const reg = /\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g;
|
|
const reg2 = /\"\/api\/attachments\/|\"\/attachments\/download\//g;
|
|
const reg3 = /\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;
|
|
str = str.replace(reg, "(" + _utils_env__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z.API_SERVER + "/api/attachments/").replace(reg2, '"' + _utils_env__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z.API_SERVER + "/api/attachments/").replace(reg3, '"' + _utils_env__WEBPACK_IMPORTED_MODULE_5__/* ["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");
|
|
} catch (e) {
|
|
}
|
|
;
|
|
if (showProgramFill) {
|
|
let num = -1;
|
|
str = str.replaceAll("<", "<").replaceAll(">", ">").replace(/(@▁▁@|@▁@)/g, function(a, b, c) {
|
|
++num;
|
|
return createInput(a, num);
|
|
});
|
|
return `<pre style="background:#fff;padding:4px">${formatMD(str || "")}</pre>`;
|
|
}
|
|
let rs = formatMD(str);
|
|
rs = (0,_utils_marked__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .ZP)(rs);
|
|
const math_expressions = (0,_utils_marked__WEBPACK_IMPORTED_MODULE_2__/* .getMathExpressions */ .ez)();
|
|
if (str.match(/\[TOC\]/)) {
|
|
rs = rs.replace("<p>[TOC]</p>", (0,_utils_marked__WEBPACK_IMPORTED_MODULE_2__/* .getTocContent */ .Qv)());
|
|
(0,_utils_marked__WEBPACK_IMPORTED_MODULE_2__/* .cleanToc */ .Iy)();
|
|
}
|
|
rs = rs.replace(/(__special_katext_id_\d+__)/g, (_match, capture) => {
|
|
const { type: type2, expression } = math_expressions[capture];
|
|
return (0,katex__WEBPACK_IMPORTED_MODULE_6__.renderToString)(_unescape(expression) || "", {
|
|
displayMode: type2 === "block",
|
|
throwOnError: false,
|
|
output: "html"
|
|
});
|
|
});
|
|
rs = rs.replace(/▁/g, "\u2581\u2581\u2581");
|
|
(0,_utils_marked__WEBPACK_IMPORTED_MODULE_2__/* .resetMathExpressions */ .AL)();
|
|
const dom = document.createElement("div");
|
|
dom.innerHTML = rs;
|
|
if (highlightKeywords) {
|
|
const escapedKeywords = highlightKeywords.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
findKeyword(dom, escapedKeywords);
|
|
return dom.innerHTML;
|
|
}
|
|
if (showTextOnly) {
|
|
return dom.innerText;
|
|
}
|
|
setTimeout(() => onLoad(), 500);
|
|
return dom.innerHTML;
|
|
}, [str, highlightKeywords]);
|
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
if (el.current) {
|
|
const inputs = el.current.querySelectorAll(["input", "textarea"]);
|
|
inputs.forEach((input) => {
|
|
input.oninput = onInput;
|
|
input.onblur = onBlur;
|
|
});
|
|
}
|
|
}, [projectValue]);
|
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
var _a, _b, _c;
|
|
if (!!(programFillValue == null ? void 0 : programFillValue.length)) {
|
|
try {
|
|
const scoreDom = el.current.querySelectorAll(".edu-program-fill-score");
|
|
const dom = el.current.querySelectorAll('[name="edu-program-fill"]');
|
|
for (const [k, i] of dom.entries()) {
|
|
i.value = (_a = programFillValue[k]) == null ? void 0 : _a.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 = "";
|
|
}
|
|
}
|
|
for (const [k, i] of scoreDom.entries()) {
|
|
i.innerHTML = ((_b = programFillValue[k]) == null ? void 0 : _b.score) ? `${(_c = programFillValue[k]) == null ? void 0 : _c.score}\u5206` : "";
|
|
}
|
|
setProjectValue(programFillValue);
|
|
} catch (error) {
|
|
}
|
|
}
|
|
}, [programFillValue]);
|
|
const onInput = (e) => {
|
|
projectValue[e.target.dataset.id] = projectValue[e.target.dataset.id] || {};
|
|
projectValue[e.target.dataset.id]["value"] = e.target.value;
|
|
setProjectValue([...projectValue]);
|
|
onFillChange(projectValue, e.target.dataset.id);
|
|
};
|
|
const onBlur = (e) => {
|
|
projectValue[e.target.dataset.id] = projectValue[e.target.dataset.id] || {};
|
|
projectValue[e.target.dataset.id]["value"] = e.target.value;
|
|
setProjectValue([...projectValue]);
|
|
onFillBlur(projectValue, e.target.dataset.id);
|
|
};
|
|
function findKeyword(node, keyword) {
|
|
return node.childNodes.forEach((childNode) => {
|
|
var _a;
|
|
if (childNode.childNodes.length > 0) {
|
|
findKeyword(childNode, keyword);
|
|
} else if (childNode.nodeName !== "IMG") {
|
|
if (childNode.innerHTML) {
|
|
childNode.innerHTML = (_a = childNode.innerHTML) == null ? void 0 : _a.replace(new RegExp(keyword, "gi"), '<span style="color:#0152d9;background-color:#1890ff33">$&</span>');
|
|
} else {
|
|
const dom = document.createElement("span");
|
|
dom.innerHTML = childNode.textContent.replace(new RegExp(keyword, "gi"), '<span style="color:#0152d9;background-color:#1890ff33">$&</span>');
|
|
childNode.replaceWith(dom);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
const el = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
|
|
_utils_marked__WEBPACK_IMPORTED_MODULE_2__/* .lines */ .jb["WebkitLineClamp"] = showLines;
|
|
if (showLines) {
|
|
style = __spreadValues(__spreadValues({}, style), _utils_marked__WEBPACK_IMPORTED_MODULE_2__/* .lines */ .jb);
|
|
}
|
|
function onAncherHandler(e) {
|
|
let target = e.target;
|
|
if (target.tagName.toUpperCase() === "A") {
|
|
let 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();
|
|
let viewEl = document.getElementById(ancher.replace("#", ""));
|
|
if (viewEl) {
|
|
viewEl.scrollIntoView(true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
const onLoad = () => {
|
|
var _a;
|
|
const videoElement = (_a = el.current) == null ? void 0 : _a.querySelectorAll("video");
|
|
videoElement == null ? void 0 : videoElement.forEach((item) => {
|
|
item.oncontextmenu = () => {
|
|
return false;
|
|
};
|
|
if (item.src.indexOf(".m3u8") > -1) {
|
|
if (item.canPlayType("application/vnd.apple.mpegurl")) {
|
|
} else if (hls_js__WEBPACK_IMPORTED_MODULE_4__/* ["default"].isSupported */ .ZP.isSupported()) {
|
|
var hls = new hls_js__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .ZP();
|
|
hls.loadSource(item.src);
|
|
hls.attachMedia(item);
|
|
}
|
|
}
|
|
});
|
|
};
|
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
if (el.current && html) {
|
|
if (html.match(preRegex)) {
|
|
window.PR.prettyPrint();
|
|
}
|
|
}
|
|
if (el.current) {
|
|
el.current.addEventListener("click", onAncherHandler);
|
|
return () => {
|
|
var _a;
|
|
(_a = el.current) == null ? void 0 : _a.removeEventListener("click", onAncherHandler);
|
|
(0,_utils_marked__WEBPACK_IMPORTED_MODULE_2__/* .resetMathExpressions */ .AL)();
|
|
(0,_utils_marked__WEBPACK_IMPORTED_MODULE_2__/* .cleanToc */ .Iy)();
|
|
};
|
|
}
|
|
}, [html, el.current, onAncherHandler]);
|
|
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, showTextOnly && /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { ref: el }, html), !showTextOnly && /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(
|
|
"div",
|
|
{
|
|
ref: el,
|
|
style: __spreadValues({}, style),
|
|
className: `${className ? className : ""} ${disabledFill ? "disabled-fill" : ""} markdown-body ${classNamesRef.current}`,
|
|
dangerouslySetInnerHTML: { __html: html }
|
|
}
|
|
), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(
|
|
_components_PreviewAll__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Z,
|
|
{
|
|
close: true,
|
|
data,
|
|
type: !!(data == null ? void 0 : data.length) ? type : "",
|
|
style: __spreadValues({}, stylesPrev),
|
|
onClose: () => setData("")
|
|
}
|
|
));
|
|
});
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 5596:
|
|
/*!*****************************!*\
|
|
!*** ./src/utils/marked.ts ***!
|
|
\*****************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ AL: function() { return /* binding */ resetMathExpressions; },
|
|
/* harmony export */ Iy: function() { return /* binding */ cleanToc; },
|
|
/* harmony export */ Qv: function() { return /* binding */ getTocContent; },
|
|
/* harmony export */ ez: function() { return /* binding */ getMathExpressions; },
|
|
/* harmony export */ jb: function() { return /* binding */ lines; }
|
|
/* harmony export */ });
|
|
/* harmony import */ var marked__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! marked */ 32834);
|
|
/* harmony import */ var marked__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(marked__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var marked_src_helpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! marked/src/helpers */ 11690);
|
|
/* harmony import */ var marked_src_helpers__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(marked_src_helpers__WEBPACK_IMPORTED_MODULE_1__);
|
|
|
|
|
|
function indentCodeCompensation(raw, text) {
|
|
const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
|
|
if (matchIndentToCode === null) {
|
|
return text;
|
|
}
|
|
const indentToCode = matchIndentToCode[1];
|
|
return text.split("\n").map((node) => {
|
|
const matchIndentInNode = node.match(/^\s+/);
|
|
if (matchIndentInNode === null) {
|
|
return node;
|
|
}
|
|
const [indentInNode] = matchIndentInNode;
|
|
if (indentInNode.length >= indentToCode.length) {
|
|
return node.slice(indentToCode.length);
|
|
}
|
|
return node;
|
|
}).join("\n");
|
|
}
|
|
let toc = [];
|
|
let ctx = ["<ul>"];
|
|
const renderer = new (marked__WEBPACK_IMPORTED_MODULE_0___default().Renderer)();
|
|
const headingRegex = /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;
|
|
function cleanToc() {
|
|
toc.length = 0;
|
|
ctx = ["<ul>"];
|
|
}
|
|
const lines = {
|
|
overflow: "hidden",
|
|
WebkitBoxOrient: "vertical",
|
|
display: "-webkit-box",
|
|
WebkitLineClamp: 2
|
|
};
|
|
function buildToc(coll, k, level, ctx2) {
|
|
if (k >= coll.length || coll[k].level <= level) {
|
|
return k;
|
|
}
|
|
var node = coll[k];
|
|
ctx2.push("<li><a href='#" + node.anchor + "'>" + node.text + "</a>");
|
|
k++;
|
|
var childCtx = [];
|
|
k = buildToc(coll, k, node.level, childCtx);
|
|
if (childCtx.length > 0) {
|
|
ctx2.push("<ul>");
|
|
childCtx.forEach(function(idm) {
|
|
ctx2.push(idm);
|
|
});
|
|
ctx2.push("</ul>");
|
|
}
|
|
ctx2.push("</li>");
|
|
k = buildToc(coll, k, level, ctx2);
|
|
return k;
|
|
}
|
|
function getTocContent() {
|
|
buildToc(toc, 0, 0, ctx);
|
|
ctx.push("</ul>");
|
|
return ctx.join("");
|
|
}
|
|
const tokenizer = {
|
|
heading(src) {
|
|
const cap = headingRegex.exec(src);
|
|
if (cap) {
|
|
return {
|
|
type: "heading",
|
|
raw: cap[0],
|
|
depth: cap[1].length,
|
|
text: cap[2]
|
|
};
|
|
}
|
|
},
|
|
fences(src) {
|
|
const cap = this.rules.block.fences.exec(src);
|
|
if (cap) {
|
|
const raw = cap[0];
|
|
let text = indentCodeCompensation(raw, cap[3] || "");
|
|
const lang = cap[2] ? cap[2].trim() : cap[2];
|
|
if (["latex", "katex", "math"].indexOf(lang) >= 0) {
|
|
const id = next_id();
|
|
const expression = text;
|
|
text = id;
|
|
math_expressions[id] = { type: "block", expression };
|
|
}
|
|
return {
|
|
type: "code",
|
|
raw,
|
|
lang,
|
|
text
|
|
};
|
|
}
|
|
}
|
|
};
|
|
const latexRegex = /(?:\${2})([^\n`]+?)(?:\${2})/gi;
|
|
let katex_count = 0;
|
|
const next_id = () => `__special_katext_id_${katex_count++}__`;
|
|
let math_expressions = {};
|
|
function getMathExpressions() {
|
|
return math_expressions;
|
|
}
|
|
function resetMathExpressions() {
|
|
katex_count = 0;
|
|
math_expressions = {};
|
|
}
|
|
function replace_math_with_ids(text) {
|
|
text = text.replace(latexRegex, (_match, expression) => {
|
|
const id = next_id();
|
|
math_expressions[id] = { type: "inline", expression };
|
|
return id;
|
|
});
|
|
return text;
|
|
}
|
|
const original_listitem = renderer.listitem;
|
|
renderer.listitem = function(text) {
|
|
return original_listitem(replace_math_with_ids(text));
|
|
};
|
|
const original_paragraph = renderer.paragraph;
|
|
renderer.paragraph = function(text) {
|
|
return original_paragraph(replace_math_with_ids(text));
|
|
};
|
|
const original_tablecell = renderer.tablecell;
|
|
renderer.tablecell = function(content, flags) {
|
|
return original_tablecell(replace_math_with_ids(content), flags);
|
|
};
|
|
renderer.code = function(code, infostring, escaped) {
|
|
const lang = (infostring || "").match(/\S*/)[0];
|
|
if (!lang) {
|
|
return '<pre class="prettyprint linenums"><code>' + (escaped ? code : (0,marked_src_helpers__WEBPACK_IMPORTED_MODULE_1__.escape)(code, true)) + "</code></pre>";
|
|
}
|
|
if (["latex", "katex", "math"].indexOf(lang) >= 0) {
|
|
return `<p class='editormd-tex'>${code}</p>`;
|
|
} else {
|
|
return `<pre class="prettyprint linenums"><code class="language-${infostring}">${escaped ? code : (0,marked_src_helpers__WEBPACK_IMPORTED_MODULE_1__.escape)(code, true)}</code></pre>
|
|
`;
|
|
}
|
|
};
|
|
renderer.heading = function(text, level, raw) {
|
|
let anchor = this.options.headerPrefix + raw.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g, "-");
|
|
toc.push({
|
|
anchor,
|
|
level,
|
|
text
|
|
});
|
|
return "<h" + level + ' id="' + anchor + '">' + text + "</h" + level + ">";
|
|
};
|
|
marked__WEBPACK_IMPORTED_MODULE_0___default().setOptions({
|
|
silent: true,
|
|
gfm: true,
|
|
pedantic: false
|
|
});
|
|
marked__WEBPACK_IMPORTED_MODULE_0___default().use({ tokenizer, renderer });
|
|
/* harmony default export */ __webpack_exports__.ZP = ((marked__WEBPACK_IMPORTED_MODULE_0___default()));
|
|
|
|
|
|
/***/ })
|
|
|
|
}]); |