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
8 changes: 4 additions & 4 deletions packages/core/src/editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ import MaxLog from '../gui/MaxLog';
import { isNode } from '../util/domUtils';
import { getViewXml, getXml } from '../util/xmlUtils';
import { load, post, submit } from '../util/MaxXmlRequest';
import PopupMenuHandler from '../view/handler/PopupMenuHandler';
import RubberBandHandler from '../view/handler/RubberBandHandler';
import type PopupMenuHandler from '../view/plugins/PopupMenuHandler';
import RubberBandHandler from '../view/plugins/RubberBandHandler';
import InternalEvent from '../view/event/InternalEvent';
import InternalMouseEvent from '../view/event/InternalMouseEvent';
import { CellStateStyle, MouseListenerSet } from '../types';
import ConnectionHandler from '../view/handler/ConnectionHandler';
import type ConnectionHandler from '../view/plugins/ConnectionHandler';
import { show } from '../util/printUtils';
import PanningHandler from '../view/handler/PanningHandler';
import type PanningHandler from '../view/plugins/PanningHandler';
import { cloneCell } from '../util/cellArrayUtils';
import { TranslationsConfig } from '../i18n/config';
import type MaxPopupMenu from '../gui/MaxPopupMenu';
Expand Down
8 changes: 0 additions & 8 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,12 @@ export { Editor } from './editor/Editor';
export { default as CellHighlight } from './view/cell/CellHighlight';
export { default as CellMarker } from './view/cell/CellMarker';
export { default as CellTracker } from './view/cell/CellTracker';
export { default as ConnectionHandler } from './view/handler/ConnectionHandler';
export { default as ConstraintHandler } from './view/handler/ConstraintHandler';
export { default as EdgeHandler } from './view/handler/EdgeHandler';
export { default as EdgeSegmentHandler } from './view/handler/EdgeSegmentHandler';
export { default as ElbowEdgeHandler } from './view/handler/ElbowEdgeHandler';
export { default as SelectionHandler } from './view/handler/SelectionHandler';
export { default as VertexHandle } from './view/cell/VertexHandle';
export { default as KeyHandler } from './view/handler/KeyHandler';
export { default as PanningHandler } from './view/handler/PanningHandler';
export { default as PopupMenuHandler } from './view/handler/PopupMenuHandler';
export { default as RubberBandHandler } from './view/handler/RubberBandHandler';
export { default as SelectionCellsHandler } from './view/handler/SelectionCellsHandler';
export { default as TooltipHandler } from './view/handler/TooltipHandler';
export { default as VertexHandler } from './view/handler/VertexHandler';
export * from './view/handler/config';

Expand Down Expand Up @@ -201,7 +194,6 @@ export { default as UndoableEdit } from './view/undoable_changes/UndoableEdit';
export { default as UndoManager } from './view/undoable_changes/UndoManager';

export { Cell } from './view/cell/Cell';
export { default as CellEditorHandler } from './view/handler/CellEditorHandler';
export { default as CellOverlay } from './view/cell/CellOverlay';
export { default as CellPath } from './view/cell/CellPath';
export { default as CellRenderer } from './view/cell/CellRenderer';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/view/Graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import EventSource from './event/EventSource';
import InternalEvent from './event/InternalEvent';
import Rectangle from './geometry/Rectangle';
import Client from '../Client';
import type PanningHandler from './handler/PanningHandler';
import type PanningHandler from './plugins/PanningHandler';
import GraphView from './GraphView';
import CellRenderer from './cell/CellRenderer';
import Point from './geometry/Point';
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 @@ -38,12 +38,12 @@ import CurrentRootChange from './undoable_changes/CurrentRootChange';
import Shape from './geometry/Shape';
import Geometry from './geometry/Geometry';
import ConnectionConstraint from './other/ConnectionConstraint';
import PopupMenuHandler from './handler/PopupMenuHandler';
import type PopupMenuHandler from './plugins/PopupMenuHandler';
import { getClientX, getClientY, getSource, isConsumed } from '../util/EventUtils';
import { clone } from '../util/cloneUtils';
import type { Graph } from './Graph';
import StyleRegistry from './style/StyleRegistry';
import type TooltipHandler from './handler/TooltipHandler';
import type TooltipHandler from './plugins/TooltipHandler';
import type { EdgeStyleFunction, MouseEventListener } from '../types';
import { TranslationsConfig } from '../i18n/config';

Expand Down
11 changes: 4 additions & 7 deletions packages/core/src/view/cell/CellRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import CellOverlay from './CellOverlay';
import { getClientX, getClientY, getSource } from '../../util/EventUtils';
import { isNode } from '../../util/domUtils';
import { CellStateStyle } from '../../types';
import SelectionCellsHandler from '../handler/SelectionCellsHandler';
import type SelectionCellsHandler from '../plugins/SelectionCellsHandler';

const placeholderStyleValues = ['inherit', 'swimlane', 'indicated'];
const placeholderStyleProperties: (keyof CellStateStyle)[] = [
Expand Down Expand Up @@ -1380,6 +1380,9 @@ class CellRenderer {
state.shape = null;
}

const selectionCellsHandler = graph.getPlugin<SelectionCellsHandler>(
'SelectionCellsHandler'
);
if (
state.shape == null &&
graph.container != null &&
Expand All @@ -1398,9 +1401,6 @@ class CellRenderer {
this.installListeners(state);

// Forces a refresh of the handler if one exists
const selectionCellsHandler = graph.getPlugin<SelectionCellsHandler>(
'SelectionCellsHandler'
);
selectionCellsHandler?.updateHandler(state);
}
} else if (
Expand All @@ -1412,9 +1412,6 @@ class CellRenderer {
state.shape.resetStyles();
this.configureShape(state);
// LATER: Ignore update for realtime to fix reset of current gesture
const selectionCellsHandler = graph.getPlugin<SelectionCellsHandler>(
'SelectionCellsHandler'
);
selectionCellsHandler?.updateHandler(state);
force = true;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/view/handler/EdgeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import InternalMouseEvent from '../event/InternalMouseEvent';
import Cell from '../cell/Cell';
import ImageBox from '../image/ImageBox';
import EventSource from '../event/EventSource';
import SelectionHandler from './SelectionHandler';
import type SelectionHandler from '../plugins/SelectionHandler';
import { equalPoints } from '../../util/arrayUtils';
import { EdgeHandlerConfig, HandleConfig } from './config';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/view/handler/KeyHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
isControlDown as _isControlDown,
isShiftDown,
} from '../../util/EventUtils';
import CellEditorHandler from './CellEditorHandler';
import type CellEditorHandler from '../plugins/CellEditorHandler';

/**
* Event handler that listens to keystroke events. This is not a singleton,
Expand Down
13 changes: 8 additions & 5 deletions packages/core/src/view/handler/VertexHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import Shape from '../geometry/Shape';
import InternalMouseEvent from '../event/InternalMouseEvent';
import EdgeHandler from './EdgeHandler';
import EventSource from '../event/EventSource';
import SelectionHandler from './SelectionHandler';
import SelectionCellsHandler from './SelectionCellsHandler';
import type SelectionHandler from '../plugins/SelectionHandler';
import type SelectionCellsHandler from '../plugins/SelectionCellsHandler';
import { HandleConfig, VertexHandlerConfig } from './config';

/**
Expand Down Expand Up @@ -235,8 +235,7 @@ class VertexHandler {
this.selectionBorder.setCursor(CURSOR.MOVABLE_VERTEX);
}

const selectionHandler = this.graph.getPlugin<SelectionHandler>('SelectionHandler');

const selectionHandler = this.getSelectionHandler();
// Adds the sizer handles
if (
selectionHandler &&
Expand Down Expand Up @@ -337,11 +336,15 @@ class VertexHandler {
(<Graph>this.state.view.graph).addListener(InternalEvent.ESCAPE, this.escapeHandler);
}

private getSelectionHandler(): SelectionHandler | undefined {
return this.graph.getPlugin<SelectionHandler>('SelectionHandler');
}

/**
* Returns `true` if the rotation handle should be showing.
*/
isRotationHandleVisible() {
const selectionHandler = this.graph.getPlugin<SelectionHandler>('SelectionHandler');
const selectionHandler = this.getSelectionHandler();
const selectionHandlerCheck = selectionHandler
? selectionHandler.maxCells <= 0 ||
this.graph.getSelectionCount() < selectionHandler.maxCells
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/view/mixins/ConnectionsMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import EventObject from '../event/EventObject';
import InternalEvent from '../event/InternalEvent';
import Dictionary from '../../util/Dictionary';
import type { Graph } from '../Graph';
import type ConnectionHandler from '../handler/ConnectionHandler';
import type ConnectionHandler from '../plugins/ConnectionHandler';

type PartialGraph = Pick<Graph, 'getView' | 'getDataModel' | 'isPortsEnabled'>;
type PartialConnections = Pick<
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/view/mixins/EditingMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { isMultiTouchEvent } from '../../util/EventUtils';
import EventObject from '../event/EventObject';
import InternalEvent from '../event/InternalEvent';
import type { Graph } from '../Graph';
import type CellEditorHandler from '../handler/CellEditorHandler';
import type CellEditorHandler from '../plugins/CellEditorHandler';

type PartialGraph = Pick<
Graph,
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/view/mixins/EventsMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ import {
} from '../../util/EventUtils';
import CellState from '../cell/CellState';
import Cell from '../cell/Cell';
import type PanningHandler from '../handler/PanningHandler';
import type ConnectionHandler from '../handler/ConnectionHandler';
import type PanningHandler from '../plugins/PanningHandler';
import type ConnectionHandler from '../plugins/ConnectionHandler';
import Point from '../geometry/Point';
import { convertPoint } from '../../util/styleUtils';
import { NONE } from '../../util/Constants';
import Client from '../../Client';
import type CellEditorHandler from '../handler/CellEditorHandler';
import type CellEditorHandler from '../plugins/CellEditorHandler';
import type { Graph } from '../Graph';
import type TooltipHandler from '../handler/TooltipHandler';
import type TooltipHandler from '../plugins/TooltipHandler';

type PartialGraph = Pick<
Graph,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/view/mixins/PanningMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ limitations under the License.
import { hasScrollbars } from '../../util/styleUtils';
import EventObject from '../event/EventObject';
import InternalEvent from '../event/InternalEvent';
import type PanningHandler from '../handler/PanningHandler';
import type PanningHandler from '../plugins/PanningHandler';
import { Graph } from '../Graph';
import Rectangle from '../geometry/Rectangle';
import Point from '../geometry/Point';
import type SelectionCellsHandler from '../handler/SelectionCellsHandler';
import type SelectionCellsHandler from '../plugins/SelectionCellsHandler';

type PartialGraph = Pick<Graph, 'getContainer' | 'getView' | 'getPlugin' | 'fireEvent'>;
type PartialPanning = Pick<
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/view/mixins/TooltipMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import Translations from '../../i18n/Translations';
import type Shape from '../geometry/Shape';
import type Cell from '../cell/Cell';
import type { Graph } from '../Graph';
import type SelectionCellsHandler from '../handler/SelectionCellsHandler';
import type TooltipHandler from '../handler/TooltipHandler';
import type SelectionCellsHandler from '../plugins/SelectionCellsHandler';
import type TooltipHandler from '../plugins/TooltipHandler';

type PartialGraph = Pick<
Graph,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/view/other/DragSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import EventSource from '../event/EventSource';
import EventObject from '../event/EventObject';
import { Graph } from '../Graph';
import Cell from '../cell/Cell';
import SelectionHandler from '../handler/SelectionHandler';
import type SelectionHandler from '../plugins/SelectionHandler';

export type DropHandler = (
graph: Graph,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import EventSource from '../event/EventSource';

import type { Graph } from '../Graph';
import type { GraphPlugin } from '../../types';
import TooltipHandler from './TooltipHandler';
import type TooltipHandler from './TooltipHandler';

/**
* In-place editor for the graph. To control this editor, use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { convertPoint, getOffset } from '../../util/styleUtils';
import InternalMouseEvent from '../event/InternalMouseEvent';
import ImageShape from '../geometry/node/ImageShape';
import CellMarker from '../cell/CellMarker';
import ConstraintHandler from './ConstraintHandler';
import ConstraintHandler from '../handler/ConstraintHandler';
import PolylineShape from '../geometry/edge/PolylineShape';
import EventSource from '../event/EventSource';
import Rectangle from '../geometry/Rectangle';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { getMainEvent, isMultiTouchEvent } from '../../util/EventUtils';
import { Graph } from '../Graph';
import InternalMouseEvent from '../event/InternalMouseEvent';
import { GraphPlugin } from '../../types';
import TooltipHandler from './TooltipHandler';
import type TooltipHandler from './TooltipHandler';
import EventSource from '../event/EventSource';
import EventObject from '../event/EventObject';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,26 @@ import { Graph } from '../Graph';
import Cell from '../cell/Cell';
import CellState from '../cell/CellState';
import { GraphPlugin } from '../../types';
import EdgeHandler from './EdgeHandler';
import VertexHandler from './VertexHandler';
import type EdgeHandler from '../handler/EdgeHandler';
import type VertexHandler from '../handler/VertexHandler';
import InternalMouseEvent from '../event/InternalMouseEvent';

type Handler = EdgeHandler | VertexHandler;

/**
* An event handler that manages cell handlers and invokes their mouse event
* processing functions.
* An event handler that manages cell handlers and invokes their mouse event processing functions.
*
* Group: Events
* ### Events
*
* Event: mxEvent.ADD
* #### InternalEvent.ADD
*
* Fires if a cell has been added to the selection. The <code>state</code>
* property contains the <CellState> that has been added.
* Fires if a cell has been added to the selection.
* The `state` property contains the {@link CellState} that has been added.
*
* Event: mxEvent.REMOVE
* #### InternalEvent.REMOVE
*
* Fires if a cell has been remove from the selection. The <code>state</code>
* property contains the <CellState> that has been removed.
* Fires if a cell has been remove from the selection.
* The `state` property contains the {@link CellState} that has been removed.
*
* @category Plugin
*/
Expand Down Expand Up @@ -97,7 +98,7 @@ class SelectionCellsHandler extends EventSource implements GraphPlugin {
/**
* {@link Dictionary} that maps from cells to handlers.
*/
handlers: Dictionary<Cell, EdgeHandler | VertexHandler>;
handlers: Dictionary<Cell, Handler>;

/**
* Returns <enabled>.
Expand Down Expand Up @@ -206,7 +207,7 @@ class SelectionCellsHandler extends EventSource implements GraphPlugin {
/**
* Returns true if the given handler is active and should not be redrawn.
*/
isHandlerActive(handler: EdgeHandler | VertexHandler) {
isHandlerActive(handler: Handler) {
return handler.index !== null;
}

Expand Down
Loading