Current state
In mxGraph, it was possible to configure a style for a cell and to explicitly state to not merge/consider the properties of the default style (which is done by default).
This is not documented in the mxGraph API, AFAIK there is no explicit example using the feature and it is quite hidden in the code.
While reviewing the mxGraph@4.2.2 code to compare with the migrated code in StyleSheet.getCellStyle to prepare #152, I realized that the feature is missing in maxGraph.
Here is the usual mxGraph way to configure styles that involve the default style
// Merge properties of the default style and 2 custom styles
'style1;style2;prop1=value1;.....'
// No additional styles, only merge properties from the default style
'prop1=value1;.....'
To not merge properties of the default style, the style string must start with ; (semicolon). Not obvious!
';style1;style2;prop1=value1;.....'
Documented in https://github.com/jgraph/mxgraph/blob/v4.2.2/javascript/src/js/view/mxStylesheet.js#L33-L38
To avoid the default style for a cell, add a leading semicolon to the style definition, eg. ;shadow=1
Source: https://github.com/jgraph/mxgraph/blob/v4.2.2/javascript/src/js/view/mxStylesheet.js#L211-L217
var style = defaultStyle;
if (style != null &&
name.charAt(0) != ';')
{
style = mxUtils.clone(style);
}
else
{
style = new Object();
}
In maxGraph, ignoring the properties of the default style is not possible as there is no way to configure that.
Prior #152, the default style was always ignored if baseStyleNames. #152 now ensures that the default style is used for properties merge.
During the migration of the style management from a string representation (#82), an intermediate commit b51504d proposed to ignore the default style when baseStyleNames was set to null. This wasn't very convenient and explicit, so this hasn't been kept in the final implementation.
} else if (cellStyle.baseStyleName === null) {
// baseStyleName is explicitly null, so don't use any default styles.
style = {};
}
Proposal
I suggest to introduce a new property ignoreDefaultStyle (whose default value is false to keep the existing behavior) in CellStateStyle.
This will be very easy to test with automatic tests introduced in #152 and the Stylesheet.stories.js example can be updated to demonstrate how a vertex is displayed when using this new property.
Also update implementation of #293.
Current state
In mxGraph, it was possible to configure a style for a cell and to explicitly state to not merge/consider the properties of the default style (which is done by default).
This is not documented in the mxGraph API, AFAIK there is no explicit example using the feature and it is quite hidden in the code.
While reviewing the mxGraph@4.2.2 code to compare with the migrated code in
StyleSheet.getCellStyleto prepare #152, I realized that the feature is missing in maxGraph.Here is the usual mxGraph way to configure styles that involve the default style
To not merge properties of the default style, the style string must start with
;(semicolon). Not obvious!';style1;style2;prop1=value1;.....'Documented in https://github.com/jgraph/mxgraph/blob/v4.2.2/javascript/src/js/view/mxStylesheet.js#L33-L38
Source: https://github.com/jgraph/mxgraph/blob/v4.2.2/javascript/src/js/view/mxStylesheet.js#L211-L217
In maxGraph, ignoring the properties of the default style is not possible as there is no way to configure that.
Prior #152, the default style was always ignored if
baseStyleNames. #152 now ensures that the default style is used for properties merge.During the migration of the style management from a string representation (#82), an intermediate commit b51504d proposed to ignore the default style when
baseStyleNameswas set tonull. This wasn't very convenient and explicit, so this hasn't been kept in the final implementation.Proposal
I suggest to introduce a new property
ignoreDefaultStyle(whose default value isfalseto keep the existing behavior) inCellStateStyle.This will be very easy to test with automatic tests introduced in #152 and the
Stylesheet.stories.jsexample can be updated to demonstrate how a vertex is displayed when using this new property.Also update implementation of #293.