Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/core/src/editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,7 @@ export class Editor extends EventSource {
*/
installInsertHandler(graph: Graph): void {
const insertHandler: MouseListenerSet = {
mouseDown: (_sender: any, me: InternalMouseEvent) => {
mouseDown: (_sender: EventSource, me: InternalMouseEvent) => {
if (
this.insertFunction &&
!me.isPopupTrigger() &&
Expand All @@ -1641,13 +1641,13 @@ export class Editor extends EventSource {
}
},

mouseMove: (_sender: any, me: InternalMouseEvent) => {
mouseMove: (_sender: EventSource, me: InternalMouseEvent) => {
if (this.isActive) {
me.consume();
}
},

mouseUp: (_sender: any, me: InternalMouseEvent) => {
mouseUp: (_sender: EventSource, me: InternalMouseEvent) => {
if (this.isActive) {
this.isActive = false;
me.consume();
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/view/GraphView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2166,12 +2166,12 @@ export class GraphView extends EventSource {
return state;
};

// Adds basic listeners for graph event dispatching outside of the
// Adds basic listeners for graph event dispatching outside the
// container and finishing the handling of a single gesture
// Implemented via graph event dispatch loop to avoid duplicate events
// in Firefox and Chrome
graph.addMouseListener({
mouseDown: (sender: any, me: InternalMouseEvent) => {
mouseDown: () => {
const popupMenuHandler = graph.getPlugin<PopupMenuHandler>('PopupMenuHandler');
popupMenuHandler?.hideMenu();
},
Expand Down
11 changes: 5 additions & 6 deletions packages/core/src/view/cell/CellTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import InternalMouseEvent from '../event/InternalMouseEvent';
import type { Graph } from '../Graph';
import type Cell from './Cell';
import EventSource from '../event/EventSource';

import type { ColorValue } from '../../types';
import type { ColorValue, MouseListenerSet } from '../../types';

/**
* Event handler that highlights cells
Expand Down Expand Up @@ -77,7 +76,7 @@ import type { ColorValue } from '../../types';
* });
* ```
*/
class CellTracker extends CellMarker {
class CellTracker extends CellMarker implements MouseListenerSet {
constructor(
graph: Graph,
color: ColorValue,
Expand All @@ -97,14 +96,14 @@ class CellTracker extends CellMarker {
/**
* Ignores the event. The event is not consumed.
*/
mouseDown(sender: EventSource, me: InternalMouseEvent) {
mouseDown() {
return;
}
Comment thread
tbouffard marked this conversation as resolved.

/**
* Handles the event by highlighting the cell under the mouse pointer if it is over the hotspot region of the cell.
*/
mouseMove(sender: EventSource, me: InternalMouseEvent) {
mouseMove(_sender: EventSource, me: InternalMouseEvent) {
if (this.isEnabled()) {
this.process(me);
}
Expand All @@ -113,7 +112,7 @@ class CellTracker extends CellMarker {
/**
* Handles the event by resetting the highlight.
*/
mouseUp(sender: EventSource, me: InternalMouseEvent) {
mouseUp() {
return;
}
Comment thread
tbouffard marked this conversation as resolved.

Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/view/handler/EdgeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import {
import type { Graph } from '../Graph';
import CellState from '../cell/CellState';
import Shape from '../geometry/Shape';
import { CellHandle, ColorValue, Listenable } from '../../types';
import type { CellHandle, ColorValue, Listenable, MouseListenerSet } from '../../types';
import InternalMouseEvent from '../event/InternalMouseEvent';
import Cell from '../cell/Cell';
import ImageBox from '../image/ImageBox';
Expand All @@ -74,7 +74,7 @@ import { EdgeHandlerConfig, HandleConfig } from './config';
*
* Some elements of this handler and its subclasses can be configured using {@link EdgeHandlerConfig}.
*/
class EdgeHandler {
class EdgeHandler implements MouseListenerSet {
/**
* Reference to the enclosing {@link Graph}.
*/
Expand Down Expand Up @@ -784,7 +784,7 @@ class EdgeHandler {
* control point. The source and target points are used for reconnecting
* the edge.
*/
mouseDown(sender: EventSource, me: InternalMouseEvent) {
mouseDown(_sender: EventSource, me: InternalMouseEvent) {
const handle = this.getHandleForEvent(me);

if (handle !== null && this.bends[handle]) {
Expand Down Expand Up @@ -1308,7 +1308,7 @@ class EdgeHandler {
/**
* Handles the event by updating the preview.
*/
mouseMove(sender: EventSource, me: InternalMouseEvent) {
mouseMove(_sender: EventSource, me: InternalMouseEvent) {
if (this.index != null && this.marker != null) {
this.currentPoint = this.getPointForEvent(me);
this.error = null;
Expand Down Expand Up @@ -1416,7 +1416,7 @@ class EdgeHandler {
* Handles the event to applying the previewed changes on the edge by
* using {@link moveLabel}, {@link connect} or {@link changePoints}.
*/
mouseUp(sender: EventSource, me: InternalMouseEvent) {
mouseUp(_sender: EventSource, me: InternalMouseEvent) {
// Workaround for wrong event source in Webkit
if (this.index != null && this.marker != null) {
if (this.shape != null && this.shape.node != null) {
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/view/handler/VertexHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import type { Graph } from '../Graph';
import CellState from '../cell/CellState';
import Image from '../image/ImageBox';
import type Cell from '../cell/Cell';
import type { CellHandle, Listenable } from '../../types';
import type { CellHandle, Listenable, MouseListenerSet } from '../../types';
import Shape from '../geometry/Shape';
import InternalMouseEvent from '../event/InternalMouseEvent';
import EdgeHandler from './EdgeHandler';
Expand All @@ -42,11 +42,11 @@ import { HandleConfig, VertexHandlerConfig } from './config';
/**
* Event handler for resizing cells.
*
* This handler is automatically created in {@link Graph#createHandler}.
* This handler is automatically created in {@link Graph.createHandler}.
*
* Some elements of this handler and its subclasses can be configured using {@link EdgeHandlerConfig}.
*/
class VertexHandler {
class VertexHandler implements MouseListenerSet {
escapeHandler: (sender: Listenable, evt: Event) => void;
selectionBounds: Rectangle;
bounds: Rectangle;
Expand Down Expand Up @@ -632,7 +632,7 @@ class VertexHandler {
* event all subsequent events of the gesture are redirected to this
* handler.
*/
mouseDown(sender: EventSource, me: InternalMouseEvent) {
mouseDown(_sender: EventSource, me: InternalMouseEvent) {
if (!me.isConsumed() && this.graph.isEnabled()) {
const handle = this.getHandleForEvent(me);

Expand Down Expand Up @@ -831,7 +831,7 @@ class VertexHandler {
/**
* Handles the event by updating the preview.
*/
mouseMove(sender: EventSource, me: InternalMouseEvent) {
mouseMove(_sender: EventSource, me: InternalMouseEvent) {
if (!me.isConsumed() && this.index != null) {
// Checks tolerance for ignoring single clicks
this.checkTolerance(me);
Expand Down Expand Up @@ -1207,7 +1207,7 @@ class VertexHandler {
/**
* Handles the event by applying the changes to the geometry.
*/
mouseUp(sender: EventSource, me: InternalMouseEvent) {
mouseUp(_sender: EventSource, me: InternalMouseEvent) {
if (this.index != null && this.state != null) {
const point = new Point(me.getGraphX(), me.getGraphY());
const { index } = this;
Expand Down
41 changes: 16 additions & 25 deletions packages/core/src/view/other/DragSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,9 @@ export type DropHandler = (
) => void;

/**
* @class DragSource
*
* Wrapper to create a drag source from a DOM element so that the element can
* be dragged over a graph and dropped into the graph as a new cell.
*
* Problem is that in the dropHandler the current preview location is not
* available, so the preview and the dropHandler must match.
* Wrapper to create a drag source from a DOM element so that the element can be dragged over a graph and dropped into the graph as a new cell.
*
* Problem is that in the dropHandler the current preview location is not available, so the preview and the dropHandler must match.
*/
class DragSource {
constructor(element: EventTarget, dropHandler: DropHandler) {
Expand Down Expand Up @@ -128,7 +123,7 @@ class DragSource {
enabled = true;

/**
* Reference to the {@link mxGraph} that is the current drop target.
* Reference to the {@link Graph} that is the current drop target.
*/
currentGraph: Graph | null = null;

Expand All @@ -143,12 +138,12 @@ class DragSource {
currentPoint: Point | null = null;

/**
* Holds an {@link mxGuide} for the {@link currentGraph} if {@link dragPreview} is not null.
* Holds an {@link Guide} for the {@link currentGraph} if {@link dragPreview} is not null.
*/
currentGuide: Guide | null = null;

/**
* Holds an {@link mxGuide} for the {@link currentGraph} if {@link dragPreview} is not null.
* Holds an {@link Guide} for the {@link currentGraph} if {@link dragPreview} is not null.
* @note wrong doc
*/
currentHighlight: CellHighlight | null = null;
Expand All @@ -159,7 +154,7 @@ class DragSource {
autoscroll = true;

/**
* Specifies if {@link mxGuide} should be enabled. Default is true.
* Specifies if {@link Guide} should be enabled. Default is true.
*/
guidesEnabled = true;

Expand Down Expand Up @@ -245,8 +240,8 @@ class DragSource {
}

/**
* Returns the drop target for the given graph and coordinates. This
* implementation uses {@link mxGraph.getCellAt}.
* Returns the drop target for the given graph and coordinates.
* This implementation uses {@link Graph.getCellAt}.
*/
getDropTarget(graph: Graph, x: number, y: number, evt: MouseEvent) {
return graph.getCellAt(x, y);
Expand Down Expand Up @@ -290,21 +285,17 @@ class DragSource {
}

/**
* Returns the drop target for the given graph and coordinates. This
* implementation uses {@link mxGraph.getCellAt}.
* Returns the drop target for the given graph and coordinates.
* This implementation uses {@link Graph.getCellAt}.
*
* To ignore popup menu events for a drag source, this function can be
* overridden as follows.
* To ignore popup menu events for a drag source, this function can be overridden as follows.
*
* @example
* ```javascript
* var mouseDown = dragSource.mouseDown;
* const mouseDown = dragSource.mouseDown;
*
* dragSource.mouseDown(evt)
* {
* if (!mxEvent.isPopupTrigger(evt))
* {
* mouseDown.apply(this, arguments);
* dragSource.mouseDown(evt) {
* if (!EventUtils.isPopupTrigger(evt)) {
* mouseDown.apply(this, [evt]);
* }
* };
* ```
Expand Down Expand Up @@ -650,7 +641,7 @@ class DragSource {

/**
* Returns the drop target for the given graph and coordinates. This
* implementation uses {@link mxGraph.getCellAt}.
* implementation uses {@link Graph.getCellAt}.
*/
drop(
graph: Graph,
Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/view/other/Outline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import EventObject from '../event/EventObject';
import { getSource, isMouseEvent } from '../../util/EventUtils';
import EventSource from '../event/EventSource';
import { hasScrollbars } from '../../util/styleUtils';
import { Listenable } from '../../types';
import type { Listenable, MouseListenerSet } from '../../types';
import { getDefaultPlugins } from '../plugins';

/**
Expand Down Expand Up @@ -78,11 +78,11 @@ import { getDefaultPlugins } from '../plugins';
* }
* ```
*/
class Outline {
constructor(source: Graph, container: HTMLElement | null = null) {
class Outline implements MouseListenerSet {
constructor(source: Graph, container?: HTMLElement | null) {
this.source = source;

if (container != null) {
if (container) {
this.init(container);
}
}
Expand Down Expand Up @@ -572,7 +572,7 @@ class Outline {
/**
* Handles the event by starting a translation or zoom.
*/
mouseDown(sender: EventSource, me: InternalMouseEvent): void {
mouseDown(_sender: EventSource, me: InternalMouseEvent): void {
if (this.enabled && this.showViewport) {
const tol = !isMouseEvent(me.getEvent()) ? this.source.tolerance : 0;
const hit =
Expand Down Expand Up @@ -604,7 +604,7 @@ class Outline {
* Handles the event by previewing the viewrect in {@link graph} and updating the
* rectangle that represents the viewrect in the outline.
*/
mouseMove(sender: EventSource, me: InternalMouseEvent): void {
mouseMove(_sender: EventSource, me: InternalMouseEvent): void {
if (this.active) {
const myBounds = <Rectangle>this.bounds;
const sizer = <RectangleShape>this.sizer;
Expand Down Expand Up @@ -699,7 +699,7 @@ class Outline {
/**
* Handles the event by applying the translation or zoom to {@link graph}.
*/
mouseUp(sender: EventSource, me: InternalMouseEvent): void {
mouseUp(_sender: EventSource, me: InternalMouseEvent): void {
if (this.active) {
const delta = this.getTranslateForEvent(me);
let dx = delta.x;
Expand Down
8 changes: 3 additions & 5 deletions packages/core/src/view/other/PanningManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ limitations under the License.
import { MouseEventListener, MouseListenerSet } from '../../types';
import { hasScrollbars } from '../../util/styleUtils';
import EventObject from '../event/EventObject';
import EventSource from '../event/EventSource';
import InternalEvent from '../event/InternalEvent';
import InternalMouseEvent from '../event/InternalMouseEvent';
import type { Graph } from '../Graph';

/**
Expand All @@ -42,13 +40,13 @@ class PanningManager {
this.scrollTop = 0;

this.mouseListener = {
mouseDown: (sender: EventSource, me: InternalMouseEvent) => {
mouseDown: () => {
return;
},
mouseMove: (sender: EventSource, me: InternalMouseEvent) => {
mouseMove: () => {
return;
},
mouseUp: (sender: EventSource, me: InternalMouseEvent) => {
mouseUp: () => {
if (this.active) {
this.stop();
}
Expand Down
Loading