-
Notifications
You must be signed in to change notification settings - Fork 2
Refactor useMark hook and rename API properties #112
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
Conversation
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
- Replaced direct child rendering logic in Piece with useMark hook to manage children as ReactNode. - Introduced useMark hook to encapsulate mark handling, including depth, parent, and child token management. - Updated related tests and documentation to reflect changes in child handling and mark properties. - Adjusted Storybook examples to use updated mark properties for consistency.
…ular dependency resolution - Updated Piece component to render children directly, eliminating the use of the useMark hook for child rendering, thus breaking the circular import. - Introduced MarkTokenComponent and TextTokenComponent in the Token component for better type discrimination and compile-time safety. - Enhanced MarkHandler class to compute depth, parent, and child tokens lazily, improving performance and clarity. - Updated documentation links in API references to reflect changes in the useMark hook and MarkHandler interface. - Adjusted related tests and Storybook examples to align with the new component structure and type safety improvements.
… functionality - Simplified the useListener implementation in the Container component for better readability. - Refactored the MarkHandler class to enhance the management of mark properties, including the introduction of content as a key property instead of label. - Updated the change method to accept a more structured props object, allowing for simultaneous updates to content, value, and meta. - Adjusted related documentation to reflect changes in the MarkHandler interface and its properties. - Modified tests to ensure compatibility with the updated MarkHandler structure and behavior.
- Introduced the MarkHandler class to encapsulate mark management, including content, value, and meta properties. - Implemented methods for changing mark properties and removing marks, enhancing interaction with the store. - Added utility functions for calculating nesting depth and finding parent marks, improving mark structure handling. - Refactored useMark hook to utilize the new MarkHandler class, streamlining mark-related logic and improving clarity.
…tation - Updated the MarkHandler class to streamline property management by consolidating change notifications into a private method. - Enhanced documentation for properties and methods, improving clarity and organization. - Removed redundant comments and improved the structure of the code for better readability. - Adjusted the export path for MarkHandler in the index file to reflect the new class location.
…t retrieval - Replaced the calculateDepth and findParent functions with a new findToken utility to streamline the retrieval of depth and parent mark tokens. - Improved the MarkHandler class by enhancing the efficiency of depth and parent property calculations. - Removed redundant helper functions, simplifying the code structure and improving maintainability.
… safety - Removed separate MarkTokenComponent and TextTokenComponent, consolidating rendering logic within the Token component. - Enhanced type safety by directly using TokenProvider for both mark and text rendering. - Streamlined the component structure for better readability and maintainability.
…rove type safety - Renamed Piece component to MarkRenderer for clarity. - Simplified child rendering logic by directly mapping children tokens. - Enhanced type safety by ensuring MarkProps are constructed correctly based on children presence.
- Streamlined the child rendering logic by directly mapping children tokens. - Improved code clarity by removing unnecessary line breaks in the rendering process.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
MarkHandlerclass to encapsulate mark state management with proper getters/settersutils→libwithclasses,hooks,utilssubdirectoriesPiececomponent toMarkRendererfor clarityTokencomponent rendering logic with early returnsfindTokenutility for traversing token treeBreaking Changes
label→content: Renamed property for displayed text of the markchildren→tokens: Renamed property for child tokens arraychange()signature: Updated from{label, value}to{content, value?, meta?}