Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts the Vditor component to render the editor inside a dedicated container element and updates styling selectors accordingly, ensuring validation styles apply to the inner Vditor instance while preserving re-initialization behavior. Sequence diagram for updated Vditor initialization and resetsequenceDiagram
actor BlazorComponent
participant JSModule as JSModule_Vditor_razor_js
participant DOM as Document
participant DataStore as DataModule
participant VditorClass as Vditor
BlazorComponent->>JSModule: init(id, invoke, options)
JSModule->>DOM: getElementById(id)
DOM-->>JSModule: el
JSModule->>JSModule: addLink(css)
JSModule->>JSModule: addScript(js)
JSModule->>DOM: el.querySelector(.bb-vditor-container)
DOM-->>JSModule: root
JSModule->>VditorClass: new Vditor(root, getOptions(invoke, optionsWithValue))
VditorClass-->>JSModule: vditorInstance
JSModule->>DataStore: set(id, { el, invoke, vditor })
DataStore-->>JSModule: stored
JSModule-->>BlazorComponent: vditorInstance
BlazorComponent->>JSModule: reset(id, value, options)
JSModule->>DataStore: get(id)
DataStore-->>JSModule: { el, invoke, vditor }
JSModule->>VditorClass: vditor.destroy()
JSModule->>DOM: el.querySelector(.bb-vditor-container)
DOM-->>JSModule: root
JSModule->>VditorClass: new Vditor(root, getOptions(invoke, optionsWithValue))
VditorClass-->>JSModule: newVditorInstance
JSModule->>DataStore: update(id, { el, invoke, vditor })
DataStore-->>JSModule: updated
JSModule-->>BlazorComponent: newVditorInstance
Flow diagram for updated Vditor DOM structure and stylingflowchart TD
A[bb_vditor_root_div
class: ClassString
id: Id] --> B[bb_vditor_container_div
class: bb-vditor-container]
B --> C[vditor_inner_root
class: vditor
created by Vditor]
subgraph ValidationClasses[Validation state on bb_vditor_root_div]
D[bb-vditor_root_div.hasClass is-invalid] --> E[CSS selector
.bb-vditor.is-invalid .vditor]
F[bb-vditor_root_div.hasClass is-valid] --> G[CSS selector
.bb-vditor.is-valid .vditor]
end
E --> C
G --> C
subgraph Styles[Border styling applied to inner vditor]
H[.bb-vditor .vditor] --> I[border-radius
overflow hidden]
E --> J[border-color: bs-danger]
G --> K[border-color: bs-success]
end
C --> I
C --> J
C --> K
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- In both
initandreset, consider guarding againstel.querySelector('.bb-vditor-container')returning null and either throwing a clearer error or no-oping, to avoid a hard runtime crash if the markup is ever changed or misused. - Since
resetneeds the.bb-vditor-containeragain, you might store the container element alongsideelinData.setduringinitto avoid repeated DOM queries and keep the code slightly simpler.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In both `init` and `reset`, consider guarding against `el.querySelector('.bb-vditor-container')` returning null and either throwing a clearer error or no-oping, to avoid a hard runtime crash if the markup is ever changed or misused.
- Since `reset` needs the `.bb-vditor-container` again, you might store the container element alongside `el` in `Data.set` during `init` to avoid repeated DOM queries and keep the code slightly simpler.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull request overview
This PR modifies the Vditor component to support usage within edit forms by restructuring the component's DOM hierarchy. The changes ensure that the Vditor editor is initialized within a dedicated container element rather than directly on the component's root element, allowing for proper form validation styling.
Key Changes:
- Restructured the Vditor component to use a dedicated container element for editor initialization
- Updated CSS selectors to target the nested Vditor instance for validation states
- Bumped package version to 10.0.2
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| vditor.css | Updated CSS selectors to target nested .vditor elements for border styling and validation states |
| Vditor.razor.js | Modified initialization and reset logic to query and use the .bb-vditor-container element instead of the root element |
| Vditor.razor | Added a nested bb-vditor-container div inside the root component element |
| BootstrapBlazor.Vditor.csproj | Incremented version from 10.0.1 to 10.0.2 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Link issues
fixes #752
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Integrate Vditor with a dedicated inner container element and adjust styling and reinitialization logic to target that container rather than the outer wrapper.
Enhancements: