Skip to content

feat(PdfReader): support Watermark component #405

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 5 commits into from
Apr 29, 2025

Conversation

densen2014
Copy link
Collaborator

@densen2014 densen2014 commented Apr 17, 2025

Link issues

fixes #418

Summary By Copilot

feat(PdfReader ): 全局水印(Watermark IsPage="true")未应用到演示模式中

dotnetcore/BootstrapBlazor#5811 (comment)

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Enhance PDF reader watermark functionality to support displaying watermark only during full-screen presentation mode

New Features:

  • Add a new parameter WatermarkDemoModeOnly to control watermark visibility in PDF reader

Enhancements:

  • Modify JavaScript to dynamically show/hide watermark based on full-screen state
  • Update URL generation to include new watermark demo mode parameter

Copy link

bb-auto bot commented Apr 17, 2025

Thanks for your PR, @densen2014. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

Copy link

sourcery-ai bot commented Apr 17, 2025

Reviewer's Guide by Sourcery

This pull request introduces a new feature to the PDF reader component that allows the watermark to be displayed only when the PDF is in fullscreen presentation mode. This is achieved by adding a new WatermarkDemoModeOnly parameter to the PdfReader component and modifying the JavaScript code to handle the conditional display of the watermark based on the fullscreen state.

Sequence diagram for Watermark display in fullscreen mode

sequenceDiagram
    participant User
    participant PdfReader.razor.cs
    participant limit.js
    participant Browser

    User->>PdfReader.razor.cs: Sets WatermarkDemoModeOnly to true and Watermark
    PdfReader.razor.cs->>PdfReader.razor.cs: GenUrl()
    PdfReader.razor.cs-->>Browser: Generates URL with wmonlydemo=true and wm=Watermark
    Browser->>limit.js: Loads limit.js with URL parameters
    limit.js->>Browser: Adds 'fullscreenchange' event listener
    Browser->>User: User enters fullscreen mode
    Browser->>limit.js: 'fullscreenchange' event triggered
    limit.js->>limit.js: Checks if viewerContainer is in fullscreen
    alt viewerContainer is in fullscreen
        limit.js->>Browser: Sets watermark value
    else viewerContainer is not in fullscreen
        limit.js->>Browser: Clears watermark value
    end
Loading

File-Level Changes

Change Details Files
Added a new parameter to the PdfReader component to control watermark display behavior in demo mode.
  • Introduced the WatermarkDemoModeOnly parameter to conditionally display the watermark only in fullscreen presentation mode.
  • Modified the URL generation logic to include the wmonlydemo parameter based on the WatermarkDemoModeOnly property.
src/components/BootstrapBlazor.PdfReader/PdfReader.razor.cs
Modified JavaScript code to handle conditional watermark display based on fullscreen mode.
  • Added a check for the wmonlydemo query parameter.
  • Implemented an event listener for fullscreen changes to update the watermark value based on the fullscreen state.
  • The watermark value is cleared when exiting fullscreen mode.
src/components/BootstrapBlazor.PdfReader/wwwroot/web/limit.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@bb-auto bb-auto bot requested a review from ArgoZhang April 17, 2025 13:15
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @densen2014 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider debouncing the fullscreen event listener to avoid excessive updates to the watermark.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@ArgoZhang ArgoZhang changed the title PDF阅读器水印内容仅在全屏演示状态显示 #5811 feat(PdfReader): support Watermark component Apr 29, 2025
@bb-auto bb-auto bot added the enhancement New feature or request label Apr 29, 2025
@bb-auto bb-auto bot added this to the v9.2.0 milestone Apr 29, 2025
@ArgoZhang ArgoZhang merged commit 770cbda into master Apr 29, 2025
1 check passed
@ArgoZhang ArgoZhang deleted the pdfReader_WatermarkDemoModeOnly#5811 branch April 29, 2025 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(PdfReader): support Watermark component
2 participants