Skip to content

feat(UniverSheet): add RibbonType parameter#855

Merged
ArgoZhang merged 2 commits intomasterfrom
feat-univer
Dec 22, 2025
Merged

feat(UniverSheet): add RibbonType parameter#855
ArgoZhang merged 2 commits intomasterfrom
feat-univer

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Dec 22, 2025

Link issues

fixes #854

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

Add support for configuring the UniverSheet toolbar style via a new ribbon type parameter and propagate it through to the JavaScript initializer.

New Features:

  • Introduce a UniverSheetRibbonType enum to represent available toolbar styles (default, classic, simple).
  • Expose a new RibbonType component parameter on UniverSheet and pass its value to the JavaScript init options so the toolbar style can be configured from .NET.

Copilot AI review requested due to automatic review settings December 22, 2025 04:15
@bb-auto bb-auto Bot added the enhancement New feature or request label Dec 22, 2025
@bb-auto bb-auto Bot added this to the v9.2.0 milestone Dec 22, 2025
@ArgoZhang ArgoZhang merged commit a3bf221 into master Dec 22, 2025
3 checks passed
@ArgoZhang ArgoZhang deleted the feat-univer branch December 22, 2025 04:15
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Dec 22, 2025

Reviewer's Guide

Adds a configurable ribbon style to the UniverSheet component by introducing a UniverSheetRibbonType enum parameter and propagating its value through the Blazor-to-JavaScript initialization pipeline.

Sequence diagram for passing RibbonType from Blazor to JavaScript

sequenceDiagram
    actor Developer
    participant Blazor as UniverSheet
    participant JSInterop
    participant Script as UniverSheet_razor_js
    participant UniverInstance as UniverSheetInstance

    Developer ->> Blazor: Set RibbonType parameter
    Developer ->> Blazor: Render UniverSheet
    Blazor ->> JSInterop: InvokeVoidAsync init(id, interop, options with RibbonType.ToDescriptionString)
    JSInterop ->> Script: init(id, invoke, options)
    Script ->> Script: Read theme, lang, plugins, data, ribbonType from options
    Script ->> UniverInstance: createUniverSheetAsync(univerSheet with ribbonType)
Loading

Class diagram for UniverSheet ribbon type parameter

classDiagram
    class UniverSheet {
        string Lang
        UniverSheetRibbonType RibbonType
        InvokeInitAsync() Task
    }

    class UniverSheetRibbonType {
        <<enumeration>>
        Default
        Classic
        Simple
    }

    UniverSheet --> UniverSheetRibbonType
Loading

File-Level Changes

Change Details Files
Introduce a typed ribbon-style parameter on the UniverSheet Blazor component and pass it into JS interop initialization.
  • Add a RibbonType [Parameter] of type UniverSheetRibbonType on the UniverSheet component with XML documentation
  • Include RibbonType (converted via ToDescriptionString) in the object passed to InvokeVoidAsync("init", ...) so it is available client-side
src/components/BootstrapBlazor.UniverSheet/Components/UniverSheet.razor.cs
Update the UniverSheet JavaScript initializer to accept and forward the ribbon type option.
  • Extend the init options destructuring to include ribbonType
  • Add ribbonType to the univerSheet configuration object passed to createUniverSheetAsync
src/components/BootstrapBlazor.UniverSheet/Components/UniverSheet.razor.js
Define an enum to represent supported ribbon styles and map them to descriptive string values used on the client side.
  • Create UniverSheetRibbonType enum with Default, Classic, and Simple values
  • Annotate enum members with Description attributes matching the expected client-side string values ("default", "classic", "simple")
src/components/BootstrapBlazor.UniverSheet/Components/UniverSheetRibbonType.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#854 Add a RibbonType parameter to the UniverSheet component and propagate it through initialization so the underlying UniverSheet instance can use it.

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

Copy link
Copy Markdown

@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 found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `src/components/BootstrapBlazor.UniverSheet/Components/UniverSheet.razor.cs:33-37` </location>
<code_context>
     [Parameter]
     public string? Lang { get; set; }

+    /// <summary>
+    /// 获得/设置 设置工具栏样式 默认 default 未设置
+    /// </summary>
+    [Parameter]
+    public UniverSheetRibbonType RibbonType { get; set; }
+
     /// <summary>
</code_context>

<issue_to_address>
**suggestion:** Explicitly initialize `RibbonType` to `UniverSheetRibbonType.Default` to make the intended default resilient to future enum changes.

This currently depends on `RibbonType` defaulting to the enum’s implicit `0` value being `Default`. If the enum order changes or a new value is added before `Default`, the runtime default will change unintentionally. Initializing it explicitly (e.g. `public UniverSheetRibbonType RibbonType { get; set; } = UniverSheetRibbonType.Default;`) makes the intended default robust to such changes.

```suggestion
    /// <summary>
    /// 获得/设置 设置工具栏样式 默认 default 未设置
    /// </summary>
    [Parameter]
    public UniverSheetRibbonType RibbonType { get; set; } = UniverSheetRibbonType.Default;
```
</issue_to_address>

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.

Comment on lines +33 to +37
/// <summary>
/// 获得/设置 设置工具栏样式 默认 default 未设置
/// </summary>
[Parameter]
public UniverSheetRibbonType RibbonType { get; set; }
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Explicitly initialize RibbonType to UniverSheetRibbonType.Default to make the intended default resilient to future enum changes.

This currently depends on RibbonType defaulting to the enum’s implicit 0 value being Default. If the enum order changes or a new value is added before Default, the runtime default will change unintentionally. Initializing it explicitly (e.g. public UniverSheetRibbonType RibbonType { get; set; } = UniverSheetRibbonType.Default;) makes the intended default robust to such changes.

Suggested change
/// <summary>
/// 获得/设置 设置工具栏样式 默认 default 未设置
/// </summary>
[Parameter]
public UniverSheetRibbonType RibbonType { get; set; }
/// <summary>
/// 获得/设置 设置工具栏样式 默认 default 未设置
/// </summary>
[Parameter]
public UniverSheetRibbonType RibbonType { get; set; } = UniverSheetRibbonType.Default;

Copy link
Copy Markdown

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 adds a RibbonType parameter to the UniverSheet component, allowing users to configure the toolbar style. The implementation introduces a new enum with three style options (Default, Classic, Simple) and passes this configuration from C# to JavaScript.

Key Changes:

  • Introduces UniverSheetRibbonType enum with three toolbar style options
  • Adds RibbonType parameter to UniverSheet component with automatic conversion to JavaScript-compatible string format
  • Version bump from 10.0.2 to 10.0.3

Reviewed changes

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

File Description
UniverSheetRibbonType.cs New enum defining three ribbon/toolbar style options with Description attributes for JavaScript interop
UniverSheet.razor.cs Adds RibbonType parameter and includes it in JavaScript initialization call
UniverSheet.razor.js Extracts ribbonType from options and passes it to the univer initialization
BootstrapBlazor.UniverSheet.csproj Version bump to 10.0.3 for the new feature

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

@@ -0,0 +1,31 @@
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

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

The website URL in this file is "https://www.blazor.zone", which is inconsistent with other files in the same directory (e.g., UniverSheetData.cs, UniverSheet.razor.cs) that use "https://www.blazor.zone or https://argozhang.github.io/". The header format should be consistent across all files in the component.

Suggested change
// Website: https://www.blazor.zone
// Website: https://www.blazor.zone or https://argozhang.github.io/

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +37
/// <summary>
/// 获得/设置 设置工具栏样式 默认 default 未设置
/// </summary>
[Parameter]
public UniverSheetRibbonType RibbonType { get; set; }
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

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

The RibbonType parameter will always send a value to JavaScript (defaulting to "default" when not explicitly set by the user), which means the JavaScript fallback ?? 'simple' in univer.js line 62 will never be used. Additionally, the documentation comment "默认 default 未设置" (defaults to default, not set) is ambiguous. Consider making the RibbonType property nullable (UniverSheetRibbonType?) to allow it to truly be unset and align with the JavaScript fallback behavior, or update the documentation to clearly state that it defaults to the Default enum value.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,31 @@
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved.
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

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

The copyright header in this file uses "BootstrapBlazor & Argo Zhang (argo@live.ca)", which is inconsistent with other files in the same directory (e.g., UniverSheetData.cs, UniverSheet.razor.cs) that use "Argo Zhang (argo@163.com)". The copyright header should be consistent across all files in the component.

Suggested change
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved.
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.

Copilot uses AI. Check for mistakes.
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(UniverSheet): add RibbonType parameter

2 participants