-
-
Notifications
You must be signed in to change notification settings - Fork 364
feat(IHtml2Image): add IHtml2Image service #5421
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 Guide by SourceryThis pull request introduces the IHtml2Image service, which allows exporting HTML elements to images. It includes the service implementation, a demo page, documentation updates, and localization support. Sequence diagram for Html2Image service usagesequenceDiagram
participant RazorComponent as Component
participant IHtml2Image as Service
participant DefaultHtml2ImageService as Implementation
participant IJSRuntime as JSRuntime
Component->>Service: GetDataAsync(selector, options)
Service->>Implementation: GetDataAsync(selector, options)
Implementation->>JSRuntime: LoadModuleByName("html2image")
alt jsModule is null
JSRuntime-->>Implementation: jsModule
end
Implementation->>JSRuntime: InvokeAsync("execute", selector, "toPng", options)
JSRuntime-->>Implementation: data
Implementation-->>Service: data
Service-->>Component: data
Updated class diagram for Html2Image serviceclassDiagram
class IHtml2Image {
+GetDataAsync(string selector, Html2ImageOptions options) Task~string~
+GetStreamAsync(string selector, Html2ImageOptions options) Task~Stream~
}
class DefaultHtml2ImageService {
-runtime: IJSRuntime
-logger: ILogger~DefaultHtml2ImageService~
-jsModule: JSModule
+GetDataAsync(string selector, Html2ImageOptions options) Task~string~
+GetStreamAsync(string selector, Html2ImageOptions options) Task~Stream~
-Execute(string selector, string methodName, Html2ImageOptions options) Task~string~
-ToBlob(string selector, Html2ImageOptions options) Task~Stream~
}
class Html2ImageOptions {
+IncludeStyleProperties: List~string~
}
IHtml2Image <|-- DefaultHtml2ImageService
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.
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 - here's some feedback:
Overall Comments:
- Consider adding a try-catch block around the
runtime.LoadModuleByNamecall inDefaultHtml2ImageService.csto handle potential module loading failures more gracefully. - The new razor component
Html2Images.razor.csis missing a summary for the class.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5421 +/- ##
===========================================
- Coverage 100.00% 99.87% -0.13%
===========================================
Files 644 646 +2
Lines 29359 29398 +39
Branches 4128 4133 +5
===========================================
+ Hits 29359 29360 +1
- Misses 0 38 +38 ☔ View full report in Codecov by Sentry. |
add IHtml2Image service
Summary of the changes (Less than 80 chars)
简单描述你更改了什么, 不超过80个字符;如果有关联 Issue 请在下方填写相关编号
Description
fixes #5418
Regression?
[If yes, specify the version the behavior has regressed from]
[是否影响老版本]
Risk
[Justify the selection above]
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
This pull request introduces a new service, IHtml2Image, that allows exporting HTML elements as images. It includes the service implementation, interface definition, options, a demo page, and necessary configurations.
New Features:
Enhancements:
Build: