Skip to content

feat!: add HasValue support #14

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 6 commits into from
May 21, 2025
Merged

feat!: add HasValue support #14

merged 6 commits into from
May 21, 2025

Conversation

javier-godoy
Copy link
Member

@javier-godoy javier-godoy commented Apr 8, 2025

I had to add an intermediate class since there is no "CustomReactFieldAdapter". I tried to use CustomField instead of AbstractCompositeField but it didn't handle state synchronization properly. (Still, it’s a breaking change because I had to change the class hierarchy.)

Close #13

Summary by CodeRabbit

  • Chores

    • Updated the Markdown Editor add-on version to 2.0.0-SNAPSHOT.
  • New Features

    • Introduced enhanced content management with a more intuitive value API and customizable input settings.
    • Added support for adjusting color modes to tailor the editing experience.
    • Added a new demo showcasing data binding integration with the Markdown Editor.
  • Refactor

    • Streamlined the editor’s core structure to deliver a more consistent and reliable experience.

@javier-godoy javier-godoy requested review from mlopezFC and paodb April 8, 2025 20:00
Copy link

coderabbitai bot commented Apr 8, 2025

"""

Walkthrough

This pull request updates the version number in the Maven configuration and refactors the markdown editor’s core classes. The primary editor class now extends a composite field class and implements additional interfaces, introducing new constructors and methods such as setting a data color mode. A new helper component class is added to manage editor state and configuration. The demo file has been updated to use the new value-based getter and setter methods. Additionally, a new demo illustrating Binder integration is added and included in the main demo view.

Changes

File(s) Change Summary
pom.xml Updated version for markdown-editor-addon from 1.1.1-SNAPSHOT to 2.0.0-SNAPSHOT.
src/main/java/.../MarkdownEditor.java Changed class inheritance to extend AbstractCompositeField<MarkdownEditorComponent, MarkdownEditor, String> and implement HasSize; added new constructors; introduced setDataColorMode(DataColorMode mode) and updated getter/setter implementations to delegate to the component.
src/main/java/.../MarkdownEditorComponent.java Added new class serving as a React adapter for the markdown editor, with constructors and methods for managing placeholder text and maximum character length.
src/test/java/.../MarkdownEditorDemo.java Modified demo usage by replacing getContent()/setContent() with getValue()/setValue(), and updated the copyright notice.
src/test/java/.../MarkdownBinderDemo.java Added new demo class demonstrating MarkdownEditor integration with Vaadin Binder for data binding.
src/test/java/.../MarkdownDemoView.java Updated constructor to add MarkdownBinderDemo to the list of demos displayed.

Assessment against linked issues

Objective Addressed Explanation
Add HasValue support (#13)
"""

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7524274 and b1e4dab.

📒 Files selected for processing (2)
  • src/test/java/com/flowingcode/vaadin/addons/markdown/MarkdownBinderDemo.java (1 hunks)
  • src/test/java/com/flowingcode/vaadin/addons/markdown/MarkdownDemoView.java (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/test/java/com/flowingcode/vaadin/addons/markdown/MarkdownBinderDemo.java (1)
src/test/java/com/flowingcode/vaadin/addons/markdown/MarkdownDemoView.java (1)
  • SuppressWarnings (28-40)
🔇 Additional comments (4)
src/test/java/com/flowingcode/vaadin/addons/markdown/MarkdownDemoView.java (1)

37-37: Good addition of the Binder demo to showcase new functionality!

Adding the MarkdownBinderDemo to the tabbed demo view is a good way to showcase the new HasValue support, which allows for integration with Vaadin's data binding system. This change aligns well with the PR's objective of adding HasValue support.

src/test/java/com/flowingcode/vaadin/addons/markdown/MarkdownBinderDemo.java (3)

31-66: Well-implemented demo class for showcasing Binder integration!

This demo effectively demonstrates how to use the new HasValue support in MarkdownEditor with Vaadin's Binder. The class is well-structured and shows the complete workflow from creating a bean to binding the editor and interacting with the data model.

The implementation correctly:

  • Creates a Binder for a specific bean type
  • Configures the MarkdownEditor with appropriate properties
  • Uses the Binder.forField() method to establish binding
  • Provides UI controls to demonstrate both reading and writing values
  • Uses the new HasValue-compliant API (setValue instead of setContent)

This addresses the PR comment suggestion to add a demo illustrating how the new implementation works.


42-43: Good demonstration of editor configuration options!

Showing how to set placeholder text and maximum length constraints is helpful for users as it demonstrates additional configuration capabilities beyond just the basic binding functionality.


55-65: Bean implementation follows best practices.

The Bean class is correctly implemented as a static inner class with proper getter and setter methods, making it compatible with Vaadin's Binder. This is a good, minimal example that focuses on the binding functionality without unnecessary complexity.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Member

@mlopezFC mlopezFC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to have the MarkdownEditorComponent class with the default package visibility?

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (2)
src/main/java/com/flowingcode/vaadin/addons/markdown/MarkdownEditor.java (2)

115-117: Nit: parameter name does not follow Java conventions

maxlength mixes camelCase and lowercase. Prefer maxLength for consistency
with the getter (getMaxLength()).

-public void setMaxLength(int maxlength) {
-  getEditor().setMaxLength(maxlength);
+public void setMaxLength(int maxLength) {
+  getEditor().setMaxLength(maxLength);
 }

23-25: Unused import?

If DataColorMode is only referenced inside MarkdownEditorComponent, you can
remove the wildcard import here to keep the public API minimal.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fd8a7d2 and d954f25.

📒 Files selected for processing (2)
  • src/main/java/com/flowingcode/vaadin/addons/markdown/MarkdownEditor.java (3 hunks)
  • src/main/java/com/flowingcode/vaadin/addons/markdown/MarkdownEditorComponent.java (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/main/java/com/flowingcode/vaadin/addons/markdown/MarkdownEditorComponent.java

@javier-godoy
Copy link
Member Author

Wouldn't it be better to have the MarkdownEditorComponent class with the default package visibility?

Since MarkdownEditor is an AbstractCompositeField<MarkdownEditorComponent, ?, ?> and getContent() returns MarkdownEditorComponent, it's no longer possible to call getContent() from client code (Not that I see a reason to call it, though). In any case, we can always make it public later.

Kudos for stepping away from the 'everything must be public' trap. That's a SOLID move.

@javier-godoy javier-godoy requested a review from mlopezFC April 25, 2025 19:06
@paodb
Copy link
Member

paodb commented May 6, 2025

Would be nice to add a demo to show how this new implementation works.

@javier-godoy
Copy link
Member Author

Would be nice to add a demo to show how this new implementation works.

Done

@paodb paodb merged commit a607206 into master May 21, 2025
3 checks passed
@paodb paodb deleted the feat-hasValue branch May 21, 2025 20:40
@github-project-automation github-project-automation bot moved this from To Do to Pending release in Flowing Code Addons May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Pending release
Development

Successfully merging this pull request may close these issues.

Add HasValue support
3 participants