(self["webpackChunk"] = self["webpackChunk"] || []).push([[35729,97579],{ /***/ 41472: /*!*********************************************************!*\ !*** ./src/components/MathematicalGraphics/js/index.js ***! \*********************************************************/ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof = (__webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/typeof.js */ 31468)["default"]); (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 GGBApplet() { "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 i = 0; i < arguments.length; i++) { var p = arguments[i]; if (p !== null) { switch (_typeof(p)) { case "number": ggbVersion = p.toFixed(1); break; case "string": if (p.match(new RegExp("^[0-9]\\.[0-9]+$"))) { ggbVersion = p; } else { appletID = p; } break; case "object": if (typeof p.is3D !== "undefined") { views = p; } else { parameters = p; } break; case "boolean": html5NoWebSimple = p; 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 !== undefined && !html5NoWebSimpleParamExists) { html5NoWebSimple = true; } } if (appletID !== null && parameters.id === undefined) { 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 !== undefined) { parameters.height = Math.round(parameters.height); } if (parameters.width !== undefined) { parameters.width = Math.round(parameters.width); } var parseVersion = function parseVersion(d) { return parseFloat(d) > 4 ? parseFloat(d) : 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 i = 0; i < arguments.length; i++) { var p = arguments[i]; if (typeof p === "string") { p = p.toLowerCase(); if (p.match(/^(prefer)?(java|html5|compiled|auto|screenshot)$/)) { type = p; } else { container_ID = arguments[i]; } } else if (typeof p === "boolean") { noPreview = p; } else if (p instanceof HTMLElement) { container = p; } } 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 === undefined && appletElem.clientWidth) { parameters.width = appletElem.clientWidth; } if (parameters.height === undefined && 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 (e) { 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 fetchParametersFromApi(successCallback) { var onSuccess = function onSuccess(text) { var jsonData = JSON.parse(text); var isGeoGebra = function isGeoGebra(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 onError() { 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 (name) { settings[name] = !!settings[name]; }); parameterNames.forEach(function (name) { if (parameters[name] === undefined && settings[name] !== undefined) { parameters[name] = settings[name]; } }); if (parameters.showToolBarHelp === undefined) { 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 i; if (typeof appletParent === "string") { appletParent = document.getElementById(appletParent); } loadedAppletType = null; var removedID = null; for (i = 0; i < appletParent.childNodes.length; i++) { var currentChild = appletParent.childNodes[i]; 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; i--; } } var appName = parameters.id !== undefined ? 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 !== undefined ? parameters.id : "ggbApplet"; return window[appName]; }; applet.resize = function () {}; var appendParam = function appendParam(applet, name, value) { var param = document.createElement("param"); param.setAttribute("name", name); param.setAttribute("value", value); applet.appendChild(param); }; var valBoolean = function valBoolean(value) { return value && value !== "false"; }; var injectHTML5Applet = function injectHTML5Applet(appletElem, parameters, 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 = parameters.width; var oriHeight = parameters.height; parameters.disableAutoScale = parameters.disableAutoScale === undefined ? GGBAppletUtils.isFlexibleWorksheetEditor() : parameters.disableAutoScale; if (parameters.width !== undefined) { if (parseVersion(html5CodebaseVersion) <= 4.4) { if (valBoolean(parameters.showToolBar)) { parameters.height -= 7; } if (valBoolean(parameters.showAlgebraInput)) { parameters.height -= 37; } if (parameters.width < 605 && valBoolean(parameters.showToolBar)) { parameters.width = 605; oriWidth = 605; } } else { var minWidth = 100; if (valBoolean(parameters.showToolBar) || valBoolean(parameters.showMenuBar)) { if (parameters.hasOwnProperty("customToolBar")) { parameters.customToolbar = parameters.customToolBar; } minWidth = valBoolean(parameters.showMenuBar) ? 245 : 155; } if (oriWidth < minWidth) { parameters.width = minWidth; oriWidth = minWidth; } } } article.style.border = "none"; article.style.display = "inline-block"; for (var key in parameters) { if (parameters.hasOwnProperty(key) && key !== "appletOnLoad") { article.setAttribute("data-param-" + key, parameters[key]); } } if (fonts_css_url) { article.setAttribute("data-param-fontscssurl", fonts_css_url); } applet.resize = function () { GGBAppletUtils.responsiveResize(appletElem, parameters); }; window.addEventListener("resize", function (evt) { applet.resize(); }); var oriAppletOnload = typeof parameters.appletOnLoad === "function" ? parameters.appletOnLoad : function () {}; if (!noPreview && parameters.width !== undefined) { if (!parameters.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, parameters.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) { parameters.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); parameters.appletOnLoad = function (api) { applet.resize(); oriAppletOnload(api); }; } function renderGGBElementWithParams(article, parameters) { if (parameters && typeof parameters.appletOnLoad === "function" && typeof renderGGBElement === "function") { renderGGBElement(article, parameters.appletOnLoad); } else { renderGGBElement(article); } log("GeoGebra HTML5 applet injected and rendered with previously loaded codebase.", parameters); } function renderGGBElementOnTube(a, parameters) { if (typeof renderGGBElement === "undefined") { if (html5AppletsToProcess === null) { html5AppletsToProcess = []; } html5AppletsToProcess.push({ article: a, params: parameters }); 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, parameters); } } if (loadScript) { scriptLoadStarted = true; for (var i = 0; i < article.childNodes.length; i++) { var tag = article.childNodes[i].tagName; if (tag === "TABLE") { article.removeChild(article.childNodes[i]); i--; } } if (ggbHTML5LoadedScript !== null) { var el = document.querySelector('script[src="' + ggbHTML5LoadedScript + '"]'); if (el !== undefined && el !== null) { el.parentNode.removeChild(el); } } var script = document.createElement("script"); var scriptLoaded = function scriptLoaded() { renderGGBElementOnTube(article, parameters); }; script.src = html5Codebase + html5CodebaseScript; ggbHTML5LoadedCodebaseIsWebSimple = html5CodebaseIsWebSimple; ggbHTML5LoadedCodebaseVersion = html5CodebaseVersion; ggbHTML5LoadedScript = script.src; log("GeoGebra HTML5 codebase loaded: '" + html5Codebase + "'.", parameters); 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 */ 68803).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(/*! ./web3d */ 68803)]; (scriptLoaded).apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__);}.bind(this))['catch'](__webpack_require__.oe); } else { script.onload = scriptLoaded; appletElem.appendChild(script); } } else { renderGGBElementOnTube(article, parameters); } parameters.height = oriHeight; parameters.width = oriWidth; }; var injectScreenshot = function injectScreenshot(appletElem, parameters, showPlayButton) { var previewContainer = createScreenShotDiv(parameters.width, parameters.height, parameters.borderColor, showPlayButton); var previewPositioner = document.createElement("div"); previewPositioner.style.position = "relative"; previewPositioner.style.display = "block"; previewPositioner.style.width = parameters.width + "px"; previewPositioner.style.height = parameters.height + "px"; previewPositioner.className = "applet_screenshot applet_scaler" + (showPlayButton ? " applet_screenshot_play" : ""); previewPositioner.appendChild(previewContainer); var scale = GGBAppletUtils.getScale(parameters, 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 = parameters.width + "px"; previewPositioner.style.height = parameters.height + "px"; previewPositioner.parentNode.style.width = parameters.width * scale + "px"; previewPositioner.parentNode.style.height = parameters.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 injectPlayButton(appletElem, parameters, noPreview, type) { injectScreenshot(appletElem, parameters, true); var play = function play() { var elems = []; for (i = 0; i < appletElem.childNodes.length; i++) { elems.push(appletElem.childNodes[i]); } if (window.GGBT_wsf_view) { var content = window.GGBT_wsf_view.renderFullScreen(appletElem, parameters.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, parameters, false); } window.GGBT_wsf_view.launchFullScreen(container); } else { loadedAppletType = type; injectHTML5Applet(appletElem, parameters, false); } if (!window.GGBT_wsf_view) { for (i = 0; i < elems.length; i++) { appletElem.removeChild(elems[i]); } } }; var imgs = appletElem.getElementsByClassName("ggb_preview_play"); for (var i = 0; i < imgs.length; i++) { imgs[i].addEventListener("click", play, false); imgs[i].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 getPlayButton() { 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 createScreenShotDiv(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 !== undefined) { 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 = .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 = .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 detectAppletType(preferredType) { preferredType = preferredType.toLowerCase(); if (preferredType === "html5" || preferredType === "screenshot") { return preferredType; } return "html5"; }; var modules = ["web", "webSimple", "web3d", "tablet", "tablet3d", "phone"]; var setDefaultHTML5CodebaseForVersion = function setDefaultHTML5CodebaseForVersion(version, offline) { html5CodebaseVersion = version; if (offline) { setHTML5CodebaseInternal(html5CodebaseVersion, true); return; } var hasWebSimple = !html5NoWebSimple; if (hasWebSimple) { var v = parseVersion(html5CodebaseVersion); if (!isNaN(v) && v < 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 setHTML5CodebaseInternal(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 log(text, parameters) { if (window.console && window.console.log) { if (!parameters || typeof parameters.showLogging === "undefined" || parameters.showLogging && parameters.showLogging !== "false") { console.log(text); } } }; if (parameters.material_id !== undefined) { 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 !== undefined; } 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] !== undefined) { el.querySelectorAll(".ggb_preview img")[0].style.maxWidth = "initial"; } if (el.querySelectorAll(".ggb_preview img")[1] !== undefined) { 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 != undefined && 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 === undefined || !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 === undefined || !allowUpscale) && appletWidth > 0 && appletWidth + border < myWidth) { myWidth = appletWidth; } else { myWidth -= border; } if (_typeof(window.GGBT_wsf_view) === "object" && window.GGBT_wsf_view.isFullscreen() && (allowUpscale === undefined || !allowUpscale)) { myHeight -= borderTop; } } return { width: myWidth, height: myHeight }; } function calcScale(parameters, appletElem, allowUpscale, showPlayButton, scaleContainerClass) { if (parameters.isScreenshoGenerator) { return 1; } var ignoreHeight = showPlayButton !== undefined && showPlayButton; var noScaleMargin = parameters.noScaleMargin != undefined && parameters.noScaleMargin; var valBoolean = function valBoolean(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 === undefined) { 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 !== undefined && !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 i = 0; i < appletElem.childNodes.length; i++) { if (appletElem.childNodes[i].className !== undefined && appletElem.childNodes[i].className.match(/^applet_scaler/)) { scaleElem = appletElem.childNodes[i]; break; } } if (scaleElem !== null && scaleElem.querySelector(".noscale") !== null) { return; } var appName = parameters.id !== undefined ? 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: responsiveResize, isFlexibleWorksheetEditor: isFlexibleWorksheetEditor, positionCenter: positionCenter, getScale: getScale, scaleElement: 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 (e) { var f = s[L].bindings; s[L].bindings = function () { var a = f ? f() : {}; var b = e[webModule.__softPermutationId]; for (var c = O; c < b.length; c++) { var d = b[c]; a[d[O]] = d[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(f) { function g(a) { function b() { if (_typeof(o.readyState) == Y) { return _typeof(o.body) != Y && o.body != null; } return /loaded|complete/.test(o.readyState); } var c = b(); if (c) { a(); return; } function d() { if (!c) { if (!b()) { return; } c = true; a(); if (o.removeEventListener) { o.removeEventListener(Z, d, false); } if (e) { clearInterval(e); } } } if (o.addEventListener) { o.addEventListener(Z, d, false); } var e = setInterval(function () { d(); }, $); } function h(a) { var b = u(); var c = b.body; var d = b.createElement(_); d.language = ab; d.crossOrigin = W; d.src = a; if (webModule.__errFn) { d.onerror = function () { webModule.__errFn(L, new Error(bb + a)); }; } c.appendChild(d); q(cb, db); } q(cb, eb); g(function () { h(f); }); } webModule.__startLoadingFragment = function (a) { return C(a); }; webModule.__installRunAsyncCode = function (a) { var b = u(); var c = b.body; var d = b.createElement(_); d.language = ab; d.text = a; c.appendChild(d); c.removeChild(d); }; 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 __gwt_getMetaProperty(a) { var b = c[a]; return b == null ? null : b; }; r = d; webModule.__errFn = e; } function B() { function e(a) { var b = a.lastIndexOf(rb); if (b == -1) { b = a.length; } var c = a.indexOf(sb); if (c == -1) { c = a.length; } var d = a.lastIndexOf(tb, Math.min(c, b)); return d >= O ? a.substring(O, d + P) : W; } function f(a) { if (a.match(/^\w+:\/\//)) {} else { var b = o.createElement(ub); b.src = a + vb; a = e(b.src); } return a; } function g() { var a = __gwt_getMetaProperty(wb); if (a != null) { return a; } return W; } function h() { var a = o.getElementsByTagName(_); for (var b = O; b < a.length; ++b) { if (a[b].src.indexOf(xb) != -1) { return e(a[b].src); } } return W; } function i() { var a = o.getElementsByTagName(yb); if (a.length > O) { return a[a.length - P].href; } return W; } function j() { var a = o.location; return a.href == a.protocol + zb + a.host + a.pathname + a.search + a.hash; } var k = g(); if (k == W) { k = h(); } if (k == W) { k = i(); } if (k == W && j()) { k = e(o.location.href); } k = f(k); return k; } function C(a) { if (a.match(/^\//)) { return a; } if (a.match(/^[a-zA-Z]+:\/\//)) { return a; } return webModule.__moduleBase + a; } function D() { var f = []; var g = O; var h = []; var i = []; function j(a) { var b = i[a](), c = h[a]; if (b in c) { return b; } var d = []; for (var e in c) { d[c[e]] = e; } if (r) { r(a, d, b); } throw null; } __gwt_isKnownPropertyValue = function __gwt_isKnownPropertyValue(a, b) { return b in h[a]; }; webModule.__getPropMap = function () { var a = {}; for (var b in h) { if (h.hasOwnProperty(b)) { a[b] = j(b); } } return a; }; webModule.__computePropValue = j; n.__gwt_activeModules[L].bindings = webModule.__getPropMap; if (p()) { return C(Bb); } var k; try { k = Cb; var l = k.indexOf(Db); if (l != -1) { g = parseInt(k.substring(l + P), $); k = k.substring(O, l); } } catch (a) {} webModule.__softPermutationId = g; return C(k + 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; })(); /***/ }), /***/ 42678: /*!*********************************!*\ !*** ./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 */ 33083); function isCompileOk(rs) { var flag = true; if (rs.length > 0) { for (var i = 0; i < rs.length; i++) { if (rs[i].compile_success == 0 || !rs[i].compile_success) { flag = false; break; } } } else { flag = false; } return flag; } function getTreeData(data) { var parentKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; var result = []; for (var i = 0; i < data.length; i++) { var item = data[i]; var key = parentKey ? "".concat(parentKey, "/").concat(item.name) : "".concat(item.name); result.push({ title: item.name, isLeaf: item.type === 'tree' ? false : true, key: key }); } return result; } function processTreeData(repos, key, newData) { for (var i = 0; i < repos.length; i++) { var item = repos[i]; if (item.key === key) { item.children = newData; break; } if (item.children) { processTreeData(item.children, key, newData); } } return repos; } function debounce(func, wait, immediate) { var timeout; return function () { var context = this, args = arguments; var later = function later() { timeout = null; if (!immediate) func.apply(context, args); }; var callNow = immediate && !timeout; clearTimeout(timeout); timeout = setTimeout(later, wait); if (callNow) func.apply(context, args); }; } var isProd = true; var apiPref = _utils_env__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z.API_SERVER; // export const isProd = // window.location.href.indexOf('test-') > 0 || // window.location.href.indexOf('localhost') > 0 // ? false // : true; // export const apiPref = isProd // ? 'https://www.educoder.net' // : 'https://test-newweb.educoder.net'; /***/ }), /***/ 37202: /*!**********************************************!*\ !*** ./src/components/AsyncButton/index.tsx ***! \**********************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Z: function() { return /* binding */ AsyncButton; } /* harmony export */ }); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/objectSpread2.js */ 82242); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/regeneratorRuntime.js */ 7557); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/asyncToGenerator.js */ 41498); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_2__); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/slicedToArray.js */ 79800); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_3__); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectWithoutProperties_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/objectWithoutProperties.js */ 39647); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectWithoutProperties_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectWithoutProperties_js__WEBPACK_IMPORTED_MODULE_4__); /* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! antd */ 3113); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react */ 59301); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ 37712); var _excluded = ["children"]; var AsyncButton = function AsyncButton(_ref) { var children = _ref.children, props = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectWithoutProperties_js__WEBPACK_IMPORTED_MODULE_4___default()(_ref, _excluded); var _useState = (0,react__WEBPACK_IMPORTED_MODULE_5__.useState)(false), _useState2 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_3___default()(_useState, 2), btnLoading = _useState2[0], setBtnLoading = _useState2[1]; return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(antd__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .ZP, _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()({}, props), {}, { loading: btnLoading, onClick: ( /*#__PURE__*/function () { var _ref2 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_2___default()( /*#__PURE__*/_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_1___default()().mark(function _callee(e) { return _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_1___default()().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.prev = 0; setBtnLoading(true); _context.next = 4; return props.onClick(e); case 4: setBtnLoading(false); _context.next = 11; break; case 7: _context.prev = 7; _context.t0 = _context["catch"](0); console.error(_context.t0); setBtnLoading(false); case 11: case "end": return _context.stop(); } }, _callee, null, [[0, 7]]); })); return function (_x) { return _ref2.apply(this, arguments); }; }()), children: children })); }; /***/ }), /***/ 16399: /*!**************************************************************!*\ !*** ./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/_@babel_runtime@7.23.6@@babel/runtime/helpers/regeneratorRuntime.js var regeneratorRuntime = __webpack_require__(7557); var regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(regeneratorRuntime); // EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/asyncToGenerator.js var asyncToGenerator = __webpack_require__(41498); var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator); // EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/slicedToArray.js var slicedToArray = __webpack_require__(79800); var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray); // EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js var _react_17_0_2_react = __webpack_require__(59301); ;// CONCATENATED MODULE: ./src/components/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__(79539); // EXTERNAL MODULE: ./src/utils/util.tsx var util = __webpack_require__(67747); // EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/jsx-runtime.js var jsx_runtime = __webpack_require__(37712); ;// CONCATENATED MODULE: ./src/components/ImageDimensions/index.tsx var ImageDimensions = function ImageDimensions(_ref) { var data = _ref.data, className = _ref.className, fullWidth = _ref.fullWidth, _ref$style = _ref.style, style = _ref$style === void 0 ? {} : _ref$style, onClose = _ref.onClose, onOk = _ref.onOk, showFullTools = _ref.showFullTools, noAssociationId = _ref.noAssociationId; var imgRef = (0,_react_17_0_2_react.useRef)(null); var markerArea = (0,_react_17_0_2_react.useRef)(null); var _useState = (0,_react_17_0_2_react.useState)(false), _useState2 = slicedToArray_default()(_useState, 2), loading = _useState2[0], setLoading = _useState2[1]; var _useState3 = (0,_react_17_0_2_react.useState)('正在加载中'), _useState4 = slicedToArray_default()(_useState3, 2), loadingText = _useState4[0], setLoadingText = _useState4[1]; (0,_react_17_0_2_react.useEffect)(function () { if (data !== null && data !== void 0 && data.visible) { document.body.setAttribute('data-custom', 'y-hidden'); } else { document.body.removeAttribute('data-custom'); } if (data !== null && data !== void 0 && data.src) { getImg(); } }, [data === null || data === void 0 ? void 0 : data.visible]); var getImg = /*#__PURE__*/function () { var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() { var res; return regeneratorRuntime_default()().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: setLoading(true); setLoadingText('正在加载中'); _context.next = 4; return (0,util/* toDataUrl */.ZJ)(data === null || data === void 0 ? void 0 : data.src); case 4: res = _context.sent; imgRef.current.src = ""; imgRef.current.src = res; imgRef.current.onload = function () { initMarkerjs(); }; setLoading(false); setLoadingText(''); case 10: case "end": return _context.stop(); } }, _callee); })); return function getImg() { return _ref2.apply(this, arguments); }; }(); var onSave = /*#__PURE__*/function () { var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2(event) { var res, result; return regeneratorRuntime_default()().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: setLoading(true); setLoadingText('正在保存中'); _context2.next = 4; return (0,fetch/* default */.ZP)('/api/attachments.json', { method: 'post', body: { file_type: 'base64', original_filename: data.title, file: event.dataUrl } }); case 4: res = _context2.sent; if (!(res !== null && res !== void 0 && res.id && !noAssociationId)) { _context2.next = 12; break; } _context2.next = 8; return (0,fetch/* default */.ZP)("/api/attachments/".concat(data.id, "/add_subitem.json"), { method: 'post', body: { subitem_id: res === null || res === void 0 ? void 0 : res.id, settings: JSON.stringify(event.state) } }); case 8: result = _context2.sent; if (result.status === 0) { onOk(); } _context2.next = 13; break; case 12: if (res !== null && res !== void 0 && res.id) { onOk(res); } case 13: setLoading(false); setLoadingText(''); case 15: case "end": return _context2.stop(); } }, _callee2); })); return function onSave(_x) { return _ref3.apply(this, arguments); }; }(); var dealDom = function dealDom() { // 删除标签 // 找到href为"https://markerjs.com/"的a标签 var targetLink = document.querySelector('a[href="https://markerjs.com/"]'); if (targetLink && targetLink.parentNode) { targetLink.parentNode.style.display = 'none'; } // 设置title var item = [{ name: '[data-action="select"]', title: '选择' }, { name: '[data-action="delete"]', title: '删除元素' }, { name: '[data-action="undo"]', title: '撤销' }, { name: '[data-type-name="FrameMarker"]', title: '矩形' }, { name: '[data-type-name="FreehandMarker"]', title: '画线' }, { name: '[data-type-name="ArrowMarker"]', title: '箭头' }, { name: '[data-type-name="TextMarker"]', title: '文本' }, { name: '[data-type-name="EllipseMarker"]', title: '椭圆' }, { name: '[data-type-name="HighlightMarker"]', title: '方块' }, { name: '[data-type-name="CalloutMarker"]', title: '注释' }, { name: '[data-action="render"]', title: '保存' }, { name: '[data-action="close"]', title: '退出' }]; item.forEach(function (e) { var targetElement = document.querySelector(e.name); if (targetElement) { targetElement.setAttribute('title', e.title); } }); }; var initMarkerjs = function initMarkerjs() { markerArea.current = new markerjs2_esm/* MarkerArea */.hP(imgRef.current); markerArea.current.addEventListener('render', onSave); markerArea.current.addEventListener('beforeclose', onClose); if (showFullTools) { markerArea.current.availableMarkerTypes = markerArea.current.ALL_MARKER_TYPES; markerArea.current.uiStyleSettings.redoButtonVisible = true; markerArea.current.uiStyleSettings.notesButtonVisible = true; markerArea.current.uiStyleSettings.zoomButtonVisible = true; markerArea.current.uiStyleSettings.zoomOutButtonVisible = true; markerArea.current.uiStyleSettings.clearButtonVisible = true; } window.markerArea = markerArea.current.uiStyleSettings; markerArea.current.show(); if (data !== null && data !== void 0 && data.snapshotData) { markerArea.current.restoreState(data.snapshotData); } setTimeout(function () { dealDom(); }, 300); }; return /*#__PURE__*/(0,jsx_runtime.jsx)(_react_17_0_2_react.Fragment, { children: (data === null || data === void 0 ? void 0 : data.visible) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: _classnames_2_5_1_classnames_default()(ImageDimensionsmodules.imageDimensions, className, fullWidth ? ImageDimensionsmodules.fullWidth : ""), style: style, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(spin/* default */.Z, { spinning: loading, tip: loadingText, style: { position: 'absolute' } }), /*#__PURE__*/(0,jsx_runtime.jsx)("img", { className: ImageDimensionsmodules.img, ref: imgRef // crossOrigin='anonymous' // src={data?.src} })] }) }); }; /* harmony default export */ var components_ImageDimensions = (ImageDimensions); /***/ }), /***/ 68444: /*!*************************************************************!*\ !*** ./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 _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/objectSpread2.js */ 82242); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/slicedToArray.js */ 79800); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ 59301); /* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! antd */ 57809); /* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! antd */ 78241); /* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! antd */ 3113); /* harmony import */ var codemirror__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! codemirror */ 89780); /* harmony import */ var codemirror__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(codemirror__WEBPACK_IMPORTED_MODULE_3__); /* harmony import */ var codemirror_lib_codemirror_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! codemirror/lib/codemirror.css */ 66940); /* harmony import */ var codemirror_theme_blackboard_css__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! codemirror/theme/blackboard.css */ 69462); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ 37712); var Option = antd__WEBPACK_IMPORTED_MODULE_7__["default"].Option; //https://github.com/codemirror/CodeMirror/issues/4838 var formItemLayout = { labelCol: { span: 4 }, wrapperCol: { span: 20 } }; var LanguageDesc = { asp: ['ASP', 'vbscript'], actionscript: ['ActionScript(3.0)/Flash/Flex', 'clike'], bash: ['Bash/Bat', 'shell'], css: ['CSS', 'css'], c: ['C', 'clike'], cpp: ['C++', 'clike'], csharp: ['C#', 'clike'], coffeescript: ['CoffeeScript', 'coffeescript'], d: ['D', 'd'], dart: ['Dart', 'dart'], delphi: ['Delphi/Pascal', 'pascal'], erlang: ['Erlang', 'erlang'], go: ['Golang', 'go'], groovy: ['Groovy', 'groovy'], html: ['HTML', 'text/html'], java: ['Java', 'clike'], json: ['JSON', 'text/json'], javascript: ['Javascript', 'javascript'], lua: ['Lua', 'lua'], less: ['LESS', 'css'], markdown: ['Markdown', 'gfm'], 'objective-c': ['Objective-C', 'clike'], php: ['PHP', 'php'], perl: ['Perl', 'perl'], python: ['Python', 'python'], r: ['R', 'r'], rst: ['reStructedText', 'rst'], ruby: ['Ruby', 'ruby'], sql: ['SQL', 'sql'], sass: ['SASS/SCSS', 'sass'], shell: ['Shell', 'shell'], scala: ['Scala', 'clike'], swift: ['Swift', 'clike'], vb: ['VB/VBScript', 'vb'], xml: ['XML', 'text/xml'], yaml: ['YAML', 'yaml'] }; /* harmony default export */ __webpack_exports__.Z = (function (_ref) { var callback = _ref.callback, onCancel = _ref.onCancel; var _useState = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)('python'), _useState2 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_1___default()(_useState, 2), mode = _useState2[0], setMode = _useState2[1]; function onSetMode(value) { setMode(LanguageDesc[value][1]); } function onSubmit(values) { callback(values); } return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(antd__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z, _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()({}, formItemLayout), {}, { className: "code-block-panel", initialValues: { language: 'python', content: '' }, onFinish: onSubmit, style: { width: 500 }, children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(antd__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z.Item, { label: "\u4EE3\u7801\u8BED\u8A00", name: "language", children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(antd__WEBPACK_IMPORTED_MODULE_7__["default"], { getPopupContainer: function getPopupContainer(trigger) { return trigger.parentNode; }, onChange: onSetMode, children: Object.keys(LanguageDesc).map(function (item) { return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(Option, { value: item, children: LanguageDesc[item][0] }, item); }) }) }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(antd__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z.Item, { label: "\u4EE3\u7801\u5185\u5BB9", name: "content", rules: [{ required: true, message: '请输入代码内容' }], children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(MyCodeMirror, { mode: mode }) }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)("div", { className: "flex-container flex-end", children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .ZP, { type: "primary", htmlType: "submit", style: { marginRight: 10 }, children: "\u786E\u5B9A" }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .ZP, { type: "ghost", onClick: onCancel, children: "\u53D6\u6D88" })] })] })); }); function MyCodeMirror(_ref2) { var value = _ref2.value, onChange = _ref2.onChange, mode = _ref2.mode, _ref2$options = _ref2.options, options = _ref2$options === void 0 ? {} : _ref2$options; var el = (0,react__WEBPACK_IMPORTED_MODULE_2__.useRef)(); var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)(), _useState4 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_1___default()(_useState3, 2), cm = _useState4[0], setCm = _useState4[1]; (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(function () { if (cm) { var onChangeHandler = function onChangeHandler(cm) { var content = cm.getValue(); onChange && onChange(content); }; cm.on('change', onChangeHandler); return function () { cm.off('change', onChangeHandler); }; } }, [cm, onChange]); (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(function () { if (cm) { cm.setOption('mode', mode); } }, [cm, mode]); (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(function () { if (cm) { if (value !== cm.getValue() || value === '') { setTimeout(function () { cm.setValue(value || ''); }, 300); } } }, [cm, value]); (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(function () { if (el.current && !cm) { var instance = codemirror__WEBPACK_IMPORTED_MODULE_3___default().fromTextArea(el.current, _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()({ mode: mode, lineNumbers: true, lineWrapping: true, autoCloseBrackets: true, tabSize: 4, autofocus: true, autoCloseTags: true, matchBrackets: true, styleActiveLine: true }, options)); setCm(instance); } }, [el.current, cm]); return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("div", { className: "my-codemirror-container", children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("textarea", { ref: el }) }); } /***/ }), /***/ 24856: /*!***************************************************************!*\ !*** ./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/_@babel_runtime@7.23.6@@babel/runtime/helpers/createForOfIteratorHelper.js var createForOfIteratorHelper = __webpack_require__(91232); var createForOfIteratorHelper_default = /*#__PURE__*/__webpack_require__.n(createForOfIteratorHelper); // EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/slicedToArray.js var slicedToArray = __webpack_require__(79800); var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray); // EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/defineProperty.js var defineProperty = __webpack_require__(85573); var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty); // EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js var _react_17_0_2_react = __webpack_require__(59301); // EXTERNAL MODULE: ./node_modules/_codemirror@5.58.2@codemirror/lib/codemirror.js var codemirror = __webpack_require__(89780); var codemirror_default = /*#__PURE__*/__webpack_require__.n(codemirror); // EXTERNAL MODULE: ./node_modules/_resize-observer-polyfill@1.5.1@resize-observer-polyfill/dist/ResizeObserver.es.js var ResizeObserver_es = __webpack_require__(76374); // EXTERNAL MODULE: ./node_modules/_codemirror@5.58.2@codemirror/lib/codemirror.css var lib_codemirror = __webpack_require__(66940); // 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__(20274); // EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/jsx-runtime.js var jsx_runtime = __webpack_require__(37712); ;// CONCATENATED MODULE: ./src/components/RenderHtml/stex.tsx // const latexjs = require('latex-l.js/dist/latex.js'); // import "latex-l.js/dist/css/base.css" /* harmony default export */ var RenderHtml_stex = (function (_ref) { var _ref$value = _ref.value, value = _ref$value === void 0 ? '' : _ref$value, className = _ref.className, showTextOnly = _ref.showTextOnly, showLines = _ref.showLines, _ref$style = _ref.style, style = _ref$style === void 0 ? {} : _ref$style; var html = (0,_react_17_0_2_react.useMemo)(function () { // try { // const latex = value || 'This is some text'; // let generator = new latexjs.default.HtmlGenerator({ hyphenate: true }) // let doc = latexjs.default.parse(latex, { generator: generator }).htmlDocument() // return doc.body.innerHTML // }catch(e){ // console.log("e:",e) // return "错误的latex语法,请检查" // } return ""; }, [value]); return /*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment, { children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", { dangerouslySetInnerHTML: { __html: html } }) }); }); // EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/objectSpread2.js var objectSpread2 = __webpack_require__(82242); var objectSpread2_default = /*#__PURE__*/__webpack_require__.n(objectSpread2); ;// CONCATENATED MODULE: ./src/components/markdown-editor/toolbar/index.less // extracted by mini-css-extract-plugin ;// CONCATENATED MODULE: ./src/components/markdown-editor/css/iconfont.css // extracted by mini-css-extract-plugin ;// CONCATENATED MODULE: ./src/components/markdown-editor/toolbar/index.tsx var DEFAULTICONS = [{ title: '粗体', icon: 'md-iconfont icon-bold', actionName: 'bold' }, { title: '斜体', icon: 'md-iconfont icon-italic', actionName: 'italic' }, '|', { title: '无序列表', icon: 'md-iconfont icon-unorder-list', actionName: 'list-ul' }, { title: '有序列表', icon: 'md-iconfont icon-order-list', actionName: 'list-ol' }, '|', { title: '行内代码', icon: 'md-iconfont icon-code', actionName: 'code' }, { title: '代码块(多语言风格)', icon: 'md-iconfont icon-file-code', actionName: 'code-block' }, { title: '链接', icon: 'md-iconfont icon-link', actionName: 'link' }, '|', { title: '行内公式', icon: 'md-iconfont icon-sum', actionName: 'inline-latex' }, { title: '数学图像', icon: 'iconfont icon-shuxuetuxiang2', actionName: 'maths-latex' }, { title: '多行公式', icon: 'iconfont icon-jisuan1', actionName: 'latex' }, '|', { title: '添加图片', icon: 'md-iconfont icon-picture', actionName: 'upload-image' }, { title: '插入画图', icon: 'iconfont icon-sheji', actionName: 'draw-image' }, { title: '插入流程图', icon: 'iconfont icon-liucheng', actionName: 'add-flowchart' }, { title: '表格', icon: 'md-iconfont icon-table', actionName: 'add-table' }, '|', { title: '换行', icon: 'md-iconfont icon-minus', actionName: 'line-break' }, { title: '清空', icon: 'md-iconfont icon-eraser', actionName: 'eraser' }]; function AButton(_ref) { var onActionCallback = _ref.onActionCallback, title = _ref.title, icon = _ref.icon, actionName = _ref.actionName, _ref$className = _ref.className, className = _ref$className === void 0 ? '' : _ref$className, children = _ref.children; function onAction() { onActionCallback(actionName); } return /*#__PURE__*/(0,jsx_runtime.jsxs)("a", { title: title, className: className, onClick: onAction, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("i", { className: "".concat(icon) }), children] }); } /* harmony default export */ var toolbar = (function (_ref2) { var watch = _ref2.watch, showNullButton = _ref2.showNullButton, showNullProgramButton = _ref2.showNullProgramButton, onActionCallback = _ref2.onActionCallback, fullScreen = _ref2.fullScreen, insertTemp = _ref2.insertTemp, hidetoolBar = _ref2.hidetoolBar, extraUse = _ref2.extraUse; var icons = [].concat(DEFAULTICONS, [{ title: "".concat(watch ? '关闭实时预览' : '开启实时预览'), icon: "".concat(watch ? 'md-iconfont icon-eye-slash' : 'md-iconfont icon-eye'), actionName: 'trigger-watch' }]); return /*#__PURE__*/(0,jsx_runtime.jsxs)("ul", { className: "markdown-toolbar-container", children: [!hidetoolBar && icons.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsx)("li", { children: item.actionName ? /*#__PURE__*/(0,jsx_runtime.jsx)(AButton, objectSpread2_default()(objectSpread2_default()({}, item), {}, { onActionCallback: onActionCallback })) : /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "v-line" }) }, index); }), showNullButton ? /*#__PURE__*/(0,jsx_runtime.jsx)("li", { children: /*#__PURE__*/(0,jsx_runtime.jsx)(AButton, { icon: "md-iconfont icon-edit insert-blank", className: "btn-null", title: "\u589E\u52A0\u586B\u7A7A", actionName: "add-null-ch", onActionCallback: onActionCallback, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "fill-tip", children: "\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879" }) }) }) : null, showNullProgramButton ? /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("li", { children: /*#__PURE__*/(0,jsx_runtime.jsx)(AButton, { icon: "md-iconfont icon-edit insert-blank", className: "btn-null", title: "\u589E\u52A0\u586B\u7A7A", actionName: "add-signal", onActionCallback: onActionCallback, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "fill-tip", children: "\u6DFB\u52A0\u5355\u884C\u586B\u7A7A\u9879" }) }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("li", { children: /*#__PURE__*/(0,jsx_runtime.jsx)(AButton, { icon: "md-iconfont icon-uniE900 insert-blank", className: "btn-null", title: "\u589E\u52A0\u586B\u7A7A", actionName: "add-multiple", onActionCallback: onActionCallback, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "fill-tip", children: "\u6DFB\u52A0\u591A\u884C\u586B\u7A7A\u9879" }) }) })] }) : null, insertTemp && /*#__PURE__*/(0,jsx_runtime.jsx)("li", { children: /*#__PURE__*/(0,jsx_runtime.jsx)(AButton, { icon: "md-iconfont icon-edit", className: "btn-null", title: "\u63D2\u5165\u6A21\u677F", actionName: "inster-template-".concat(insertTemp), onActionCallback: onActionCallback, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "fill-tip", children: "\u63D2\u5165\u6A21\u677F" }) }) }), extraUse && /*#__PURE__*/(0,jsx_runtime.jsx)("li", { children: extraUse }), /*#__PURE__*/(0,jsx_runtime.jsx)("li", { className: "btn-full-screen", children: /*#__PURE__*/(0,jsx_runtime.jsx)(AButton, { icon: "".concat(fullScreen ? 'md-iconfont icon-shrink' : 'md-iconfont icon-enlarge'), title: fullScreen ? '关闭全屏' : '开启全屏', actionName: "trigger-full-screen", onActionCallback: onActionCallback }) })] }); }); // EXTERNAL MODULE: ./src/components/modal.tsx var modal = __webpack_require__(226); // 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__(62680); // EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/button/index.js var es_button = __webpack_require__(3113); ;// CONCATENATED MODULE: ./src/components/markdown-editor/link/index.tsx var formItemLayout = { labelCol: { span: 4 }, wrapperCol: { span: 20 } }; /* harmony default export */ var markdown_editor_link = (function (_ref) { var callback = _ref.callback, onCancel = _ref.onCancel; function onSubmit(values) { callback(values); } return /*#__PURE__*/(0,jsx_runtime.jsxs)(es_form/* default */.Z, objectSpread2_default()(objectSpread2_default()({}, formItemLayout), {}, { initialValues: { link: 'http://', title: '' }, className: "link-panel", onFinish: onSubmit, style: { width: 500 }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, { label: "\u94FE\u63A5\u5730\u5740", name: "link", rules: [{ required: true, message: '请输入链接地址' }], children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, {}) }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, { label: "\u94FE\u63A5\u6807\u9898", name: "title", rules: [{ required: true, message: '请输入链接标题' }], children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, {}) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: "flex-container flex-end", children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, { type: "primary", htmlType: "submit", style: { marginRight: 10 }, children: "\u786E\u5B9A" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, { type: "ghost", onClick: onCancel, children: "\u53D6\u6D88" })] })] })); }); // EXTERNAL MODULE: ./src/components/markdown-editor/code-block/index.tsx var code_block = __webpack_require__(68444); // 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__(42678); ;// CONCATENATED MODULE: ./src/components/markdown-editor/upload-image/index.tsx var useForm = es_form/* default */.Z.useForm; var style = { width: 280, marginRight: 10 }; var upload_image_formItemLayout = { labelCol: { span: 5 }, wrapperCol: { span: 19 } }; /* harmony default export */ var upload_image = (function (_ref) { var callback = _ref.callback, onCancel = _ref.onCancel; var _useForm = useForm(), _useForm2 = slicedToArray_default()(_useForm, 1), form = _useForm2[0]; var 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/".concat(data.id), type: file.type }); } function onFileChange(e) { var file = e.target.files[0]; currentFile.current = file; uploadImage(file, onAddUrl); } return /*#__PURE__*/(0,jsx_runtime.jsxs)(es_form/* default */.Z, objectSpread2_default()(objectSpread2_default()({ form: form }, upload_image_formItemLayout), {}, { className: "upload-image-panel", onFinish: onSubmit, style: { width: 470, overflow: "hidden" }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, { label: "\u56FE\u7247\u5730\u5740", required: true, children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: "flex-container", children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, { noStyle: true, name: "src", rules: [{ required: true, message: '请输入图片地址' }], children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, { style: style }) }), /*#__PURE__*/(0,jsx_runtime.jsx)(UploadButton, { onFileChange: onFileChange })] }) }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, { label: "\u56FE\u7247\u63CF\u8FF0", name: "alt" // rules={[{ required: true, message: '请输入图片描述' }]} , children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, { style: { width: 264 } }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)(es_form/* default */.Z.Item, { style: { textAlign: "right" }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, { type: "primary", htmlType: "submit", style: { marginRight: 10 }, children: "\u786E\u5B9A" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, { type: "default", onClick: onCancel, children: "\u53D6\u6D88" })] })] })); }); function UploadButton(_ref2) { var onFileChange = _ref2.onFileChange; return /*#__PURE__*/(0,jsx_runtime.jsxs)("label", { className: "upload-button", style: { cursor: "pointer" }, children: ["\u672C\u5730\u4E0A\u4F20", /*#__PURE__*/(0,jsx_runtime.jsx)("input", { type: "file", onChange: onFileChange })] }); } function uploadImage(file, callback) { if (!file) { throw new String('没有文件'); return; } var formData = new FormData(); formData.append('editormd-image-file', file); formData.append('file_param_name', 'editormd-image-file'); formData.append('byxhr', 'true'); var xhr = new window.XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener('load', function (response) { callback(JSON.parse(response.target.responseText), file); }, false); xhr.addEventListener('error', function (error) { console.error(error); }, false); xhr.open('POST', "".concat(util/* apiPref */.KI, "/api/attachments.json")); xhr.send(formData); } // EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/row/index.js var row = __webpack_require__(95237); // EXTERNAL MODULE: ./src/components/ImageDimensions/index.tsx + 1 modules var ImageDimensions = __webpack_require__(16399); ;// CONCATENATED MODULE: ./src/components/markdown-editor/draw-image/index.tsx /* harmony default export */ var draw_image = (function (_ref) { var callback = _ref.callback, onCancel = _ref.onCancel; var canvas = document.createElement('canvas'); var context = canvas.getContext('2d'); canvas.width = 1000; canvas.height = 800; context.fillStyle = '#ffffff'; context.fillRect(0, 0, canvas.width, canvas.height); var base64Image = canvas.toDataURL('image/png'); return /*#__PURE__*/(0,jsx_runtime.jsx)(row/* default */.Z, { style: { height: "100vh" }, children: /*#__PURE__*/(0,jsx_runtime.jsx)(ImageDimensions/* default */.Z, { fullWidth: true, noAssociationId: true, showFullTools: true, data: { src: base64Image, visible: true, title: String(Date.now()) }, onOk: function onOk(data) { callback({ src: data.url }); }, onClose: onCancel }) }); }); // EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/regeneratorRuntime.js var regeneratorRuntime = __webpack_require__(7557); var regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(regeneratorRuntime); // EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/asyncToGenerator.js var asyncToGenerator = __webpack_require__(41498); var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator); // EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/toConsumableArray.js var toConsumableArray = __webpack_require__(37205); var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray); // EXTERNAL MODULE: ./node_modules/_gojs3@2.3.10@gojs3/release/go-module.js var go_module = __webpack_require__(12378); ;// CONCATENATED MODULE: ./public/js/go/DrawCommandHandler.js /* * Copyright (C) 1998-2023 by Northwoods Software Corporation. All Rights Reserved. */ /* * This is an extension and not part of the main GoJS library. * Note that the API for this class may change with any version, even point releases. * If you intend to use an extension in production, you should copy the code to your own source directory. * Extensions can be found in the GoJS kit under the extensions or extensionsJSM folders. * See the Extensions intro page (https://gojs.net/latest/intro/extensions.html) for more information. */ /** * @constructor * @extends CommandHandler * @class * This CommandHandler class allows the user to position selected Parts in a diagram * relative to the first part selected, in addition to overriding the doKeyDown method * of the CommandHandler for handling the arrow keys in additional manners. ** Typical usage: *
* new go.Diagram("myDiagramDiv",
* {
* commandHandler: $(DrawCommandHandler),
* . . .
* }
* )
*
* or:
* * myDiagram.commandHandler = new DrawCommandHandler(); **/ function DrawCommandHandler() { go.CommandHandler.call(this); this._arrowKeyBehavior = "move"; this._pasteOffset = new go.Point(10, 10); this._lastPasteOffset = new go.Point(0, 0); } go.Diagram.inherit(DrawCommandHandler, go.CommandHandler); /** * This controls whether or not the user can invoke the {@link #alignLeft}, {@link #alignRight}, * {@link #alignTop}, {@link #alignBottom}, {@link #alignCenterX}, {@link #alignCenterY} commands. * @this {DrawCommandHandler} * @return {boolean} * This returns true: * if the diagram is not {@link Diagram#isReadOnly}, * if the model is not {@link Model#isReadOnly}, and * if there are at least two selected {@link Part}s. */ DrawCommandHandler.prototype.canAlignSelection = function () { var diagram = this.diagram; if (diagram === null || diagram.isReadOnly || diagram.isModelReadOnly) return false; if (diagram.selection.count < 2) return false; return true; }; /** * Aligns selected parts along the left-most edge of the left-most part. * @this {DrawCommandHandler} */ DrawCommandHandler.prototype.alignLeft = function () { var diagram = this.diagram; diagram.startTransaction("aligning left"); var minPosition = Infinity; diagram.selection.each(function (current) { if (current instanceof go.Link) return; // skips over go.Link minPosition = Math.min(current.position.x, minPosition); }); diagram.selection.each(function (current) { if (current instanceof go.Link) return; // skips over go.Link current.move(new go.Point(minPosition, current.position.y)); }); diagram.commitTransaction("aligning left"); }; /** * Aligns selected parts at the right-most edge of the right-most part. * @this {DrawCommandHandler} */ DrawCommandHandler.prototype.alignRight = function () { var diagram = this.diagram; diagram.startTransaction("aligning right"); var maxPosition = -Infinity; diagram.selection.each(function (current) { if (current instanceof go.Link) return; // skips over go.Link var rightSideLoc = current.actualBounds.x + current.actualBounds.width; maxPosition = Math.max(rightSideLoc, maxPosition); }); diagram.selection.each(function (current) { if (current instanceof go.Link) return; // skips over go.Link current.move(new go.Point(maxPosition - current.actualBounds.width, current.position.y)); }); diagram.commitTransaction("aligning right"); }; /** * Aligns selected parts at the top-most edge of the top-most part. * @this {DrawCommandHandler} */ DrawCommandHandler.prototype.alignTop = function () { var diagram = this.diagram; diagram.startTransaction("alignTop"); var minPosition = Infinity; diagram.selection.each(function (current) { if (current instanceof go.Link) return; // skips over go.Link minPosition = Math.min(current.position.y, minPosition); }); diagram.selection.each(function (current) { if (current instanceof go.Link) return; // skips over go.Link current.move(new go.Point(current.position.x, minPosition)); }); diagram.commitTransaction("alignTop"); }; /** * Aligns selected parts at the bottom-most edge of the bottom-most part. * @this {DrawCommandHandler} */ DrawCommandHandler.prototype.alignBottom = function () { var diagram = this.diagram; diagram.startTransaction("aligning bottom"); var maxPosition = -Infinity; diagram.selection.each(function (current) { if (current instanceof go.Link) return; // skips over go.Link var bottomSideLoc = current.actualBounds.y + current.actualBounds.height; maxPosition = Math.max(bottomSideLoc, maxPosition); }); diagram.selection.each(function (current) { if (current instanceof go.Link) return; // skips over go.Link current.move(new go.Point(current.actualBounds.x, maxPosition - current.actualBounds.height)); }); diagram.commitTransaction("aligning bottom"); }; /** * Aligns selected parts at the x-value of the center point of the first selected part. * @this {DrawCommandHandler} */ DrawCommandHandler.prototype.alignCenterX = function () { var diagram = this.diagram; var firstSelection = diagram.selection.first(); if (!firstSelection) return; diagram.startTransaction("aligning Center X"); var centerX = firstSelection.actualBounds.x + firstSelection.actualBounds.width / 2; diagram.selection.each(function (current) { if (current instanceof go.Link) return; // skips over go.Link current.move(new go.Point(centerX - current.actualBounds.width / 2, current.actualBounds.y)); }); diagram.commitTransaction("aligning Center X"); }; /** * Aligns selected parts at the y-value of the center point of the first selected part. * @this {DrawCommandHandler} */ DrawCommandHandler.prototype.alignCenterY = function () { var diagram = this.diagram; var firstSelection = diagram.selection.first(); if (!firstSelection) return; diagram.startTransaction("aligning Center Y"); var centerY = firstSelection.actualBounds.y + firstSelection.actualBounds.height / 2; diagram.selection.each(function (current) { if (current instanceof go.Link) return; // skips over go.Link current.move(new go.Point(current.actualBounds.x, centerY - current.actualBounds.height / 2)); }); diagram.commitTransaction("aligning Center Y"); }; /** * Aligns selected parts top-to-bottom in order of the order selected. * Distance between parts can be specified. Default distance is 0. * @this {DrawCommandHandler} * @param {number} distance */ DrawCommandHandler.prototype.alignColumn = function (distance) { var diagram = this.diagram; diagram.startTransaction("align Column"); if (distance === undefined) distance = 0; // for aligning edge to edge distance = parseFloat(distance); var selectedParts = new Array(); diagram.selection.each(function (current) { if (current instanceof go.Link) return; // skips over go.Link selectedParts.push(current); }); for (var i = 0; i < selectedParts.length - 1; i++) { var current = selectedParts[i]; // adds distance specified between parts var curBottomSideLoc = current.actualBounds.y + current.actualBounds.height + distance; var next = selectedParts[i + 1]; next.move(new go.Point(current.actualBounds.x, curBottomSideLoc)); } diagram.commitTransaction("align Column"); }; /** * Aligns selected parts left-to-right in order of the order selected. * Distance between parts can be specified. Default distance is 0. * @this {DrawCommandHandler} * @param {number} distance */ DrawCommandHandler.prototype.alignRow = function (distance) { if (distance === undefined) distance = 0; // for aligning edge to edge distance = parseFloat(distance); var diagram = this.diagram; diagram.startTransaction("align Row"); var selectedParts = new Array(); diagram.selection.each(function (current) { if (current instanceof go.Link) return; // skips over go.Link selectedParts.push(current); }); for (var i = 0; i < selectedParts.length - 1; i++) { var current = selectedParts[i]; // adds distance specified between parts var curRightSideLoc = current.actualBounds.x + current.actualBounds.width + distance; var next = selectedParts[i + 1]; next.move(new go.Point(curRightSideLoc, current.actualBounds.y)); } diagram.commitTransaction("align Row"); }; /** * This controls whether or not the user can invoke the {@link #rotate} command. * @this {DrawCommandHandler} * @param {number=} angle the positive (clockwise) or negative (counter-clockwise) change in the rotation angle of each Part, in degrees. * @return {boolean} * This returns true: * if the diagram is not {@link Diagram#isReadOnly}, * if the model is not {@link Model#isReadOnly}, and * if there is at least one selected {@link Part}. */ DrawCommandHandler.prototype.canRotate = function (number) { var diagram = this.diagram; if (diagram === null || diagram.isReadOnly || diagram.isModelReadOnly) return false; if (diagram.selection.count < 1) return false; return true; }; /** * Change the angle of the parts connected with the given part. This is in the command handler * so it can be easily accessed for the purpose of creating commands that change the rotation of a part. * @this {DrawCommandHandler} * @param {number=} angle the positive (clockwise) or negative (counter-clockwise) change in the rotation angle of each Part, in degrees. */ DrawCommandHandler.prototype.rotate = function (angle) { if (angle === undefined) angle = 90; var diagram = this.diagram; diagram.startTransaction("rotate " + angle.toString()); var diagram = this.diagram; diagram.selection.each(function (current) { if (current instanceof go.Link || current instanceof go.Group) return; // skips over Links and Groups current.angle += angle; }); diagram.commitTransaction("rotate " + angle.toString()); }; /** * Change the z-ordering of selected parts to pull them forward, in front of all other parts * in their respective layers. * All unselected parts in each layer with a selected Part with a non-numeric {@link Part#zOrder} will get a zOrder of zero. * @this {DrawCommandHandler} */ DrawCommandHandler.prototype.pullToFront = function () { var diagram = this.diagram; diagram.startTransaction("pullToFront"); // find the affected Layers var layers = new go.Map(); diagram.selection.each(function (part) { layers.set(part.layer, 0); }); // find the maximum zOrder in each Layer layers.iteratorKeys.each(function (layer) { var max = 0; layer.parts.each(function (part) { if (part.isSelected) return; var z = part.zOrder; if (isNaN(z)) { part.zOrder = 0; } else { max = Math.max(max, z); } }); layers.set(layer, max); }); // assign each selected Part.zOrder to the computed value for each Layer diagram.selection.each(function (part) { DrawCommandHandler._assignZOrder(part, layers.get(part.layer) + 1); }); diagram.commitTransaction("pullToFront"); }; /** * Change the z-ordering of selected parts to push them backward, behind of all other parts * in their respective layers. * All unselected parts in each layer with a selected Part with a non-numeric {@link Part#zOrder} will get a zOrder of zero. * @this {DrawCommandHandler} */ DrawCommandHandler.prototype.pushToBack = function () { var diagram = this.diagram; diagram.startTransaction("pushToBack"); // find the affected Layers var layers = new go.Map(); diagram.selection.each(function (part) { layers.set(part.layer, 0); }); // find the minimum zOrder in each Layer layers.iteratorKeys.each(function (layer) { var min = 0; layer.parts.each(function (part) { if (part.isSelected) return; var z = part.zOrder; if (isNaN(z)) { part.zOrder = 0; } else { min = Math.min(min, z); } }); layers.set(layer, min); }); // assign each selected Part.zOrder to the computed value for each Layer diagram.selection.each(function (part) { DrawCommandHandler._assignZOrder(part, // make sure a group's nested nodes are also behind everything else layers.get(part.layer) - 1 - DrawCommandHandler._findGroupDepth(part)); }); diagram.commitTransaction("pushToBack"); }; DrawCommandHandler._assignZOrder = function (part, z, root) { if (root === undefined) root = part; if (part.layer === root.layer) part.zOrder = z; if (part instanceof go.Group) { part.memberParts.each(function (m) { DrawCommandHandler._assignZOrder(m, z + 1, root); }); } }; DrawCommandHandler._findGroupDepth = function (part) { if (part instanceof go.Group) { var d = 0; part.memberParts.each(function (m) { d = Math.max(d, DrawCommandHandler._findGroupDepth(m)); }); return d + 1; } else { return 0; } }; /** * This implements custom behaviors for arrow key keyboard events. * Set {@link #arrowKeyBehavior} to "select", "move" (the default), "scroll" (the standard behavior), or "none" * to affect the behavior when the user types an arrow key. * @this {DrawCommandHandler}*/ DrawCommandHandler.prototype.doKeyDown = function () { var diagram = this.diagram; if (diagram === null) return; var e = diagram.lastInput; // determines the function of the arrow keys if (e.key === "Up" || e.key === "Down" || e.key === "Left" || e.key === "Right") { var behavior = this.arrowKeyBehavior; if (behavior === "none") { // no-op return; } else if (behavior === "select") { this._arrowKeySelect(); return; } else if (behavior === "move") { this._arrowKeyMove(); return; } else if (behavior === "tree") { this._arrowKeyTree(); return; } // otherwise drop through to get the default scrolling behavior } // otherwise still does all standard commands go.CommandHandler.prototype.doKeyDown.call(this); }; /** * Collects in an Array all of the non-Link Parts currently in the Diagram. * @this {DrawCommandHandler} * @return {Array} */ DrawCommandHandler.prototype._getAllParts = function () { var allParts = new Array(); this.diagram.nodes.each(function (node) { allParts.push(node); }); this.diagram.parts.each(function (part) { allParts.push(part); }); // note that this ignores Links return allParts; }; /** * To be called when arrow keys should move the Diagram.selection. * @this {DrawCommandHandler} */ DrawCommandHandler.prototype._arrowKeyMove = function () { var diagram = this.diagram; var e = diagram.lastInput; // moves all selected parts in the specified direction var vdistance = 0; var hdistance = 0; // if control is being held down, move pixel by pixel. Else, moves by grid cell size if (e.control || e.meta) { vdistance = 1; hdistance = 1; } else if (diagram.grid !== null) { var cellsize = diagram.grid.gridCellSize; hdistance = cellsize.width; vdistance = cellsize.height; } diagram.startTransaction("arrowKeyMove"); diagram.selection.each(function (part) { if (e.key === "Up") { part.move(new go.Point(part.actualBounds.x, part.actualBounds.y - vdistance)); } else if (e.key === "Down") { part.move(new go.Point(part.actualBounds.x, part.actualBounds.y + vdistance)); } else if (e.key === "Left") { part.move(new go.Point(part.actualBounds.x - hdistance, part.actualBounds.y)); } else if (e.key === "Right") { part.move(new go.Point(part.actualBounds.x + hdistance, part.actualBounds.y)); } }); diagram.commitTransaction("arrowKeyMove"); }; /** * To be called when arrow keys should change selection. * @this {DrawCommandHandler} */ DrawCommandHandler.prototype._arrowKeySelect = function () { var diagram = this.diagram; var e = diagram.lastInput; // with a part selected, arrow keys change the selection // arrow keys + shift selects the additional part in the specified direction // arrow keys + control toggles the selection of the additional part var nextPart = null; if (e.key === "Up") { nextPart = this._findNearestPartTowards(270); } else if (e.key === "Down") { nextPart = this._findNearestPartTowards(90); } else if (e.key === "Left") { nextPart = this._findNearestPartTowards(180); } else if (e.key === "Right") { nextPart = this._findNearestPartTowards(0); } if (nextPart !== null) { if (e.shift) { nextPart.isSelected = true; } else if (e.control || e.meta) { nextPart.isSelected = !nextPart.isSelected; } else { diagram.select(nextPart); } } }; /** * Finds the nearest selectable Part in the specified direction, based on their center points. * if it doesn't find anything, it just returns the current Part. * @this {DrawCommandHandler} * @param {number} dir the direction, in degrees * @return {Part} the closest Part found in the given direction */ DrawCommandHandler.prototype._findNearestPartTowards = function (dir) { var originalPart = this.diagram.selection.first(); if (originalPart === null) return null; var originalPoint = originalPart.actualBounds.center; var allParts = this._getAllParts(); var closestDistance = Infinity; var closest = originalPart; // if no parts meet the criteria, the same part remains selected for (var i = 0; i < allParts.length; i++) { var nextPart = allParts[i]; if (nextPart === originalPart) continue; // skips over currently selected part if (!nextPart.canSelect()) continue; var nextPoint = nextPart.actualBounds.center; var angle = originalPoint.directionPoint(nextPoint); var anglediff = this._angleCloseness(angle, dir); if (anglediff <= 45) { // if this part's center is within the desired direction's sector, var distance = originalPoint.distanceSquaredPoint(nextPoint); distance *= 1 + Math.sin(anglediff * Math.PI / 180); // the more different from the intended angle, the further it is if (distance < closestDistance) { // and if it's closer than any other part, closestDistance = distance; // remember it as a better choice closest = nextPart; } } } return closest; }; /** * @this {DrawCommandHandler} * @param {number} a * @param {number} dir * @return {number} */ DrawCommandHandler.prototype._angleCloseness = function (a, dir) { return Math.min(Math.abs(dir - a), Math.min(Math.abs(dir + 360 - a), Math.abs(dir - 360 - a))); }; /** * To be called when arrow keys should change the selected node in a tree and expand or collapse subtrees. * @this {DrawCommandHandler} */ DrawCommandHandler.prototype._arrowKeyTree = function () { var diagram = this.diagram; var selected = diagram.selection.first(); if (!(selected instanceof go.Node)) return; var e = diagram.lastInput; if (e.key === "Right") { if (selected.isTreeLeaf) { // no-op } else if (!selected.isTreeExpanded) { if (diagram.commandHandler.canExpandTree(selected)) { diagram.commandHandler.expandTree(selected); // expands the tree } } else { // already expanded -- select the first child node var first = this._sortTreeChildrenByY(selected).first(); if (first !== null) diagram.select(first); } } else if (e.key === "Left") { if (!selected.isTreeLeaf && selected.isTreeExpanded) { if (diagram.commandHandler.canCollapseTree(selected)) { diagram.commandHandler.collapseTree(selected); // collapses the tree } } else { // either a leaf or is already collapsed -- select the parent node var parent = selected.findTreeParentNode(); if (parent !== null) diagram.select(parent); } } else if (e.key === "Up") { var parent = selected.findTreeParentNode(); if (parent !== null) { var list = this._sortTreeChildrenByY(parent); var idx = list.indexOf(selected); if (idx > 0) { // if there is a previous sibling var prev = list.elt(idx - 1); // keep looking at the last child until it's a leaf or collapsed while (prev !== null && prev.isTreeExpanded && !prev.isTreeLeaf) { var children = this._sortTreeChildrenByY(prev); prev = children.last(); } if (prev !== null) diagram.select(prev); } else { // no previous sibling -- select parent diagram.select(parent); } } } else if (e.key === "Down") { // if at an expanded parent, select the first child if (selected.isTreeExpanded && !selected.isTreeLeaf) { var first = this._sortTreeChildrenByY(selected).first(); if (first !== null) diagram.select(first); } else { while (selected !== null) { var parent = selected.findTreeParentNode(); if (parent === null) break; var list = this._sortTreeChildrenByY(parent); var idx = list.indexOf(selected); if (idx < list.length - 1) { // select next lower node diagram.select(list.elt(idx + 1)); break; } else { // already at bottom of list of children selected = parent; } } } } // make sure the selection is now in the viewport, but not necessarily centered var sel = diagram.selection.first(); if (sel !== null) diagram.scrollToRect(sel.actualBounds); }; DrawCommandHandler.prototype._sortTreeChildrenByY = function (node) { var list = new go.List().addAll(node.findTreeChildrenNodes()); list.sort(function (a, b) { var aloc = a.location; var bloc = b.location; if (aloc.y < bloc.y) return -1; if (aloc.y > bloc.y) return 1; if (aloc.x < bloc.x) return -1; if (aloc.x > bloc.x) return 1; return 0; }); return list; }; /** * Reset the last offset for pasting. * @this {DrawCommandHandler} * @param {Iterable.