Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>10.0.6</Version>
<Version>10.0.7</Version>
</PropertyGroup>

<PropertyGroup>
<PackageTags>Bootstrap Blazor WebAssembly wasm UI Components Univer Sheet Excel</PackageTags>
<Description>Bootstrap UI components extensions of Univer Sheet</Description>
</PropertyGroup>

<ItemGroup>
<Content Remove="Locales\*.json" />
<EmbeddedResource Include="Locales\*.json" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="BootstrapBlazor" Version="$(BBVersion)" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@
@inherits BootstrapModuleComponentBase
@attribute [JSModuleAutoLoader("./_content/BootstrapBlazor.UniverSheet/Components/UniverSheet.razor.js", JSObjectReference = true)]

<div @attributes="@AdditionalAttributes" class="@ClassString" id="@Id"></div>
<div @attributes="@AdditionalAttributes" class="@ClassString" id="@Id" style="position: relative; overflow: hidden;">
<div class="bb-univer-sheet-wrap" style="height: 100%;"></div>
<div class="bb-univer-sheet-backdrop" style="background-color: #000; opacity: 0.3; position: absolute; inset: 0; z-index: 1205; display: flex; align-items: center; justify-content: center;">
Comment on lines +5 to +7
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider moving inline styles to CSS to keep layout/styling consistent and maintainable.

These elements now depend on complex inline styles for positioning and centering. Moving these into CSS classes (e.g., extending .bb-univer-sheet and defining .bb-univer-sheet-backdrop) will simplify future layout/theming changes and prevent clashes with user inline styles from AdditionalAttributes.

Suggested implementation:

<div @attributes="@AdditionalAttributes" class="@($"{ClassString} bb-univer-sheet")" id="@Id">
    <div class="bb-univer-sheet-wrap"></div>
    <div class="bb-univer-sheet-backdrop">
        <div class="bb-univer-sheet-loading-text">@LoadingText</div>
    </div>
</div>

To complete the refactor away from inline styles, add CSS for these classes in the appropriate stylesheet (e.g. UniverSheet.razor.css, the library's main .css, or a shared theme file):

.bb-univer-sheet {
    position: relative;
    overflow: hidden;
}

.bb-univer-sheet-wrap {
    height: 100%;
}

.bb-univer-sheet-backdrop {
    background-color: #000;
    opacity: 0.3;
    position: absolute;
    inset: 0;
    z-index: 1205;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bb-univer-sheet-loading-text {
    color: #fff;
}

If ClassString already includes bb-univer-sheet, adjust the class attribute to avoid duplication (e.g. via the existing class-composition helper used elsewhere in the codebase).

Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

The loading backdrop lacks accessibility attributes. Consider adding role="status" and aria-live="polite" to the backdrop div to inform screen reader users that content is loading.

Suggested change
<div class="bb-univer-sheet-backdrop" style="background-color: #000; opacity: 0.3; position: absolute; inset: 0; z-index: 1205; display: flex; align-items: center; justify-content: center;">
<div class="bb-univer-sheet-backdrop" role="status" aria-live="polite" style="background-color: #000; opacity: 0.3; position: absolute; inset: 0; z-index: 1205; display: flex; align-items: center; justify-content: center;">

Copilot uses AI. Check for mistakes.
<div style="color: #fff;">@LoadingText</div>
</div>
</div>
Comment on lines +5 to +10
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

Inline styles should be extracted to a CSS class for better maintainability. The backdrop styling on line 7 and the wrapper on line 6 contain multiple inline styles that would be better managed in a stylesheet.

Suggested change
<div @attributes="@AdditionalAttributes" class="@ClassString" id="@Id" style="position: relative; overflow: hidden;">
<div class="bb-univer-sheet-wrap" style="height: 100%;"></div>
<div class="bb-univer-sheet-backdrop" style="background-color: #000; opacity: 0.3; position: absolute; inset: 0; z-index: 1205; display: flex; align-items: center; justify-content: center;">
<div style="color: #fff;">@LoadingText</div>
</div>
</div>
<div @attributes="@AdditionalAttributes" class="@ClassString bb-univer-sheet-root" id="@Id">
<div class="bb-univer-sheet-wrap bb-univer-sheet-wrap-fullheight"></div>
<div class="bb-univer-sheet-backdrop bb-univer-sheet-backdrop-style">
<div class="bb-univer-sheet-loading-text">@LoadingText</div>
</div>
</div>
<style>
.bb-univer-sheet-root {
position: relative;
overflow: hidden;
}
.bb-univer-sheet-wrap-fullheight {
height: 100%;
}
.bb-univer-sheet-backdrop-style {
background-color: #000;
opacity: 0.3;
position: absolute;
inset: 0;
z-index: 1205;
display: flex;
align-items: center;
justify-content: center;
}
.bb-univer-sheet-loading-text {
color: #fff;
}
</style>

Copilot uses AI. Check for mistakes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Website: https://www.blazor.zone or https://argozhang.github.io/

using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

The NotNull attribute is used on line 64, but the required namespace System.Diagnostics.CodeAnalysis is not imported. Add using System.Diagnostics.CodeAnalysis; to the using statements to resolve this compilation issue.

Suggested change
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Localization;
using System.Diagnostics.CodeAnalysis;

Copilot uses AI. Check for mistakes.
using System.Globalization;

namespace BootstrapBlazor.Components;
Expand Down Expand Up @@ -48,12 +49,21 @@ public partial class UniverSheet
[Parameter]
public UniverSheetData? Data { get; set; }

/// <summary>
/// 获得/设置 正在加载显示文本 默认 null 未设置读取资源文件
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

The XML documentation comment is in Chinese. The comment states "获得/设置 正在加载显示文本 默认 null 未设置读取资源文件" which appears to be missing punctuation and spacing. It should read: "获得/设置 正在加载显示文本 默认 null 未设置,读取资源文件" with a comma added before "读取资源文件" for proper grammar.

Suggested change
/// 获得/设置 正在加载显示文本 默认 null 未设置读取资源文件
/// 获得/设置 正在加载显示文本 默认 null 未设置,读取资源文件

Copilot uses AI. Check for mistakes.
/// </summary>
[Parameter]
public string? LoadingText { get; set; }

/// <summary>
/// 获得/设置 Frame 加载页面传递过来的数据
/// </summary>
[Parameter]
public Func<UniverSheetData?, Task<UniverSheetData?>>? OnPostDataAsync { get; set; }

[Inject, NotNull]
private IStringLocalizer<UniverSheet>? Localizer { get; set; }

private string? ClassString => CssBuilder.Default("bb-univer-sheet")
.AddClassFromAttributes(AdditionalAttributes)
.Build();
Expand All @@ -78,6 +88,7 @@ protected override void OnParametersSet()
base.OnParametersSet();

Lang ??= CultureInfo.CurrentUICulture.Name;
LoadingText ??= Localizer[nameof(LoadingText)];
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,22 @@ export async function init(id, invoke, options) {

const { theme, lang, plugins, data, ribbonType, darkMode } = options;
const univerSheet = {
el,
el: el.querySelector('.bb-univer-sheet-wrap'),
invoke,
data,
plugins,
theme,
lang,
ribbonType,
darkMode
darkMode,
events: {
onRendered: () => {
const backdrop = el.querySelector('.bb-univer-sheet-backdrop');
if (backdrop) {
backdrop.classList.add('d-none');
}
}
}
};

await createUniverSheetAsync(univerSheet);
Expand Down
5 changes: 5 additions & 0 deletions src/components/BootstrapBlazor.UniverSheet/Locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"BootstrapBlazor.Components.UniverSheet": {
"LoadingText": "Loading ..."
}
}
5 changes: 5 additions & 0 deletions src/components/BootstrapBlazor.UniverSheet/Locales/zh.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"BootstrapBlazor.Components.UniverSheet": {
"LoadingText": "正在加载 ..."
}
}
22 changes: 17 additions & 5 deletions src/components/BootstrapBlazor.UniverSheet/wwwroot/univer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { addScript, addLink, getTheme } from '../BootstrapBlazor/modules/utility.js'
import { addScript, addLink, getTheme } from '../BootstrapBlazor/modules/utility.js'
import DataService from './data-service.js'

const loadAssets2 = async lang => {
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

Unused variable loadAssets2.

Copilot uses AI. Check for mistakes.
Expand Down Expand Up @@ -30,6 +30,7 @@ const loadAssets = async lang => {
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/univer-bundle.js');
await addLink('./_content/BootstrapBlazor.UniverSheet/univer/univer-sheet.bundle.css');
}

export async function createUniverSheetAsync(sheet) {
sheet.lang = sheet.lang ?? 'en-US';
await loadAssets(sheet.lang);
Expand All @@ -46,7 +47,7 @@ export async function createUniverSheetAsync(sheet) {
const lang = sheet.lang.replace('-', '')
const langStr = lang.charAt(0).toUpperCase() + lang.slice(1)
Comment on lines 47 to 48
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

Avoid automated semicolon insertion (90% of all statements in the enclosing function have an explicit semicolon).

Suggested change
const lang = sheet.lang.replace('-', '')
const langStr = lang.charAt(0).toUpperCase() + lang.slice(1)
const lang = sheet.lang.replace('-', '');
const langStr = lang.charAt(0).toUpperCase() + lang.slice(1);

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

Avoid automated semicolon insertion (90% of all statements in the enclosing function have an explicit semicolon).

Copilot uses AI. Check for mistakes.
const options = {
theme: sheet.theme,
theme: sheet.theme,
darkMode: sheet.darkMode,
locale: lang,
locales: {
Expand All @@ -66,12 +67,12 @@ export async function createUniverSheetAsync(sheet) {
ribbonType: sheet.ribbonType ?? 'simple', // default | classic | simple
menu: {
'sheet.menu.print': {
hidden: true,
hidden: true,
},
'sheets-exchange-client.operation.exchange': {
hidden: true,
hidden: true,
},
},
},
}),
UniverSheetsDrawingPreset(),
UniverSheetsThreadCommentPreset(),
Expand Down Expand Up @@ -113,6 +114,17 @@ export async function createUniverSheetAsync(sheet) {
univerAPI.createWorkbook();
}

const { onRendered } = sheet.events;
if (onRendered) {
const disposable = univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, e => {
Comment on lines +117 to +119
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): Guard against sheet.events being undefined before destructuring.

If callers omit sheet.events, const { onRendered } = sheet.events; will throw at runtime. Consider using optional chaining (e.g. const onRendered = sheet.events?.onRendered;) or ensuring sheet.events is defaulted when constructing sheet to handle partial/legacy callers safely.

const { stage } = e;
if (stage === univerAPI.Enum.LifecycleStages.Rendered) {
onRendered();
disposable.dispose()
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

Missing semicolon after disposable.dispose(). Add a semicolon at the end of this statement to maintain code consistency and avoid potential JavaScript issues.

Suggested change
disposable.dispose()
disposable.dispose();

Copilot uses AI. Check for mistakes.
}
});
}

sheet.univer = univer;
sheet.univerAPI = univerAPI;
sheet.dispose = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
.bb-univer-sheet {
width: 100%;
height: 100%;
overflow: hidden;
}

.univer-theme {
Expand Down
Loading