diff --git a/packages/mindplot/src/components/Command.ts b/packages/mindplot/src/components/Command.ts index a1cb6feb..a5677ca0 100644 --- a/packages/mindplot/src/components/Command.ts +++ b/packages/mindplot/src/components/Command.ts @@ -23,7 +23,7 @@ abstract class Command { static _uuid: number; - private _discardDuplicated: string; + private _discardDuplicated: string | undefined; constructor() { this._id = Command._nextUUID(); @@ -46,7 +46,7 @@ abstract class Command { return this._uuid; } - getDiscardDuplicated(): string { + getDiscardDuplicated(): string | undefined { return this._discardDuplicated; } diff --git a/packages/mindplot/src/components/DesignerKeyboard.ts b/packages/mindplot/src/components/DesignerKeyboard.ts index 1f84f1e1..ec77efdb 100644 --- a/packages/mindplot/src/components/DesignerKeyboard.ts +++ b/packages/mindplot/src/components/DesignerKeyboard.ts @@ -219,7 +219,7 @@ class DesignerKeyboard extends Keyboard { }); } - private _goToBrother(designer: Designer, node: Topic, direction) { + private _goToBrother(designer: Designer, node: Topic, direction: 'UP' | 'DOWN') { const parent = node.getParent(); if (parent) { const brothers = parent.getChildren(); @@ -227,19 +227,19 @@ class DesignerKeyboard extends Keyboard { let target = node; const { y } = node.getPosition(); const { x } = node.getPosition(); - let dist = null; + let dist: number | null = null; for (let i = 0; i < brothers.length; i++) { const sameSide = x * brothers[i].getPosition().x >= 0; if (brothers[i] !== node && sameSide) { const brother = brothers[i]; const brotherY = brother.getPosition().y; if (direction === 'DOWN' && brotherY > y) { - let distancia = y - brotherY; - if (distancia < 0) { - distancia *= -1; + let distance = y - brotherY; + if (distance < 0) { + distance *= -1; } - if (dist == null || dist > distancia) { - dist = distancia; + if (dist == null || dist > distance) { + dist = distance; target = brothers[i]; } } else if (direction === 'UP' && brotherY < y) { diff --git a/packages/mindplot/src/components/DesignerModel.ts b/packages/mindplot/src/components/DesignerModel.ts index 3b1ac42e..2f0c1ef3 100644 --- a/packages/mindplot/src/components/DesignerModel.ts +++ b/packages/mindplot/src/components/DesignerModel.ts @@ -107,7 +107,7 @@ class DesignerModel extends Events { // Add node only if it's valid. if (isValid) { result.push(topic.getId()); - } else { + } else if (errorMsg) { $notify(errorMsg); } }); diff --git a/packages/mindplot/src/components/DragConnector.ts b/packages/mindplot/src/components/DragConnector.ts index 2690f869..62b27c6f 100644 --- a/packages/mindplot/src/components/DragConnector.ts +++ b/packages/mindplot/src/components/DragConnector.ts @@ -100,8 +100,8 @@ class DragConnector { const av = me._isVerticallyAligned(a.getSize(), aPos, sPos); const bv = me._isVerticallyAligned(b.getSize(), bPos, sPos); return ( - me._proximityWeight(av, a, sPos, currentConnection) - - me._proximityWeight(bv, b, sPos, currentConnection) + me._proximityWeight(av, a, sPos, currentConnection!) - + me._proximityWeight(bv, b, sPos, currentConnection!) ); }); return topics; diff --git a/packages/mindplot/src/components/DragPivot.ts b/packages/mindplot/src/components/DragPivot.ts index ccbfbfd0..2d751281 100644 --- a/packages/mindplot/src/components/DragPivot.ts +++ b/packages/mindplot/src/components/DragPivot.ts @@ -29,7 +29,7 @@ class DragPivot { private _isVisible: boolean; - private _targetTopic: Topic; + private _targetTopic: Topic | null; private _connectRect: Rect; @@ -57,7 +57,7 @@ class DragPivot { return this._isVisible; } - getTargetTopic(): Topic { + getTargetTopic(): Topic | null { return this._targetTopic; } @@ -91,7 +91,7 @@ class DragPivot { // Calculate pivot connection point ... const size = this._size; - const targetPosition = targetTopic.getPosition(); + const targetPosition = targetTopic!.getPosition(); const line = this._getConnectionLine(); // Update Line position. @@ -106,7 +106,7 @@ class DragPivot { // Make line visible only when the position has been already changed. // This solve several strange effects ;) - const targetPoint = targetTopic.workoutIncomingConnectionPoint(pivotPoint); + const targetPoint = targetTopic!.workoutIncomingConnectionPoint(pivotPoint); line.setTo(targetPoint.x, targetPoint.y); } diff --git a/packages/mindplot/src/components/DragTopic.ts b/packages/mindplot/src/components/DragTopic.ts index d7aee43b..3bd775f0 100644 --- a/packages/mindplot/src/components/DragTopic.ts +++ b/packages/mindplot/src/components/DragTopic.ts @@ -73,14 +73,14 @@ class DragTopic { if (this.isConnected() && !this.isFreeLayoutOn()) { const parent = this.getConnectedToTopic(); const predict = this._layoutManager.predict( - parent.getId(), + parent!.getId(), this._draggedNode.getId(), this.getPosition(), ); if (this._order !== predict.order) { const dragPivot = this._getDragPivot(); const pivotPosition = predict.position; - dragPivot.connectTo(parent, pivotPosition); + dragPivot.connectTo(parent!, pivotPosition); this.setOrder(predict.order); } } @@ -191,7 +191,7 @@ class DragTopic { } } - getConnectedToTopic(): Topic { + getConnectedToTopic(): Topic | null { const dragPivot = this._getDragPivot(); return dragPivot.getTargetTopic(); } diff --git a/packages/mindplot/src/components/IconGroup.ts b/packages/mindplot/src/components/IconGroup.ts index 71f8aecd..15e48340 100644 --- a/packages/mindplot/src/components/IconGroup.ts +++ b/packages/mindplot/src/components/IconGroup.ts @@ -97,7 +97,7 @@ class IconGroup { icons.push(icon); this._icons = icons.sort( (a, b) => - ORDER_BY_TYPE.get(a.getModel().getType()) - ORDER_BY_TYPE.get(b.getModel().getType()), + ORDER_BY_TYPE.get(a.getModel().getType())! - ORDER_BY_TYPE.get(b.getModel().getType())!, ); // Add all the nodes back ... @@ -115,7 +115,7 @@ class IconGroup { } private _findIconFromModel(iconModel: FeatureModel) { - let result = null; + let result: ImageIcon | null = null; this._icons.forEach((icon) => { const elModel = icon.getModel(); diff --git a/packages/mindplot/src/components/WidgetManager.ts b/packages/mindplot/src/components/WidgetManager.ts index 821b9382..7dd4aa6d 100644 --- a/packages/mindplot/src/components/WidgetManager.ts +++ b/packages/mindplot/src/components/WidgetManager.ts @@ -24,9 +24,11 @@ abstract class WidgetManager { linkModel?: LinkModel, noteModel?: NoteModel, ) { - const webcomponentShadowRoot = $($('#mindmap-comp')[0].shadowRoot); + const { shadowRoot } = $('#mindmap-comp')[0]; + const webcomponentShadowRoot = $(shadowRoot!); + let tooltip = webcomponentShadowRoot.find('#mindplot-svg-tooltip'); - if (!tooltip.length) { + if (!tooltip.length || !tooltip) { webcomponentShadowRoot.append( '