-
-
Notifications
You must be signed in to change notification settings - Fork 363
feat(Vditor): add Vditor component #6228
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
Reviewer's GuideIntroduces a Vditor rich text editor component by adding sample pages and code-behind logic, updating navigation, localization, and documentation, refining preformatted styling, enhancing an existing sample, and extending unit tests for struct equality. Sequence Diagram for Vditor Mode ChangesequenceDiagram
actor User
participant VditorsPage as "Vditors.razor (UI)"
participant VditorsLogic as "Vditors.razor.cs (Backend)"
participant VditorComponent as "Vditor (JS Core)"
User->>VditorsPage: Selects new editor mode (e.g., IR)
VditorsPage->>VditorsLogic: OnModeChanged(newMode)
VditorsLogic->>VditorsLogic: _mode = newMode
VditorsLogic->>VditorsLogic: _vditorOptions.Mode = newMode
VditorsLogic->>VditorsLogic: _vditorValueString = "Content for newMode"
VditorsLogic->>VditorComponent: GetHtmlAsync()
VditorComponent-->>VditorsLogic: HTML content for newMode
VditorsLogic->>VditorsLogic: _htmlString = HTML content
VditorsLogic->>VditorsPage: Re-render UI (StateHasChanged)
Sequence Diagram for Vditor User Input and Value RetrievalsequenceDiagram
actor User
participant VditorsPage as "Vditors.razor (UI)"
participant VditorsLogic as "Vditors.razor.cs (Backend)"
participant VditorComponent as "Vditor (JS Core)"
User->>VditorComponent: Types content into editor
VditorComponent->>VditorsLogic: OnInputAsync(newMarkdownValue)
VditorsLogic->>VditorsLogic: _vditorValueString = newMarkdownValue
VditorsLogic->>VditorComponent: GetHtmlAsync()
VditorComponent-->>VditorsLogic: Rendered HTML content
VditorsLogic->>VditorsLogic: _htmlString = Rendered HTML content
VditorsLogic->>VditorsPage: Re-render UI with updated values (StateHasChanged)
User->>VditorsPage: Clicks "GetValue" button
VditorsPage->>VditorsLogic: OnTriggerGetValueAsync()
VditorsLogic->>VditorComponent: GetValueAsync()
VditorComponent-->>VditorsLogic: Current Markdown value
VditorsLogic->>VditorsLogic: _vditorValueString = Current Markdown value
VditorsLogic->>VditorsPage: Re-render UI to display value (StateHasChanged)
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6228 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 704 704
Lines 31113 31113
Branches 4398 4398
=========================================
Hits 31113 31113
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Hey @ArgoZhang - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/BootstrapBlazor.Server/Components/Samples/Vditors.razor:2` </location>
<code_context>
+@page "/vditor"
+@inject IOptionsMonitor<WebsiteOptions> WebsiteOption
+
+<h3>@Localizer["VditorTitle"]</h3>
</code_context>
<issue_to_address>
Remove unused injected service
Since `WebsiteOption` is not used, removing it will eliminate unnecessary warnings and dependencies.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
@page "/vditor"
@inject IOptionsMonitor<WebsiteOptions> WebsiteOption
<h3>@Localizer["VditorTitle"]</h3>
=======
@page "/vditor"
<h3>@Localizer["VditorTitle"]</h3>
>>>>>>> REPLACE
</suggested_fix>
### Comment 2
<location> `src/BootstrapBlazor.Server/Components/Samples/Vditors.razor:48` </location>
<code_context>
+ <textarea class="form-control" rows="6" disabled="disabled">@_vditorValueString</textarea>
+ </p>
+ <p>
+ <textarea class="form-control" rows="6" disabled="disabled"> @_htmlString</textarea>
+ </p>
+ <ConsoleLogger @ref="_logger"></ConsoleLogger>
</code_context>
<issue_to_address>
Remove leading space before binding
The whitespace before `@_htmlString` causes an extra space in the rendered textarea. Remove it or use `>@(_htmlString)` for correct output.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
<p>
<textarea class="form-control" rows="6" disabled="disabled"> @_htmlString</textarea>
</p>
=======
<p>
<textarea class="form-control" rows="6" disabled="disabled">@_htmlString</textarea>
</p>
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| @page "/vditor" | ||
| @inject IOptionsMonitor<WebsiteOptions> WebsiteOption | ||
|
|
||
| <h3>@Localizer["VditorTitle"]</h3> |
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.
suggestion: Remove unused injected service
Since WebsiteOption is not used, removing it will eliminate unnecessary warnings and dependencies.
| @page "/vditor" | |
| @inject IOptionsMonitor<WebsiteOptions> WebsiteOption | |
| <h3>@Localizer["VditorTitle"]</h3> | |
| @page "/vditor" | |
| <h3>@Localizer["VditorTitle"]</h3> |
| <p> | ||
| <textarea class="form-control" rows="6" disabled="disabled"> @_htmlString</textarea> | ||
| </p> |
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.
suggestion: Remove leading space before binding
The whitespace before @_htmlString causes an extra space in the rendered textarea. Remove it or use >@(_htmlString) for correct output.
| <p> | |
| <textarea class="form-control" rows="6" disabled="disabled"> @_htmlString</textarea> | |
| </p> | |
| <p> | |
| <textarea class="form-control" rows="6" disabled="disabled">@_htmlString</textarea> | |
| </p> |
Link issues
fixes #6227
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Add a new Vditor component sample with menu integration, update related docs and localization, and include a unit test for record equality scenarios
New Features:
Enhancements:
Tests: