forked from jgraph/mxgraph
-
Notifications
You must be signed in to change notification settings - Fork 200
feat: let register and unregister default style elements #757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
5048127
feat: let register and unregister default style elements
tbouffard 0c9d467
Merge branch 'main' into feat/register_unregister_default_styles
tbouffard e89778f
edge markers: improve JSDoc
tbouffard 1f252ae
fix typo in registerDefaultEdgStyles function name (missing "e")
tbouffard e7a7e1f
Examples: improve comments [skip ci]
tbouffard 2d67db1
fix: remove extra call in registerDefaultEdgeStyles
tbouffard 8aed80b
docs: mention unregister functions [skip ci]
tbouffard 6baa5b2
Improve jsdoc of unregisterAllEdgeStylesAndPerimeters [skip ci]
tbouffard 5968aa4
Move stencils to a dedicated directory
tbouffard 178ba34
Add unregisterAllStencilShapes
tbouffard 5f4f987
docs: list all unregister functions
tbouffard 3d13833
use unregisterAllStencilShapes in stories
tbouffard 60346ad
index.ts: reorg - group related exports
tbouffard 162084f
jsdoc: add for EdgeMarker [skip ci]
tbouffard 44a3ff4
Merge branch 'main' into feat/register_unregister_default_styles
tbouffard 6b3d1a5
examples without defaults: do not unregister styles, never load them …
tbouffard a097261
Graph constructor: no need for stylesheet default value
tbouffard 85bd665
fix JSDoc of createArrow
tbouffard 7ab0941
docs: explain how to unregister codec only in the codec page (for con…
tbouffard 3cad120
docs: explain how to register default styles configuration
tbouffard 77f30d2
refactor Graph.registerDefaults: call of methods in alphabetic order …
tbouffard 80f6c88
Merge branch 'main' into feat/register_unregister_default_styles
tbouffard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* | ||
| Copyright 2025-present The maxGraph project Contributors | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| import StencilShapeRegistry from './StencilShapeRegistry'; | ||
|
|
||
| /** | ||
| * Unregister all {@link StencilShape}s from {@link StencilShapeRegistry}. | ||
| * | ||
| * @category Configuration | ||
| * @category Style | ||
| * @since 0.18.0 | ||
| */ | ||
| export function unregisterAllStencilShapes() { | ||
| StencilShapeRegistry.stencils = {}; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| /* | ||
| Copyright 2021-present The maxGraph project Contributors | ||
| Copyright (c) 2006-2015, JGraph Ltd | ||
| Copyright (c) 2006-2015, Gaudenz Alder | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| import type { MarkerFactoryFunction, StyleArrowValue } from '../../types'; | ||
| import type AbstractCanvas2D from '../canvas/AbstractCanvas2D'; | ||
| import type Point from '../geometry/Point'; | ||
| import type Shape from '../geometry/Shape'; | ||
|
|
||
| /** | ||
| * A registry that stores the factory functions that create edge markers. | ||
| * | ||
| * NOTE: The signature and the name of in this class will change. | ||
| */ | ||
| class MarkerShape { | ||
| /** | ||
| * Maps from markers names to functions to paint the markers. | ||
| * | ||
| * Mapping: the attribute name on the object is the marker type, the associated value is the function to paint the marker | ||
| */ | ||
| static markers: Record<string, MarkerFactoryFunction> = {}; | ||
|
|
||
| /** | ||
| * Adds a factory method that updates a given endpoint and returns a | ||
| * function to paint the marker onto the given canvas. | ||
| */ | ||
| static addMarker(type: string, funct: MarkerFactoryFunction) { | ||
| MarkerShape.markers[type] = funct; | ||
| } | ||
|
|
||
| /** | ||
| * Returns a function to paint the given marker. | ||
| */ | ||
| static createMarker( | ||
| canvas: AbstractCanvas2D, | ||
| shape: Shape, | ||
| type: StyleArrowValue, | ||
| pe: Point, | ||
| unitX: number, | ||
| unitY: number, | ||
| size: number, | ||
| source: boolean, | ||
| sw: number, | ||
| filled: boolean | ||
| ) { | ||
| const markerFunction = MarkerShape.markers[type]; | ||
| return markerFunction | ||
| ? markerFunction(canvas, shape, type, pe, unitX, unitY, size, source, sw, filled) | ||
| : null; | ||
| } | ||
| } | ||
|
|
||
| export default MarkerShape; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.