(self["webpackChunk"] = self["webpackChunk"] || []).push([[986],{ /***/ 94471: /*!*********************************************************!*\ !*** ./src/components/MathematicalGraphics/js/index.js ***! \*********************************************************/ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function() { if (typeof window.GGBApplet == "function") { console.warn("deployggb.js was loaded twice"); return; } var isRenderGGBElementEnabled = false; var scriptLoadStarted = false; var html5AppletsToProcess = null; var ggbHTML5LoadedCodebaseIsWebSimple = false; var ggbHTML5LoadedCodebaseVersion = null; var ggbHTML5LoadedScript = null; var GGBApplet = function() { "use strict"; var applet = {}; var ggbVersion = "5.0"; var parameters = {}; var views = null; var html5NoWebSimple = false; var html5NoWebSimpleParamExists = false; var appletID = null; var initComplete = false; var html5OverwrittenCodebaseVersion = null; var html5OverwrittenCodebase = null; for (var i2 = 0; i2 < arguments.length; i2++) { var p2 = arguments[i2]; if (p2 !== null) { switch (typeof p2) { case "number": ggbVersion = p2.toFixed(1); break; case "string": if (p2.match(new RegExp("^[0-9]\\.[0-9]+$"))) { ggbVersion = p2; } else { appletID = p2; } break; case "object": if (typeof p2.is3D !== "undefined") { views = p2; } else { parameters = p2; } break; case "boolean": html5NoWebSimple = p2; html5NoWebSimpleParamExists = true; break; } } } if (views === null) { views = { is3D: false, AV: false, SV: false, CV: false, EV2: false, CP: false, PC: false, DA: false, FI: false, PV: false, macro: false }; if (parameters.material_id !== void 0 && !html5NoWebSimpleParamExists) { html5NoWebSimple = true; } } if (appletID !== null && parameters.id === void 0) { parameters.id = appletID; } var jnlpFilePath = ""; var html5Codebase = ""; var isHTML5Offline = false; var loadedAppletType = null; var html5CodebaseVersion = null; var html5CodebaseScript = null; var html5CodebaseIsWebSimple = false; var previewImagePath = null; var previewLoadingPath = null; var previewPlayPath = null; var fonts_css_url = null; var jnlpBaseDir = null; if (parameters.height !== void 0) { parameters.height = Math.round(parameters.height); } if (parameters.width !== void 0) { parameters.width = Math.round(parameters.width); } var parseVersion = function(d2) { return parseFloat(d2) > 4 ? parseFloat(d2) : 5; }; applet.setHTML5Codebase = function(codebase, offline) { html5OverwrittenCodebase = codebase; setHTML5CodebaseInternal(codebase, offline); }; applet.setJavaCodebase = applet.setJavaCodebaseVersion = applet.isCompiledInstalled = applet.setPreCompiledScriptPath = applet.setPreCompiledResourcePath = function() { }; applet.setHTML5CodebaseVersion = function(version, offline) { var numVersion = parseFloat(version); if (numVersion !== NaN && numVersion < 5) { console.log("The GeoGebra HTML5 codebase version " + numVersion + " is deprecated. Using version latest instead."); return; } html5OverwrittenCodebaseVersion = version; setDefaultHTML5CodebaseForVersion(version, offline); }; applet.getHTML5CodebaseVersion = function() { return html5CodebaseVersion; }; applet.getParameters = function() { return parameters; }; applet.setFontsCSSURL = function(url) { fonts_css_url = url; }; applet.setGiacJSURL = function(url) { }; applet.setJNLPFile = function(newJnlpFilePath) { jnlpFilePath = newJnlpFilePath; }; applet.setJNLPBaseDir = function(baseDir) { }; applet.inject = function() { function isOwnIFrame() { return window.frameElement && window.frameElement.getAttribute("data-singleton"); } var type = "auto"; var container_ID = parameters.id; var container; var noPreview = false; for (var i3 = 0; i3 < arguments.length; i3++) { var p3 = arguments[i3]; if (typeof p3 === "string") { p3 = p3.toLowerCase(); if (p3.match(/^(prefer)?(java|html5|compiled|auto|screenshot)$/)) { type = p3; } else { container_ID = arguments[i3]; } } else if (typeof p3 === "boolean") { noPreview = p3; } else if (p3 instanceof HTMLElement) { container = p3; } } continueInject(); function continueInject() { if (!initComplete) { setTimeout(continueInject, 200); return; } type = detectAppletType(type); var appletElem = container || document.getElementById(container_ID); if (!appletElem) { console.log("possibly bug on ajax loading? "); return; } applet.removeExistingApplet(appletElem, false); if (parameters.width === void 0 && appletElem.clientWidth) { parameters.width = appletElem.clientWidth; } if (parameters.height === void 0 && appletElem.clientHeight) { parameters.height = appletElem.clientHeight; } if (!(parameters.width && parameters.height) && type === "html5") { delete parameters.width; delete parameters.height; } loadedAppletType = type; if (type === "screenshot") { injectScreenshot(appletElem, parameters); } else { var playButton = false; if (parameters.hasOwnProperty("playButton") && parameters.playButton || parameters.hasOwnProperty("clickToLoad") && parameters.clickToLoad) { playButton = true; } else if (parameters.hasOwnProperty("playButtonAutoDecide") && parameters.playButtonAutoDecide) { playButton = (!isInIframe() || isOwnIFrame()) && isMobileDevice(); } if (playButton) { loadedAppletType = "screenshot"; injectPlayButton(appletElem, parameters, noPreview, type); } else { injectHTML5Applet(appletElem, parameters, noPreview); } } } return; }; function isInIframe() { try { return window.self !== window.top; } catch (e2) { return true; } } function isMobileDevice() { if (parameters.hasOwnProperty("screenshotGenerator") && parameters.screenshotGenerator) { return false; } return Math.max(screen.width, screen.height) < 800; } applet.getViews = function() { return views; }; applet.isJavaInstalled = function() { return false; }; var fetchParametersFromApi = function(successCallback) { var onSuccess = function(text) { var jsonData = JSON.parse(text); var isGeoGebra = function(element) { return element.type == "G" || element.type == "E"; }; var item = jsonData.elements ? jsonData.elements.filter(isGeoGebra)[0] : jsonData; if (!item || !item.url) { onError(); return; } parameters.fileName = item.url; updateAppletSettings(item.settings || {}); views.is3D = true; var imageDir = "https://www.geogebra.org/images/"; applet.setPreviewImage(previewImagePath || item.previewUrl, imageDir + "GeoGebra_loading.png", imageDir + "applet_play.png"); successCallback(); }; var onError = function() { parameters.onError && parameters.onError(); log("Error: Fetching material (id " + parameters.material_id + ") failed.", parameters); }; var host = location.host.match(/(www|stage|beta|groot|alpha).geogebra.(org|net)/) ? location.host : "www.geogebra.org"; var path = "/materials/" + parameters.material_id + "?scope=basic"; sendCorsRequest("https://" + host + "/api/proxy.php?path=" + encodeURIComponent(path), onSuccess, onError); }; function updateAppletSettings(settings) { var parameterNames = ["width", "height", "showToolBar", "showMenuBar", "showAlgebraInput", "allowStyleBar", "showResetIcon", "enableLabelDrags", "enableShiftDragZoom", "enableRightClick", "appName"]; ["enableLabelDrags", "enableShiftDragZoom", "enableRightClick"].forEach(function(name2) { settings[name2] = !!settings[name2]; }); parameterNames.forEach(function(name2) { if (parameters[name2] === void 0 && settings[name2] !== void 0) { parameters[name2] = settings[name2]; } }); if (parameters.showToolBarHelp === void 0) { parameters.showToolBarHelp = parameters.showToolBar; } } function sendCorsRequest(url, onSuccess, onError) { var xhr = new XMLHttpRequest(); xhr.open("GET", url); xhr.onload = function() { onSuccess(xhr.responseText); }; xhr.onerror = onError; xhr.send(); } applet.isHTML5Installed = function() { return true; }; applet.getLoadedAppletType = function() { return loadedAppletType; }; applet.setPreviewImage = function(previewFilePath, loadingFilePath, playFilePath) { previewImagePath = previewFilePath; previewLoadingPath = loadingFilePath; previewPlayPath = playFilePath; }; applet.removeExistingApplet = function(appletParent, showScreenshot) { var i3; if (typeof appletParent === "string") { appletParent = document.getElementById(appletParent); } loadedAppletType = null; var removedID = null; for (i3 = 0; i3 < appletParent.childNodes.length; i3++) { var currentChild = appletParent.childNodes[i3]; var className = currentChild.className; if (className === "applet_screenshot") { if (showScreenshot) { currentChild.style.display = "block"; loadedAppletType = "screenshot"; } else { currentChild.style.display = "none"; } } else if (className !== "applet_scaler prerender") { appletParent.removeChild(currentChild); removedID = className && className.indexOf("appletParameters") != -1 ? currentChild.id : null; i3--; } } var appName = parameters.id !== void 0 ? parameters.id : removedID; var app = window[appName]; if (app && typeof app.getBase64 === "function") { app.remove(); window[appName] = null; } }; applet.refreshHitPoints = function() { if (parseVersion(ggbHTML5LoadedCodebaseVersion) >= 5) { return true; } var app = applet.getAppletObject(); if (app) { if (typeof app.recalculateEnvironments === "function") { app.recalculateEnvironments(); return true; } } return false; }; applet.startAnimation = function() { var app = applet.getAppletObject(); if (app) { if (typeof app.startAnimation === "function") { app.startAnimation(); return true; } } return false; }; applet.stopAnimation = function() { var app = applet.getAppletObject(); if (app) { if (typeof app.stopAnimation === "function") { app.stopAnimation(); return true; } } return false; }; applet.getAppletObject = function() { var appName = parameters.id !== void 0 ? parameters.id : "ggbApplet"; return window[appName]; }; applet.resize = function() { }; var appendParam = function(applet2, name2, value) { var param = document.createElement("param"); param.setAttribute("name", name2); param.setAttribute("value", value); applet2.appendChild(param); }; var valBoolean = function(value) { return value && value !== "false"; }; var injectHTML5Applet = function(appletElem, parameters2, noPreview) { if (parseVersion(html5CodebaseVersion) <= 4.2) { noPreview = true; } var loadScript = !isRenderGGBElementEnabled && !scriptLoadStarted; if (!isRenderGGBElementEnabled && !scriptLoadStarted || (ggbHTML5LoadedCodebaseVersion !== html5CodebaseVersion || ggbHTML5LoadedCodebaseIsWebSimple && !html5CodebaseIsWebSimple)) { loadScript = true; isRenderGGBElementEnabled = false; scriptLoadStarted = false; } var article = document.createElement("div"); article.classList.add("appletParameters", "notranslate"); var oriWidth = parameters2.width; var oriHeight = parameters2.height; parameters2.disableAutoScale = parameters2.disableAutoScale === void 0 ? GGBAppletUtils.isFlexibleWorksheetEditor() : parameters2.disableAutoScale; if (parameters2.width !== void 0) { if (parseVersion(html5CodebaseVersion) <= 4.4) { if (valBoolean(parameters2.showToolBar)) { parameters2.height -= 7; } if (valBoolean(parameters2.showAlgebraInput)) { parameters2.height -= 37; } if (parameters2.width < 605 && valBoolean(parameters2.showToolBar)) { parameters2.width = 605; oriWidth = 605; } } else { var minWidth = 100; if (valBoolean(parameters2.showToolBar) || valBoolean(parameters2.showMenuBar)) { if (parameters2.hasOwnProperty("customToolBar")) { parameters2.customToolbar = parameters2.customToolBar; } minWidth = valBoolean(parameters2.showMenuBar) ? 245 : 155; } if (oriWidth < minWidth) { parameters2.width = minWidth; oriWidth = minWidth; } } } article.style.border = "none"; article.style.display = "inline-block"; for (var key in parameters2) { if (parameters2.hasOwnProperty(key) && key !== "appletOnLoad") { article.setAttribute("data-param-" + key, parameters2[key]); } } if (fonts_css_url) { article.setAttribute("data-param-fontscssurl", fonts_css_url); } applet.resize = function() { GGBAppletUtils.responsiveResize(appletElem, parameters2); }; window.addEventListener("resize", function(evt) { applet.resize(); }); var oriAppletOnload = typeof parameters2.appletOnLoad === "function" ? parameters2.appletOnLoad : function() { }; if (!noPreview && parameters2.width !== void 0) { if (!parameters2.hasOwnProperty("showSplash")) { article.setAttribute("data-param-showSplash", "false"); } var previewPositioner = appletElem.querySelector(".applet_scaler.prerender"); var preRendered = previewPositioner !== null; if (!preRendered) { var previewContainer = createScreenShotDiv(oriWidth, oriHeight, parameters2.borderColor, false); previewPositioner = document.createElement("div"); previewPositioner.className = "applet_scaler"; previewPositioner.style.position = "relative"; previewPositioner.style.display = "block"; previewPositioner.style.width = oriWidth + "px"; previewPositioner.style.height = oriHeight + "px"; } else { var previewContainer = previewPositioner.querySelector(".ggb_preview"); } if (window.GGBT_spinner) { window.GGBT_spinner.attachSpinner(previewPositioner, "66%"); } if (parseVersion(html5CodebaseVersion) >= 5) { parameters2.appletOnLoad = function(api) { var preview = appletElem.querySelector(".ggb_preview"); if (preview) { preview.parentNode.removeChild(preview); } if (window.GGBT_spinner) { window.GGBT_spinner.removeSpinner(previewPositioner); } if (window.GGBT_wsf_view) { $(window).trigger("resize"); } oriAppletOnload(api); }; if (!preRendered) { previewPositioner.appendChild(previewContainer); } } else { article.appendChild(previewContainer); } previewPositioner.appendChild(article); if (!preRendered) { appletElem.appendChild(previewPositioner); } setTimeout(function() { applet.resize(); }, 1); } else { var appletScaler = document.createElement("div"); appletScaler.className = "applet_scaler"; appletScaler.style.position = "relative"; appletScaler.style.display = "block"; appletScaler.appendChild(article); appletElem.appendChild(appletScaler); parameters2.appletOnLoad = function(api) { applet.resize(); oriAppletOnload(api); }; } function renderGGBElementWithParams(article2, parameters3) { if (parameters3 && typeof parameters3.appletOnLoad === "function" && typeof renderGGBElement === "function") { renderGGBElement(article2, parameters3.appletOnLoad); } else { renderGGBElement(article2); } log("GeoGebra HTML5 applet injected and rendered with previously loaded codebase.", parameters3); } function renderGGBElementOnTube(a, parameters3) { if (typeof renderGGBElement === "undefined") { if (html5AppletsToProcess === null) { html5AppletsToProcess = []; } html5AppletsToProcess.push({ article: a, params: parameters3 }); window.renderGGBElementReady = function() { isRenderGGBElementEnabled = true; if (html5AppletsToProcess !== null && html5AppletsToProcess.length) { html5AppletsToProcess.forEach(function(obj) { renderGGBElementWithParams(obj.article, obj.params); }); html5AppletsToProcess = null; } }; if (parseVersion(html5CodebaseVersion) < 5) { a.className += " geogebraweb"; } } else { renderGGBElementWithParams(a, parameters3); } } if (loadScript) { scriptLoadStarted = true; for (var i3 = 0; i3 < article.childNodes.length; i3++) { var tag = article.childNodes[i3].tagName; if (tag === "TABLE") { article.removeChild(article.childNodes[i3]); i3--; } } if (ggbHTML5LoadedScript !== null) { var el = document.querySelector('script[src="' + ggbHTML5LoadedScript + '"]'); if (el !== void 0 && el !== null) { el.parentNode.removeChild(el); } } var script = document.createElement("script"); var scriptLoaded = function() { renderGGBElementOnTube(article, parameters2); }; script.src = html5Codebase + html5CodebaseScript; ggbHTML5LoadedCodebaseIsWebSimple = html5CodebaseIsWebSimple; ggbHTML5LoadedCodebaseVersion = html5CodebaseVersion; ggbHTML5LoadedScript = script.src; log("GeoGebra HTML5 codebase loaded: '" + html5Codebase + "'.", parameters2); if (!html5OverwrittenCodebase && (!html5OverwrittenCodebaseVersion || html5OverwrittenCodebaseVersion == "5.0")) { if (html5CodebaseIsWebSimple) { webSimple.succeeded = webSimple.succeeded || webSimple(); } else { web3d.succeeded = web3d.succeeded || web3d(); } scriptLoaded(); } else if (html5Codebase.requirejs) { __webpack_require__.e(/*! AMD require */ 2376).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(/*! ./web3d */ 63442)]; (scriptLoaded).apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__);}.bind(this))['catch'](__webpack_require__.oe); } else { script.onload = scriptLoaded; appletElem.appendChild(script); } } else { renderGGBElementOnTube(article, parameters2); } parameters2.height = oriHeight; parameters2.width = oriWidth; }; var injectScreenshot = function(appletElem, parameters2, showPlayButton) { var previewContainer = createScreenShotDiv(parameters2.width, parameters2.height, parameters2.borderColor, showPlayButton); var previewPositioner = document.createElement("div"); previewPositioner.style.position = "relative"; previewPositioner.style.display = "block"; previewPositioner.style.width = parameters2.width + "px"; previewPositioner.style.height = parameters2.height + "px"; previewPositioner.className = "applet_screenshot applet_scaler" + (showPlayButton ? " applet_screenshot_play" : ""); previewPositioner.appendChild(previewContainer); var scale = GGBAppletUtils.getScale(parameters2, appletElem, showPlayButton); if (showPlayButton) { appletElem.appendChild(getPlayButton()); if (!window.GGBT_wsf_view) { appletElem.style.position = "relative"; } } else if (window.GGBT_spinner) { window.GGBT_spinner.attachSpinner(previewPositioner, "66%"); } appletElem.appendChild(previewPositioner); if (scale !== 1 && !isNaN(scale)) { GGBAppletUtils.scaleElement(previewPositioner, scale); previewPositioner.style.width = parameters2.width + "px"; previewPositioner.style.height = parameters2.height + "px"; previewPositioner.parentNode.style.width = parameters2.width * scale + "px"; previewPositioner.parentNode.style.height = parameters2.height * scale + "px"; } applet.resize = function() { resizeScreenshot(appletElem, previewContainer, previewPositioner, showPlayButton); }; window.addEventListener("resize", function(evt) { applet.resize(); }); applet.resize(); }; function resizeScreenshot(appletElem, previewContainer, previewPositioner, showPlayButton) { if (!appletElem.contains(previewContainer)) { return; } if (typeof window.GGBT_wsf_view === "object" && window.GGBT_wsf_view.isFullscreen()) { if (appletElem.id !== "fullscreencontent") { return; } window.GGBT_wsf_view.setCloseBtnPosition(appletElem); } var scale = GGBAppletUtils.getScale(parameters, appletElem, showPlayButton); if (previewPositioner.parentNode !== null) { if (!isNaN(scale) && scale !== 1) { GGBAppletUtils.scaleElement(previewPositioner, scale); previewPositioner.parentNode.style.width = parameters.width * scale + "px"; previewPositioner.parentNode.style.height = parameters.height * scale + "px"; } else { GGBAppletUtils.scaleElement(previewPositioner, 1); previewPositioner.parentNode.style.width = parameters.width + "px"; previewPositioner.parentNode.style.height = parameters.height + "px"; } } if (typeof window.GGBT_wsf_view === "object" && window.GGBT_wsf_view.isFullscreen()) { GGBAppletUtils.positionCenter(appletElem); } if (typeof window.GGBT_ws_header_footer === "object") { window.GGBT_ws_header_footer.setWsScrollerHeight(); } } applet.onExitFullscreen = function(fullscreenContainer, appletElem) { appletElem.appendChild(fullscreenContainer); }; var injectPlayButton = function(appletElem, parameters2, noPreview, type) { injectScreenshot(appletElem, parameters2, true); var play = function() { var elems = []; for (i3 = 0; i3 < appletElem.childNodes.length; i3++) { elems.push(appletElem.childNodes[i3]); } if (window.GGBT_wsf_view) { var content = window.GGBT_wsf_view.renderFullScreen(appletElem, parameters2.id); var container = document.getElementById("fullscreencontainer"); var oldcontent = jQuery(appletElem).find(".fullscreencontent"); if (oldcontent.length > 0) { content.remove(); oldcontent.attr("id", "fullscreencontent").show(); jQuery(container).append(oldcontent); window.dispatchEvent(new Event("resize")); } else { injectHTML5Applet(content, parameters2, false); } window.GGBT_wsf_view.launchFullScreen(container); } else { loadedAppletType = type; injectHTML5Applet(appletElem, parameters2, false); } if (!window.GGBT_wsf_view) { for (i3 = 0; i3 < elems.length; i3++) { appletElem.removeChild(elems[i3]); } } }; var imgs = appletElem.getElementsByClassName("ggb_preview_play"); for (var i3 = 0; i3 < imgs.length; i3++) { imgs[i3].addEventListener("click", play, false); imgs[i3].addEventListener("ontouchstart", play, false); } if (typeof window.ggbAppletPlayerOnload === "function") { window.ggbAppletPlayerOnload(appletElem); } if (isMobileDevice() && window.GGBT_wsf_view) { $(".wsf-element-fullscreen-button").remove(); } }; var getPlayButton = function() { var playButtonContainer = document.createElement("div"); playButtonContainer.className = "ggb_preview_play icon-applet-play"; if (!window.GGBT_wsf_view) { var css = '.icon-applet-play { width: 100%; height: 100%;box-sizing: border-box;position: absolute;z-index: 1001;cursor: pointer;border-width: 0px; background-color: transparent;background-repeat: no-repeat;left: 0;top: 0;background-position: center center; background-image: url("https://www.geogebra.org/images/worksheet/icon-start-applet.png");}.icon-applet-play:hover {background-image: url("https://www.geogebra.org/images/worksheet/icon-start-applet-hover.png");}'; var style = document.createElement("style"); if (style.styleSheet) { style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); } document.getElementsByTagName("head")[0].appendChild(style); } return playButtonContainer; }; var createScreenShotDiv = function(oriWidth, oriHeight, borderColor, showPlayButton) { var previewContainer = document.createElement("div"); previewContainer.className = "ggb_preview"; previewContainer.style.position = "absolute"; previewContainer.style.zIndex = "90"; previewContainer.style.width = oriWidth - 2 + "px"; previewContainer.style.height = oriHeight - 2 + "px"; previewContainer.style.top = "0px"; previewContainer.style.left = "0px"; previewContainer.style.overflow = "hidden"; previewContainer.style.backgroundColor = "white"; var bc = "lightgrey"; if (borderColor !== void 0) { if (borderColor === "none") { bc = "transparent"; } else { bc = borderColor; } } previewContainer.style.border = "1px solid " + bc; var preview = document.createElement("img"); preview.style.position = "relative"; preview.style.zIndex = "1000"; preview.style.top = "-1px"; preview.style.left = "-1px"; if (previewImagePath !== null) { preview.setAttribute("src", previewImagePath); } preview.style.opacity = 0.7; if (previewLoadingPath !== null) { var previewOverlay; var pWidth, pHeight; if (!showPlayButton) { previewOverlay = document.createElement("img"); previewOverlay.style.position = "absolute"; previewOverlay.style.zIndex = "1001"; previewOverlay.style.opacity = 1; preview.style.opacity = 0.3; pWidth = 360; if (pWidth > oriWidth / 4 * 3) { pWidth = oriWidth / 4 * 3; } pHeight = pWidth / 5.8; previewOverlay.setAttribute("src", previewLoadingPath); previewOverlay.setAttribute("width", pWidth); previewOverlay.setAttribute("height", pHeight); var pX = (oriWidth - pWidth) / 2; var pY = (oriHeight - pHeight) / 2; previewOverlay.style.left = pX + "px"; previewOverlay.style.top = pY + "px"; previewContainer.appendChild(previewOverlay); } } previewContainer.appendChild(preview); return previewContainer; }; var detectAppletType = function(preferredType) { preferredType = preferredType.toLowerCase(); if (preferredType === "html5" || preferredType === "screenshot") { return preferredType; } return "html5"; }; var modules = ["web", "webSimple", "web3d", "tablet", "tablet3d", "phone"]; var setDefaultHTML5CodebaseForVersion = function(version, offline) { html5CodebaseVersion = version; if (offline) { setHTML5CodebaseInternal(html5CodebaseVersion, true); return; } var hasWebSimple = !html5NoWebSimple; if (hasWebSimple) { var v2 = parseVersion(html5CodebaseVersion); if (!isNaN(v2) && v2 < 4.4) { hasWebSimple = false; } } var protocol, codebase; if (window.location.protocol.substr(0, 4) === "http") { protocol = window.location.protocol; } else { protocol = "http:"; } var index = html5CodebaseVersion.indexOf("//"); if (index > 0) { codebase = html5CodebaseVersion; } else if (index === 0) { codebase = protocol + html5CodebaseVersion; } else { codebase = "https://www.geogebra.org/apps/5.2.814.0/"; } for (var key in modules) { if (html5CodebaseVersion.slice(modules[key].length * -1) === modules[key] || html5CodebaseVersion.slice((modules[key].length + 1) * -1) === modules[key] + "/") { setHTML5CodebaseInternal(codebase, false); return; } } if (!GGBAppletUtils.isFlexibleWorksheetEditor() && hasWebSimple && !views.is3D && !views.AV && !views.SV && !views.CV && !views.EV2 && !views.CP && !views.PC && !views.DA && !views.FI && !views.PV && !valBoolean(parameters.showToolBar) && !valBoolean(parameters.showMenuBar) && !valBoolean(parameters.showAlgebraInput) && !valBoolean(parameters.enableRightClick) && (!parameters.appName || parameters.appName == "classic")) { codebase += "webSimple/"; } else { codebase += "web3d/"; } setHTML5CodebaseInternal(codebase, false); }; var setHTML5CodebaseInternal = function(codebase, offline) { if (codebase.requirejs) { html5Codebase = codebase; return; } if (codebase.slice(-1) !== "/") { codebase += "/"; } html5Codebase = codebase; if (offline === null) { offline = codebase.indexOf("http") === -1; } isHTML5Offline = offline; html5CodebaseScript = "web.nocache.js"; html5CodebaseIsWebSimple = false; var folders = html5Codebase.split("/"); if (folders.length > 1) { if (!offline && folders[folders.length - 2] === "webSimple") { html5CodebaseScript = "webSimple.nocache.js"; html5CodebaseIsWebSimple = true; } else if (modules.indexOf(folders[folders.length - 2]) >= 0) { html5CodebaseScript = folders[folders.length - 2] + ".nocache.js"; } } folders = codebase.split("/"); html5CodebaseVersion = folders[folders.length - 3]; if (html5CodebaseVersion.substr(0, 4) === "test") { html5CodebaseVersion = html5CodebaseVersion.substr(4, 1) + "." + html5CodebaseVersion.substr(5, 1); } else if (html5CodebaseVersion.substr(0, 3) === "war" || html5CodebaseVersion.substr(0, 4) === "beta") { html5CodebaseVersion = "5.0"; } var numVersion = parseFloat(html5CodebaseVersion); if (numVersion !== NaN && numVersion < 5 && codebase.indexOf("geogebra.org") >= 0) { console.log("The GeoGebra HTML5 codebase version " + numVersion + " is deprecated. Using version latest instead."); setDefaultHTML5CodebaseForVersion("5.0", offline); } }; var log = function(text, parameters2) { if (window.console && window.console.log) { if (!parameters2 || typeof parameters2.showLogging === "undefined" || parameters2.showLogging && parameters2.showLogging !== "false") { console.log(text); } } }; if (parameters.material_id !== void 0) { fetchParametersFromApi(continueInit); } else { continueInit(); } function continueInit() { var html5Version = ggbVersion; if (html5OverwrittenCodebaseVersion !== null) { html5Version = html5OverwrittenCodebaseVersion; } else { if (parseFloat(html5Version) < 5) { html5Version = "5.0"; } } setDefaultHTML5CodebaseForVersion(html5Version, false); if (html5OverwrittenCodebase !== null) { setHTML5CodebaseInternal(html5OverwrittenCodebase, isHTML5Offline); } initComplete = true; } return applet; }; var GGBAppletUtils = function() { "use strict"; function isFlexibleWorksheetEditor() { return window.GGBT_wsf_edit !== void 0; } function scaleElement(el, scale) { if (scale != 1) { el.style.transformOrigin = "0% 0% 0px"; el.style.webkitTransformOrigin = "0% 0% 0px"; el.style.transform = "scale(" + scale + "," + scale + ")"; el.style.webkitTransform = "scale(" + scale + "," + scale + ")"; el.style.maxWidth = "initial"; if (el.querySelector(".ggb_preview") !== null) { el.querySelector(".ggb_preview").style.maxWidth = "initial"; } if (el.querySelectorAll(".ggb_preview img")[0] !== void 0) { el.querySelectorAll(".ggb_preview img")[0].style.maxWidth = "initial"; } if (el.querySelectorAll(".ggb_preview img")[1] !== void 0) { el.querySelectorAll(".ggb_preview img")[1].style.maxWidth = "initial"; } } else { el.style.transform = "none"; el.style.webkitTransform = "none"; } } function getWidthHeight(appletElem, appletWidth, allowUpscale, autoHeight, noBorder, scaleContainerClass) { var container = null; if (scaleContainerClass != void 0 && scaleContainerClass != "") { var parent = appletElem.parentNode; while (parent != null) { if ((" " + parent.className + " ").indexOf(" " + scaleContainerClass + " ") > -1) { container = parent; break; } else { parent = parent.parentNode; } } } var myWidth = 0, myHeight = 0, windowWidth = 0, border = 0, borderRight = 0, borderLeft = 0, borderTop = 0; if (container) { myWidth = container.offsetWidth; myHeight = Math.max(autoHeight ? container.offsetWidth : 0, container.offsetHeight); } else { if (window.innerWidth && document.documentElement.clientWidth) { myWidth = Math.min(window.innerWidth, document.documentElement.clientWidth); myHeight = Math.min(window.innerHeight, document.documentElement.clientHeight); windowWidth = myWidth; } else { myWidth = window.innerWidth; myHeight = window.innerHeight; windowWidth = window.innerWidth; } if (appletElem) { var rect = appletElem.getBoundingClientRect(); if (rect.left > 0) { if (rect.left <= myWidth && (noBorder === void 0 || !noBorder)) { if (document.dir === "rtl") { borderRight = myWidth - rect.width - rect.left; borderLeft = windowWidth <= 480 ? 10 : 30; } else { borderLeft = rect.left; borderRight = windowWidth <= 480 ? 10 : 30; } border = borderLeft + borderRight; } } } if (appletElem && typeof window.GGBT_wsf_view === "object" && window.GGBT_wsf_view.isFullscreen()) { var appletRect = appletElem.getBoundingClientRect(); if (window.GGBT_wsf_view.getCloseBtnPosition() === "closePositionRight") { border = 40; borderTop = 0; } else if (window.GGBT_wsf_view.getCloseBtnPosition() === "closePositionTop") { border = 0; borderTop = 40; } } } if (appletElem) { if ((allowUpscale === void 0 || !allowUpscale) && appletWidth > 0 && appletWidth + border < myWidth) { myWidth = appletWidth; } else { myWidth -= border; } if (typeof window.GGBT_wsf_view === "object" && window.GGBT_wsf_view.isFullscreen() && (allowUpscale === void 0 || !allowUpscale)) { myHeight -= borderTop; } } return { width: myWidth, height: myHeight }; } function calcScale(parameters, appletElem, allowUpscale, showPlayButton, scaleContainerClass) { if (parameters.isScreenshoGenerator) { return 1; } var ignoreHeight = showPlayButton !== void 0 && showPlayButton; var noScaleMargin = parameters.noScaleMargin != void 0 && parameters.noScaleMargin; var valBoolean = function(value) { return value && value !== "false"; }; var autoHeight = valBoolean(parameters.autoHeight); var windowSize = getWidthHeight(appletElem, parameters.width, allowUpscale, autoHeight, ignoreHeight && window.GGBT_wsf_view || noScaleMargin, scaleContainerClass); var windowWidth = parseInt(windowSize.width); var appletWidth = parameters.width; var appletHeight = parameters.height; if (appletWidth === void 0) { var article = appletElem.querySelector(".appletParameters"); if (article) { appletWidth = article.offsetWidth; appletHeight = article.offsetHeight; } } var xscale = windowWidth / appletWidth; var yscale = ignoreHeight ? 1 : windowSize.height / appletHeight; if (allowUpscale !== void 0 && !allowUpscale) { xscale = Math.min(1, xscale); yscale = Math.min(1, yscale); } return Math.min(xscale, yscale); } function getScale(parameters, appletElem, showPlayButton) { var scale = 1, autoScale, allowUpscale = false; if (parameters.hasOwnProperty("allowUpscale")) { allowUpscale = parameters.allowUpscale; } if (parameters.hasOwnProperty("scale")) { scale = parseFloat(parameters.scale); if (isNaN(scale) || scale === null || scale === 0) { scale = 1; } if (scale > 1) { allowUpscale = true; } } if (appletElem && typeof window.GGBT_wsf_view === "object" && window.GGBT_wsf_view.isFullscreen()) { allowUpscale = true; } if (!(parameters.hasOwnProperty("disableAutoScale") && parameters.disableAutoScale)) { autoScale = calcScale(parameters, appletElem, allowUpscale, showPlayButton, parameters.scaleContainerClass); } else { return scale; } if (allowUpscale && (!parameters.hasOwnProperty("scale") || scale === 1)) { return autoScale; } else { return Math.min(scale, autoScale); } } function positionCenter(appletElem) { var windowWidth = Math.min(window.innerWidth, document.documentElement.clientWidth); var windowHeight = Math.min(window.innerHeight, document.documentElement.clientHeight); var appletRect = appletElem.getBoundingClientRect(); var calcHorizontalBorder = (windowWidth - appletRect.width) / 2; var calcVerticalBorder = (windowHeight - appletRect.height) / 2; if (calcVerticalBorder < 0) { calcVerticalBorder = 0; } appletElem.style.position = "relative"; if (window.GGBT_wsf_view.getCloseBtnPosition() === "closePositionRight") { if (calcHorizontalBorder < 40) { appletElem.style.left = "40px"; } else { appletElem.style.left = calcHorizontalBorder + "px"; } appletElem.style.top = calcVerticalBorder + "px"; } else if (window.GGBT_wsf_view.getCloseBtnPosition() === "closePositionTop") { if (calcVerticalBorder < 40) { appletElem.style.top = "40px"; } else { appletElem.style.top = calcVerticalBorder + "px"; } appletElem.style.left = calcHorizontalBorder + "px"; } } function responsiveResize(appletElem, parameters) { var article = appletElem.querySelector(".appletParameters"); if (article) { if (typeof window.GGBT_wsf_view === "object" && window.GGBT_wsf_view.isFullscreen()) { if (parameters.id !== article.getAttribute("data-param-id")) { return; } window.GGBT_wsf_view.setCloseBtnPosition(appletElem); } if (article.parentElement && /fullscreen/.test(article.parentElement.className)) { return; } var scale = getScale(parameters, appletElem); if (isFlexibleWorksheetEditor()) { article.setAttribute("data-param-scale", scale); } var scaleElem = null; for (var i2 = 0; i2 < appletElem.childNodes.length; i2++) { if (appletElem.childNodes[i2].className !== void 0 && appletElem.childNodes[i2].className.match(/^applet_scaler/)) { scaleElem = appletElem.childNodes[i2]; break; } } if (scaleElem !== null && scaleElem.querySelector(".noscale") !== null) { return; } var appName = parameters.id !== void 0 ? parameters.id : "ggbApplet"; var app = window[appName]; if ((app == null || !app.recalculateEnvironments) && scaleElem !== null && !scaleElem.className.match(/fullscreen/)) { scaleElem.parentNode.style.transform = ""; if (!isNaN(scale) && scale !== 1) { scaleElem.parentNode.style.width = parameters.width * scale + "px"; scaleElem.parentNode.style.height = parameters.height * scale + "px"; scaleElement(scaleElem, scale); } else { scaleElement(scaleElem, 1); scaleElem.parentNode.style.width = parameters.width + "px"; scaleElem.parentNode.style.height = parameters.height + "px"; } } if (typeof window.GGBT_wsf_view === "object" && window.GGBT_wsf_view.isFullscreen()) { positionCenter(appletElem); } if (window.GGBT_wsf_view && !window.GGBT_wsf_view.isFullscreen()) { window.GGBT_wsf_general.adjustContentToResize($(article).parents(".content-added-content")); } } } return { responsiveResize, isFlexibleWorksheetEditor, positionCenter, getScale, scaleElement }; }(); if (true) { !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() { return GGBApplet; }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } GGBAppletUtils.makeModule = function(name, permutation) { function webModule() { var H = "bootstrap", I = "begin", J = "gwt.codesvr." + name + "=", K = "gwt.codesvr=", L = name, M = "startup", N = "DUMMY", O = 0, P = 1, Q = "iframe", R = "position:absolute; width:0; height:0; border:none; left: -1000px;", S = " top: -1000px;", T = "Chrome", U = "CSS1Compat", V = "", W = "", X = "", Y = "undefined", Z = "readystatechange", $ = 10, _ = "script", ab = "javascript", bb = "Failed to load ", cb = "moduleStartup", db = "scriptTagAdded", eb = "moduleRequested", fb = "meta", gb = "name", hb = name + "::", ib = "::", jb = "gwt:property", kb = "content", lb = "=", mb = "gwt:onPropertyErrorFn", nb = 'Bad handler "', ob = '" for "gwt:onPropertyErrorFn"', pb = "gwt:onLoadErrorFn", qb = '" for "gwt:onLoadErrorFn"', rb = "#", sb = "?", tb = "/", ub = "img", vb = "clear.cache.gif", wb = "baseUrl", xb = name + ".nocache.js", yb = "base", zb = "//", Ab = "selectingPermutation", Bb = name + ".devmode.js", Cb = permutation, Db = ":", Eb = ".cache.js", Fb = "loadExternalRefs", Gb = "end"; var n = window; var o = document; q(H, I); function p() { var a = n.location.search; return a.indexOf(J) != -1 || a.indexOf(K) != -1; } function q(a, b) { } webModule.__sendStats = q; webModule.__moduleName = L; webModule.__errFn = null; webModule.__moduleBase = N; webModule.__softPermutationId = O; webModule.__computePropValue = null; webModule.__getPropMap = null; webModule.__installRunAsyncCode = function() { }; webModule.__gwtStartLoadingFragment = function() { return null; }; webModule.__gwt_isKnownPropertyValue = function() { return false; }; webModule.__gwt_getMetaProperty = function() { return null; }; var r = null; var s = n.__gwt_activeModules = n.__gwt_activeModules || {}; s[L] = { moduleName: L }; webModule.__moduleStartupDone = function(e2) { var f2 = s[L].bindings; s[L].bindings = function() { var a = f2 ? f2() : {}; var b = e2[webModule.__softPermutationId]; for (var c2 = O; c2 < b.length; c2++) { var d2 = b[c2]; a[d2[O]] = d2[P]; } return a; }; }; var t; function u() { v(); return t; } function v() { if (t) { return; } var a = o.createElement(Q); a.id = L; a.style.cssText = R + S; a.tabIndex = -1; o.body.appendChild(a); t = a.contentWindow.document; if (navigator.userAgent.indexOf(T) == -1) { t.open(); var b = document.compatMode == U ? V : W; t.write(b + X); t.close(); } } function w(f2) { function g2(a) { function b() { if (typeof o.readyState == Y) { return typeof o.body != Y && o.body != null; } return /loaded|complete/.test(o.readyState); } var c2 = b(); if (c2) { a(); return; } function d2() { if (!c2) { if (!b()) { return; } c2 = true; a(); if (o.removeEventListener) { o.removeEventListener(Z, d2, false); } if (e2) { clearInterval(e2); } } } if (o.addEventListener) { o.addEventListener(Z, d2, false); } var e2 = setInterval(function() { d2(); }, $); } function h2(a) { var b = u(); var c2 = b.body; var d2 = b.createElement(_); d2.language = ab; d2.crossOrigin = W; d2.src = a; if (webModule.__errFn) { d2.onerror = function() { webModule.__errFn(L, new Error(bb + a)); }; } c2.appendChild(d2); q(cb, db); } q(cb, eb); g2(function() { h2(f2); }); } webModule.__startLoadingFragment = function(a) { return C(a); }; webModule.__installRunAsyncCode = function(a) { var b = u(); var c2 = b.body; var d2 = b.createElement(_); d2.language = ab; d2.text = a; c2.appendChild(d2); c2.removeChild(d2); }; function A() { var c = {}; var d; var e; var f = o.getElementsByTagName(fb); for (var g = O, h = f.length; g < h; ++g) { var i = f[g], j = i.getAttribute(gb), k; if (j) { j = j.replace(hb, W); if (j.indexOf(ib) >= O) { continue; } if (j == jb) { k = i.getAttribute(kb); if (k) { var l, m = k.indexOf(lb); if (m >= O) { j = k.substring(O, m); l = k.substring(m + P); } else { j = k; l = W; } c[j] = l; } } else if (j == mb) { k = i.getAttribute(kb); if (k) { try { d = eval(k); } catch (a) { alert(nb + k + ob); } } } else if (j == pb) { k = i.getAttribute(kb); if (k) { try { e = eval(k); } catch (a) { alert(nb + k + qb); } } } } } __gwt_getMetaProperty = function(a) { var b = c[a]; return b == null ? null : b; }; r = d; webModule.__errFn = e; } function B() { function e2(a) { var b = a.lastIndexOf(rb); if (b == -1) { b = a.length; } var c2 = a.indexOf(sb); if (c2 == -1) { c2 = a.length; } var d2 = a.lastIndexOf(tb, Math.min(c2, b)); return d2 >= O ? a.substring(O, d2 + P) : W; } function f2(a) { if (a.match(/^\w+:\/\//)) { } else { var b = o.createElement(ub); b.src = a + vb; a = e2(b.src); } return a; } function g2() { var a = __gwt_getMetaProperty(wb); if (a != null) { return a; } return W; } function h2() { var a = o.getElementsByTagName(_); for (var b = O; b < a.length; ++b) { if (a[b].src.indexOf(xb) != -1) { return e2(a[b].src); } } return W; } function i2() { var a = o.getElementsByTagName(yb); if (a.length > O) { return a[a.length - P].href; } return W; } function j2() { var a = o.location; return a.href == a.protocol + zb + a.host + a.pathname + a.search + a.hash; } var k2 = g2(); if (k2 == W) { k2 = h2(); } if (k2 == W) { k2 = i2(); } if (k2 == W && j2()) { k2 = e2(o.location.href); } k2 = f2(k2); return k2; } function C(a) { if (a.match(/^\//)) { return a; } if (a.match(/^[a-zA-Z]+:\/\//)) { return a; } return webModule.__moduleBase + a; } function D() { var f2 = []; var g2 = O; var h2 = []; var i2 = []; function j2(a) { var b = i2[a](), c2 = h2[a]; if (b in c2) { return b; } var d2 = []; for (var e2 in c2) { d2[c2[e2]] = e2; } if (r) { r(a, d2, b); } throw null; } __gwt_isKnownPropertyValue = function(a, b) { return b in h2[a]; }; webModule.__getPropMap = function() { var a = {}; for (var b in h2) { if (h2.hasOwnProperty(b)) { a[b] = j2(b); } } return a; }; webModule.__computePropValue = j2; n.__gwt_activeModules[L].bindings = webModule.__getPropMap; if (p()) { return C(Bb); } var k2; try { k2 = Cb; var l2 = k2.indexOf(Db); if (l2 != -1) { g2 = parseInt(k2.substring(l2 + P), $); k2 = k2.substring(O, l2); } } catch (a) { } webModule.__softPermutationId = g2; return C(k2 + Eb); } function F() { if (!n.__gwt_stylesLoaded) { n.__gwt_stylesLoaded = {}; } } A(); webModule.__moduleBase = "/js/mathematicalGraphics/" + name + "/"; s[L].moduleBase = webModule.__moduleBase; var G = D(); F(); w(G); return true; } return webModule; }; if (typeof window.web3d !== "function") { window.web3d = GGBAppletUtils.makeModule("web3d", "A18F540516513B1292CA7CEF2F6AFC7E"); } if (typeof window.webSimple !== "function") { window.webSimple = GGBAppletUtils.makeModule("webSimple", "96B09BF1B436BF53F0DF54116700F16A"); } window.GGBApplet = GGBApplet; })(); /***/ }), /***/ 73976: /*!*********************************!*\ !*** ./src/pages/tasks/util.js ***! \*********************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* 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 */ 21873); 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, type: item.type, 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; /***/ }), /***/ 88700: /*!**************************************************************!*\ !*** ./src/components/ImageDimensions/index.tsx + 1 modules ***! \**************************************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; // 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.5.1@classnames/index.js var _classnames_2_5_1_classnames = __webpack_require__(92310); var _classnames_2_5_1_classnames_default = /*#__PURE__*/__webpack_require__.n(_classnames_2_5_1_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__(51165); // EXTERNAL MODULE: ./src/utils/util.tsx var util = __webpack_require__(13462); ;// 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_5_1_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); /***/ }), /***/ 42019: /*!*************************************************************!*\ !*** ./src/components/markdown-editor/code-block/index.tsx ***! \*************************************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* 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 */ 81974); /* harmony import */ var codemirror_theme_blackboard_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! codemirror/theme/blackboard.css */ 3693); 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, style: { width: 500 } }), /* @__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 })); } /***/ }), /***/ 96180: /*!***************************************************************!*\ !*** ./src/components/markdown-editor/index.tsx + 15 modules ***! \***************************************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; // 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__(81974); // 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 var RenderHtml = __webpack_require__(16921); ;// 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 /* provided dependency */ var React = __webpack_require__(/*! react */ 59301); 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: "\u6570\u5B66\u56FE\u50CF", icon: "iconfont icon-shuxuetuxiang2", actionName: "maths-latex" }, { title: "\u591A\u884C\u516C\u5F0F", icon: "iconfont icon-jisuan1", 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.createElement("a", { title, className, onClick: onAction }, /* @__PURE__ */ 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.createElement("ul", { className: "markdown-toolbar-container" }, !hidetoolBar && icons.map((item, index) => /* @__PURE__ */ React.createElement("li", { key: index }, item.actionName ? /* @__PURE__ */ React.createElement(AButton, __spreadProps(__spreadValues({}, item), { onActionCallback })) : /* @__PURE__ */ React.createElement("span", { className: "v-line" }))), showNullButton ? /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ 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.createElement("span", { className: "fill-tip" }, "\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879") )) : null, showNullProgramButton ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement( AButton, { icon: "md-iconfont icon-edit insert-blank", className: "btn-null", title: "\u589E\u52A0\u586B\u7A7A", actionName: "add-signal", onActionCallback }, /* @__PURE__ */ React.createElement("span", { className: "fill-tip" }, "+\u5355\u884C\u586B\u7A7A\u9879") )), /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement( AButton, { icon: "md-iconfont icon-uniE900 insert-blank", className: "btn-null", title: "\u589E\u52A0\u586B\u7A7A", actionName: "add-multiple", onActionCallback }, /* @__PURE__ */ React.createElement("span", { className: "fill-tip" }, "+\u591A\u884C\u586B\u7A7A\u9879") ))) : null, insertTemp && /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement( AButton, { icon: "md-iconfont icon-edit", className: "btn-null", title: "\u63D2\u5165\u6A21\u677F", actionName: `inster-template-${insertTemp}`, onActionCallback }, /* @__PURE__ */ React.createElement("span", { className: "fill-tip" }, "\u63D2\u5165\u6A21\u677F") )), extraUse && /* @__PURE__ */ React.createElement("li", null, extraUse), /* @__PURE__ */ React.createElement("li", { className: "btn-full-screen" }, /* @__PURE__ */ 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__(8027); // 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__(98135); // 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, style: { width: 500 } }), /* @__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__(42019); // 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__(73976); ;// CONCATENATED MODULE: ./src/components/markdown-editor/upload-image/index.tsx /* provided dependency */ var upload_image_React = __webpack_require__(/*! react */ 59301); 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(); let currentFile = (0,_react_17_0_2_react.useRef)(); function onSubmit(values) { callback(values, currentFile.current); } 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]; currentFile.current = file; uploadImage(file, onAddUrl); } return /* @__PURE__ */ upload_image_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__ */ upload_image_React.createElement(es_form["default"].Item, { label: "\u56FE\u7247\u5730\u5740", required: true }, /* @__PURE__ */ upload_image_React.createElement("div", { className: "flex-container" }, /* @__PURE__ */ upload_image_React.createElement( es_form["default"].Item, { noStyle: true, name: "src", rules: [{ required: true, message: "\u8BF7\u8F93\u5165\u56FE\u7247\u5730\u5740" }] }, /* @__PURE__ */ upload_image_React.createElement(input["default"], { style }) ), /* @__PURE__ */ upload_image_React.createElement(UploadButton, { onFileChange }))), /* @__PURE__ */ upload_image_React.createElement( es_form["default"].Item, { label: "\u56FE\u7247\u63CF\u8FF0", name: "alt" }, /* @__PURE__ */ upload_image_React.createElement(input["default"], { style: { width: 264 } }) ), /* @__PURE__ */ upload_image_React.createElement(es_form["default"].Item, { style: { textAlign: "right" } }, /* @__PURE__ */ upload_image_React.createElement(es_button/* default */.ZP, { type: "primary", htmlType: "submit", style: { marginRight: 10 } }, "\u786E\u5B9A"), /* @__PURE__ */ upload_image_React.createElement(es_button/* default */.ZP, { type: "default", onClick: onCancel }, "\u53D6\u6D88"))); }); function UploadButton({ onFileChange }) { return /* @__PURE__ */ upload_image_React.createElement("label", { className: "upload-button", style: { cursor: "pointer" } }, "\u672C\u5730\u4E0A\u4F20", /* @__PURE__ */ upload_image_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__(88700); ;// 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__(14253); // 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__(51165); ;// 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)(); 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 modalRef = (0,_react_17_0_2_react.useRef)(false); const [updateModal, setUpdateModal] = (0,_react_17_0_2_react.useState)(0); function initDiagram() { 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.current = new go_module.Diagram( myDiagramDivRef.current, { padding: 20, // extra space when scrolled all the way grid: $( go_module.Panel, "Grid", // a simple 10x10 grid $(go_module.Shape, "LineH", { stroke: "lightgray", strokeWidth: 0.5 }), $(go_module.Shape, "LineV", { stroke: "lightgray", strokeWidth: 0.5 }) ), "draggingTool.isGridSnapEnabled": true, handlesDragDropForTopLevelParts: true, mouseDrop: (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.current.nodeTemplate = $( go_module.Node, "Auto", { locationSpot: go_module.Spot.Center, locationObjectName: "SHAPE", desiredSize: new go_module.Size(120, 60), minSize: new go_module.Size(40, 40), resizable: true, resizeCellSize: new go_module.Size(10, 10), rotatable: true // rotateObjectName: "SHAPE", // rotate the Shape without rotating the label }, // these Bindings are TwoWay because the DraggingTool and ResizingTool modify the target properties new go_module.Binding("location", "loc", go_module.Point.parse).makeTwoWay(go_module.Point.stringify), new go_module.Binding("desiredSize", "size", go_module.Size.parse).makeTwoWay(go_module.Size.stringify), $( go_module.Shape, { // the border name: "SHAPE", fill: colors.white, cursor: "pointer", portId: "", fromLinkable: true, toLinkable: true, fromLinkableDuplicates: true, toLinkableDuplicates: true, fromSpot: go_module.Spot.AllSides, toSpot: go_module.Spot.AllSides }, new go_module.Binding("figure"), new go_module.Binding("fill"), new go_module.Binding("stroke", "borderColor"), new go_module.Binding("strokeWidth", "thickness"), new go_module.Binding("strokeDashArray", "dash") ), // this Shape prevents mouse events from reaching the middle of the port $(go_module.Shape, { width: 100, height: 20, strokeWidth: 0, fill: "transparent" }), $( go_module.TextBlock, { margin: 1, textAlign: "center", overflow: go_module.TextBlock.OverflowEllipsis, editable: true }, // this Binding is TwoWay due to the user editing the text with the TextEditingTool new go_module.Binding("text").makeTwoWay(), new go_module.Binding("stroke", "color") ) ); myDiagram.current.nodeTemplate.toolTip = $( "ToolTip", // show some detailed information $( go_module.Panel, "Vertical", { maxSize: new go_module.Size(200, NaN) }, // limit width but not height $( go_module.TextBlock, { font: "bold 10pt sans-serif", textAlign: "center" }, new go_module.Binding("text") ), $( go_module.TextBlock, { font: "10pt sans-serif", textAlign: "center" }, new go_module.Binding("text", "details") ) ) ); 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.current.nodeTemplate.selectionAdornmentTemplate = $( go_module.Adornment, "Spot", $(go_module.Placeholder, { padding: 10 }), makeArrowButton(go_module.Spot.Top, "TriangleUp"), makeArrowButton(go_module.Spot.Left, "TriangleLeft"), makeArrowButton(go_module.Spot.Right, "TriangleRight"), makeArrowButton(go_module.Spot.Bottom, "TriangleDown"), CMButton({ alignment: new go_module.Spot(0.75, 0) }) ); 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.current.nodeTemplate.contextMenu = $( "ContextMenu", // $("ContextMenuButton", // $(go.TextBlock, 'Move Up', { // // Associate the custom command to move the node up // click: (e, obj) => { // const node = obj.part.adornedPart; // myDiagram.current.commandHandler['MoveNodeUp'].execute(myDiagram.current); // } // }) // ), // $("ContextMenuButton", // $(go.TextBlock, 'Move Up', { // // Associate the custom command to move the node up // click: (e, obj) => { // const node = obj.part.adornedPart; // myDiagram.current.commandHandler['moveNodeUpCommand'].execute(myDiagram.current); // } // }) // ), $( "ContextMenuButton", $( go_module.Panel, "Horizontal", FigureButton("Rectangle"), FigureButton("RoundedRectangle"), FigureButton("Ellipse"), FigureButton("Diamond") ) ), $( "ContextMenuButton", $( go_module.Panel, "Horizontal", FigureButton("Parallelogram2"), FigureButton("ManualOperation"), FigureButton("Procedure"), FigureButton("Cylinder1") ) ), $( "ContextMenuButton", $( go_module.Panel, "Horizontal", FigureButton("Terminator"), FigureButton("CreateRequest"), FigureButton("Document"), FigureButton("TriangleDown") ) ), LightFillButtons(), DarkColorButtons(), StrokeOptionsButtons() ); myDiagram.current.groupTemplate = $( go_module.Group, "Spot", { layerName: "Background", ungroupable: true, locationSpot: go_module.Spot.Center, selectionObjectName: "BODY", computesBoundsAfterDrag: true, // allow dragging out of a Group that uses a Placeholder handlesDragDropForMembers: true, // don't need to define handlers on Nodes and Links mouseDrop: (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.current.groupTemplate.selectionAdornmentTemplate = $( go_module.Adornment, "Spot", $( go_module.Panel, "Auto", $(go_module.Shape, { fill: null, stroke: "dodgerblue", strokeWidth: 3 }), $(go_module.Placeholder, { margin: 1.5 }) ), CMButton({ alignment: go_module.Spot.TopRight, alignmentFocus: go_module.Spot.BottomRight }) ); myDiagram.current.groupTemplate.contextMenu = $( "ContextMenu", LightFillButtons(), DarkColorButtons(), StrokeOptionsButtons() ); myDiagram.current.linkTemplate = $( go_module.Link, { layerName: "Foreground", routing: go_module.Link.AvoidsNodes, corner: 10, fromShortLength: 10, toShortLength: 15, // assume arrowhead at "to" end, need to avoid bad appearance when path is thick relinkableFrom: true, relinkableTo: true, reshapable: true, resegmentable: true }, new go_module.Binding("fromSpot", "fromSpot", go_module.Spot.parse), new go_module.Binding("toSpot", "toSpot", go_module.Spot.parse), new go_module.Binding("fromShortLength", "dir", (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.current.linkTemplate.selectionAdornmentTemplate = $( go_module.Adornment, // use a special selection Adornment that does not obscure the link path itself $( go_module.Shape, { // this uses a pathPattern with a gap in it, in order to avoid drawing on top of the link path Shape isPanelMain: true, stroke: "transparent", strokeWidth: 6, pathPattern: makeAdornmentPathPattern(2) // == thickness or strokeWidth }, new go_module.Binding("pathPattern", "thickness", makeAdornmentPathPattern) ), CMButton({ alignmentFocus: new go_module.Spot(0, 0, -6, -4) }) ); function makeAdornmentPathPattern(w) { return $( go_module.Shape, { stroke: "dodgerblue", strokeWidth: 2, strokeCap: "square", geometryString: "M0 0 M4 2 H3 M4 " + (w + 4).toString() + " H3" } ); } 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.current.linkTemplate.contextMenu = $( "ContextMenu", DarkColorButtons(), StrokeOptionsButtons(), $( "ContextMenuButton", $( go_module.Panel, "Horizontal", ArrowButton(0), ArrowButton(1), ArrowButton(2) ) ), $( "ContextMenuButton", $( go_module.Panel, "Horizontal", $( go_module.Panel, "Spot", AllSidesButton(false), SpotButton(go_module.Spot.Top, false), SpotButton(go_module.Spot.Left, false), SpotButton(go_module.Spot.Right, false), SpotButton(go_module.Spot.Bottom, false) ), $( go_module.Panel, "Spot", { margin: new go_module.Margin(0, 0, 0, 2) }, AllSidesButton(true), SpotButton(go_module.Spot.Top, true), SpotButton(go_module.Spot.Left, true), SpotButton(go_module.Spot.Right, true), SpotButton(go_module.Spot.Bottom, true) ) ) ) ); 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; } var myPalette = new go_module.Palette( myPaletteDivRef.current, // must name or refer to the DIV HTML element { maxSelectionCount: 1, // nodeTemplateMap: myDiagram.current.nodeTemplateMap, // share the templates used by myDiagram.current linkTemplate: ( // simplify the link template, just in this Palette $( go_module.Link, { // because the GridLayout.alignment is Location and the nodes have locationSpot == Spot.Center, // to line up the Link in the same manner we have to pretend the Link has the same location spot locationSpot: go_module.Spot.Center, selectionAdornmentTemplate: $( go_module.Adornment, "Link", { locationSpot: go_module.Spot.Center }, $( go_module.Shape, { isPanelMain: true, fill: null, stroke: "deepskyblue", strokeWidth: 0 } ), $( go_module.Shape, // the arrowhead { toArrow: "Standard", stroke: null } ) ) }, { routing: go_module.Link.AvoidsNodes, curve: go_module.Link.JumpOver, corner: 5, toShortLength: 4 }, new go_module.Binding("points"), $( go_module.Shape, // the link path shape { isPanelMain: true, strokeWidth: 2 } ), $( go_module.Shape, // the arrowhead { toArrow: "Standard", stroke: null } ) ) ), model: new go_module.GraphLinksModel( [ // specify the contents of the Palette { text: "\u672A\u547D\u540D", "size": "100 100", fill: null, stroke: "#000" }, ...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() ) ); setTimeout(() => { myDiagram.current.grid = $( go_module.Panel, "Grid", $(go_module.Shape, "LineH", { stroke: "lightgray", strokeWidth: 0.5 }), $(go_module.Shape, "LineV", { stroke: "lightgray", strokeWidth: 0.5 }) ); myDiagram.current.grid.visible = true; myDiagram.current.grid.gridCellStroke = "darkgray"; myDiagram.current.grid.gridCellStrokeWidth = 1; }, 300); window.myDiagrams = myDiagram.current; return myDiagram.current; } const save = () => __async(this, null, function* () { var imgs = myDiagram.current.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)(() => { setUpdateModal(updateModal + 1); }, []); return /* @__PURE__ */ _react_17_0_2_react.createElement( "div", { ref: modalRef, className: hidedenContentRef.current ? `${flow_chartmodules.maxH60} body-overflow-initial` : "body-overflow-initial" }, /* @__PURE__ */ _react_17_0_2_react.createElement( es_modal["default"], { width: 1200, icon: null, footer: null, closable: true, visible: !!updateModal, destroyOnClose: true, maskClosable: false, getContainer: modalRef.current, rootClassName: "zIndex-9999", 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; setUpdateModal(updateModal + 1); } }, /* @__PURE__ */ _react_17_0_2_react.createElement("span", { className: "current c-blue mr30", style: { fontWeight: 400 } }, "\u5C55\u5F00/\u6536\u8D77"))), onCancel }, /* @__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"))) ) ); } /* 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__(54449); ;// 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: ./node_modules/_antd@5.9.0@antd/es/switch/index.js + 2 modules var es_switch = __webpack_require__(78673); // EXTERNAL MODULE: ./src/components/MathematicalGraphics/js/index.js var js = __webpack_require__(94471); var js_default = /*#__PURE__*/__webpack_require__.n(js); ;// CONCATENATED MODULE: ./src/components/MathematicalGraphics/index.tsx const MathematicalGraphics_FlowChart = (0,_react_17_0_2_react.forwardRef)(({ use3d, width, height, callback, showSaveButton }, ref) => { const ggbAppletRef = (0,_react_17_0_2_react.useRef)(); const appletRef = (0,_react_17_0_2_react.useRef)(); const [is3D, setIs3d] = (0,_react_17_0_2_react.useState)(false); const parameters = (0,_react_17_0_2_react.useRef)({ "id": ggbAppletRef, "appName": "graphing", "width": width || 1e3, "height": height || 600, "showToolBar": true, "showMenuBar": true, "allowStyleBar": true, "showAlgebraInput": true, "enableLabelDrags": false, "enableShiftDragZoom": true, "showToolBarHelp": false, "errorDialogsActive": true, "showTutorialLink": true, "showLogging": true, "useBrowserForJS": false }); (0,_react_17_0_2_react.useEffect)(() => { appletRef.current = new (js_default())(parameters.current, true); window.onload = function() { appletRef.current.inject("applet_container"); }; }, []); const getImgData = () => { var str = window.ggbApplet.getPNGBase64(1, true, 72); callback && callback(str); return str; }; (0,_react_17_0_2_react.useEffect)(() => { parameters.current.appName = is3D ? "3D" : "graphing"; appletRef.current.inject("applet_container"); }, [is3D]); (0,_react_17_0_2_react.useEffect)(() => { setIs3d(use3d); }, [use3d]); (0,_react_17_0_2_react.useImperativeHandle)(ref, () => ({ getImgData })); return /* @__PURE__ */ _react_17_0_2_react.createElement(_react_17_0_2_react.Fragment, null, /* @__PURE__ */ _react_17_0_2_react.createElement("div", { style: { width: "100%", height: "100%" }, id: "applet_container", ref: ggbAppletRef }), /* @__PURE__ */ _react_17_0_2_react.createElement(row/* default */.Z, { align: "middle" }, /* @__PURE__ */ _react_17_0_2_react.createElement(col/* default */.Z, { flex: 1 }, /* @__PURE__ */ _react_17_0_2_react.createElement(es_switch/* default */.Z, { size: "default", checkedChildren: "\u5173\u95ED3D\u56FE\u50CF", unCheckedChildren: "\u5F00\u542F3D\u56FE\u50CF", checked: is3D, onChange: (e) => setIs3d(e) })), /* @__PURE__ */ _react_17_0_2_react.createElement(col/* default */.Z, null, /* @__PURE__ */ _react_17_0_2_react.createElement(es_button/* default */.ZP, { size: "large", onClick: getImgData, style: { zIndex: 8, marginTop: 10 }, type: "primary" }, "\u4FDD\u5B58\u5230\u7F16\u8F91\u5668")))); }); /* harmony default export */ var MathematicalGraphics = (MathematicalGraphics_FlowChart); // EXTERNAL MODULE: ./src/components/MathsLatexKeybords/keybords.tsx var keybords = __webpack_require__(68585); // EXTERNAL MODULE: ./src/utils/env.ts + 1 modules var env = __webpack_require__(21873); ;// 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__(75318); ;// 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"; 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" ]; 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", "maths-latex": "\u6570\u5B66\u56FE\u50CF", "inline-latex": "LATEX\u516C\u5F0F" }; /* 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 [styleLeft, setStyleLeft] = (0,_react_17_0_2_react.useState)(0); const [styleTop, setStyleTop] = (0,_react_17_0_2_react.useState)(0); 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; 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(``); } else if (((_c = file == null ? void 0 : file.type) == null ? void 0 : _c.indexOf("pdf")) > -1) { instance.replaceSelection(`${file.name}`); } else if (officeSix.includes(fileSix)) { instance.replaceSelection(`${file.name}`); } 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": setAction("inline-latex"); return cm.focus(); case "latex": cm.replaceSelection("```latex\n" + selection + "\n```"); cm.setCursor(cursor.line + 1, selection.length + 1); return cm.focus(); case "line-break": cm.replaceSelection("
\n"); return cm.focus(); case "list-ul": if (selection === "") { cm.replaceSelection("- " + selection); } else { cm.replaceSelection( selectionText.map((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 "maths-latex": setAction("maths-latex"); 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, currentFile) => { var _a, _b, _c, _d, _e, _f; 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 "maths-latex": var binaryString = atob(values2); var uint8Array = new Uint8Array(binaryString.length); for (var i = 0; i < binaryString.length; i++) { uint8Array[i] = binaryString.charCodeAt(i); } var files = new Blob([uint8Array], { type: "image/png" }); uploadImage(files, (data) => { if (data.id) { cm.replaceSelection(`![,](/api/attachments/${data.id}?type=${data.content_type})`); } else { if ((data == null ? void 0 : data.status) === 401) document.location.href = "/user/login"; } }); break; case "inline-latex": cm.replaceSelection("`$$" + values2 + "$$`"); break; case UPLOAD_IMAGE: case DRAW_IMAGE: case FLOW_CHART: const { src, alt } = values2; const file = currentFile; const fileSix = (_c = (_b = (_a = file == null ? void 0 : file.name) == null ? void 0 : _a.split(".")) == null ? void 0 : _b.pop) == null ? void 0 : _c.call(_b); if (((_d = file == null ? void 0 : file.type) == null ? void 0 : _d.indexOf("image")) > -1 || !(file == null ? void 0 : file.type)) { if (alt) { cm.replaceSelection(`![ ${alt} ]( ${src} "${alt}" )`); } else { cm.replaceSelection(`![,](${src})`); } } else if (((_e = file == null ? void 0 : file.type) == null ? void 0 : _e.indexOf("video")) > -1) { cm.replaceSelection(``); } else if (((_f = file == null ? void 0 : file.type) == null ? void 0 : _f.indexOf("pdf")) > -1) { cm.replaceSelection(`${file.name}`); } else if (officeSix.includes(fileSix)) { cm.replaceSelection(`${file.name}`); } else { cm.replaceSelection(`[${file.name}](${env/* default */.Z.API_SERVER}${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 }); case "maths-latex": return /* @__PURE__ */ _react_17_0_2_react.createElement(MathematicalGraphics, { showSaveButton: true, callback: ExecutePluginAction }); case "inline-latex": return /* @__PURE__ */ _react_17_0_2_react.createElement(keybords/* default */.Z, { showSaveButton: true, callback: ExecutePluginAction }); 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)); } (0,_react_17_0_2_react.useEffect)(() => { if (TitleDesc[action] && action !== DRAW_IMAGE && action !== ADD_FLOWCHART) { const modal = document.getElementsByClassName("ant-modal")[0]; const centerX = window.innerWidth / 2 - modal.offsetWidth / 2; const centerY = window.innerHeight / 2 - modal.offsetHeight / 2; setStyleLeft(centerX); setStyleTop(centerY); } }, [action]); const onTitleMouseDown = (e) => { e.preventDefault(); const startPosX = e.clientX - styleLeft; const startPosY = e.clientY - styleTop; document.body.onmousemove = (e2) => { let left = e2.clientX - startPosX; let top = e2.clientY - startPosY; const modal = document.getElementsByClassName("ant-modal")[0]; const maxWidth = window.innerWidth - modal.offsetWidth; const maxHeight = window.innerHeight - modal.offsetHeight; left = Math.max(0, Math.min(left, maxWidth)); top = Math.max(0, Math.min(top, maxHeight)); if (inWindow(e2.clientX, e2.clientY, startPosX, startPosY)) { setStyleLeft(left); setStyleTop(top); } }; document.body.onmouseup = function() { document.body.onmousemove = null; }; }; const inWindow = (left, top, startPosX, startPosY) => { const H = document.body.clientHeight; const W = document.body.clientWidth; if (left < 20 && startPosX > left || left > W - 20 && startPosX < left || top < 20 && startPosY > top || top > H - 20 && startPosY < top) { document.body.onmousemove = null; document.body.onmouseup = null; return false; } return true; }; 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"], { maskClosable: false, centered: true, style: { position: "absolute", left: styleLeft, top: styleTop }, title: /* @__PURE__ */ _react_17_0_2_react.createElement("div", { style: { cursor: "move" }, onMouseDown: onTitleMouseDown }, TitleDesc[action]), open: true, onCancel, footer: null, destroyOnClose: true, width: action === ADD_FLOWCHART ? "1200px" : null, height: action === ADD_FLOWCHART ? "80vh" : null, className: "markdown-popup-form" }, PluginEl ) : null)); }); /***/ }), /***/ 8027: /*!**********************************!*\ !*** ./src/components/modal.tsx ***! \**********************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* 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); } } /***/ }), /***/ 75318: /*!****************************************!*\ !*** ./src/components/useInterval.tsx ***! \****************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* 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]); } /***/ }) }]);