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.
NewEduCoderBuild/2016.async.js

3130 lines
116 KiB

"use strict";
(self["webpackChunk"] = self["webpackChunk"] || []).push([[2016],{
/***/ 67886:
/*!*********************************!*\
!*** ./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 */ 64741);
function isCompileOk(rs) {
let flag = true;
if (rs.length > 0) {
for (let 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, parentKey = "") {
let result = [];
for (let i = 0; i < data.length; i++) {
let item = data[i];
let key = parentKey ? `${parentKey}/${item.name}` : `${item.name}`;
result.push({
title: item.name,
isLeaf: item.type === "tree" ? false : true,
key
});
}
return result;
}
function processTreeData(repos, key, newData) {
for (let i = 0; i < repos.length; i++) {
let 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) {
let timeout;
return function() {
let context = this, args = arguments;
let later = function() {
timeout = null;
if (!immediate)
func.apply(context, args);
};
let callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow)
func.apply(context, args);
};
}
const isProd = true;
const apiPref = _utils_env__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z.API_SERVER;
/***/ }),
/***/ 37704:
/*!**************************************************************!*\
!*** ./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/_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.3.2@classnames/index.js
var _classnames_2_3_2_classnames = __webpack_require__(12124);
var _classnames_2_3_2_classnames_default = /*#__PURE__*/__webpack_require__.n(_classnames_2_3_2_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__(87101);
// EXTERNAL MODULE: ./src/utils/util.tsx
var util = __webpack_require__(3163);
;// CONCATENATED MODULE: ./src/components/ImageDimensions/index.tsx
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());
});
};
const ImageDimensions = ({
data,
className,
fullWidth,
style = {},
onClose,
onOk,
showFullTools,
noAssociationId
}) => {
const imgRef = (0,_react_17_0_2_react.useRef)(null);
const markerArea = (0,_react_17_0_2_react.useRef)(null);
const [loading, setLoading] = (0,_react_17_0_2_react.useState)(false);
const [loadingText, setLoadingText] = (0,_react_17_0_2_react.useState)("\u6B63\u5728\u52A0\u8F7D\u4E2D");
(0,_react_17_0_2_react.useEffect)(() => {
if (data == null ? void 0 : data.visible) {
document.body.setAttribute("data-custom", "y-hidden");
} else {
document.body.removeAttribute("data-custom");
}
if (data == null ? void 0 : data.src) {
getImg();
}
}, [data == null ? void 0 : data.visible]);
const getImg = () => __async(void 0, null, function* () {
setLoading(true);
setLoadingText("\u6B63\u5728\u52A0\u8F7D\u4E2D");
const res = yield (0,util/* toDataUrl */.ZJ)(data == null ? void 0 : data.src);
imgRef.current.src = "";
imgRef.current.src = res;
imgRef.current.onload = function() {
initMarkerjs();
};
setLoading(false);
setLoadingText("");
});
const onSave = (event) => __async(void 0, null, function* () {
setLoading(true);
setLoadingText("\u6B63\u5728\u4FDD\u5B58\u4E2D");
const res = yield (0,fetch/* default */.ZP)("/api/attachments.json", {
method: "post",
body: {
file_type: "base64",
original_filename: data.title,
file: event.dataUrl
}
});
if ((res == null ? void 0 : res.id) && !noAssociationId) {
const result = yield (0,fetch/* default */.ZP)(`/api/attachments/${data.id}/add_subitem.json`, {
method: "post",
body: {
subitem_id: res == null ? void 0 : res.id,
settings: JSON.stringify(event.state)
}
});
if (result.status === 0) {
onOk();
}
} else if (res == null ? void 0 : res.id) {
onOk(res);
}
setLoading(false);
setLoadingText("");
});
const dealDom = () => {
const targetLink = document.querySelector('a[href="https://markerjs.com/"]');
if (targetLink && targetLink.parentNode) {
targetLink.parentNode.style.display = "none";
}
const item = [{
name: '[data-action="select"]',
title: "\u9009\u62E9"
}, {
name: '[data-action="delete"]',
title: "\u5220\u9664\u5143\u7D20"
}, {
name: '[data-action="undo"]',
title: "\u64A4\u9500"
}, {
name: '[data-type-name="FrameMarker"]',
title: "\u77E9\u5F62"
}, {
name: '[data-type-name="FreehandMarker"]',
title: "\u753B\u7EBF"
}, {
name: '[data-type-name="ArrowMarker"]',
title: "\u7BAD\u5934"
}, {
name: '[data-type-name="TextMarker"]',
title: "\u6587\u672C"
}, {
name: '[data-type-name="EllipseMarker"]',
title: "\u692D\u5706"
}, {
name: '[data-type-name="HighlightMarker"]',
title: "\u65B9\u5757"
}, {
name: '[data-type-name="CalloutMarker"]',
title: "\u6CE8\u91CA"
}, {
name: '[data-action="render"]',
title: "\u4FDD\u5B58"
}, {
name: '[data-action="close"]',
title: "\u9000\u51FA"
}];
item.forEach((e) => {
const targetElement = document.querySelector(e.name);
if (targetElement) {
targetElement.setAttribute("title", e.title);
}
});
};
const 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 ? void 0 : data.snapshotData) {
markerArea.current.restoreState(data.snapshotData);
}
setTimeout(() => {
dealDom();
}, 300);
};
return /* @__PURE__ */ _react_17_0_2_react.createElement(_react_17_0_2_react.Fragment, null, (data == null ? void 0 : data.visible) && /* @__PURE__ */ _react_17_0_2_react.createElement("div", { className: _classnames_2_3_2_classnames_default()(ImageDimensionsmodules.imageDimensions, className, fullWidth ? ImageDimensionsmodules.fullWidth : ""), style }, /* @__PURE__ */ _react_17_0_2_react.createElement(
spin/* default */.Z,
{
spinning: loading,
tip: loadingText,
style: { position: "absolute" }
}
), /* @__PURE__ */ _react_17_0_2_react.createElement(
"img",
{
className: ImageDimensionsmodules.img,
ref: imgRef
}
)));
};
/* harmony default export */ var components_ImageDimensions = (ImageDimensions);
/***/ }),
/***/ 75312:
/*!*************************************************************!*\
!*** ./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 react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ 59301);
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! antd */ 57809);
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! antd */ 78241);
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! antd */ 3113);
/* harmony import */ var codemirror__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! codemirror */ 89780);
/* harmony import */ var codemirror__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(codemirror__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var codemirror_lib_codemirror_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! codemirror/lib/codemirror.css */ 89835);
/* harmony import */ var codemirror_theme_blackboard_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! codemirror/theme/blackboard.css */ 49744);
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 Option = antd__WEBPACK_IMPORTED_MODULE_4__["default"].Option;
const formItemLayout = {
labelCol: { span: 4 },
wrapperCol: { span: 20 }
};
const 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 = (({ callback, onCancel }) => {
const [mode, setMode] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)("python");
function onSetMode(value) {
setMode(LanguageDesc[value][1]);
}
function onSubmit(values) {
callback(values);
}
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(
antd__WEBPACK_IMPORTED_MODULE_5__["default"],
__spreadProps(__spreadValues({}, formItemLayout), {
className: "code-block-panel",
initialValues: { language: "python", content: "" },
onFinish: onSubmit
}),
/* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_5__["default"].Item, { label: "\u4EE3\u7801\u8BED\u8A00", name: "language" }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(
antd__WEBPACK_IMPORTED_MODULE_4__["default"],
{
getPopupContainer: (trigger) => trigger.parentNode,
onChange: onSetMode
},
Object.keys(LanguageDesc).map((item) => /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(Option, { key: item, value: item }, LanguageDesc[item][0]))
)),
/* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(
antd__WEBPACK_IMPORTED_MODULE_5__["default"].Item,
{
label: "\u4EE3\u7801\u5185\u5BB9",
name: "content",
rules: [{ required: true, message: "\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9" }]
},
/* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(MyCodeMirror, { mode })
),
/* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: "flex-container flex-end" }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .ZP, { type: "primary", htmlType: "submit", style: { marginRight: 10 } }, "\u786E\u5B9A"), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .ZP, { type: "ghost", onClick: onCancel }, "\u53D6\u6D88"))
);
});
function MyCodeMirror({ value, onChange, mode, options = {} }) {
const el = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
const [cm, setCm] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)();
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
if (cm) {
let onChangeHandler = function(cm2) {
const content = cm2.getValue();
onChange && onChange(content);
};
cm.on("change", onChangeHandler);
return () => {
cm.off("change", onChangeHandler);
};
}
}, [cm, onChange]);
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
if (cm) {
cm.setOption("mode", mode);
}
}, [cm, mode]);
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
if (cm) {
if (value !== cm.getValue() || value === "") {
setTimeout(() => {
cm.setValue(value || "");
}, 300);
}
}
}, [cm, value]);
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
if (el.current && !cm) {
const instance = codemirror__WEBPACK_IMPORTED_MODULE_1___default().fromTextArea(el.current, __spreadValues({
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__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: "my-codemirror-container" }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("textarea", { ref: el }));
}
/***/ }),
/***/ 20103:
/*!***************************************************************!*\
!*** ./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/_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__(89835);
// 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__(12586);
;// CONCATENATED MODULE: ./src/components/RenderHtml/stex.tsx
/* harmony default export */ var RenderHtml_stex = (({
value = "",
className,
showTextOnly,
showLines,
style = {}
}) => {
const html = (0,_react_17_0_2_react.useMemo)(() => {
return "";
}, [value]);
return /* @__PURE__ */ _react_17_0_2_react.createElement(_react_17_0_2_react.Fragment, null, /* @__PURE__ */ _react_17_0_2_react.createElement("div", { dangerouslySetInnerHTML: { __html: html } }));
});
;// 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 __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));
let DEFAULTICONS = [
{ title: "\u7C97\u4F53", icon: "md-iconfont icon-bold", actionName: "bold" },
{ title: "\u659C\u4F53", icon: "md-iconfont icon-italic", actionName: "italic" },
"|",
{ title: "\u65E0\u5E8F\u5217\u8868", icon: "md-iconfont icon-unorder-list", actionName: "list-ul" },
{ title: "\u6709\u5E8F\u5217\u8868", icon: "md-iconfont icon-order-list", actionName: "list-ol" },
"|",
{ title: "\u884C\u5185\u4EE3\u7801", icon: "md-iconfont icon-code", actionName: "code" },
{
title: "\u4EE3\u7801\u5757\uFF08\u591A\u8BED\u8A00\u98CE\u683C\uFF09",
icon: "md-iconfont icon-file-code",
actionName: "code-block"
},
{ title: "\u94FE\u63A5", icon: "md-iconfont icon-link", actionName: "link" },
"|",
{
title: "\u884C\u5185\u516C\u5F0F",
icon: "md-iconfont icon-sum",
actionName: "inline-latex"
},
{
title: "\u591A\u884C\u516C\u5F0F",
icon: "md-iconfont icon-formula",
actionName: "latex"
},
"|",
{ title: "\u6DFB\u52A0\u56FE\u7247", icon: "md-iconfont icon-picture", actionName: "upload-image" },
{ title: "\u63D2\u5165\u753B\u56FE", icon: "iconfont icon-sheji", actionName: "draw-image" },
{ title: "\u63D2\u5165\u6D41\u7A0B\u56FE", icon: "iconfont icon-liucheng", actionName: "add-flowchart" },
{ title: "\u8868\u683C", icon: "md-iconfont icon-table", actionName: "add-table" },
"|",
{ title: "\u6362\u884C", icon: "md-iconfont icon-minus", actionName: "line-break" },
{ title: "\u6E05\u7A7A", icon: "md-iconfont icon-eraser", actionName: "eraser" }
];
function AButton({
onActionCallback,
title,
icon,
actionName,
className = "",
children
}) {
function onAction() {
onActionCallback(actionName);
}
return /* @__PURE__ */ _react_17_0_2_react.createElement("a", { title, className, onClick: onAction }, /* @__PURE__ */ _react_17_0_2_react.createElement("i", { className: `${icon}` }), children);
}
/* harmony default export */ var toolbar = (({ watch, showNullButton, showNullProgramButton, onActionCallback, fullScreen, insertTemp, hidetoolBar, extraUse }) => {
const icons = [
...DEFAULTICONS,
{
title: `${watch ? "\u5173\u95ED\u5B9E\u65F6\u9884\u89C8" : "\u5F00\u542F\u5B9E\u65F6\u9884\u89C8"}`,
icon: `${watch ? "md-iconfont icon-eye-slash" : "md-iconfont icon-eye"}`,
actionName: "trigger-watch"
}
];
return /* @__PURE__ */ _react_17_0_2_react.createElement("ul", { className: "markdown-toolbar-container" }, !hidetoolBar && icons.map((item, index) => /* @__PURE__ */ _react_17_0_2_react.createElement("li", { key: index }, item.actionName ? /* @__PURE__ */ _react_17_0_2_react.createElement(AButton, __spreadProps(__spreadValues({}, item), { onActionCallback })) : /* @__PURE__ */ _react_17_0_2_react.createElement("span", { className: "v-line" }))), showNullButton ? /* @__PURE__ */ _react_17_0_2_react.createElement("li", null, /* @__PURE__ */ _react_17_0_2_react.createElement(
AButton,
{
icon: "md-iconfont icon-edit insert-blank",
className: "btn-null",
title: "\u589E\u52A0\u586B\u7A7A",
actionName: "add-null-ch",
onActionCallback
},
/* @__PURE__ */ _react_17_0_2_react.createElement("span", { className: "fill-tip" }, "\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879")
)) : null, showNullProgramButton ? /* @__PURE__ */ _react_17_0_2_react.createElement(_react_17_0_2_react.Fragment, null, /* @__PURE__ */ _react_17_0_2_react.createElement("li", null, /* @__PURE__ */ _react_17_0_2_react.createElement(
AButton,
{
icon: "md-iconfont icon-edit insert-blank",
className: "btn-null",
title: "\u589E\u52A0\u586B\u7A7A",
actionName: "add-signal",
onActionCallback
},
/* @__PURE__ */ _react_17_0_2_react.createElement("span", { className: "fill-tip" }, "\u6DFB\u52A0\u5355\u884C\u586B\u7A7A\u9879")
)), /* @__PURE__ */ _react_17_0_2_react.createElement("li", null, /* @__PURE__ */ _react_17_0_2_react.createElement(
AButton,
{
icon: "md-iconfont icon-uniE900 insert-blank",
className: "btn-null",
title: "\u589E\u52A0\u586B\u7A7A",
actionName: "add-multiple",
onActionCallback
},
/* @__PURE__ */ _react_17_0_2_react.createElement("span", { className: "fill-tip" }, "\u6DFB\u52A0\u591A\u884C\u586B\u7A7A\u9879")
))) : null, insertTemp && /* @__PURE__ */ _react_17_0_2_react.createElement("li", null, /* @__PURE__ */ _react_17_0_2_react.createElement(
AButton,
{
icon: "md-iconfont icon-edit",
className: "btn-null",
title: "\u63D2\u5165\u6A21\u677F",
actionName: `inster-template-${insertTemp}`,
onActionCallback
},
/* @__PURE__ */ _react_17_0_2_react.createElement("span", { className: "fill-tip" }, "\u63D2\u5165\u6A21\u677F")
)), extraUse && /* @__PURE__ */ _react_17_0_2_react.createElement("li", null, extraUse), /* @__PURE__ */ _react_17_0_2_react.createElement("li", { className: "btn-full-screen" }, /* @__PURE__ */ _react_17_0_2_react.createElement(AButton, { icon: `${fullScreen ? "md-iconfont icon-shrink" : "md-iconfont icon-enlarge"}`, title: fullScreen ? "\u5173\u95ED\u5168\u5C4F" : "\u5F00\u542F\u5168\u5C4F", actionName: "trigger-full-screen", onActionCallback })));
});
// EXTERNAL MODULE: ./src/components/modal.tsx
var modal = __webpack_require__(69210);
// 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 link_defProp = Object.defineProperty;
var link_defProps = Object.defineProperties;
var link_getOwnPropDescs = Object.getOwnPropertyDescriptors;
var link_getOwnPropSymbols = Object.getOwnPropertySymbols;
var link_hasOwnProp = Object.prototype.hasOwnProperty;
var link_propIsEnum = Object.prototype.propertyIsEnumerable;
var link_defNormalProp = (obj, key, value) => key in obj ? link_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var link_spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (link_hasOwnProp.call(b, prop))
link_defNormalProp(a, prop, b[prop]);
if (link_getOwnPropSymbols)
for (var prop of link_getOwnPropSymbols(b)) {
if (link_propIsEnum.call(b, prop))
link_defNormalProp(a, prop, b[prop]);
}
return a;
};
var link_spreadProps = (a, b) => link_defProps(a, link_getOwnPropDescs(b));
const formItemLayout = {
labelCol: { span: 4 },
wrapperCol: { span: 20 }
};
/* harmony default export */ var markdown_editor_link = (({ callback, onCancel }) => {
function onSubmit(values) {
callback(values);
}
return /* @__PURE__ */ _react_17_0_2_react.createElement(
es_form["default"],
link_spreadProps(link_spreadValues({}, formItemLayout), {
initialValues: { link: "http://", title: "" },
className: "link-panel",
onFinish: onSubmit
}),
/* @__PURE__ */ _react_17_0_2_react.createElement(
es_form["default"].Item,
{
label: "\u94FE\u63A5\u5730\u5740",
name: "link",
rules: [{ required: true, message: "\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740" }]
},
/* @__PURE__ */ _react_17_0_2_react.createElement(input["default"], null)
),
/* @__PURE__ */ _react_17_0_2_react.createElement(
es_form["default"].Item,
{
label: "\u94FE\u63A5\u6807\u9898",
name: "title",
rules: [{ required: true, message: "\u8BF7\u8F93\u5165\u94FE\u63A5\u6807\u9898" }]
},
/* @__PURE__ */ _react_17_0_2_react.createElement(input["default"], null)
),
/* @__PURE__ */ _react_17_0_2_react.createElement("div", { className: "flex-container flex-end" }, /* @__PURE__ */ _react_17_0_2_react.createElement(es_button/* default */.ZP, { type: "primary", htmlType: "submit", style: { marginRight: 10 } }, "\u786E\u5B9A"), /* @__PURE__ */ _react_17_0_2_react.createElement(es_button/* default */.ZP, { type: "ghost", onClick: onCancel }, "\u53D6\u6D88"))
);
});
// EXTERNAL MODULE: ./src/components/markdown-editor/code-block/index.tsx
var code_block = __webpack_require__(75312);
// 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__(67886);
;// CONCATENATED MODULE: ./src/components/markdown-editor/upload-image/index.tsx
var upload_image_defProp = Object.defineProperty;
var upload_image_defProps = Object.defineProperties;
var upload_image_getOwnPropDescs = Object.getOwnPropertyDescriptors;
var upload_image_getOwnPropSymbols = Object.getOwnPropertySymbols;
var upload_image_hasOwnProp = Object.prototype.hasOwnProperty;
var upload_image_propIsEnum = Object.prototype.propertyIsEnumerable;
var upload_image_defNormalProp = (obj, key, value) => key in obj ? upload_image_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var upload_image_spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (upload_image_hasOwnProp.call(b, prop))
upload_image_defNormalProp(a, prop, b[prop]);
if (upload_image_getOwnPropSymbols)
for (var prop of upload_image_getOwnPropSymbols(b)) {
if (upload_image_propIsEnum.call(b, prop))
upload_image_defNormalProp(a, prop, b[prop]);
}
return a;
};
var upload_image_spreadProps = (a, b) => upload_image_defProps(a, upload_image_getOwnPropDescs(b));
const { useForm } = es_form["default"];
const style = { width: 280, marginRight: 10 };
const upload_image_formItemLayout = {
labelCol: { span: 5 },
wrapperCol: { span: 19 }
};
/* harmony default export */ var upload_image = (({ callback, onCancel }) => {
const [form] = useForm();
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/${data.id}`, type: file.type });
}
function onFileChange(e) {
let file = e.target.files[0];
uploadImage(file, onAddUrl);
}
return /* @__PURE__ */ _react_17_0_2_react.createElement(es_form["default"], upload_image_spreadProps(upload_image_spreadValues({ form }, upload_image_formItemLayout), { className: "upload-image-panel", onFinish: onSubmit, style: { width: 470, overflow: "hidden" } }), /* @__PURE__ */ _react_17_0_2_react.createElement(es_form["default"].Item, { label: "\u56FE\u7247\u5730\u5740", required: true }, /* @__PURE__ */ _react_17_0_2_react.createElement("div", { className: "flex-container" }, /* @__PURE__ */ _react_17_0_2_react.createElement(
es_form["default"].Item,
{
noStyle: true,
name: "src",
rules: [{ required: true, message: "\u8BF7\u8F93\u5165\u56FE\u7247\u5730\u5740" }]
},
/* @__PURE__ */ _react_17_0_2_react.createElement(input["default"], { style })
), /* @__PURE__ */ _react_17_0_2_react.createElement(UploadButton, { onFileChange }))), /* @__PURE__ */ _react_17_0_2_react.createElement(
es_form["default"].Item,
{
label: "\u56FE\u7247\u63CF\u8FF0",
name: "alt"
},
/* @__PURE__ */ _react_17_0_2_react.createElement(input["default"], { style: { width: 264 } })
), /* @__PURE__ */ _react_17_0_2_react.createElement(es_form["default"].Item, { style: { textAlign: "right" } }, /* @__PURE__ */ _react_17_0_2_react.createElement(es_button/* default */.ZP, { type: "primary", htmlType: "submit", style: { marginRight: 10 } }, "\u786E\u5B9A"), /* @__PURE__ */ _react_17_0_2_react.createElement(es_button/* default */.ZP, { type: "default", onClick: onCancel }, "\u53D6\u6D88")));
});
function UploadButton({ onFileChange }) {
return /* @__PURE__ */ _react_17_0_2_react.createElement("label", { className: "upload-button", style: { cursor: "pointer" } }, "\u672C\u5730\u4E0A\u4F20", /* @__PURE__ */ _react_17_0_2_react.createElement("input", { type: "file", onChange: onFileChange }));
}
function uploadImage(file, callback) {
if (!file) {
throw new String("\u6CA1\u6709\u6587\u4EF6");
return;
}
let 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", `${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__(37704);
;// CONCATENATED MODULE: ./src/components/markdown-editor/draw-image/index.tsx
/* harmony default export */ var draw_image = (({
callback,
onCancel
}) => {
const canvas = document.createElement("canvas");
const context = canvas.getContext("2d");
canvas.width = 1e3;
canvas.height = 800;
context.fillStyle = "#ffffff";
context.fillRect(0, 0, canvas.width, canvas.height);
const base64Image = canvas.toDataURL("image/png");
return /* @__PURE__ */ _react_17_0_2_react.createElement(row/* default */.Z, { style: { height: "100vh" } }, /* @__PURE__ */ _react_17_0_2_react.createElement(
ImageDimensions/* default */.Z,
{
fullWidth: true,
noAssociationId: true,
showFullTools: true,
data: {
src: base64Image,
visible: true,
title: String(Date.now())
},
onOk: (data) => {
callback({ src: data.url });
},
onClose: onCancel
}
));
});
// 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
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);
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;
};
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;
minPosition = Math.min(current.position.x, minPosition);
});
diagram.selection.each(function(current) {
if (current instanceof go.Link)
return;
current.move(new go.Point(minPosition, current.position.y));
});
diagram.commitTransaction("aligning left");
};
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;
var rightSideLoc = current.actualBounds.x + current.actualBounds.width;
maxPosition = Math.max(rightSideLoc, maxPosition);
});
diagram.selection.each(function(current) {
if (current instanceof go.Link)
return;
current.move(new go.Point(maxPosition - current.actualBounds.width, current.position.y));
});
diagram.commitTransaction("aligning right");
};
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;
minPosition = Math.min(current.position.y, minPosition);
});
diagram.selection.each(function(current) {
if (current instanceof go.Link)
return;
current.move(new go.Point(current.position.x, minPosition));
});
diagram.commitTransaction("alignTop");
};
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;
var bottomSideLoc = current.actualBounds.y + current.actualBounds.height;
maxPosition = Math.max(bottomSideLoc, maxPosition);
});
diagram.selection.each(function(current) {
if (current instanceof go.Link)
return;
current.move(new go.Point(current.actualBounds.x, maxPosition - current.actualBounds.height));
});
diagram.commitTransaction("aligning bottom");
};
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;
current.move(new go.Point(centerX - current.actualBounds.width / 2, current.actualBounds.y));
});
diagram.commitTransaction("aligning Center X");
};
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;
current.move(new go.Point(current.actualBounds.x, centerY - current.actualBounds.height / 2));
});
diagram.commitTransaction("aligning Center Y");
};
DrawCommandHandler.prototype.alignColumn = function(distance) {
var diagram = this.diagram;
diagram.startTransaction("align Column");
if (distance === void 0)
distance = 0;
distance = parseFloat(distance);
var selectedParts = new Array();
diagram.selection.each(function(current2) {
if (current2 instanceof go.Link)
return;
selectedParts.push(current2);
});
for (var i = 0; i < selectedParts.length - 1; i++) {
var current = selectedParts[i];
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");
};
DrawCommandHandler.prototype.alignRow = function(distance) {
if (distance === void 0)
distance = 0;
distance = parseFloat(distance);
var diagram = this.diagram;
diagram.startTransaction("align Row");
var selectedParts = new Array();
diagram.selection.each(function(current2) {
if (current2 instanceof go.Link)
return;
selectedParts.push(current2);
});
for (var i = 0; i < selectedParts.length - 1; i++) {
var current = selectedParts[i];
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");
};
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;
};
DrawCommandHandler.prototype.rotate = function(angle) {
if (angle === void 0)
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;
current.angle += angle;
});
diagram.commitTransaction("rotate " + angle.toString());
};
DrawCommandHandler.prototype.pullToFront = function() {
var diagram = this.diagram;
diagram.startTransaction("pullToFront");
var layers = new go.Map();
diagram.selection.each(function(part) {
layers.set(part.layer, 0);
});
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);
});
diagram.selection.each(function(part) {
DrawCommandHandler._assignZOrder(part, layers.get(part.layer) + 1);
});
diagram.commitTransaction("pullToFront");
};
DrawCommandHandler.prototype.pushToBack = function() {
var diagram = this.diagram;
diagram.startTransaction("pushToBack");
var layers = new go.Map();
diagram.selection.each(function(part) {
layers.set(part.layer, 0);
});
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);
});
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 === void 0)
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;
}
};
DrawCommandHandler.prototype.doKeyDown = function() {
var diagram = this.diagram;
if (diagram === null)
return;
var e = diagram.lastInput;
if (e.key === "Up" || e.key === "Down" || e.key === "Left" || e.key === "Right") {
var behavior = this.arrowKeyBehavior;
if (behavior === "none") {
return;
} else if (behavior === "select") {
this._arrowKeySelect();
return;
} else if (behavior === "move") {
this._arrowKeyMove();
return;
} else if (behavior === "tree") {
this._arrowKeyTree();
return;
}
}
go.CommandHandler.prototype.doKeyDown.call(this);
};
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);
});
return allParts;
};
DrawCommandHandler.prototype._arrowKeyMove = function() {
var diagram = this.diagram;
var e = diagram.lastInput;
var vdistance = 0;
var hdistance = 0;
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");
};
DrawCommandHandler.prototype._arrowKeySelect = function() {
var diagram = this.diagram;
var e = diagram.lastInput;
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);
}
}
};
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;
for (var i = 0; i < allParts.length; i++) {
var nextPart = allParts[i];
if (nextPart === originalPart)
continue;
if (!nextPart.canSelect())
continue;
var nextPoint = nextPart.actualBounds.center;
var angle = originalPoint.directionPoint(nextPoint);
var anglediff = this._angleCloseness(angle, dir);
if (anglediff <= 45) {
var distance = originalPoint.distanceSquaredPoint(nextPoint);
distance *= 1 + Math.sin(anglediff * Math.PI / 180);
if (distance < closestDistance) {
closestDistance = distance;
closest = nextPart;
}
}
}
return closest;
};
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)));
};
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) {
} else if (!selected.isTreeExpanded) {
if (diagram.commandHandler.canExpandTree(selected)) {
diagram.commandHandler.expandTree(selected);
}
} else {
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);
}
} else {
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) {
var prev = list.elt(idx - 1);
while (prev !== null && prev.isTreeExpanded && !prev.isTreeLeaf) {
var children = this._sortTreeChildrenByY(prev);
prev = children.last();
}
if (prev !== null)
diagram.select(prev);
} else {
diagram.select(parent);
}
}
} else if (e.key === "Down") {
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) {
diagram.select(list.elt(idx + 1));
break;
} else {
selected = parent;
}
}
}
}
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;
};
DrawCommandHandler.prototype.copyToClipboard = function(coll) {
go.CommandHandler.prototype.copyToClipboard.call(this, coll);
this._lastPasteOffset.set(this.pasteOffset);
};
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;
};
Object.defineProperty(DrawCommandHandler.prototype, "arrowKeyBehavior", {
get: function() {
return this._arrowKeyBehavior;
},
set: function(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;
}
});
Object.defineProperty(DrawCommandHandler.prototype, "pasteOffset", {
get: function() {
return this._pasteOffset;
},
set: function(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__(56600);
// 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__(87101);
;// 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
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());
});
};
window.go = go_module;
function FlowChart({ onCancel, callback }) {
let myDiagram = (0,_react_17_0_2_react.useRef)().current;
let myDiagramDivRef = (0,_react_17_0_2_react.useRef)();
let myPaletteDivRef = (0,_react_17_0_2_react.useRef)();
let hidedenContentRef = (0,_react_17_0_2_react.useRef)(false);
const [modal, contextHolder] = es_modal["default"].useModal();
function initDiagram() {
var _a;
const $ = go_module.GraphObject.make;
const 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 = 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: (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: "\u672A\u547D\u540D", fill: null, stroke: null, borderColor: "rgba(0,0,0,0)" },
// create a new node by double-clicking in background
"PartCreated": (e) => {
var node = e.subject;
node.location = node.location.copy().snapToGridPoint(e.diagram.grid.gridOrigin, e.diagram.grid.gridCellSize);
setTimeout(() => {
e.diagram.commandHandler.editTextBlock();
}, 20);
},
"commandHandler.archetypeGroupData": { isGroup: true, text: "NEW GROUP" },
"SelectionGrouped": (e) => {
var group = e.subject;
setTimeout(() => {
e.diagram.commandHandler.editTextBlock();
});
},
"LinkRelinked": (e) => {
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
}
);
myDiagram.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.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")
)
)
);
function makeArrowButton(spot, fig) {
var maker = (e, shape) => {
e.handled = true;
e.diagram.model.commit((m) => {
var selnode = shape.part.adornedPart;
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);
var nodedata = m.copyNodeData(selnode.data);
m.setGroupKeyForNodeData(nodedata, m.getGroupKeyForNodeData(selnode.data));
m.addNodeData(nodedata);
var linkdata = { from: selnode.key, to: m.getKeyForNodeData(nodedata) };
m.addLinkData(linkdata);
var newnode = e.diagram.findNodeForData(nodedata);
newnode.location = p;
e.diagram.select(newnode);
setTimeout(() => {
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: (e, shape) => shape.fill = "dodgerblue",
mouseLeave: (e, shape) => shape.fill = "orange",
isActionable: true,
// needed because it's in an Adornment
click: maker,
contextClick: maker
}
);
}
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: (e, shape) => shape.fill = "dodgerblue",
mouseLeave: (e, shape) => shape.fill = "orange",
click: (e, shape) => {
e.diagram.commandHandler.showContextMenu(shape.part.adornedPart);
}
},
options || {}
);
}
myDiagram.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) })
);
function ClickFunction(propname, value) {
return (e, obj) => {
e.handled = true;
e.diagram.model.commit((m) => {
m.set(obj.part.adornedPart.data, propname, 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: (e, shape) => shape.stroke = "dodgerblue",
mouseLeave: (e, shape) => shape.stroke = "lightgray",
click: ClickFunction(propname, color),
contextClick: ClickFunction(propname, color)
}
);
}
function LightFillButtons() {
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() {
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)
)
)
];
}
function ThicknessButton(sw, propname) {
if (!propname)
propname = "thickness";
return $(
go_module.Shape,
"LineH",
{
width: 16,
height: 16,
strokeWidth: sw,
margin: 1,
background: "transparent",
mouseEnter: (e, shape) => shape.background = "dodgerblue",
mouseLeave: (e, shape) => shape.background = "transparent",
click: ClickFunction(propname, sw),
contextClick: ClickFunction(propname, sw)
}
);
}
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: (e, shape) => shape.background = "dodgerblue",
mouseLeave: (e, shape) => shape.background = "transparent",
click: ClickFunction(propname, dash),
contextClick: ClickFunction(propname, dash)
}
);
}
function StrokeOptionsButtons() {
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])
)
)
];
}
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: (e, shape) => shape.fill = "dodgerblue",
mouseLeave: (e, shape) => shape.fill = "lightgray",
click: ClickFunction(propname, fig),
contextClick: ClickFunction(propname, fig)
}
);
}
myDiagram.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.commandHandler['MoveNodeUp'].execute(myDiagram);
// }
// })
// ),
// $("ContextMenuButton",
// $(go.TextBlock, 'Move Up', {
// // Associate the custom command to move the node up
// click: (e, obj) => {
// const node = obj.part.adornedPart;
// myDiagram.commandHandler['moveNodeUpCommand'].execute(myDiagram);
// }
// })
// ),
$(
"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()
);
myDiagram.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: (e, grp) => {
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.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.groupTemplate.contextMenu = $(
"ContextMenu",
LightFillButtons(),
DarkColorButtons(),
StrokeOptionsButtons()
);
myDiagram.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", (dir) => dir >= 1 ? 10 : 0),
new go_module.Binding("toShortLength", "dir", (dir) => 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", (dir) => 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", (dir) => dir >= 1),
new go_module.Binding("width", "thickness", (t) => 7 + 3 * t),
// custom arrowhead must scale with the size of the while
new go_module.Binding("height", "thickness", (t) => 7 + 3 * t),
// while remaining centered on line
new go_module.Binding("segmentOffset", "thickness", (t) => 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", (dir) => dir === 2),
new go_module.Binding("width", "thickness", (t) => 7 + 3 * t),
new go_module.Binding("height", "thickness", (t) => 7 + 3 * t),
new go_module.Binding("segmentOffset", "thickness", (t) => 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.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"
}
);
}
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: (e, shape) => shape.background = "dodgerblue",
mouseLeave: (e, shape) => shape.background = "transparent",
click: ClickFunction("dir", num),
contextClick: ClickFunction("dir", num)
}
);
}
function AllSidesButton(to) {
var setter = (e, shape) => {
e.handled = true;
e.diagram.model.commit((m) => {
var link = shape.part.adornedPart;
m.set(link.data, to ? "toSpot" : "fromSpot", go_module.Spot.stringify(go_module.Spot.AllSides));
(to ? link.toNode : link.fromNode).invalidateConnectedLinks();
});
};
return $(
go_module.Shape,
{
width: 12,
height: 12,
fill: "transparent",
mouseEnter: (e, shape) => shape.background = "dodgerblue",
mouseLeave: (e, shape) => 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 = (e, shape) => {
e.handled = true;
e.diagram.model.commit((m) => {
var link = shape.part.adornedPart;
m.set(link.data, to ? "toSpot" : "fromSpot", go_module.Spot.stringify(side));
(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: (e, shape) => shape.background = "dodgerblue",
mouseLeave: (e, shape) => shape.background = "transparent",
click: setter,
contextClick: setter
}
);
}
myDiagram.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)
)
)
)
);
const 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]}';
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;
}
console.log("1111111:", go_module.Shape.getFigureGenerators().toArray());
var myPalette = new go_module.Palette(
myPaletteDivRef.current,
// must name or refer to the DIV HTML element
{
maxSelectionCount: 1,
// nodeTemplateMap: myDiagram.nodeTemplateMap, // share the templates used by myDiagram
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
// "LineH", "LineV", "None", "BarH", "BarV", "MinusLine", "PlusLine", "XLine", "LineRight", "LineDown", "LineLeft", "LineUp"
// { text: "未命名", figure: "Diamond", "size":"100 100", fill: "#00AD5F" },
{ text: "\u672A\u547D\u540D", "size": "100 100", fill: null, stroke: "#000" },
// { text: "未命名", figure: "Database", "size":"100 100", fill: "lightgray" },
// { text: "未命名", figure: "Rectangle", "size":"100 100", fill: "lightskyblue" },
// { text: "未命名", figure: "Ellipse", "size":"100 100", fill: "#CE0620" },
// { text: "", "size":"100 20", figure: "LineH", fill: "lightyellow" },
// { text: "", "size":"20 100", figure: "LineV", fill: "lightyellow" },
// { text: "未命名", "size":"100 100", figure: "BarH", fill: "lightyellow" },
// { text: "", "size":"100 100", figure: "PlusLine", fill: "lightyellow" },
// { text: "", "size":"100 100", figure: "XLine", fill: "lightyellow" },
// { text: "", "size":"100 100", figure: "LineRight", fill: "lightyellow" },
// { text: "", "size":"100 100", figure: "LineDown", fill: "lightyellow" },
// { text: "", "size":"100 100", figure: "LineLeft", fill: "lightyellow" },
// { text: "", "size":"100 100", figure: "LineUp", fill: "lightyellow" },
// { text: "未命名", "size":"100 100", figure: "TriangleRight", fill: "lightyellow" },
// { text: "未命名", "size":"100 100", figure: "TriangleDown", fill: "lightyellow" },
// { text: "未命名", "size":"100 100", figure: "TriangleLeft", fill: "lightyellow" },
// { text: "未命名", "size":"100 100", figure: "TriangleUp", fill: "lightyellow" },
// { text: "未命名", "size":"100 100", figure: "Document", fill: "lightyellow" },
// { text: "未命名", "size":"100 100", figure: "CreateRequest", fill: "lightyellow" },
// { text: "未命名", "size":"100 100", figure: "ManualOperation", fill: "lightyellow" },
// { text: "未命名", "size":"100 100", figure: "Procedure", fill: "lightyellow" },
// { text: "未命名", "size":"100 100", figure: "Cylinder1", fill: "lightyellow" },
// { text: "未命名", "size":"100 100", figure: "RoundedRectangle", fill: "lightyellow" },
...go_module.Shape.getFigureGenerators().toArray().map((item) => {
return { text: "\u672A\u547D\u540D", "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)]) }
// ]
)
}
);
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()
)
);
myDiagram.addDiagramListener("InitialLayoutCompleted", () => {
var _a2;
(_a2 = myDiagram == null ? void 0 : myDiagram.zoomToFit) == null ? void 0 : _a2.call(myDiagram);
});
(_a = myDiagram == null ? void 0 : myDiagram.zoomToRect) == null ? void 0 : _a.call(myDiagram, new go_module.Rect(0.1, 0.1, 0.1, 0.1));
setTimeout(() => {
var _a2, _b;
(_a2 = myDiagram == null ? void 0 : myDiagram.zoomToRect) == null ? void 0 : _a2.call(myDiagram, new go_module.Rect(1, 1, 0.1, 0.1));
(_b = myDiagram == null ? void 0 : myDiagram.zoomToFit) == null ? void 0 : _b.call(myDiagram);
}, 1300);
window.myDiagram = myDiagram;
return myDiagram;
}
const save = () => __async(this, null, function* () {
var imgs = myDiagram.makeImage();
const res = yield (0,fetch/* default */.ZP)("/api/attachments.json", {
method: "post",
body: {
file_type: "base64",
original_filename: Date.now(),
file: imgs.src
}
});
callback({ src: res.url });
});
(0,_react_17_0_2_react.useEffect)(() => {
const instance = modal.confirm({
width: 1200,
icon: null,
footer: null,
closable: true,
onCancel,
className: "body-overflow-initial",
title: /* @__PURE__ */ _react_17_0_2_react.createElement(row/* default */.Z, null, /* @__PURE__ */ _react_17_0_2_react.createElement(col/* default */.Z, { flex: 1 }, "\u63D2\u5165\u6D41\u7A0B\u56FE"), /* @__PURE__ */ _react_17_0_2_react.createElement(col/* default */.Z, { onClick: () => {
hidedenContentRef.current = !hidedenContentRef.current;
instance.update(
{ icon: null, className: hidedenContentRef.current ? `${flow_chartmodules.maxH60} body-overflow-initial` : "body-overflow-initial", width: 1200 }
);
} }, /* @__PURE__ */ _react_17_0_2_react.createElement("span", { className: "current c-blue mr30", style: { fontWeight: 400 } }, "\u5C55\u5F00/\u6536\u8D77"))),
content: /* @__PURE__ */ _react_17_0_2_react.createElement("div", { style: { width: "100%", height: "80vh", overflow: "hidden", position: "relative" } }, /* @__PURE__ */ _react_17_0_2_react.createElement("div", { style: { display: "flex", height: "100%" } }, /* @__PURE__ */ _react_17_0_2_react.createElement("div", { style: { width: "300px", height: "100%" } }, /* @__PURE__ */ _react_17_0_2_react.createElement("div", { style: { background: "#fff", position: "relative", zIndex: 12, fontSize: 16, color: "#3061d0" } }, "\u56FE\u5F62\u5E93"), /* @__PURE__ */ _react_17_0_2_react.createElement("div", { style: { height: "calc(100% - 50px)" }, className: flow_chartmodules.myPaletteDiv, ref: myPaletteDivRef })), /* @__PURE__ */ _react_17_0_2_react.createElement("div", { style: { flex: 1, position: "relative" } }, /* @__PURE__ */ _react_17_0_2_react.createElement(
gojsreact/* ReactDiagram */.FI,
{
initDiagram,
divClassName: "diagram-component",
style: { height: "80vh" }
}
), /* @__PURE__ */ _react_17_0_2_react.createElement("div", { ref: myDiagramDivRef }))), /* @__PURE__ */ _react_17_0_2_react.createElement("div", { className: "tr" }, /* @__PURE__ */ _react_17_0_2_react.createElement(es_button/* default */.ZP, { size: "large", onClick: save, style: { position: "absolute", right: 0, bottom: 0, zIndex: 8 }, type: "primary" }, "\u4FDD\u5B58\u5230\u7F16\u8F91\u5668")))
});
return () => {
instance.destroy();
};
}, []);
return /* @__PURE__ */ _react_17_0_2_react.createElement("div", null, contextHolder);
}
/* 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
const RadioGroup = es_radio/* default.Group */.ZP.Group;
const add_table_panel_style = {
margin: "0 8px"
};
/* harmony default export */ var add_table_panel = (({ callback, onCancel }) => {
function onSubmit(values) {
callback(values);
}
return /* @__PURE__ */ _react_17_0_2_react.createElement(
es_form["default"],
{
className: "add-table-panel",
initialValues: { row: 3, col: 2, align: "default" },
onFinish: onSubmit
},
/* @__PURE__ */ _react_17_0_2_react.createElement("div", { className: "flex-container", style: { alignItems: "baseline" } }, /* @__PURE__ */ _react_17_0_2_react.createElement("span", { style: add_table_panel_style }, "\u5355\u5143\u683C\u6570\uFF1A"), /* @__PURE__ */ _react_17_0_2_react.createElement("span", { style: add_table_panel_style }, "\u884C\u6570"), /* @__PURE__ */ _react_17_0_2_react.createElement(
es_form["default"].Item,
{
name: "row",
rules: [{ required: true, message: "\u8BF7\u8F93\u5165\u884C\u6570" }]
},
/* @__PURE__ */ _react_17_0_2_react.createElement(input_number/* default */.Z, null)
), /* @__PURE__ */ _react_17_0_2_react.createElement("span", { style: add_table_panel_style }, "\u5217\u6570"), /* @__PURE__ */ _react_17_0_2_react.createElement(
es_form["default"].Item,
{
name: "col",
rules: [{ required: true, message: "\u8BF7\u8F93\u5165\u5217\u6570" }]
},
/* @__PURE__ */ _react_17_0_2_react.createElement(input_number/* default */.Z, null)
)),
/* @__PURE__ */ _react_17_0_2_react.createElement("div", { className: "flex-container", style: { marginTop: 12, alignItems: "baseline" } }, /* @__PURE__ */ _react_17_0_2_react.createElement("span", { style: add_table_panel_style }, "\u5BF9\u9F50\u65B9\u5F0F\uFF1A"), /* @__PURE__ */ _react_17_0_2_react.createElement(es_form["default"].Item, { name: "align" }, /* @__PURE__ */ _react_17_0_2_react.createElement(RadioGroup, null, /* @__PURE__ */ _react_17_0_2_react.createElement(es_radio/* default */.ZP, { value: "default" }, /* @__PURE__ */ _react_17_0_2_react.createElement("i", { className: "fa fa-align-justify" })), /* @__PURE__ */ _react_17_0_2_react.createElement(es_radio/* default */.ZP, { value: "left" }, /* @__PURE__ */ _react_17_0_2_react.createElement("i", { className: "fa fa-align-left" })), /* @__PURE__ */ _react_17_0_2_react.createElement(es_radio/* default */.ZP, { value: "center" }, /* @__PURE__ */ _react_17_0_2_react.createElement("i", { className: "fa fa-align-center" })), /* @__PURE__ */ _react_17_0_2_react.createElement(es_radio/* default */.ZP, { value: "right" }, /* @__PURE__ */ _react_17_0_2_react.createElement("i", { className: "fa fa-align-right" }))))),
/* @__PURE__ */ _react_17_0_2_react.createElement("div", { className: "flex-container flex-end" }, /* @__PURE__ */ _react_17_0_2_react.createElement(es_button/* default */.ZP, { type: "primary", htmlType: "submit", style: { marginRight: 10 } }, "\u786E\u5B9A"), /* @__PURE__ */ _react_17_0_2_react.createElement(es_button/* default */.ZP, { type: "ghost", onClick: onCancel }, "\u53D6\u6D88"))
);
});
// EXTERNAL MODULE: ./src/utils/env.ts + 1 modules
var env = __webpack_require__(64741);
;// CONCATENATED MODULE: ./src/components/markdown-editor/constant.ts
const LINK = "link";
const UPLOAD_IMAGE = "upload-image";
const ADD_FLOWCHART = "add-flowchart";
const DRAW_IMAGE = "draw-image";
const FLOW_CHART = "add-flowchart";
const CODE_BLOCK = "code-block";
const ADD_TABLE = "add-table";
const HRLINE = "------------";
const ALIGNSIGN = {
default: HRLINE,
left: `:${HRLINE}`,
center: `:${HRLINE}:`,
right: `${HRLINE}:`
};
// EXTERNAL MODULE: ./src/components/useInterval.tsx
var useInterval = __webpack_require__(26440);
;// CONCATENATED MODULE: ./src/components/markdown-editor/index.tsx
function noop() {
}
let pending = 0;
const StorageTimeTicket = 1e4;
const NULL_CH = "\u2581";
const ADD_MULTI = "@\u2581\u2581@";
const ADD_SINGLE = "@\u2581@";
const TEMP1 = "\n**\u6A21\u677F\u6807\u9898**\n\u6A21\u677F\u6B63\u6587\u5185\u5BB9\uFF0C\u53EF\u8F93\u5165\u6587\u672C\u5185\u5BB9\u548C\u7C98\u8D34\u56FE\u7247\u7B49\u64CD\u4F5C";
function processSize(size) {
return !/^\d+$/.test(size) ? size : `${size}px`;
}
const isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0;
const key = isMac ? "Cmd" : "Ctrl";
const DEFAULTKEYMAP = {
[key + "-B"]: "bold",
[key + "-I"]: "italic"
};
const TitleDesc = {
[LINK]: "\u6DFB\u52A0\u94FE\u63A5",
[CODE_BLOCK]: "\u6DFB\u52A0\u4EE3\u7801\u5757",
[UPLOAD_IMAGE]: "\u6DFB\u52A0\u56FE\u7247",
[DRAW_IMAGE]: "\u6DFB\u52A0\u753B\u56FE",
[ADD_FLOWCHART]: "\u63D2\u5165\u6D41\u7A0B\u56FE",
[ADD_TABLE]: "\u6DFB\u52A0\u8868\u683C"
};
/* harmony default export */ var markdown_editor = (({
defaultValue = "",
onChange,
width = "100%",
height = 400,
miniToolbar = false,
isFocus = false,
watch,
insertTemp,
mode = "markdown",
id = "markdown-editor-id",
showResizeBar = false,
noStorage = false,
showNullButton = false,
showNullProgramButton = false,
hidetoolBar = false,
fullScreen = false,
onBlur,
onCMBeforeChange,
onFullScreen,
className = "",
disablePaste = false,
disabled = false,
disabledFill = false,
placeholder = "",
values = "",
extraUse
}) => {
const [cm, setCm] = (0,_react_17_0_2_react.useState)(null);
const [value, setValue] = (0,_react_17_0_2_react.useState)(defaultValue);
const [preview, setPreview] = (0,_react_17_0_2_react.useState)(watch);
const [isFull, setIsFull] = (0,_react_17_0_2_react.useState)(fullScreen);
const [action, setAction] = (0,_react_17_0_2_react.useState)("");
const [lastedUpdateTime, setLastedUpdateTime] = (0,_react_17_0_2_react.useState)(0);
const [h, setH] = (0,_react_17_0_2_react.useState)(height);
const [tip, setTip] = (0,_react_17_0_2_react.useState)(false);
const cmEl = (0,_react_17_0_2_react.useRef)();
const containerEl = (0,_react_17_0_2_react.useRef)();
const resizeBarEl = (0,_react_17_0_2_react.useRef)();
const previewEl = (0,_react_17_0_2_react.useRef)();
(0,_react_17_0_2_react.useEffect)(() => {
const scrollTop = window.scrollY || window.pageYOffset;
setValue(values);
cm == null ? void 0 : cm.setValue(values);
window.scrollTo(0, scrollTop);
}, [values]);
(0,_react_17_0_2_react.useEffect)(() => {
onFullScreen == null ? void 0 : onFullScreen(isFull);
}, [isFull]);
(0,_react_17_0_2_react.useEffect)(() => {
if (cmEl.current) {
let onPaste = function(_, e) {
var _a;
if (disablePaste) {
e.preventDefault();
return;
}
const clipboardData = e.clipboardData;
if (clipboardData) {
const types = clipboardData.types.toString();
const items = clipboardData.items;
const 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 {
let item = items[1];
if (((_a = items[0]) == null ? void 0 : _a.kind) === "file") {
item = items[0];
}
const file = item.getAsFile();
const fileSix = file.name.split(".").pop();
uploadImage(file, (data) => {
var _a2, _b, _c;
if (data.id) {
if (((_a2 = file == null ? void 0 : file.type) == null ? void 0 : _a2.indexOf("image")) > -1) {
instance.replaceSelection(`![,](/api/attachments/${data.id}?type=${data.content_type})`);
} else if (((_b = file == null ? void 0 : file.type) == null ? void 0 : _b.indexOf("video")) > -1) {
instance.replaceSelection(`<video width="100%" controls src="${env/* default */.Z.API_SERVER}/api/attachments/${data.id}"></video>`);
} else if (((_c = file == null ? void 0 : file.type) == null ? void 0 : _c.indexOf("pdf")) > -1) {
instance.replaceSelection(`<a href="${env/* default */.Z.API_SERVER}/api/attachments/${data.id}?type=${file.type}&disposition=inline" target="_blank">${file.name}</a>`);
} else if (officeSix.includes(fileSix)) {
instance.replaceSelection(`<a href="${env/* default */.Z.API_SERVER}/api/attachments/${data.id}?type=office&disposition=inline" target="_blank">${file.name}</a>`);
} else {
instance.replaceSelection(`[${file.name}](${env/* default */.Z.API_SERVER}/api/attachments/${data.id}?type=${data.content_type})`);
}
} else {
if ((data == null ? void 0 : data.status) === 401)
document.location.href = "/user/login";
}
});
} catch (e2) {
message/* default */.ZP.warning("\u8BF7\u4F7F\u7528chrome\u6D4F\u89C8\u5668\u7C98\u8D34");
}
return true;
} else {
return true;
}
}
return true;
};
const instance = codemirror_default().fromTextArea(cmEl.current, {
mode,
// inputStyle: 'contenteditable',
lineNumbers: miniToolbar ? false : true,
lineWrapping: true,
value: defaultValue,
autoCloseTags: true,
autoCloseBrackets: true
});
instance.on("keyup", function(cm2, event) {
if (event.keyCode === 8) {
if (cm2.getValue() == "") {
instance.setOption("placeholder", placeholder);
} else {
instance.setOption("placeholder", null);
}
}
});
instance.on("keydown", function(cm2, event) {
if (event.keyCode === 8) {
var pos = deleteAtSymbol(cm2);
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 () => {
instance.off("paste", onPaste);
};
}
}, []);
const resizeEditorBodyHeight = (0,_react_17_0_2_react.useCallback)(() => {
if (containerEl.current) {
try {
} catch (error) {
console.log(error, "---- to set md editor body height");
}
}
}, [h, containerEl, isFull]);
(0,_react_17_0_2_react.useEffect)(() => {
function onLayout() {
let ro = new ResizeObserver_es/* default */.Z((entries) => {
for (let entry of entries) {
if (entry.target.offsetHeight > 0 || entry.target.offsetWidth > 0) {
resizeEditorBodyHeight();
cm.setSize("100%", "100%");
cm.refresh();
}
}
});
ro.observe(cmEl.current.parentElement);
return ro;
}
if (cm) {
const ro = onLayout();
return () => {
var _a, _b;
if ((_a = cmEl.current) == null ? void 0 : _a.parentElement)
ro.unobserve((_b = cmEl.current) == null ? void 0 : _b.parentElement);
};
}
}, [cm, resizeEditorBodyHeight]);
(0,_react_17_0_2_react.useEffect)(() => {
if (cm) {
let keymap = [];
for (const [k, value2] of Object.entries(DEFAULTKEYMAP)) {
let map = {
[k]: () => {
onActionCallback(value2);
}
};
keymap.push(map);
cm.addKeyMap(map);
}
return () => {
for (let m of keymap) {
cm.removeKeyMap(m);
}
};
}
}, [cm]);
(0,_react_17_0_2_react.useEffect)(() => {
if (fullScreen !== isFull) {
setIsFull(fullScreen);
}
}, [fullScreen]);
(0,useInterval/* default */.Z)(() => {
if (!noStorage && lastedUpdateTime > 0) {
let currentTime = (/* @__PURE__ */ new Date()).getTime();
let 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)(() => {
setPreview(watch);
}, [cm, watch]);
(0,_react_17_0_2_react.useEffect)(() => {
if (cm) {
isFocus && cm.focus();
}
}, [cm, isFocus]);
(0,_react_17_0_2_react.useEffect)(() => {
if (preview && cm) {
let syncScroll = function(e) {
let target = e.target;
if (previewEl.current) {
let ratio = target.scrollTop / target.scrollHeight;
previewEl.current.scrollTop = previewEl.current.scrollHeight * ratio;
}
};
const scrollEl = cm.getScrollerElement();
scrollEl.addEventListener("scroll", syncScroll);
return () => {
scrollEl.removeEventListener("scroll", syncScroll);
};
}
}, [cm, preview]);
(0,_react_17_0_2_react.useEffect)(() => {
if (cm && onCMBeforeChange) {
let onChangeHandler = function(cm2, change) {
onCMBeforeChange(cm2, change);
};
cm.on("beforeChange", onChangeHandler);
return () => {
cm.off("beforeChange", onChangeHandler);
};
}
}, [cm, onCMBeforeChange]);
(0,_react_17_0_2_react.useEffect)(() => {
if (cm && onBlur) {
let onBlurHandler = function() {
onBlur(cm.getValue());
};
cm.on("blur", onBlurHandler);
return () => {
cm.off("blur", onBlurHandler);
};
}
}, [cm, onBlur]);
function deleteAtSymbol(cm2, change) {
var doc = cm2.getDoc();
var cursor = doc.getCursor();
var line = doc.getLine(cursor.line);
var ch = line.charAt(cursor.ch - 1);
var p1 = line.lastIndexOf("@\u2581@", cursor.ch);
var p2 = line.lastIndexOf("@\u2581\u2581@", 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, cm2, 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)(() => {
if (cm) {
let onChangeHandler = function(cm2, change) {
const content = cm2.getValue();
setValue(content);
setLastedUpdateTime((/* @__PURE__ */ new Date()).getTime());
cm2.getScrollerElement().dispatchEvent(new CustomEvent("scroll"));
if (onChange) {
if (showNullProgramButton) {
onChange(content, formatProgramFill(content));
} else {
onChange(content);
}
}
};
cm.on("change", onChangeHandler);
return () => {
cm.off("change", onChangeHandler);
};
}
}, [cm, onChange]);
(0,_react_17_0_2_react.useEffect)(() => {
if (cm) {
if (defaultValue === null || defaultValue === void 0) {
cm.setValue("");
setValue("");
} else {
const 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]);
const onActionCallback = (0,_react_17_0_2_react.useCallback)(
(actionName) => {
const cursor = cm.getCursor();
const selection = cm.getSelection();
let 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((item) => item === "" ? "" : `- ${item}`).join("\n")
);
}
return cm.focus();
case "list-ol":
if (selection === "") {
cm.replaceSelection("1. " + selection);
} else {
cm.replaceSelection(
selectionText.map(
(item, index) => item === "" ? "" : `${index + 1}. ${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]
);
const ExecutePluginAction = (0,_react_17_0_2_react.useCallback)(
(values2) => {
setAction("");
switch (action) {
case LINK:
const { title, link } = values2;
cm.replaceSelection(`[${title}](${link})`);
return cm.focus();
case CODE_BLOCK:
const { language, content } = values2;
cm.replaceSelection(["```" + language, content, "```"].join("\n"));
return cm.focus();
case UPLOAD_IMAGE:
case DRAW_IMAGE:
case FLOW_CHART:
const { src, alt } = values2;
if (alt) {
cm.replaceSelection(`![ ${alt} ]( ${src} "${alt}" )`);
} else {
cm.replaceSelection(`![,](${src})`);
}
return cm.focus();
case ADD_TABLE:
const { row, col, align } = values2;
let table = "\n";
for (let r = 0; r < row; r++) {
let rows = [];
let heads = [];
for (let c = 0; c < col; c++) {
if (r === 1) {
heads.push(ALIGNSIGN[align]);
}
rows.push(" ");
}
if (r === 1) {
table += `| ${heads.join(" | ")} |
`;
}
table += `| ${rows.join(col === 1 ? "" : " | ")} |
`;
}
cm.replaceSelection(table + "\n");
return cm.focus();
default:
throw new Error();
}
},
[cm, action]
);
const PluginEl = (0,_react_17_0_2_react.useMemo)(() => {
switch (action) {
case LINK:
return /* @__PURE__ */ _react_17_0_2_react.createElement(markdown_editor_link, { callback: ExecutePluginAction, onCancel });
case CODE_BLOCK:
return /* @__PURE__ */ _react_17_0_2_react.createElement(code_block/* default */.Z, { callback: ExecutePluginAction, onCancel });
case UPLOAD_IMAGE:
return /* @__PURE__ */ _react_17_0_2_react.createElement(upload_image, { callback: ExecutePluginAction, onCancel });
case ADD_FLOWCHART:
return /* @__PURE__ */ _react_17_0_2_react.createElement(flow_chart, { callback: ExecutePluginAction, onCancel });
case ADD_TABLE:
return /* @__PURE__ */ _react_17_0_2_react.createElement(add_table_panel, { callback: ExecutePluginAction, onCancel });
default:
return null;
}
}, [action]);
function onCancel() {
setAction("");
}
(0,_react_17_0_2_react.useEffect)(() => {
if (resizeBarEl.current) {
let onMouseDown = function(e) {
dragging = true;
startY = e.pageY;
}, onMouseUp = function() {
dragging = false;
}, onMouseMove = function(e) {
if (dragging) {
let delta = e.pageY - startY;
if (delta < 0) {
delta = 0;
}
if (delta > 300) {
delta = 300;
}
let resizeH = height + delta + "px";
setH(resizeH);
}
};
let resizeBar = resizeBarEl.current;
let dragging = false;
let startY = 0;
resizeBar.addEventListener("mousedown", onMouseDown);
document.addEventListener("mousemove", onMouseMove);
document.addEventListener("mouseup", onMouseUp);
return () => {
resizeBar.removeEventListener("mousedown", onMouseDown);
document.removeEventListener("mousemove", onMouseMove);
document.removeEventListener("mouseup", onMouseUp);
};
}
}, [cm, resizeBarEl]);
(0,_react_17_0_2_react.useEffect)(() => {
setH(height);
}, [height]);
const fixedWidth = processSize(width);
const fixedHeight = processSize(h);
const style = {
width: fixedWidth,
height: fixedHeight
};
const saveTime = (0,_react_17_0_2_react.useMemo)(() => {
if (lastedUpdateTime) {
let d = new Date(lastedUpdateTime);
let h2 = d.getHours();
let m = d.getMinutes();
let s = d.getSeconds();
h2 = h2 < 10 ? "0" + h2 : h2;
m = m < 10 ? "0" + m : m;
s = s < 10 ? "0" + s : s;
return `${h2}:${m}:${s}`;
}
return 0;
}, [lastedUpdateTime]);
const formatProgramFill = (str) => {
const arr = [];
if (showNullProgramButton) {
let 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__ */ _react_17_0_2_react.createElement(_react_17_0_2_react.Fragment, null, /* @__PURE__ */ _react_17_0_2_react.createElement("div", { className: "markdown-editor-wrapper", ref: containerEl }, /* @__PURE__ */ _react_17_0_2_react.createElement(
"div",
{
className: `markdown-editor-container ${className} ${preview ? "on-preview" : ""} ${miniToolbar ? "mini" : ""} ${isFull ? "full-screen" : ""}`,
style
},
/* @__PURE__ */ _react_17_0_2_react.createElement(
toolbar,
{
insertTemp,
watch: preview,
fullScreen: isFull,
showNullButton,
showNullProgramButton,
onActionCallback,
hidetoolBar,
extraUse
}
),
/* @__PURE__ */ _react_17_0_2_react.createElement("div", { className: "markdown-editor-body" }, /* @__PURE__ */ _react_17_0_2_react.createElement("div", { className: "codemirror-container" }, /* @__PURE__ */ _react_17_0_2_react.createElement("textarea", { ref: cmEl, placeholder })), preview ? /* @__PURE__ */ _react_17_0_2_react.createElement("div", { ref: previewEl, className: "preview-container" }, mode === "stex" && /* @__PURE__ */ _react_17_0_2_react.createElement(RenderHtml_stex, { value }), mode !== "stex" && /* @__PURE__ */ _react_17_0_2_react.createElement(RenderHtml/* default */.Z, { disabledFill, showProgramFill: showNullProgramButton, value })) : null)
)), showResizeBar ? /* @__PURE__ */ _react_17_0_2_react.createElement("a", { ref: resizeBarEl, className: "editor-resize" }) : null, action === DRAW_IMAGE && /* @__PURE__ */ _react_17_0_2_react.createElement(draw_image, { callback: ExecutePluginAction, onCancel }), action === ADD_FLOWCHART && /* @__PURE__ */ _react_17_0_2_react.createElement(flow_chart, { callback: ExecutePluginAction, onCancel }), /* @__PURE__ */ _react_17_0_2_react.createElement(modal/* default */.Z, null, TitleDesc[action] && action !== DRAW_IMAGE && action !== ADD_FLOWCHART ? /* @__PURE__ */ _react_17_0_2_react.createElement(
es_modal["default"],
{
centered: true,
title: TitleDesc[action],
open: true,
onCancel,
footer: null,
destroyOnClose: true,
width: action === ADD_FLOWCHART ? "1200px" : 520,
height: action === ADD_FLOWCHART ? "80vh" : null,
className: "markdown-popup-form"
},
PluginEl
) : null));
});
/***/ }),
/***/ 69210:
/*!**********************************!*\
!*** ./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 react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ 59301);
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ 4676);
class Dialog extends react__WEBPACK_IMPORTED_MODULE_0__.Component {
constructor(props) {
super(props);
const doc = window.document;
this.node = doc.createElement("div");
doc.body.appendChild(this.node);
}
render() {
const { children } = this.props;
return (0,react_dom__WEBPACK_IMPORTED_MODULE_1__.createPortal)(children, this.node);
}
componentWillUnmount() {
window.document.body.removeChild(this.node);
}
}
/***/ }),
/***/ 26440:
/*!****************************************!*\
!*** ./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) {
const savedCallback = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
savedCallback.current = callback;
});
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
function tick() {
savedCallback.current();
}
if (delay !== null) {
let id = setInterval(tick, delay);
return () => clearInterval(id);
}
}, [delay]);
}
/***/ })
}]);