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
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ The following properties that were previously on `EdgeStyle` have moved to `Manh
- `MANHATTAN_MAXIMUM_LOOPS` to `maxLoops`
- `MANHATTAN_START_DIRECTIONS` to `startDirections`
- `MANHATTAN_STEP` to `step`
- `OrthConnector` is now configured with the global `OrthConnectorConfig` object.
The following properties that were previously on `EdgeStyle` have moved to `OrthConnectorConfig`:
- `OrthConnector` is now configured with the global `OrthogonalConnectorConfig` object.
The following properties that were previously on `EdgeStyle` have moved to `OrthogonalConnectorConfig`:
- `orthBuffer` to `buffer`
- `orthPointsFallback` to `pointsFallback`

Expand Down
20 changes: 10 additions & 10 deletions packages/core/__tests__/view/style/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ limitations under the License.
import { describe, expect, test } from '@jest/globals';
import {
ManhattanConnectorConfig,
OrthConnectorConfig,
OrthogonalConnectorConfig,
resetManhattanConnectorConfig,
resetOrthConnectorConfig,
resetOrthogonalConnectorConfig,
} from '../../../src';
import { DIRECTION } from '../../../src/util/Constants';

test('resetOrthConnectorConfig', () => {
test('resetOrthogonalConnectorConfig', () => {
// Keep track of original default values
const originalConfig = { ...OrthConnectorConfig };
const originalConfig = { ...OrthogonalConnectorConfig };

// Change some values
OrthConnectorConfig.buffer = 18;
OrthConnectorConfig.pointsFallback = false;
OrthogonalConnectorConfig.buffer = 18;
OrthogonalConnectorConfig.pointsFallback = false;

resetOrthConnectorConfig();
resetOrthogonalConnectorConfig();

// Ensure that the values have correctly been reset
expect(OrthConnectorConfig.buffer).toBe(10);
expect(OrthConnectorConfig.pointsFallback).toBeTruthy();
expect(OrthConnectorConfig).toStrictEqual(originalConfig);
expect(OrthogonalConnectorConfig.buffer).toBe(10);
expect(OrthogonalConnectorConfig.pointsFallback).toBeTruthy();
expect(OrthogonalConnectorConfig).toStrictEqual(originalConfig);
});

describe('resetManhattanConnectorConfig', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ export type CellStateStyle = {
indicatorWidth?: number;
/**
* The jetty size in {@link EdgeStyle.OrthConnector} when {@link sourceJettySize} or {@link targetJettySize}.
* @default {@link OrthConnectorConfig.buffer}
* @default {@link OrthogonalConnectorConfig.buffer}
*/
jettySize?: number | 'auto';
/**
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/view/style/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const resetEntityRelationConnectorConfig = (): void => {
* @since 0.16.0
* @category Configuration
*/
export const OrthConnectorConfig = {
export const OrthogonalConnectorConfig = {
/**
* If the value is not set in {@link CellStateStyle.jettySize}, defines the jetty size of the connector.
*
Expand All @@ -71,16 +71,16 @@ export const OrthConnectorConfig = {
pointsFallback: true,
};

const originalOrthConnectorConfig = { ...OrthConnectorConfig };
const originalOrthogonalConnectorConfig = { ...OrthogonalConnectorConfig };
/**
* Resets {@link OrthConnectorConfig} to default values.
* Resets {@link OrthogonalConnectorConfig} to default values.
*
* @experimental Subject to change or removal. maxGraph's global configuration may be modified in the future without prior notice.
* @since 0.16.0
* @category Configuration
*/
export const resetOrthConnectorConfig = (): void => {
shallowCopy(originalOrthConnectorConfig, OrthConnectorConfig);
export const resetOrthogonalConnectorConfig = (): void => {
shallowCopy(originalOrthogonalConnectorConfig, OrthogonalConnectorConfig);
};

export type ManhattanConnectorConfigType = {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/view/style/edge/Orthogonal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
reversePortConstraints,
} from '../../../util/mathUtils';
import type CellState from '../../cell/CellState';
import { OrthConnectorConfig } from '../config';
import { OrthogonalConnectorConfig } from '../config';
import type { EdgeStyleFunction } from '../../../types';
import Point from '../../geometry/Point';
import Rectangle from '../../geometry/Rectangle';
Expand Down Expand Up @@ -119,7 +119,7 @@ const VERTEX_MASK = 3072;
// SOURCE_MASK | TARGET_MASK,

function getJettySize(state: CellState, isSource: boolean): number {
const buffer = OrthConnectorConfig.buffer;
const buffer = OrthogonalConnectorConfig.buffer;
let value =
(isSource ? state.style.sourceJettySize : state.style.targetJettySize) ??
state.style.jettySize ??
Expand Down Expand Up @@ -204,7 +204,7 @@ export const OrthogonalConnector: EdgeStyleFunction = (

if (
tooShort ||
(OrthConnectorConfig.pointsFallback &&
(OrthogonalConnectorConfig.pointsFallback &&
controlHints != null &&
controlHints.length > 0) ||
sourceEdge ||
Expand Down
4 changes: 2 additions & 2 deletions packages/html/.storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
resetEntityRelationConnectorConfig,
resetHandleConfig,
resetManhattanConnectorConfig,
resetOrthConnectorConfig,
resetOrthogonalConnectorConfig,
resetStyleDefaultsConfig,
resetVertexHandlerConfig,
} from '@maxgraph/core';
Expand All @@ -25,7 +25,7 @@ const resetMaxGraphConfigs = (): void => {
resetEntityRelationConnectorConfig();
resetHandleConfig();
resetManhattanConnectorConfig();
resetOrthConnectorConfig();
resetOrthogonalConnectorConfig();
resetStyleDefaultsConfig();
resetVertexHandlerConfig();
};
Expand Down
4 changes: 2 additions & 2 deletions packages/website/docs/usage/global-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The following objects can be used to configure `maxGraph` globally:
- For Connectors/EdgeStyles:
- `EntityRelationConnectorConfig` (since 0.15.0): for `EntityRelation`.
- `ManhattanConnectorConfig` (since 0.16.0): for `ManhattanConnector`.
- `OrthConnectorConfig` (since 0.16.0): for `OrthConnector`.
- `OrthogonalConnectorConfig` (since 0.16.0): for `OrthConnector`.

Some functions are provided to reset the global configuration to the default values. For example:

Expand All @@ -33,7 +33,7 @@ Some functions are provided to reset the global configuration to the default val
- For Connectors/EdgeStyles:
- `resetEntityRelationConnectorConfig` (since 0.15.0)
- `resetManhattanConnectorConfig` (since 0.16.0)
- `resetOrthConnectorConfig` (since 0.16.0)
- `resetOrthogonalConnectorConfig` (since 0.16.0)

:::note
Notice that the new global configuration elements introduced as version _0.11.0_ are experimental and are subject to change in future versions.
Expand Down