Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Dec 24, 2025

Link issues

fixes #862

Summary By Copilot

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

Simplify the SummerNote editor integration by removing support for global JavaScript callback registration and clarifying the IsEditor parameter documentation.

Enhancements:

  • Remove reliance on the global BootstrapBlazor.SummerNote.callbacks mechanism from the SummerNote editor initialization script.
  • Clarify the C# Editor component IsEditor parameter XML comment to document its default behavior.

Copilot AI review requested due to automatic review settings December 24, 2025 03:20
@bb-auto bb-auto bot added the enhancement New feature or request label Dec 24, 2025
@bb-auto bb-auto bot added this to the v9.2.0 milestone Dec 24, 2025
@sourcery-ai
Copy link

sourcery-ai bot commented Dec 24, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors the SummerNote editor integration by removing the global BootstrapBlazor.SummerNote.callbacks wiring in JavaScript and making a small documentation improvement to the Editor IsEditor parameter.

Sequence diagram for SummerNote editor initialization and image upload callback after callbacks refactor

sequenceDiagram
    actor Developer
    participant EditorComponent
    participant JSRuntime
    participant EditorJs
    participant DataStore
    participant SummernoteInstance

    Developer->>EditorComponent: Render Editor
    EditorComponent->>JSRuntime: InvokeVoidAsync init(id, invoker, methods, height, value, lang,...)
    JSRuntime->>EditorJs: init(id, invoker, methodGetPluginAttrs, methodClickPluginItem, height, value, lang, langUrl, hasUpload)

    EditorJs->>EditorJs: const el = document.getElementById(id)
    EditorJs->>EditorJs: Build toolbar and option
    EditorJs->>EditorJs: option.toolbar = toolbar
    alt hasUpload is true
        EditorJs->>EditorJs: option.callbacks.onImageUpload = async files => {...}
    end
    EditorJs->>SummernoteInstance: Initialize summernote with option
    EditorJs->>DataStore: Data.set(id, editor)

    rect rgb(230,230,250)
        SummernoteInstance-->>EditorJs: onImageUpload(files)
        EditorJs->>EditorJs: editor.files = files
        EditorJs->>EditorJs: await addUploadScriptIfNeeded()
        EditorJs->>JSRuntime: invoker.invokeMethodAsync(methodClickPluginItem, ...)
    end
Loading

File-Level Changes

Change Details Files
Remove use of global BootstrapBlazor.SummerNote.callbacks from the SummerNote editor initialization JavaScript.
  • Stop creating a global window.BootstrapBlazor object when undefined.
  • Stop invoking reloadCallbacks during SummerNote initialization so options are no longer patched from global callbacks.
  • Delete the reloadCallbacks helper that mapped global callback definitions onto the SummerNote callbacks option.
src/components/BootstrapBlazor.SummerNote/Components/Editor/Editor.razor.js
Clarify the meaning of the IsEditor parameter in the editor component.
  • Update the XML summary comment for IsEditor to explicitly document that the default is false.
src/components/BootstrapBlazor.SummerNote/Components/Editor/Editor.razor.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#862 Remove use of the global BootstrapBlazor.SummerNote.callbacks mechanism from the Editor component implementation.

Possibly linked issues


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!

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

@ArgoZhang ArgoZhang merged commit 6c05499 into master Dec 24, 2025
3 of 4 checks passed
@ArgoZhang ArgoZhang deleted the refactor-editor branch December 24, 2025 03:20
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 - I've left some high level feedback:

  • Removing the window.BootstrapBlazor.SummerNote.callbacks wiring is a breaking change for anyone using those global callbacks; consider either providing a migration path (e.g., a new event API on the component) or adding a runtime warning when callbacks are still present to make the breakage more discoverable.
  • Now that the global BootstrapBlazor object creation is removed from this file, double-check that no other SummerNote-related scripts still rely on window.BootstrapBlazor being defined implicitly here, or consider centralizing its initialization in a single shared script if it is still needed elsewhere.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Removing the `window.BootstrapBlazor.SummerNote.callbacks` wiring is a breaking change for anyone using those global callbacks; consider either providing a migration path (e.g., a new event API on the component) or adding a runtime warning when callbacks are still present to make the breakage more discoverable.
- Now that the global `BootstrapBlazor` object creation is removed from this file, double-check that no other SummerNote-related scripts still rely on `window.BootstrapBlazor` being defined implicitly here, or consider centralizing its initialization in a single shared script if it is still needed elsewhere.

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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the Editor component by removing the legacy BootstrapBlazor.SummerNote.callbacks functionality that allowed external JavaScript code to register custom event callbacks. The change simplifies the codebase by removing unused infrastructure while maintaining all existing component functionality.

Key Changes:

  • Removed the reloadCallbacks function and associated callback registration mechanism from the JavaScript initialization
  • Removed the BootstrapBlazor namespace initialization check that was only needed for the callbacks feature
  • Updated documentation for the IsEditor property to include default value
  • Bumped package version to 10.0.2

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
Editor.razor.js Removed callback registration infrastructure including the reloadCallbacks function and BootstrapBlazor namespace initialization
Editor.razor.cs Enhanced documentation by adding default value information to the IsEditor property comment
BootstrapBlazor.SummerNote.csproj Version bump from 10.0.1 to 10.0.2 reflecting the refactoring changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

refactor(Editor): remove BootstrapBlazor.SummerNote.callbacks

2 participants