diff --git a/packages/core/__tests__/utils.ts b/packages/core/__tests__/utils.ts index 92079b8a9a..9582145c13 100644 --- a/packages/core/__tests__/utils.ts +++ b/packages/core/__tests__/utils.ts @@ -18,9 +18,9 @@ import { Cell, type CellStateStyle, Graph } from '../src'; import { jest } from '@jest/globals'; // no need for a container, we don't check the view here -export const createGraphWithoutContainer = (): Graph => new Graph(null!); +export const createGraphWithoutContainer = (): Graph => new Graph(); -export const createGraphWithoutPlugins = (): Graph => new Graph(null!, null!, []); +export const createGraphWithoutPlugins = (): Graph => new Graph(undefined, undefined, []); export const createCellWithStyle = (style: CellStateStyle): Cell => { const cell = new Cell(); diff --git a/packages/core/src/editor/Editor.ts b/packages/core/src/editor/Editor.ts index 411f63644a..44bb90a6bf 100644 --- a/packages/core/src/editor/Editor.ts +++ b/packages/core/src/editor/Editor.ts @@ -1387,12 +1387,13 @@ export class Editor extends EventSource { } /** - * Creates the {@link graph} for the editor. The graph is created with no - * container and is initialized from {@link setGraphContainer}. + * Creates the {@link graph} for the editor. + * + * The graph is created with no container and is initialized from {@link setGraphContainer}. * @returns graph instance */ createGraph(): Graph { - const graph = new Graph(undefined!); + const graph = new Graph(); // Enables rubberband, tooltips, panning graph.setTooltips(true); diff --git a/packages/core/src/serialization/codecs/GraphCodec.ts b/packages/core/src/serialization/codecs/GraphCodec.ts index 76f1ade1f2..97606bc5a5 100644 --- a/packages/core/src/serialization/codecs/GraphCodec.ts +++ b/packages/core/src/serialization/codecs/GraphCodec.ts @@ -37,9 +37,8 @@ import { Graph } from '../../view/Graph'; */ export class GraphCodec extends ObjectCodec { constructor() { - const __dummy: any = undefined; - // TODO: Register every possible plugin (i.e. all not being excluded via tree-shaking(?)) - super(new Graph(__dummy), [ + // TODO review the Graph initialization. Currently it registers all default plugins (check impact on tree-shaking) + super(new Graph(), [ 'graphListeners', 'eventListeners', 'view', diff --git a/packages/core/src/view/Graph.ts b/packages/core/src/view/Graph.ts index dea19688b0..c8bd88cbe9 100644 --- a/packages/core/src/view/Graph.ts +++ b/packages/core/src/view/Graph.ts @@ -494,7 +494,7 @@ class Graph extends EventSource { } constructor( - container: HTMLElement, + container?: HTMLElement, model?: GraphDataModel, plugins: GraphPluginConstructor[] = getDefaultPlugins(), stylesheet: Stylesheet | null = null