-
Notifications
You must be signed in to change notification settings - Fork 199
refactor!: remove the DIALECT enum #800
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
Conversation
Introduce the `DialectValue` type. BREAKING CHANGES: the DIALECT enum has been removed. Use the `DialectValue` type instead.
WalkthroughThe changes remove the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant AbstractGraph
participant Shape
Client->>AbstractGraph: Set dialect property (DialectValue)
AbstractGraph->>Shape: Pass dialect as DialectValue string
Shape-->>Client: Uses dialect for rendering logic
sequenceDiagram
participant Renderer
participant Shape
Renderer->>Shape: Assign dialect ('svg', 'strictHtml', etc. as string)
Shape->>Renderer: Render shape based on dialect string
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/core/src/view/handler/EdgeHandler.ts (1)
674-674: Consistent mixed/html dialect logic
The bend initialization uses the same ternary expression as the main selection shape. Consider extracting this into a helper if used frequently.packages/core/src/view/handler/VertexHandler.ts (1)
488-488: Consistent mixedHtml/svg logic for sizers
Uses the same ternary as elsewhere:graph.dialect !== 'svg' ? 'mixedHtml' : 'svg'. Consider DRYing this up into a helper.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (19)
CHANGELOG.md(1 hunks)packages/core/src/types.ts(1 hunks)packages/core/src/util/Constants.ts(0 hunks)packages/core/src/util/xmlUtils.ts(2 hunks)packages/core/src/view/AbstractGraph.ts(2 hunks)packages/core/src/view/cell/CellHighlight.ts(1 hunks)packages/core/src/view/cell/CellRenderer.ts(6 hunks)packages/core/src/view/cell/VertexHandle.ts(1 hunks)packages/core/src/view/geometry/Shape.ts(2 hunks)packages/core/src/view/geometry/node/TextShape.ts(7 hunks)packages/core/src/view/handler/ConstraintHandler.ts(2 hunks)packages/core/src/view/handler/EdgeHandler.ts(3 hunks)packages/core/src/view/handler/VertexHandler.ts(5 hunks)packages/core/src/view/other/Guide.ts(3 hunks)packages/core/src/view/other/PrintPreview.ts(1 hunks)packages/core/src/view/plugins/CellEditorHandler.ts(1 hunks)packages/core/src/view/plugins/ConnectionHandler.ts(2 hunks)packages/core/src/view/plugins/SelectionHandler.ts(1 hunks)packages/html/stories/SecondLabel.stories.js(1 hunks)
💤 Files with no reviewable changes (1)
- packages/core/src/util/Constants.ts
🧰 Additional context used
🧬 Code Graph Analysis (3)
packages/core/src/view/geometry/Shape.ts (1)
packages/core/src/types.ts (1)
DialectValue(1454-1462)
packages/core/src/view/geometry/node/TextShape.ts (1)
packages/core/src/util/domUtils.ts (1)
isNode(223-238)
packages/core/src/view/AbstractGraph.ts (1)
packages/core/src/types.ts (1)
DialectValue(1454-1462)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: build
- GitHub Check: build (macos-14)
- GitHub Check: build (windows-2022)
- GitHub Check: build (ubuntu-22.04)
🔇 Additional comments (47)
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 removedDIALECT.SVGenum value. This change aligns with the broader refactoring of removing theDIALECTenum 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 removedDIALECT.STRICTHTMLenum 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
DIALECTimport, 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
DIALECTenum 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 theDIALECTenum.
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.STRICTHTMLto the string literal'strictHtml'properly implements the refactoring to remove theDIALECTenum 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
DIALECTenum and its replacement with the newDialectValuetype. 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.SVGenum usage has been appropriately replaced with the string literal'svg'.
175-175: Dialect comparison properly updated.The conditional check comparing
this.graph.dialecttoDIALECT.SVGhas 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.STRICTHTMLenum value has been correctly replaced with the string literal'strictHtml'.
715-715: SVG dialect reference properly updated.The
DIALECT.SVGenum 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 removedDIALECT.STRICTHTMLenum value. This change aligns with the newDialectValuetype introduced in thetypes.tsfile.
210-210: String literals replace DIALECT enum in conditional assignment.The code now uses string literals
'svg'and'mixedHtml'instead ofDIALECT.SVGandDIALECT.MIXEDHTMLenum 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 removedDIALECT.SVGenum 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 ofDIALECT.SVGandDIALECT.MIXEDHTMLenum 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
DialectValuetype 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
DialectValuetype from the types module. This import is necessary to apply the type to thedialectproperty.
149-149: Update dialect property type to use DialectValue.The type annotation for the
dialectproperty has been updated fromstring | nulltoDialectValue | 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 oldDIALECTenum with string literals. Confirm that'mixedHtml'and'svg'are included in the newDialectValueunion so there are no type errors.
362-362: Verify parent highlight dialect
TheparentHighlightis 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 byShape.dialectand aligns with other HTML-rendered handles.packages/core/src/view/cell/CellRenderer.ts (6)
379-379: Replace enum with string literal for text dialect
Assignsstate.text.dialectto either'strictHtml'or the currentgraph.dialect. Confirm that both branches satisfy the newDialectValuetype.
420-420: UpdatedforceGetCellconditional
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 onshape.dialect. Behavior is unchanged; approve.
655-655: Removed enum inisForceHtmlcheck
Usesgraph.dialect === 'svg'instead ofDIALECT.SVG. Confirm no side effects in environments where VML was previously used.
658-658: Use'preferHtml'literal for control dialect
Assigns the newDialectValue'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: RemovedDIALECTimport; using literals
Now imports onlyCURSORandNONE. All dialect references use string literals, so the enum is no longer needed.
228-228: Force selection border to use SVG dialect
SetsselectionBorder.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'. ConfirmHandleConfiginteractions remain correct.
697-697: UsestrictHtmlfor preview when required
Switches from enum to'strictHtml'. Approved as equivalent behavior.
700-700: Default preview dialect to SVG
Setspreview.dialect = 'svg'in the non-HTML branch. Matches prior logic.
1983-1983: Replace enum in parent highlight with string literal
SetsparentHighlight.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 ofDIALECT.SVGis part of the broader refactor to remove theDIALECTenum. This ensures consistency with the new approach using theDialectValuetype.
637-637: String literal replaces enum constant for HTML dialect.Using
'strictHtml'directly in place ofDIALECT.STRICTHTMLaligns 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 theDIALECTenum.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 theDIALECT.STRICTHTMLenum 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 theDIALECTenum.
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
DialectValuetype from the types file, which is a more maintainable approach than using inline string unions.
146-146: Use type alias for dialect property.The
dialectproperty's type annotation has been updated to use the importedDialectValuetype alias instead of an inline string union. This improves code maintainability and consistency across the codebase.



Introduce the
DialectValuetype.BREAKING CHANGES: the DIALECT enum has been removed. Use the
DialectValuetype instead.Notes
Covers #378
Summary by CodeRabbit
DIALECTenum constant. All dialect assignments and checks now use string literals (e.g.,'svg','strictHtml').DialectValue, representing valid dialect string values.DialectValuetype.constants.DIALECTand its replacement withDialectValue.