From 1d29e57258a4d2a2e8df2a7b0cce169efad05b1d Mon Sep 17 00:00:00 2001 From: mcyph <20507948+mcyph@users.noreply.github.com> Date: Sat, 3 Apr 2021 15:32:02 +1100 Subject: [PATCH] reorganize directory structure and converting to typescript --- src/.eslintrc | 4 +- src/mxgraph/util/datatypes/mxCellState.ts | 28 +++++----- src/mxgraph/view/cell/mxCell.ts | 6 +-- src/mxgraph/view/cell/mxCellPath.ts | 4 +- src/mxgraph/view/cell/mxCellRenderer.ts | 7 +-- .../view/cell/mxTemporaryCellStates.ts | 29 ++++++----- src/mxgraph/view/graph/mxLayoutManager.ts | 51 ++++++++++--------- src/pages/basic/Template.js | 2 +- src/pages/connections/Anchors.js | 2 +- src/pages/connections/FixedPoints.js | 2 +- src/pages/connections/HelloPort.js | 4 +- src/pages/connections/Orthogonal.js | 2 +- src/pages/dnd_copypaste/Clipboard.js | 2 +- src/pages/events/Events.js | 2 +- src/pages/icons_images/Images.js | 2 +- src/pages/icons_images/Indicators.js | 2 +- src/pages/layout/Folding.js | 2 +- src/pages/layout/HierarchicalLayout.js | 2 +- src/pages/layout/OrgChart.js | 2 +- src/pages/layout/RadialTreeLayout.js | 2 +- src/pages/layout/SwimLanes.js | 4 +- src/pages/layout/Tree.js | 2 +- src/pages/misc/DynamicLoading.js | 4 +- src/pages/misc/Guides.js | 2 +- src/pages/misc/Merge.js | 2 +- src/pages/misc/Monitor.js | 6 +-- src/pages/styles/Stylesheet.js | 4 +- src/pages/xml_json/FileIO.js | 4 +- src/pages/xml_json/JsonData.js | 6 +-- src/pages/xml_json/UserObject.js | 2 +- src/tsconfig.json | 23 +++++++++ 31 files changed, 126 insertions(+), 90 deletions(-) create mode 100644 src/tsconfig.json diff --git a/src/.eslintrc b/src/.eslintrc index 107984be5..224b972ed 100644 --- a/src/.eslintrc +++ b/src/.eslintrc @@ -1,6 +1,8 @@ { "extends": "@ijsto", "rules": { - "newIsCap": false + "newIsCap": 0, + "indent": ["error", 2, {"FunctionDeclaration": {"parameters": "first"}, + "FunctionExpression": {"parameters": "first"}}] } } \ No newline at end of file diff --git a/src/mxgraph/util/datatypes/mxCellState.ts b/src/mxgraph/util/datatypes/mxCellState.ts index f755e442f..e3ea594e0 100644 --- a/src/mxgraph/util/datatypes/mxCellState.ts +++ b/src/mxgraph/util/datatypes/mxCellState.ts @@ -14,17 +14,17 @@ import mxText from '../../shape/mxText'; class mxCellState extends mxRectangle { // TODO: Document me!! - cellBounds: mxRectangle; + cellBounds: mxRectangle | undefined; - paintBounds: mxRectangle; + paintBounds: mxRectangle | undefined; - boundingBox: mxRectangle; + boundingBox: mxRectangle | undefined; // Used by mxCellRenderer's createControl() - control: mxShape; + control: mxShape | undefined; // Used by mxCellRenderer's createCellOverlays() - overlays: any[]; + overlays: any[] | null | undefined; /** * Variable: view @@ -76,7 +76,7 @@ class mxCellState extends mxRectangle { * Holds an array of that represent the absolute points of an * edge. */ - absolutePoints: mxPoint[] | null = null; + absolutePoints: (mxPoint | null)[] | null = null; /** * Variable: absoluteOffset @@ -336,7 +336,7 @@ class mxCellState extends mxRectangle { * Returns the unscaled, untranslated bounds. */ getCellBounds(): mxRectangle { - return this.cellBounds; + return this.cellBounds; } /** @@ -347,7 +347,7 @@ class mxCellState extends mxRectangle { * isPaintBoundsInverted returns true. */ getPaintBounds(): mxRectangle { - return this.paintBounds; + return this.paintBounds; } /** @@ -356,8 +356,10 @@ class mxCellState extends mxRectangle { * Updates the cellBounds and paintBounds. */ updateCachedBounds(): void { - const tr = this.view.translate; - const s = this.view.scale; + const view = this.view; + + const tr = view.translate; + const s = view.scale; this.cellBounds = new mxRectangle( this.x / s - tr.x, this.y / s - tr.y, @@ -401,14 +403,14 @@ class mxCellState extends mxRectangle { * Returns a clone of this . */ clone(): mxCellState { - const clone = new mxCellState(this.view, this.cell, this.style); + const clone = new mxCellState(this.view, this.cell, this.style); // Clones the absolute points if (this.absolutePoints != null) { clone.absolutePoints = []; for (let i = 0; i < this.absolutePoints.length; i += 1) { - clone.absolutePoints[i] = this.absolutePoints[i].clone(); + clone.absolutePoints[i] = (this.absolutePoints)[i].clone(); } } @@ -443,7 +445,7 @@ class mxCellState extends mxRectangle { * Destroys the state and all associated resources. */ destroy(): void { - this.view.graph.cellRenderer.destroy(this); + (this.view).graph.cellRenderer.destroy(this); } } diff --git a/src/mxgraph/view/cell/mxCell.ts b/src/mxgraph/view/cell/mxCell.ts index e189e876e..465337b34 100644 --- a/src/mxgraph/view/cell/mxCell.ts +++ b/src/mxgraph/view/cell/mxCell.ts @@ -218,7 +218,7 @@ class mxCell { * * Returns the Id of the cell as a string. */ - getId(): number { + getId(): number | null { return this.id; } @@ -279,7 +279,7 @@ class mxCell { * * Sets the to be used as the . */ - setGeometry(geometry: mxGeometry): void { + setGeometry(geometry: mxGeometry | null): void { this.geometry = geometry; } @@ -297,7 +297,7 @@ class mxCell { * * Sets the string to be used as the