diff --git a/src/mxgraph/handler/mxCellMarker.js b/src/mxgraph/handler/mxCellMarker.js index 817a7ad62..84c20c967 100644 --- a/src/mxgraph/handler/mxCellMarker.js +++ b/src/mxgraph/handler/mxCellMarker.js @@ -3,6 +3,10 @@ * Copyright (c) 2006-2015, Gaudenz Alder * Updated to ES9 syntax by David Morrissey 2021 */ +import mxEventSource from "../util/mxEventSource"; +import mxConstants from "../util/mxConstants"; +import mxCellHighlight from "./mxCellHighlight"; +import mxEventObject from "../util/mxEventObject"; class mxCellMarker extends mxEventSource { /** @@ -261,7 +265,7 @@ class mxCellMarker extends mxEventSource { this.validState = null; } - if (state != this.markedState || color != this.currentColor) { + if (state !== this.markedState || color !== this.currentColor) { this.currentColor = color; if (state != null && this.currentColor != null) { diff --git a/src/mxgraph/handler/mxEdgeHandler.js b/src/mxgraph/handler/mxEdgeHandler.js index 99f2c9ff9..39dbdc5a8 100644 --- a/src/mxgraph/handler/mxEdgeHandler.js +++ b/src/mxgraph/handler/mxEdgeHandler.js @@ -6,7 +6,7 @@ import mxCellMarker from "./mxCellMarker"; import mxPoint from "../util/mxPoint"; import mxConstants from "../util/mxConstants"; -import mxUtils from "../examples/map-background/leaflet"; +import mxUtils from "../util/mxUtils"; import mxImageShape from "../shape/mxImageShape"; import mxRectangleShape from "../shape/mxRectangleShape"; import mxConnectionConstraint from "../view/mxConnectionConstraint"; diff --git a/src/mxgraph/handler/mxElbowEdgeHandler.js b/src/mxgraph/handler/mxElbowEdgeHandler.js index 15ec5e592..7393af851 100644 --- a/src/mxgraph/handler/mxElbowEdgeHandler.js +++ b/src/mxgraph/handler/mxElbowEdgeHandler.js @@ -3,6 +3,7 @@ * Copyright (c) 2006-2015, Gaudenz Alder * Updated to ES9 syntax by David Morrissey 2021 */ +import mxEdgeHandler from "./mxEdgeHandler"; class mxElbowEdgeHandler extends mxEdgeHandler { /** diff --git a/src/mxgraph/handler/mxSelectionCellsHandler.js b/src/mxgraph/handler/mxSelectionCellsHandler.js index 7dfee704a..bd8f6f0cd 100644 --- a/src/mxgraph/handler/mxSelectionCellsHandler.js +++ b/src/mxgraph/handler/mxSelectionCellsHandler.js @@ -3,6 +3,9 @@ * Copyright (c) 2006-2015, Gaudenz Alder * Updated to ES9 syntax by David Morrissey 2021 */ +import mxEventSource from "../util/mxEventSource"; +import mxDictionary from "../util/mxDictionary"; +import mxEventObject from "../util/mxEventObject"; class mxSelectionCellsHandler extends mxEventSource { /** diff --git a/src/mxgraph/model/mxGraphModel.js b/src/mxgraph/model/mxGraphModel.js index 11a0bf616..c7664099c 100644 --- a/src/mxgraph/model/mxGraphModel.js +++ b/src/mxgraph/model/mxGraphModel.js @@ -4,6 +4,11 @@ * Updated to ES9 syntax by David Morrissey 2021 */ import mxEventSource from "../util/mxEventSource"; +import mxUndoableEdit from "../util/mxUndoableEdit"; +import mxCellPath from "./mxCellPath"; +import mxDictionary from "../util/mxDictionary"; +import mxObjectIdentity from "../util/mxObjectIdentity"; +import mxCell from "./mxCell"; class mxGraphModel extends mxEventSource { /** diff --git a/src/mxgraph/mxClient.js b/src/mxgraph/mxClient.js index 0484b28a0..3440dcf4a 100644 --- a/src/mxgraph/mxClient.js +++ b/src/mxgraph/mxClient.js @@ -2,6 +2,8 @@ * Copyright (c) 2006-2017, JGraph Ltd * Copyright (c) 2006-2017, Gaudenz Alder */ +import mxResources from "./util/mxResources"; + let mxClient = { /** * Class: mxClient @@ -23,19 +25,247 @@ let mxClient = { */ VERSION: '4.2.2', + /** + * Variable: mxResourceExtension + * + * Optional global config variable to specify the extension of resource files. + * Default is true. NOTE: This is a global variable, not a variable of mxClient. + * + * (code) + * + * + * (end) + */ + mxResourceExtension: '.txt', + setResourceExtension: (value) => { + mxClient.mxResourceExtension = value; + mxResources.extension = value; + }, + + /** + * Variable: mxLoadResources + * + * Optional global config variable to toggle loading of the two resource files + * in and . Default is true. NOTE: This is a global variable, + * not a variable of mxClient. If this is false, you can use + * with its callback to load the default bundles asynchronously. + * + * (code) + * + * + * (end) + */ + mxLoadResources: true, + setLoadResources: (value) => {}, + + /** + * Variable: mxForceIncludes + * + * Optional global config variable to force loading the JavaScript files in + * development mode. Default is undefined. NOTE: This is a global variable, + * not a variable of mxClient. + * + * (code) + * + * + * (end) + */ + mxForceIncludes: false, + setForceIncludes: (value) => { + mxClient.mxForceIncludes = value; + }, + + /** + * Variable: mxLoadStylesheets + * + * Optional global config variable to toggle loading of the CSS files when + * the library is initialized. Default is true. NOTE: This is a global variable, + * not a variable of mxClient. + * + * (code) + * + * + * (end) + */ + mxLoadStylesheets: true, + setLoadStylesheets: (value) => { + mxClient.mxLoadStylesheets = value; + }, + + /** + * Variable: basePath + * + * Basepath for all URLs in the core without trailing slash. Default is '.'. + * Set mxBasePath prior to loading the mxClient library as follows to override + * this setting: + * + * (code) + * + * + * (end) + * + * When using a relative path, the path is relative to the URL of the page that + * contains the assignment. Trailing slashes are automatically removed. + */ + basePath: '.', + setBasePath: (value) => { + if (typeof(value) != 'undefined' && value.length > 0) { + // Adds a trailing slash if required + if (value.substring(value.length - 1) === '/') { + value = value.substring(0, value.length - 1); + } + mxClient.basePath = value; + } else { + mxClient.basePath = '.'; + } + }, + + /** + * Variable: imageBasePath + * + * Basepath for all images URLs in the core without trailing slash. Default is + * + '/images'. Set mxImageBasePath prior to loading the + * mxClient library as follows to override this setting: + * + * (code) + * + * + * (end) + * + * When using a relative path, the path is relative to the URL of the page that + * contains the assignment. Trailing slashes are automatically removed. + */ + imageBasePath: '.', + setImageBasePath: (value) => { + if (typeof(value) != 'undefined' && value.length > 0) { + // Adds a trailing slash if required + if (value.substring(value.length - 1) === '/') { + value = value.substring(0, value.length - 1); + } + mxClient.imageBasePath = value; + } else { + mxClient.imageBasePath = mxClient.basePath + '/images'; + } + }, + + /** + * Variable: language + * + * Defines the language of the client, eg. en for english, de for german etc. + * The special value 'none' will disable all built-in internationalization and + * resource loading. See for handling identifiers + * with and without a dash. + * + * Set mxLanguage prior to loading the mxClient library as follows to override + * this setting: + * + * (code) + * + * + * (end) + * + * If internationalization is disabled, then the following variables should be + * overridden to reflect the current language of the system. These variables are + * cleared when i18n is disabled. + * , , + * , , + * , , , + * , , + * , , + * , , + * , , + * and + * . + */ + language: typeof window !== "undefined" ? navigator.language : 'en', + setLanguage: (value) => { + if (typeof(value) != 'undefined' && value != null) { + mxClient.language = value; + } + else { + mxClient.language = navigator.language; + } + }, + + /** + * Variable: defaultLanguage + * + * Defines the default language which is used in the common resource files. Any + * resources for this language will only load the common resource file, but not + * the language-specific resource file. Default is 'en'. + * + * Set mxDefaultLanguage prior to loading the mxClient library as follows to override + * this setting: + * + * (code) + * + * + * (end) + */ + defaultLanguage: 'en', + setDefaultLanguage: (value) => { + if (typeof(value) != 'undefined' && value != null) { + mxClient.defaultLanguage = value; + } else { + mxClient.defaultLanguage = 'en'; + } + }, + + /** + * Variable: languages + * + * Defines the optional array of all supported language extensions. The default + * language does not have to be part of this list. See + * . + * + * (code) + * + * + * (end) + * + * This is used to avoid unnecessary requests to language files, ie. if a 404 + * will be returned. + */ + + setLanguages: (value) => { + if (typeof(value) != 'undefined' && value != null) { + mxClient.languages = value; + } + }, + /** * Variable: IS_EDGE * * True if the current browser is Microsoft Edge. */ - IS_EDGE: navigator.userAgent != null && !!navigator.userAgent.match(/Edge\//), + IS_EDGE: typeof window !== 'undefined' && + navigator.userAgent != null && !!navigator.userAgent.match(/Edge\//), /** * Variable: IS_NS * * True if the current browser is Netscape (including Firefox). */ - IS_NS: navigator.userAgent != null && + IS_NS: typeof window !== 'undefined' && + navigator.userAgent != null && navigator.userAgent.indexOf('Mozilla/') >= 0 && navigator.userAgent.indexOf('MSIE') < 0 && navigator.userAgent.indexOf('Edge/') < 0, @@ -45,42 +275,48 @@ let mxClient = { * * True if the current browser is Safari. */ - IS_SF: /Apple Computer, Inc/.test(navigator.vendor), + IS_SF: typeof window !== 'undefined' && + /Apple Computer, Inc/.test(navigator.vendor), /** * Variable: IS_ANDROID * * Returns true if the user agent contains Android. */ - IS_ANDROID: navigator.appVersion.indexOf('Android') >= 0, + IS_ANDROID: typeof window !== 'undefined' && + navigator.appVersion.indexOf('Android') >= 0, /** * Variable: IS_IOS * * Returns true if the user agent is an iPad, iPhone or iPod. */ - IS_IOS: (/iP(hone|od|ad)/.test(navigator.platform)), + IS_IOS: typeof window !== 'undefined' && + (/iP(hone|od|ad)/.test(navigator.platform)), /** * Variable: IS_GC * * True if the current browser is Google Chrome. */ - IS_GC: /Google Inc/.test(navigator.vendor), + IS_GC: typeof window !== 'undefined' && + /Google Inc/.test(navigator.vendor), /** * Variable: IS_CHROMEAPP * * True if the this is running inside a Chrome App. */ - IS_CHROMEAPP: window.chrome != null && chrome.app != null && chrome.app.runtime != null, + IS_CHROMEAPP: typeof window !== 'undefined' && + window.chrome != null && chrome.app != null && chrome.app.runtime != null, /** * Variable: IS_FF * * True if the current browser is Firefox. */ - IS_FF: typeof InstallTrigger !== 'undefined', + IS_FF: typeof window !== 'undefined' && + typeof InstallTrigger !== 'undefined', /** * Variable: IS_MT @@ -89,7 +325,8 @@ let mxClient = { * for all Firefox-based browsers newer than or equal 3, such as Camino, * Iceweasel, Seamonkey and Iceape. */ - IS_MT: (navigator.userAgent.indexOf('Firefox/') >= 0 && + IS_MT: typeof window !== 'undefined' && + ((navigator.userAgent.indexOf('Firefox/') >= 0 && navigator.userAgent.indexOf('Firefox/1.') < 0 && navigator.userAgent.indexOf('Firefox/2.') < 0) || (navigator.userAgent.indexOf('Iceweasel/') >= 0 && @@ -98,14 +335,15 @@ let mxClient = { (navigator.userAgent.indexOf('SeaMonkey/') >= 0 && navigator.userAgent.indexOf('SeaMonkey/1.') < 0) || (navigator.userAgent.indexOf('Iceape/') >= 0 && - navigator.userAgent.indexOf('Iceape/1.') < 0), + navigator.userAgent.indexOf('Iceape/1.') < 0)), /** * Variable: IS_SVG * * True if the browser supports SVG. */ - IS_SVG: navigator.appName.toUpperCase() != 'MICROSOFT INTERNET EXPLORER', + IS_SVG: typeof window !== 'undefined' && + navigator.appName.toUpperCase() !== 'MICROSOFT INTERNET EXPLORER', /** * Variable: NO_FO @@ -113,29 +351,33 @@ let mxClient = { * True if foreignObject support is not available. This is the case for * Opera, older SVG-based browsers and all versions of IE. */ - NO_FO: !document.createElementNS || document.createElementNS('http://www.w3.org/2000/svg', - 'foreignObject') != '[object SVGForeignObjectElement]' || navigator.userAgent.indexOf('Opera/') >= 0, + NO_FO: typeof window !== 'undefined' && + (!document.createElementNS || document.createElementNS('http://www.w3.org/2000/svg','foreignObject') !== + '[object SVGForeignObjectElement]' || navigator.userAgent.indexOf('Opera/') >= 0), /** * Variable: IS_WIN * * True if the client is a Windows. */ - IS_WIN: navigator.appVersion.indexOf('Win') > 0, + IS_WIN: typeof window !== 'undefined' && + navigator.appVersion.indexOf('Win') > 0, /** * Variable: IS_MAC * * True if the client is a Mac. */ - IS_MAC: navigator.appVersion.indexOf('Mac') > 0, + IS_MAC: typeof window !== 'undefined' && + navigator.appVersion.indexOf('Mac') > 0, /** * Variable: IS_CHROMEOS * * True if the client is a Chrome OS. */ - IS_CHROMEOS: /\bCrOS\b/.test(navigator.appVersion), + IS_CHROMEOS: typeof window !== 'undefined' && + /\bCrOS\b/.test(navigator.appVersion), /** * Variable: IS_TOUCH @@ -143,21 +385,25 @@ let mxClient = { * True if this device supports touchstart/-move/-end events (Apple iOS, * Android, Chromebook and Chrome Browser on touch-enabled devices). */ - IS_TOUCH: 'ontouchstart' in document.documentElement, + IS_TOUCH: typeof window !== 'undefined' && + 'ontouchstart' in document.documentElement, /** * Variable: IS_POINTER * * True if this device supports Microsoft pointer events (always false on Macs). */ - IS_POINTER: window.PointerEvent != null && !(navigator.appVersion.indexOf('Mac') > 0), + IS_POINTER: typeof window !== 'undefined' && + window.PointerEvent != null && + !(navigator.appVersion.indexOf('Mac') > 0), /** * Variable: IS_LOCAL * * True if the documents location does not start with http:// or https://. */ - IS_LOCAL: document.location.href.indexOf('http://') < 0 && + IS_LOCAL: typeof window !== 'undefined' && + document.location.href.indexOf('http://') < 0 && document.location.href.indexOf('https://') < 0, /** @@ -239,7 +485,7 @@ let mxClient = { let pending = mxClient.defaultBundles.length; function callback() { - if (--pending == 0) { + if (--pending === 0) { fn(); } } @@ -250,215 +496,4 @@ let mxClient = { } }; -/** - * Variable: mxLoadResources - * - * Optional global config variable to toggle loading of the two resource files - * in and . Default is true. NOTE: This is a global variable, - * not a variable of mxClient. If this is false, you can use - * with its callback to load the default bundles asynchronously. - * - * (code) - * - * - * (end) - */ -if (typeof(mxLoadResources) == 'undefined') { - mxLoadResources = true; -} - -/** - * Variable: mxForceIncludes - * - * Optional global config variable to force loading the JavaScript files in - * development mode. Default is undefined. NOTE: This is a global variable, - * not a variable of mxClient. - * - * (code) - * - * - * (end) - */ -if (typeof(mxForceIncludes) == 'undefined') { - mxForceIncludes = false; -} - -/** - * Variable: mxResourceExtension - * - * Optional global config variable to specify the extension of resource files. - * Default is true. NOTE: This is a global variable, not a variable of mxClient. - * - * (code) - * - * - * (end) - */ -if (typeof(mxResourceExtension) == 'undefined') { - mxResourceExtension = '.txt'; -} - -/** - * Variable: mxLoadStylesheets - * - * Optional global config variable to toggle loading of the CSS files when - * the library is initialized. Default is true. NOTE: This is a global variable, - * not a variable of mxClient. - * - * (code) - * - * - * (end) - */ -if (typeof(mxLoadStylesheets) == 'undefined') { - mxLoadStylesheets = true; -} - -/** - * Variable: basePath - * - * Basepath for all URLs in the core without trailing slash. Default is '.'. - * Set mxBasePath prior to loading the mxClient library as follows to override - * this setting: - * - * (code) - * - * - * (end) - * - * When using a relative path, the path is relative to the URL of the page that - * contains the assignment. Trailing slashes are automatically removed. - */ -if (typeof(mxBasePath) != 'undefined' && mxBasePath.length > 0) { - // Adds a trailing slash if required - if (mxBasePath.substring(mxBasePath.length - 1) === '/') { - mxBasePath = mxBasePath.substring(0, mxBasePath.length - 1); - } - mxClient.basePath = mxBasePath; -} else { - mxClient.basePath = '.'; -} - -/** - * Variable: imageBasePath - * - * Basepath for all images URLs in the core without trailing slash. Default is - * + '/images'. Set mxImageBasePath prior to loading the - * mxClient library as follows to override this setting: - * - * (code) - * - * - * (end) - * - * When using a relative path, the path is relative to the URL of the page that - * contains the assignment. Trailing slashes are automatically removed. - */ -if (typeof(mxImageBasePath) != 'undefined' && mxImageBasePath.length > 0) { - // Adds a trailing slash if required - if (mxImageBasePath.substring(mxImageBasePath.length - 1) === '/') { - mxImageBasePath = mxImageBasePath.substring(0, mxImageBasePath.length - 1); - } - mxClient.imageBasePath = mxImageBasePath; -} else { - mxClient.imageBasePath = mxClient.basePath + '/images'; -} - -/** - * Variable: language - * - * Defines the language of the client, eg. en for english, de for german etc. - * The special value 'none' will disable all built-in internationalization and - * resource loading. See for handling identifiers - * with and without a dash. - * - * Set mxLanguage prior to loading the mxClient library as follows to override - * this setting: - * - * (code) - * - * - * (end) - * - * If internationalization is disabled, then the following variables should be - * overridden to reflect the current language of the system. These variables are - * cleared when i18n is disabled. - * , , - * , , - * , , , - * , , - * , , - * , , - * , , - * and - * . - */ -if (typeof(mxLanguage) != 'undefined' && mxLanguage != null) { - mxClient.language = mxLanguage; -} -else { - mxClient.language = navigator.language; -} - -/** - * Variable: defaultLanguage - * - * Defines the default language which is used in the common resource files. Any - * resources for this language will only load the common resource file, but not - * the language-specific resource file. Default is 'en'. - * - * Set mxDefaultLanguage prior to loading the mxClient library as follows to override - * this setting: - * - * (code) - * - * - * (end) - */ -if (typeof(mxDefaultLanguage) != 'undefined' && mxDefaultLanguage != null) { - mxClient.defaultLanguage = mxDefaultLanguage; -} else { - mxClient.defaultLanguage = 'en'; -} - -// Adds all required stylesheets and namespaces -if (mxLoadStylesheets) { - mxClient.link('stylesheet', mxClient.basePath + '/css/common.css'); -} - -/** - * Variable: languages - * - * Defines the optional array of all supported language extensions. The default - * language does not have to be part of this list. See - * . - * - * (code) - * - * - * (end) - * - * This is used to avoid unnecessary requests to language files, ie. if a 404 - * will be returned. - */ -if (typeof(mxLanguages) != 'undefined' && mxLanguages != null) { - mxClient.languages = mxLanguages; -} +export default mxClient; diff --git a/src/mxgraph/shape/mxActor.js b/src/mxgraph/shape/mxActor.js index 6b27818a7..7a47de923 100644 --- a/src/mxgraph/shape/mxActor.js +++ b/src/mxgraph/shape/mxActor.js @@ -3,6 +3,7 @@ * Copyright (c) 2006-2015, Gaudenz Alder * Updated to ES9 syntax by David Morrissey 2021 */ +import mxShape from "./mxShape"; class mxActor extends mxShape { /** diff --git a/src/mxgraph/shape/mxArrow.js b/src/mxgraph/shape/mxArrow.js index 48b78bbcc..6910b92c8 100644 --- a/src/mxgraph/shape/mxArrow.js +++ b/src/mxgraph/shape/mxArrow.js @@ -3,6 +3,7 @@ * Copyright (c) 2006-2015, Gaudenz Alder * Updated to ES9 syntax by David Morrissey 2021 */ +import mxShape from "./mxShape"; class mxArrow extends mxShape { /** diff --git a/src/mxgraph/shape/mxArrowConnector.js b/src/mxgraph/shape/mxArrowConnector.js index ca2c9d947..5ac26a655 100644 --- a/src/mxgraph/shape/mxArrowConnector.js +++ b/src/mxgraph/shape/mxArrowConnector.js @@ -3,6 +3,9 @@ * Copyright (c) 2006-2015, Gaudenz Alder * Updated to ES9 syntax by David Morrissey 2021 */ +import mxShape from "./mxShape"; +import mxConstants from "../util/mxConstants"; +import mxUtils from "../util/mxUtils"; class mxArrowConnector extends mxShape { /** diff --git a/src/mxgraph/shape/mxCloud.js b/src/mxgraph/shape/mxCloud.js index 10a50ed66..07139b7a2 100644 --- a/src/mxgraph/shape/mxCloud.js +++ b/src/mxgraph/shape/mxCloud.js @@ -3,6 +3,7 @@ * Copyright (c) 2006-2015, Gaudenz Alder * Updated to ES9 syntax by David Morrissey 2021 */ +import mxActor from "./mxActor"; class mxCloud extends mxActor { /** diff --git a/src/mxgraph/shape/mxConnector.js b/src/mxgraph/shape/mxConnector.js index 0391f2987..2917643f5 100644 --- a/src/mxgraph/shape/mxConnector.js +++ b/src/mxgraph/shape/mxConnector.js @@ -4,8 +4,10 @@ * Updated to ES9 syntax by David Morrissey 2021 */ import mxConstants from "../util/mxConstants"; +import mxPolyline from "./mxPolyline"; +import mxUtils from "../util/mxUtils"; -class mxConnector extends mxPolyLine { +class mxConnector extends mxPolyline { /** * Class: mxConnector * diff --git a/src/mxgraph/shape/mxCylinder.js b/src/mxgraph/shape/mxCylinder.js index 4324a0e11..9fd234abb 100644 --- a/src/mxgraph/shape/mxCylinder.js +++ b/src/mxgraph/shape/mxCylinder.js @@ -3,6 +3,9 @@ * Copyright (c) 2006-2015, Gaudenz Alder * Updated to ES9 syntax by David Morrissey 2021 */ +import mxShape from "./mxShape"; +import mxConstants from "../util/mxConstants"; +import mxUtils from "../util/mxUtils"; class mxCylinder extends mxShape { /** diff --git a/src/mxgraph/shape/mxDoubleEllipse.js b/src/mxgraph/shape/mxDoubleEllipse.js index 7225168ea..12becc4de 100644 --- a/src/mxgraph/shape/mxDoubleEllipse.js +++ b/src/mxgraph/shape/mxDoubleEllipse.js @@ -5,6 +5,9 @@ */ import mxRectangle from "../util/mxRectangle"; +import mxShape from "./mxShape"; +import mxConstants from "../util/mxConstants"; +import mxUtils from "../util/mxUtils"; class mxDoubleEllipse extends mxShape { /** diff --git a/src/mxgraph/shape/mxEllipse.js b/src/mxgraph/shape/mxEllipse.js index 3e4fd065d..0d133ec9c 100644 --- a/src/mxgraph/shape/mxEllipse.js +++ b/src/mxgraph/shape/mxEllipse.js @@ -3,6 +3,7 @@ * Copyright (c) 2006-2015, Gaudenz Alder * Updated to ES9 syntax by David Morrissey 2021 */ +import mxShape from "./mxShape"; class mxEllipse extends mxShape { /** diff --git a/src/mxgraph/shape/mxHexagon.js b/src/mxgraph/shape/mxHexagon.js index 4a3693e8f..bc128a6b6 100644 --- a/src/mxgraph/shape/mxHexagon.js +++ b/src/mxgraph/shape/mxHexagon.js @@ -3,6 +3,10 @@ * Copyright (c) 2006-2015, Gaudenz Alder * Updated to ES9 syntax by David Morrissey 2021 */ +import mxActor from "./mxActor"; +import mxPoint from "../util/mxPoint"; +import mxUtils from "../util/mxUtils"; +import mxConstants from "../util/mxConstants"; class mxHexagon extends mxActor { /** diff --git a/src/mxgraph/shape/mxImageShape.js b/src/mxgraph/shape/mxImageShape.js index 44fbe0995..47d1cc26c 100644 --- a/src/mxgraph/shape/mxImageShape.js +++ b/src/mxgraph/shape/mxImageShape.js @@ -6,6 +6,7 @@ import mxUtils from "../util/mxUtils"; import mxConstants from "../util/mxConstants"; +import mxRectangleShape from "./mxRectangleShape"; class mxImageShape extends mxRectangleShape { /** diff --git a/src/mxgraph/shape/mxLine.js b/src/mxgraph/shape/mxLine.js index c0018d629..8827411ad 100644 --- a/src/mxgraph/shape/mxLine.js +++ b/src/mxgraph/shape/mxLine.js @@ -3,6 +3,7 @@ * Copyright (c) 2006-2015, Gaudenz Alder * Updated to ES9 syntax by David Morrissey 2021 */ +import mxShape from "./mxShape"; class mxLine extends mxShape { /** diff --git a/src/mxgraph/shape/mxPolyline.js b/src/mxgraph/shape/mxPolyline.js index 43624d2d7..068b15b60 100644 --- a/src/mxgraph/shape/mxPolyline.js +++ b/src/mxgraph/shape/mxPolyline.js @@ -3,6 +3,8 @@ * Copyright (c) 2006-2015, Gaudenz Alder * Updated to ES9 syntax by David Morrissey 2021 */ +import mxShape from "./mxShape"; +import mxConstants from "../util/mxConstants"; class mxPolyline extends mxShape { /** diff --git a/src/mxgraph/shape/mxRectangleShape.js b/src/mxgraph/shape/mxRectangleShape.js index 82226a9af..87fa87d66 100644 --- a/src/mxgraph/shape/mxRectangleShape.js +++ b/src/mxgraph/shape/mxRectangleShape.js @@ -6,6 +6,7 @@ import mxConstants from "../util/mxConstants"; import mxUtils from "../util/mxUtils"; +import mxShape from "./mxShape"; class mxRectangleShape extends mxShape { /** diff --git a/src/mxgraph/shape/mxRhombus.js b/src/mxgraph/shape/mxRhombus.js index 0df028aef..ccf28858b 100644 --- a/src/mxgraph/shape/mxRhombus.js +++ b/src/mxgraph/shape/mxRhombus.js @@ -3,6 +3,8 @@ * Copyright (c) 2006-2015, Gaudenz Alder * Updated to ES9 syntax by David Morrissey 2021 */ +import mxShape from "./mxShape"; +import mxPoint from "../util/mxPoint"; class mxRhombus extends mxShape { /** diff --git a/src/mxgraph/shape/mxShape.js b/src/mxgraph/shape/mxShape.js index 35c57e9bb..19d2ceca9 100644 --- a/src/mxgraph/shape/mxShape.js +++ b/src/mxgraph/shape/mxShape.js @@ -3,6 +3,11 @@ * Copyright (c) 2006-2015, Gaudenz Alder * Updated to ES9 syntax by David Morrissey 2021 */ +import mxRectangle from "../util/mxRectangle"; +import mxUtils from "../util/mxUtils"; +import mxConstants from "../util/mxConstants"; +import mxPoint from "../util/mxPoint"; +import mxSvgCanvas2D from "../util/mxSvgCanvas2D"; class mxShape { /** @@ -212,7 +217,11 @@ class mxShape { * * Constructs a new shape. */ - constructor(stencil) { + constructor(...args) { + this._constructor(...args); + }; + + _constructor = (stencil) => { this.stencil = stencil; this.initStyles(); }; diff --git a/src/mxgraph/shape/mxStencil.js b/src/mxgraph/shape/mxStencil.js index b8eb1cfb5..d2473393b 100644 --- a/src/mxgraph/shape/mxStencil.js +++ b/src/mxgraph/shape/mxStencil.js @@ -6,6 +6,7 @@ import mxRectangle from "../util/mxRectangle"; import mxConnectionConstraint from "FIXME"; +import mxShape from "./mxShape"; class mxStencil extends mxShape { /** @@ -281,7 +282,7 @@ class mxStencil extends mxShape { * desc - XML node that contains the stencil description. */ constructor(desc) { - // constructor not called + super(); this.desc = desc; this.parseDescription(); this.parseConstraints(); diff --git a/src/mxgraph/shape/mxSwimlane.js b/src/mxgraph/shape/mxSwimlane.js index b34867ee6..89441228f 100644 --- a/src/mxgraph/shape/mxSwimlane.js +++ b/src/mxgraph/shape/mxSwimlane.js @@ -3,6 +3,9 @@ * Copyright (c) 2006-2015, Gaudenz Alder * Updated to ES9 syntax by David Morrissey 2021 */ +import mxShape from "./mxShape"; +import mxRectangle from "../util/mxRectangle"; +import mxConstants from "../util/mxConstants"; class mxSwimlane extends mxShape { /** @@ -46,6 +49,11 @@ class mxSwimlane extends mxShape { this.strokewidth = (strokewidth != null) ? strokewidth : 1; }; + _constructor = () => { + // explicitly do nothing in + // overridden constructor in mxShape + }; + /** * Function: isRoundable * diff --git a/src/mxgraph/shape/mxText.js b/src/mxgraph/shape/mxText.js index 0f42e45a5..605fea7ee 100644 --- a/src/mxgraph/shape/mxText.js +++ b/src/mxgraph/shape/mxText.js @@ -9,6 +9,7 @@ import mxConstants from "../util/mxConstants"; import mxUtils from "../util/mxUtils"; import mxPoint from "../util/mxPoint"; import mxSvgCanvas2D from "../util/mxSvgCanvas2D"; +import mxShape from "./mxShape"; class mxText extends mxShape { /** diff --git a/src/mxgraph/util/mxConstants.js b/src/mxgraph/util/mxConstants.js index a816a9b75..bb8431ff9 100644 --- a/src/mxgraph/util/mxConstants.js +++ b/src/mxgraph/util/mxConstants.js @@ -4,6 +4,8 @@ * Updated to ES9 syntax by David Morrissey 2021 */ +import mxRectangle from "./mxRectangle"; + let mxConstants = { /** * Class: mxConstants diff --git a/src/mxgraph/util/mxResources.js b/src/mxgraph/util/mxResources.js index 42e4728df..3b731d98d 100644 --- a/src/mxgraph/util/mxResources.js +++ b/src/mxgraph/util/mxResources.js @@ -2,388 +2,389 @@ * Copyright (c) 2006-2016, JGraph Ltd * Copyright (c) 2006-2016, Gaudenz Alder */ -let mxResources = - { - /** - * Class: mxResources - * - * Implements internationalization. You can provide any number of - * resource files on the server using the following format for the - * filename: name[-en].properties. The en stands for any lowercase - * 2-character language shortcut (eg. de for german, fr for french). - * - * If the optional language extension is omitted, then the file is used as a - * default resource which is loaded in all cases. If a properties file for a - * specific language exists, then it is used to override the settings in the - * default resource. All entries in the file are of the form key=value. The - * values may then be accessed in code via . Lines without - * equal signs in the properties files are ignored. - * - * Resource files may either be added programmatically using - * or via a resource tag in the UI section of the - * editor configuration file, eg: - * - * (code) - * - * - * - * (end) - * - * The above element will load examples/resources/mxWorkflow.properties as well - * as the language specific file for the current language, if it exists. - * - * Values may contain placeholders of the form {1}...{n} where each placeholder - * is replaced with the value of the corresponding array element in the params - * argument passed to . The placeholder {1} maps to the first - * element in the array (at index 0). - * - * See for more information on specifying the default - * language or disabling all loading of resources. - * - * Lines that start with a # sign will be ignored. - * - * Special characters - * - * To use unicode characters, use the standard notation (eg. \u8fd1) or %u as a - * prefix (eg. %u20AC will display a Euro sign). For normal hex encoded strings, - * use % as a prefix, eg. %F6 will display a "o umlaut" (ö). - * - * See to disable this. If you disable this, make sure that - * your files are UTF-8 encoded. - * - * Asynchronous loading - * - * By default, the core adds two resource files synchronously at load time. - * To load these files asynchronously, set to false - * before loading mxClient.js and use instead. - * - * Variable: resources - * - * Object that maps from keys to values. - */ - resources: {}, +import mxClient from "../mxClient"; +import mxConstants from "./mxConstants"; - /** - * Variable: extension - * - * Specifies the extension used for language files. Default is . - */ - extension: mxResourceExtension, +let mxResources = { + /** + * Class: mxResources + * + * Implements internationalization. You can provide any number of + * resource files on the server using the following format for the + * filename: name[-en].properties. The en stands for any lowercase + * 2-character language shortcut (eg. de for german, fr for french). + * + * If the optional language extension is omitted, then the file is used as a + * default resource which is loaded in all cases. If a properties file for a + * specific language exists, then it is used to override the settings in the + * default resource. All entries in the file are of the form key=value. The + * values may then be accessed in code via . Lines without + * equal signs in the properties files are ignored. + * + * Resource files may either be added programmatically using + * or via a resource tag in the UI section of the + * editor configuration file, eg: + * + * (code) + * + * + * + * (end) + * + * The above element will load examples/resources/mxWorkflow.properties as well + * as the language specific file for the current language, if it exists. + * + * Values may contain placeholders of the form {1}...{n} where each placeholder + * is replaced with the value of the corresponding array element in the params + * argument passed to . The placeholder {1} maps to the first + * element in the array (at index 0). + * + * See for more information on specifying the default + * language or disabling all loading of resources. + * + * Lines that start with a # sign will be ignored. + * + * Special characters + * + * To use unicode characters, use the standard notation (eg. \u8fd1) or %u as a + * prefix (eg. %u20AC will display a Euro sign). For normal hex encoded strings, + * use % as a prefix, eg. %F6 will display a "o umlaut" (ö). + * + * See to disable this. If you disable this, make sure that + * your files are UTF-8 encoded. + * + * Asynchronous loading + * + * By default, the core adds two resource files synchronously at load time. + * To load these files asynchronously, set to false + * before loading mxClient.js and use instead. + * + * Variable: resources + * + * Object that maps from keys to values. + */ + resources: {}, - /** - * Variable: resourcesEncoded - * - * Specifies whether or not values in resource files are encoded with \u or - * percentage. Default is false. - */ - resourcesEncoded: false, + /** + * Variable: extension + * + * Specifies the extension used for language files. Default is . + */ + extension: '.txt', - /** - * Variable: loadDefaultBundle - * - * Specifies if the default file for a given basename should be loaded. - * Default is true. - */ - loadDefaultBundle: true, + /** + * Variable: resourcesEncoded + * + * Specifies whether or not values in resource files are encoded with \u or + * percentage. Default is false. + */ + resourcesEncoded: false, - /** - * Variable: loadDefaultBundle - * - * Specifies if the specific language file file for a given basename should - * be loaded. Default is true. - */ - loadSpecialBundle: true, + /** + * Variable: loadDefaultBundle + * + * Specifies if the default file for a given basename should be loaded. + * Default is true. + */ + loadDefaultBundle: true, - /** - * Function: isLanguageSupported - * - * Hook for subclassers to disable support for a given language. This - * implementation returns true if lan is in . - * - * Parameters: - * - * lan - The current language. - */ - isLanguageSupported: (lan) => { - if (mxClient.languages != null) { - return mxUtils.indexOf(mxClient.languages, lan) >= 0; - } + /** + * Variable: loadDefaultBundle + * + * Specifies if the specific language file file for a given basename should + * be loaded. Default is true. + */ + loadSpecialBundle: true, - return true; - }, + /** + * Function: isLanguageSupported + * + * Hook for subclassers to disable support for a given language. This + * implementation returns true if lan is in . + * + * Parameters: + * + * lan - The current language. + */ + isLanguageSupported: (lan) => { + if (mxClient.languages != null) { + return mxUtils.indexOf(mxClient.languages, lan) >= 0; + } - /** - * Function: getDefaultBundle - * - * Hook for subclassers to return the URL for the special bundle. This - * implementation returns basename + or null if - * is false. - * - * Parameters: - * - * basename - The basename for which the file should be loaded. - * lan - The current language. - */ - getDefaultBundle: (basename, lan) => { - if (mxResources.loadDefaultBundle || !mxResources.isLanguageSupported(lan)) { - return basename + mxResources.extension; - } else { - return null; - } - }, + return true; + }, - /** - * Function: getSpecialBundle - * - * Hook for subclassers to return the URL for the special bundle. This - * implementation returns basename + '_' + lan + or null if - * is false or lan equals . - * - * If is not null and contains - * a dash, then this method checks if returns true - * for the full language (including the dash). If that returns false the - * first part of the language (up to the dash) will be tried as an extension. - * - * If is null then the first part of the language is - * used to maintain backwards compatibility. - * - * Parameters: - * - * basename - The basename for which the file should be loaded. - * lan - The language for which the file should be loaded. - */ - getSpecialBundle: (basename, lan) => { - if (mxClient.languages == null || !this.isLanguageSupported(lan)) { - let dash = lan.indexOf('-'); + /** + * Function: getDefaultBundle + * + * Hook for subclassers to return the URL for the special bundle. This + * implementation returns basename + or null if + * is false. + * + * Parameters: + * + * basename - The basename for which the file should be loaded. + * lan - The current language. + */ + getDefaultBundle: (basename, lan) => { + if (mxResources.loadDefaultBundle || !mxResources.isLanguageSupported(lan)) { + return basename + mxResources.extension; + } else { + return null; + } + }, - if (dash > 0) { - lan = lan.substring(0, dash); - } - } + /** + * Function: getSpecialBundle + * + * Hook for subclassers to return the URL for the special bundle. This + * implementation returns basename + '_' + lan + or null if + * is false or lan equals . + * + * If is not null and contains + * a dash, then this method checks if returns true + * for the full language (including the dash). If that returns false the + * first part of the language (up to the dash) will be tried as an extension. + * + * If is null then the first part of the language is + * used to maintain backwards compatibility. + * + * Parameters: + * + * basename - The basename for which the file should be loaded. + * lan - The language for which the file should be loaded. + */ + getSpecialBundle: (basename, lan) => { + if (mxClient.languages == null || !this.isLanguageSupported(lan)) { + let dash = lan.indexOf('-'); - if (mxResources.loadSpecialBundle && mxResources.isLanguageSupported(lan) && lan != mxClient.defaultLanguage) { - return basename + '_' + lan + mxResources.extension; - } else { - return null; - } - }, + if (dash > 0) { + lan = lan.substring(0, dash); + } + } - /** - * Function: add - * - * Adds the default and current language properties file for the specified - * basename. Existing keys are overridden as new files are added. If no - * callback is used then the request is synchronous. - * - * Example: - * - * At application startup, additional resources may be - * added using the following code: - * - * (code) - * mxResources.add('resources/editor'); - * (end) - * - * Parameters: - * - * basename - The basename for which the file should be loaded. - * lan - The language for which the file should be loaded. - * callback - Optional callback for asynchronous loading. - */ - add: (basename, lan, callback) => { - lan = (lan != null) ? lan : ((mxClient.language != null) ? - mxClient.language.toLowerCase() : mxConstants.NONE); + if (mxResources.loadSpecialBundle && mxResources.isLanguageSupported(lan) && lan != mxClient.defaultLanguage) { + return basename + '_' + lan + mxResources.extension; + } else { + return null; + } + }, - if (lan != mxConstants.NONE) { - let defaultBundle = mxResources.getDefaultBundle(basename, lan); - let specialBundle = mxResources.getSpecialBundle(basename, lan); + /** + * Function: add + * + * Adds the default and current language properties file for the specified + * basename. Existing keys are overridden as new files are added. If no + * callback is used then the request is synchronous. + * + * Example: + * + * At application startup, additional resources may be + * added using the following code: + * + * (code) + * mxResources.add('resources/editor'); + * (end) + * + * Parameters: + * + * basename - The basename for which the file should be loaded. + * lan - The language for which the file should be loaded. + * callback - Optional callback for asynchronous loading. + */ + add: (basename, lan, callback) => { + lan = (lan != null) ? lan : ((mxClient.language != null) ? + mxClient.language.toLowerCase() : mxConstants.NONE); - let loadSpecialBundle = () => { - if (specialBundle != null) { - if (callback) { - mxUtils.get(specialBundle, (req) => { - mxResources.parse(req.getText()); - callback(); - }, () => { - callback(); - }); - } else { - try { - let req = mxUtils.load(specialBundle); + if (lan !== mxConstants.NONE) { + let defaultBundle = mxResources.getDefaultBundle(basename, lan); + let specialBundle = mxResources.getSpecialBundle(basename, lan); - if (req.isReady()) { - mxResources.parse(req.getText()); - } - } catch (e) { - // ignore - } - } - } else if (callback != null) { + let loadSpecialBundle = () => { + if (specialBundle != null) { + if (callback) { + mxUtils.get(specialBundle, (req) => { + mxResources.parse(req.getText()); callback(); - } - } + }, () => { + callback(); + }); + } else { + try { + let req = mxUtils.load(specialBundle); - if (defaultBundle != null) { - if (callback) { - mxUtils.get(defaultBundle, (req) => { + if (req.isReady()) { mxResources.parse(req.getText()); - loadSpecialBundle(); - }, () => { - loadSpecialBundle(); - }); - } else { - try { - let req = mxUtils.load(defaultBundle); - - if (req.isReady()) { - mxResources.parse(req.getText()); - } - - loadSpecialBundle(); - } catch (e) { - // ignore - } - } - } else { - // Overlays the language specific file (_lan-extension) - loadSpecialBundle(); - } - } - }, - - /** - * Function: parse - * - * Parses the key, value pairs in the specified - * text and stores them as local resources. - */ - parse: (text) => { - if (text != null) { - let lines = text.split('\n'); - - for (let i = 0; i < lines.length; i++) { - if (lines[i].charAt(0) != '#') { - let index = lines[i].indexOf('='); - - if (index > 0) { - let key = lines[i].substring(0, index); - let idx = lines[i].length; - - if (lines[i].charCodeAt(idx - 1) == 13) { - idx--; - } - - let value = lines[i].substring(index + 1, idx); - - if (this.resourcesEncoded) { - value = value.replace(/\\(?=u[a-fA-F\d]{4})/g, "%"); - mxResources.resources[key] = unescape(value); - } else { - mxResources.resources[key] = value; - } } + } catch (e) { + // ignore } } + } else if (callback != null) { + callback(); } - }, - - /** - * Function: get - * - * Returns the value for the specified resource key. - * - * Example: - * To read the value for 'welomeMessage', use the following: - * (code) - * let result = mxResources.get('welcomeMessage') || ''; - * (end) - * - * This would require an entry of the following form in - * one of the English language resource files: - * (code) - * welcomeMessage=Welcome to mxGraph! - * (end) - * - * The part behind the || is the string value to be used if the given - * resource is not available. - * - * Parameters: - * - * key - String that represents the key of the resource to be returned. - * params - Array of the values for the placeholders of the form {1}...{n} - * to be replaced with in the resulting string. - * defaultValue - Optional string that specifies the default return value. - */ - get: (key, params, defaultValue) => { - let value = mxResources.resources[key]; - - // Applies the default value if no resource was found - if (value == null) { - value = defaultValue; - } - - // Replaces the placeholders with the values in the array - if (value != null && params != null) { - value = mxResources.replacePlaceholders(value, params); - } - - return value; - }, - - /** - * Function: replacePlaceholders - * - * Replaces the given placeholders with the given parameters. - * - * Parameters: - * - * value - String that contains the placeholders. - * params - Array of the values for the placeholders of the form {1}...{n} - * to be replaced with in the resulting string. - */ - replacePlaceholders: (value, params) => { - let result = []; - let index = null; - - for (let i = 0; i < value.length; i++) { - let c = value.charAt(i); - - if (c == '{') { - index = ''; - } else if (index != null && c == '}') { - index = parseInt(index) - 1; - - if (index >= 0 && index < params.length) { - result.push(params[index]); - } - - index = null; - } else if (index != null) { - index += c; - } else { - result.push(c); - } - } - - return result.join(''); - }, - - /** - * Function: loadResources - * - * Loads all required resources asynchronously. Use this to load the graph and - * editor resources if is false. - * - * Parameters: - * - * callback - Callback function for asynchronous loading. - */ - loadResources: (callback) => { - mxResources.add(mxClient.basePath + '/resources/editor', null, () => { - mxResources.add(mxClient.basePath + '/resources/graph', null, callback); - }); } - }; + if (defaultBundle != null) { + if (callback) { + mxUtils.get(defaultBundle, (req) => { + mxResources.parse(req.getText()); + loadSpecialBundle(); + }, () => { + loadSpecialBundle(); + }); + } else { + try { + let req = mxUtils.load(defaultBundle); + + if (req.isReady()) { + mxResources.parse(req.getText()); + } + + loadSpecialBundle(); + } catch (e) { + // ignore + } + } + } else { + // Overlays the language specific file (_lan-extension) + loadSpecialBundle(); + } + } + }, + + /** + * Function: parse + * + * Parses the key, value pairs in the specified + * text and stores them as local resources. + */ + parse: (text) => { + if (text != null) { + let lines = text.split('\n'); + + for (let i = 0; i < lines.length; i++) { + if (lines[i].charAt(0) !== '#') { + let index = lines[i].indexOf('='); + + if (index > 0) { + let key = lines[i].substring(0, index); + let idx = lines[i].length; + + if (lines[i].charCodeAt(idx - 1) === 13) { + idx--; + } + + let value = lines[i].substring(index + 1, idx); + + if (this.resourcesEncoded) { + value = value.replace(/\\(?=u[a-fA-F\d]{4})/g, "%"); + mxResources.resources[key] = unescape(value); + } else { + mxResources.resources[key] = value; + } + } + } + } + } + }, + + /** + * Function: get + * + * Returns the value for the specified resource key. + * + * Example: + * To read the value for 'welomeMessage', use the following: + * (code) + * let result = mxResources.get('welcomeMessage') || ''; + * (end) + * + * This would require an entry of the following form in + * one of the English language resource files: + * (code) + * welcomeMessage=Welcome to mxGraph! + * (end) + * + * The part behind the || is the string value to be used if the given + * resource is not available. + * + * Parameters: + * + * key - String that represents the key of the resource to be returned. + * params - Array of the values for the placeholders of the form {1}...{n} + * to be replaced with in the resulting string. + * defaultValue - Optional string that specifies the default return value. + */ + get: (key, params, defaultValue) => { + let value = mxResources.resources[key]; + + // Applies the default value if no resource was found + if (value == null) { + value = defaultValue; + } + + // Replaces the placeholders with the values in the array + if (value != null && params != null) { + value = mxResources.replacePlaceholders(value, params); + } + + return value; + }, + + /** + * Function: replacePlaceholders + * + * Replaces the given placeholders with the given parameters. + * + * Parameters: + * + * value - String that contains the placeholders. + * params - Array of the values for the placeholders of the form {1}...{n} + * to be replaced with in the resulting string. + */ + replacePlaceholders: (value, params) => { + let result = []; + let index = null; + + for (let i = 0; i < value.length; i++) { + let c = value.charAt(i); + + if (c === '{') { + index = ''; + } else if (index != null && c === '}') { + index = parseInt(index) - 1; + + if (index >= 0 && index < params.length) { + result.push(params[index]); + } + + index = null; + } else if (index != null) { + index += c; + } else { + result.push(c); + } + } + + return result.join(''); + }, + + /** + * Function: loadResources + * + * Loads all required resources asynchronously. Use this to load the graph and + * editor resources if is false. + * + * Parameters: + * + * callback - Callback function for asynchronous loading. + */ + loadResources: (callback) => { + mxResources.add(mxClient.basePath + '/resources/editor', null, () => { + mxResources.add(mxClient.basePath + '/resources/graph', null, callback); + }); + } +}; export default mxResources; diff --git a/src/mxgraph/util/mxUtils.js b/src/mxgraph/util/mxUtils.js index 5c321f9b6..5770073b6 100644 --- a/src/mxgraph/util/mxUtils.js +++ b/src/mxgraph/util/mxUtils.js @@ -6,6 +6,7 @@ import mxEffects from "./mxEffects"; import mxXmlRequest from "./mxXmlRequest"; import mxClient from "../mxClient"; +import mxConstants from "./mxConstants"; let mxUtils = { /** @@ -30,7 +31,7 @@ let mxUtils = { * resource for this key does not exist then the value is used as * the title. Default is 'error'. */ - errorResource: (mxClient.language != 'none') ? 'error' : '', + errorResource: (mxClient.language !== 'none') ? 'error' : '', /** * Variable: closeResource @@ -39,7 +40,7 @@ let mxUtils = { * resource for this key does not exist then the value is used as * the label. Default is 'close'. */ - closeResource: (mxClient.language != 'none') ? 'close' : '', + closeResource: (mxClient.language !== 'none') ? 'close' : '', /** * Variable: errorImage @@ -163,11 +164,11 @@ let mxUtils = { * function to the specified scope. Inside funct, the "this" keyword * becomes a reference to that scope. */ - /*bind: (scope, funct) => { + bind: (scope, funct) => { return () => { return funct.apply(scope, arguments); }; - },*/ + }, /** * Function: eval @@ -393,7 +394,7 @@ let mxUtils = { let parent = child; while (parent != null) { - if (parent == ancestor) { + if (parent === ancestor) { return true; } @@ -582,11 +583,11 @@ let mxUtils = { removeWhitespace: (node, before) => { let tmp = (before) ? node.previousSibling : node.nextSibling; - while (tmp != null && tmp.nodeType == mxConstants.NODETYPE_TEXT) { + while (tmp != null && tmp.nodeType === mxConstants.NODETYPE_TEXT) { let next = (before) ? tmp.previousSibling : tmp.nextSibling; let text = mxUtils.getTextContent(tmp); - if (mxUtils.trim(text).length == 0) { + if (mxUtils.trim(text).length === 0) { tmp.parentNode.removeChild(tmp); } @@ -689,7 +690,7 @@ let mxUtils = { indent = (indent != null) ? indent : ''; newline = (newline != null) ? newline : '\n'; - if (node.namespaceURI != null && node.namespaceURI != ns) { + if (node.namespaceURI != null && node.namespaceURI !== ns) { ns = node.namespaceURI; if (node.getAttribute('xmlns') == null) { @@ -697,9 +698,9 @@ let mxUtils = { } } - if (node.nodeType == mxConstants.NODETYPE_DOCUMENT) { + if (node.nodeType === mxConstants.NODETYPE_DOCUMENT) { result.push(mxUtils.getPrettyXml(node.documentElement, tab, indent, newline, ns)); - } else if (node.nodeType == mxConstants.NODETYPE_DOCUMENT_FRAGMENT) { + } else if (node.nodeType === mxConstants.NODETYPE_DOCUMENT_FRAGMENT) { let tmp = node.firstChild; if (tmp != null) { @@ -708,19 +709,19 @@ let mxUtils = { tmp = tmp.nextSibling; } } - } else if (node.nodeType == mxConstants.NODETYPE_COMMENT) { + } else if (node.nodeType === mxConstants.NODETYPE_COMMENT) { let value = mxUtils.getTextContent(node); if (value.length > 0) { result.push(indent + '' + newline); } - } else if (node.nodeType == mxConstants.NODETYPE_TEXT) { + } else if (node.nodeType === mxConstants.NODETYPE_TEXT) { let value = mxUtils.trim(mxUtils.getTextContent(node)); if (value.length > 0) { result.push(indent + mxUtils.htmlEntities(value, false) + newline); } - } else if (node.nodeType == mxConstants.NODETYPE_CDATA) { + } else if (node.nodeType === mxConstants.NODETYPE_CDATA) { let value = mxUtils.getTextContent(node); if (value.length > 0) { diff --git a/src/mxgraph/view/mxCellOverlay.js b/src/mxgraph/view/mxCellOverlay.js index c726a1526..bece6c482 100644 --- a/src/mxgraph/view/mxCellOverlay.js +++ b/src/mxgraph/view/mxCellOverlay.js @@ -6,6 +6,8 @@ import mxPoint from "../util/mxPoint"; import mxRectangle from "../util/mxRectangle"; +import mxEventSource from "../util/mxEventSource"; +import mxConstants from "../util/mxConstants"; class mxCellOverlay extends mxEventSource { /** diff --git a/src/mxgraph/view/mxGraph.js b/src/mxgraph/view/mxGraph.js index 64aae558d..12e251258 100644 --- a/src/mxgraph/view/mxGraph.js +++ b/src/mxgraph/view/mxGraph.js @@ -36,6 +36,7 @@ import mxMouseEvent from "../util/mxMouseEvent"; import mxResources from "../util/mxResources"; import mxGeometry from "../model/mxGeometry"; import mxCell from "../model/mxCell"; +import mxGraphModel from "../model/mxGraphModel"; class mxGraph extends mxEventSource { /** @@ -11703,7 +11704,7 @@ class mxGraph extends mxEventSource { * Installs the required language resources at class * loading time. */ -if (mxLoadResources) { +if (mxClient.mxLoadResources) { mxResources.add(mxClient.basePath + '/resources/graph'); } else { mxClient.defaultBundles.push(mxClient.basePath + '/resources/graph');