refactor!: remove the DIALECT enum by tbouffard · Pull Request #800 · maxGraph/maxGraph

packages/core/src/view/other/PrintPreview.ts (1)

805-805: String literal replaces DIALECT enum value correctly.

The string literal 'svg' is now directly used for the dialect check instead of the removed DIALECT.SVG enum value. This change aligns with the broader refactoring of removing the DIALECT enum throughout the codebase.

packages/core/src/view/plugins/CellEditorHandler.ts (1)

731-731: String literal 'strictHtml' replaces DIALECT enum value correctly.

The string literal 'strictHtml' is properly used for dialect comparison instead of the removed DIALECT.STRICTHTML enum value. This maintains the same functionality while adhering to the new type system using string literals.

packages/core/src/util/xmlUtils.ts (2)

19-19: DIALECT import correctly removed.

The import statement has been updated to remove the DIALECT import, keeping only the necessary constants. This helps clean up imports as part of the enum removal refactoring.


66-66: String literal replaces DIALECT enum value correctly.

The dialect check now uses the string literal 'svg' instead of the enum value, maintaining the same conditional logic while adhering to the refactoring approach.

packages/core/src/view/other/Guide.ts (3)

19-19: DIALECT import correctly removed.

The import statement has been properly updated to remove the DIALECT enum import, keeping only the necessary constants from the Constants file.


186-186: String literal used for dialect assignment.

The direct string literal 'svg' is now used for setting the dialect property instead of using the enum value. This implementation is consistent with the broader refactoring to remove the DIALECT enum.


225-225: String literal used for dialect assignment.

Similar to the previous instance, the string literal 'svg' is correctly used to set the dialect property on the vertical guide shape, maintaining consistency across the codebase.

packages/html/stories/SecondLabel.stories.js (1)

135-135: Dialect replacement correctly implemented.

The change from constants.DIALECT.STRICTHTML to the string literal 'strictHtml' properly implements the refactoring to remove the DIALECT enum as described in the PR objectives.

CHANGELOG.md (1)

14-17: Appropriate documentation of breaking changes.

The changelog has been properly updated to inform users about the removal of the DIALECT enum and its replacement with the new DialectValue type. This documentation is essential for users to migrate their code correctly.

packages/core/src/view/cell/CellHighlight.ts (2)

171-171: Correctly replaced enum with string literal.

The DIALECT.SVG enum usage has been appropriately replaced with the string literal 'svg'.


175-175: Dialect comparison properly updated.

The conditional check comparing this.graph.dialect to DIALECT.SVG has been correctly updated to use the string literal 'svg'.

packages/core/src/view/plugins/SelectionHandler.ts (2)

709-709: Enum replaced with appropriate string literal.

The DIALECT.STRICTHTML enum value has been correctly replaced with the string literal 'strictHtml'.


715-715: SVG dialect reference properly updated.

The DIALECT.SVG enum value has been correctly replaced with the string literal 'svg'.

packages/core/src/view/cell/VertexHandle.ts (2)

207-207: String literal 'strictHtml' replaces DIALECT enum usage.

The code now uses the string literal 'strictHtml' instead of the removed DIALECT.STRICTHTML enum value. This change aligns with the new DialectValue type introduced in the types.ts file.


210-210: String literals replace DIALECT enum in conditional assignment.

The code now uses string literals 'svg' and 'mixedHtml' instead of DIALECT.SVG and DIALECT.MIXEDHTML enum values in this conditional expression. This change is consistent with the PR objective of removing the DIALECT enum.

packages/core/src/view/handler/ConstraintHandler.ts (2)

323-323: String literal 'svg' replaces DIALECT.SVG enum usage.

The code now correctly uses the string literal 'svg' instead of the removed DIALECT.SVG enum value when setting the dialect property on the highlight shape.


418-418: String literals replace DIALECT enum in conditional assignment for icon dialect.

The code now uses string literals 'svg' and 'mixedHtml' instead of DIALECT.SVG and DIALECT.MIXEDHTML enum values when determining the icon dialect. This change is consistent with the removal of the DIALECT enum.

packages/core/src/types.ts (1)

1451-1462: Good addition of DialectValue type alias to replace DIALECT enum.

The new DialectValue type alias is well-documented with appropriate JSDoc comments for each variant. This type alias provides a clear replacement for the removed DIALECT enum, making it a type-safe alternative that uses string literals.

The values 'mixedHtml', 'preferHtml', 'strictHtml', and 'svg' correctly match the string literals now being used throughout the codebase. This creates a centralized type definition that can be imported where needed.

packages/core/src/view/geometry/Shape.ts (2)

42-42: Import DialectValue type from types module.

The code correctly imports the new DialectValue type from the types module. This import is necessary to apply the type to the dialect property.


149-149: Update dialect property type to use DialectValue.

The type annotation for the dialect property has been updated from string | null to DialectValue | null. This improves type safety by ensuring only valid dialect values can be assigned to this property.

packages/core/src/view/handler/EdgeHandler.ts (3)

245-245: Ensure valid dialect assignment
Replaces the old DIALECT enum with string literals. Confirm that 'mixedHtml' and 'svg' are included in the new DialectValue union so there are no type errors.


362-362: Verify parent highlight dialect
The parentHighlight is now forced to 'svg'. Ensure this matches the intended behavior for event transparency in IE and that no VML fallback is needed.


671-671: Use new string literal for HTML dialect
Assigning 'strictHtml' directly replaces the former enum constant. Confirm that this value is accepted by Shape.dialect and aligns with other HTML-rendered handles.

packages/core/src/view/cell/CellRenderer.ts (6)

379-379: Replace enum with string literal for text dialect
Assigns state.text.dialect to either 'strictHtml' or the current graph.dialect. Confirm that both branches satisfy the new DialectValue type.


420-420: Updated forceGetCell conditional
Switches from enum comparison to string literal check (graph.dialect !== 'svg'). Verify this logic covers all previous enum cases and doesn’t introduce regressions in touch handling.


461-461: Preserve SVG vs HTML label initialization
Replaces enum check with a literal comparison on shape.dialect. Behavior is unchanged; approve.


655-655: Removed enum in isForceHtml check
Uses graph.dialect === 'svg' instead of DIALECT.SVG. Confirm no side effects in environments where VML was previously used.


658-658: Use 'preferHtml' literal for control dialect
Assigns the new DialectValue 'preferHtml' to the folding icon. Ensure this matches the type alias and is handled correctly in rendering.


841-841: Standardize label redraw dialect
Replaces enum with literal in the label redraw path. Logical behavior remains the same.

packages/core/src/view/handler/VertexHandler.ts (6)

20-20: Removed DIALECT import; using literals
Now imports only CURSOR and NONE. All dialect references use string literals, so the enum is no longer needed.


228-228: Force selection border to use SVG dialect
Sets selectionBorder.dialect = 'svg' for IE transparency. Verify that IE support is still appropriate and that no VML case is required.


485-485: Assign strictHtml to sizer when using HTML labels
Replaces the enum constant for HTML mode with 'strictHtml'. Confirm HandleConfig interactions remain correct.


697-697: Use strictHtml for preview when required
Switches from enum to 'strictHtml'. Approved as equivalent behavior.


700-700: Default preview dialect to SVG
Sets preview.dialect = 'svg' in the non-HTML branch. Matches prior logic.


1983-1983: Replace enum in parent highlight with string literal
Sets parentHighlight.dialect = 'svg' for IE. Ensure this change continues to meet the original requirement.

packages/core/src/view/plugins/ConnectionHandler.ts (3)

506-506: String literal replaces enum constant.

The use of the string literal 'svg' directly instead of DIALECT.SVG is part of the broader refactor to remove the DIALECT enum. This ensures consistency with the new approach using the DialectValue type.


637-637: String literal replaces enum constant for HTML dialect.

Using 'strictHtml' directly in place of DIALECT.STRICTHTML aligns with the refactoring approach. This change maintains the same functionality while simplifying the code.


640-640: String literal replaces enum constant for SVG dialect.

Similar to the other dialect changes, using 'svg' directly here is consistent with the PR's overall goal of removing the DIALECT enum.

packages/core/src/view/geometry/node/TextShape.ts (7)

252-252: String literal replaces enum reference for HTML dialect check.

Using the string literal 'strictHtml' directly instead of the DIALECT.STRICTHTML enum value maintains the same functionality while simplifying the code.


310-310: String literal replaces enum reference in caching condition.

The condition now uses the string literal 'strictHtml' directly, which is consistent with the refactoring approach to remove the DIALECT enum.


330-330: String literal replaces enum reference in value caching check.

The condition logic remains the same while using the string literal 'strictHtml' instead of the enum value, aligning with the refactoring approach.


576-576: String literal replaces enum reference in HTML encoding condition.

The negation check now uses the string literal 'strictHtml' directly, maintaining the same functionality as before.


700-700: String literal replaces enum reference in HTML value update condition.

The condition uses 'strictHtml' directly, maintaining the same encoding logic as before.


726-726: String literal replaces enum reference in HTML entity encoding condition.

The condition now uses the string literal 'strictHtml' directly while maintaining the same logic for determining when to apply HTML entity encoding.


772-772: String literal replaces enum reference in text direction condition.

The condition for determining text direction now uses the string literal 'strictHtml' directly, maintaining the same logic as before.

packages/core/src/view/AbstractGraph.ts (2)

48-48: Import type alias instead of using direct string union.

The code now imports the DialectValue type from the types file, which is a more maintainable approach than using inline string unions.


146-146: Use type alias for dialect property.

The dialect property's type annotation has been updated to use the imported DialectValue type alias instead of an inline string union. This improves code maintainability and consistency across the codebase.