diff --git a/packages/mindplot/src/components/DragManager.js b/packages/mindplot/src/components/DragManager.ts similarity index 86% rename from packages/mindplot/src/components/DragManager.js rename to packages/mindplot/src/components/DragManager.ts index 02d0ce84..09403006 100644 --- a/packages/mindplot/src/components/DragManager.js +++ b/packages/mindplot/src/components/DragManager.ts @@ -17,9 +17,25 @@ */ import { $assert, $defined } from '@wisemapping/core-js'; import DragTopic from './DragTopic'; +import EventBusDispatcher from './layout/EventBusDispatcher'; +import Workspace from './Workspace'; class DragManager { - constructor(workspace, eventDispatcher) { + private _workspace: Workspace; + + private _designerModel: Workspace; + + private _isDragInProcess: boolean; + + private _eventDispatcher: EventBusDispatcher; + + private _listeners; + + private _mouseMoveListener; + + private _mouseUpListener; + + constructor(workspace: Workspace, eventDispatcher: EventBusDispatcher) { this._workspace = workspace; this._designerModel = workspace; this._listeners = {}; @@ -34,7 +50,7 @@ class DragManager { const screen = workspace.getScreenManager(); const dragManager = this; const me = this; - const mouseDownListener = function mouseDownListener(event) { + const mouseDownListener = function mouseDownListener() { if (workspace.isWorkspaceEventsEnabled()) { // Disable double drag... workspace.enableWorkspaceEvents(false); @@ -62,11 +78,11 @@ class DragManager { node.addEvent('mousedown', mouseDownListener); } - remove(node) { + remove() { throw new Error('Not implemented: DragManager.prototype.remove'); } - _buildMouseMoveListener(workspace, dragNode, dragManager) { + protected _buildMouseMoveListener(workspace: Workspace, dragNode, dragManager: DragManager) { const screen = workspace.getScreenManager(); const me = this; const result = (event) => { @@ -98,7 +114,7 @@ class DragManager { return result; } - _buildMouseUpListener(workspace, node, dragNode, dragManager) { + protected _buildMouseUpListener(workspace: Workspace, node, dragNode, dragManager: DragManager) { const screen = workspace.getScreenManager(); const me = this; const result = (event) => { diff --git a/packages/mindplot/src/components/Relationship.ts b/packages/mindplot/src/components/Relationship.ts index a7d62a0e..3e056911 100644 --- a/packages/mindplot/src/components/Relationship.ts +++ b/packages/mindplot/src/components/Relationship.ts @@ -258,7 +258,7 @@ class Relationship extends ConnectionLine { } // @typescript-eslint/ban-types - addEvent(eventType: string, listener: any) { + addEvent(eventType: string, listener) { let type = eventType; // Translate to web 2d events ... if (type === 'onfocus') { diff --git a/packages/mindplot/src/components/ScreenManager.ts b/packages/mindplot/src/components/ScreenManager.ts index ab49de12..286ec05c 100644 --- a/packages/mindplot/src/components/ScreenManager.ts +++ b/packages/mindplot/src/components/ScreenManager.ts @@ -17,6 +17,7 @@ */ import { $assert } from '@wisemapping/core-js'; import { Point } from '@wisemapping/web2d'; +import Icon from './Icon'; import Topic from './Topic'; class ScreenManager { @@ -75,7 +76,7 @@ class ScreenManager { fireEvent(type: string, event: UIEvent = null) { if (type === 'click') { - this._clickEvents.forEach((listener: (arg0: any, arg1: any) => void) => { + this._clickEvents.forEach((listener) => { listener(type, event); }); } else { @@ -101,7 +102,7 @@ class ScreenManager { return { x, y }; } - getWorkspaceIconPosition(e: { getImage: () => any; getSize: () => any; getGroup: () => any; }) { + getWorkspaceIconPosition(e: Icon) { // Retrieve current icon position. const image = e.getImage(); const elementPosition = image.getPosition(); diff --git a/packages/mindplot/src/components/commands/DragTopicCommand.ts b/packages/mindplot/src/components/commands/DragTopicCommand.ts index aad827a4..8bee475c 100644 --- a/packages/mindplot/src/components/commands/DragTopicCommand.ts +++ b/packages/mindplot/src/components/commands/DragTopicCommand.ts @@ -24,7 +24,7 @@ import Topic from '../Topic'; class DragTopicCommand extends Command { private _topicsId: number; - private _parentId: any; + private _parentId: number; private _position: Point; @@ -62,7 +62,7 @@ class DragTopicCommand extends Command { const origPosition = topic.getPosition(); // Disconnect topic .. - if ($defined(origParentTopic) && origParentTopic !== this._parentId) { + if ($defined(origParentTopic) && origParentTopic.getId() !== this._parentId) { commandContext.disconnect(topic); } @@ -76,9 +76,9 @@ class DragTopicCommand extends Command { } // Finally, connect topic ... - if (origParentTopic !== this._parentId) { + if (origParentTopic.getId() !== this._parentId) { if ($defined(this._parentId)) { - const parentTopic = commandContext.findTopics(this._parentId)[0]; + const parentTopic = commandContext.findTopics([this._parentId])[0]; commandContext.connect(topic, parentTopic); } diff --git a/packages/mindplot/src/components/commands/RemoveFeatureFromTopicCommand.ts b/packages/mindplot/src/components/commands/RemoveFeatureFromTopicCommand.ts index 414edff7..8a791cc8 100644 --- a/packages/mindplot/src/components/commands/RemoveFeatureFromTopicCommand.ts +++ b/packages/mindplot/src/components/commands/RemoveFeatureFromTopicCommand.ts @@ -18,13 +18,14 @@ import { $assert, $defined } from '@wisemapping/core-js'; import Command from '../Command'; import CommandContext from '../CommandContext'; +import FeatureModel from '../model/FeatureModel'; class RemoveFeatureFromTopicCommand extends Command { private _topicId: number; private _featureId: number; - private _oldFeature: any; + private _oldFeature: FeatureModel; /** * @classdesc This command handles do/undo of removing a feature from a topic, e.g. an icon or @@ -43,7 +44,7 @@ class RemoveFeatureFromTopicCommand extends Command { /** * Overrides abstract parent method */ - execute(commandContext:CommandContext):void { + execute(commandContext: CommandContext): void { const topic = commandContext.findTopics([this._topicId])[0]; const feature = topic.findFeatureById(this._featureId); topic.removeFeature(feature); @@ -54,7 +55,7 @@ class RemoveFeatureFromTopicCommand extends Command { * Overrides abstract parent method * @see {@link mindplot.Command.undoExecute} */ - undoExecute(commandContext:CommandContext) { + undoExecute(commandContext: CommandContext) { const topic = commandContext.findTopics([this._topicId])[0]; topic.addFeature(this._oldFeature); this._oldFeature = null;