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,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>9.0.2</Version>
<Version>9.0.3</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
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 System.Globalization;

namespace BootstrapBlazor.Components;

Expand Down Expand Up @@ -47,6 +48,16 @@ public partial class UniverSheet

private UniverSheetData? _lastData;

/// <summary>
/// <inheritdoc/>
/// </summary>
protected override void OnParametersSet()
{
base.OnParametersSet();

Lang ??= CultureInfo.CurrentUICulture.Name;
}

/// <summary>
/// <inheritdoc/>
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ export async function init(id, invoke, options) {
return;
}

const { theme, lang, plugins, data } = options;
const univerSheet = {
el,
invoke,
options
data,
plugins,
theme,
lang
};

await createUniverSheetAsync(univerSheet);
Data.set(id, univerSheet);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ public class UniverSheetData
public string? CommandName { get; set; }

/// <summary>
/// 获得/设置 数据 默认 null 未设置
/// 获得/设置 UniverSheet workbook 数据 默认 null 未设置
/// </summary>
public object? WorkbookData { get; set; }

/// <summary>
/// 获得/设置 附加业务数据 默认 null 未设置
/// </summary>
public object? Data { get; set; }
}
9 changes: 4 additions & 5 deletions src/components/BootstrapBlazor.UniverSheet/wwwroot/plugin.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import DataService from './data-service.js'

const { Plugin, Injector, setDependencies, UniverInstanceType } = UniverCore;
const { Plugin, Injector, setDependencies } = UniverCore;

// 定义插件类
export class DefaultPlugin extends Plugin {
static pluginName = 'DefaultPlugin';

Expand All @@ -28,10 +27,10 @@ export class DefaultPlugin extends Plugin {
}

receiveData(payload) {
const { messageName, commandName, data } = payload;
const { messageName, commandName, data, workbookData } = payload;
if (messageName === null) {
if (commandName === 'SetWorkbook') {
this.setWorkbookData(JSON.parse(data));
this.setWorkbookData(JSON.parse(workbookData));
}
else if (commandName === 'GetWorkbook') {
return this.getWorkbookData();
Expand Down Expand Up @@ -65,7 +64,7 @@ export class DefaultPlugin extends Plugin {
delete data.resources;
return {
messageName: null,
commandName: 'Save',
commandName: null,
data: JSON.stringify(data)
};
}
Expand Down
60 changes: 30 additions & 30 deletions src/components/BootstrapBlazor.UniverSheet/wwwroot/univer.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { addScript, addLink } from '../BootstrapBlazor/modules/utility.js'
import DataService from './data-service.js'

const loadAssets = async () => {
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/react.production.min.js');
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/react-dom.production.min.js');
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/rxjs.umd.min.js');
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.presets.umd.min.js');
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.preset-sheets-core.umd.min.js');
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.preset-sheets-drawing.umd.min.js');
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.sheets-zen-editor.umd.min.js');
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.preset-sheets-data-validation.umd.min.js');
const loadAssets = async lang => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nitpick: Temporary debug console log remains in production code.

If the console.log is not needed for production diagnostics, consider removing it to maintain clean logging output.

console.log(lang, 'lang');
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/react.production.min.js');
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/react-dom.production.min.js');
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/rxjs.umd.min.js');
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/univerjs.presets.umd.min.js');
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/univerjs.preset-sheets-core/index.umd.min.js');
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/univerjs.preset-sheets-drawing/index.umd.min.js');
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/univerjs.sheets-zen-editor/index.umd.min.js');
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/univerjs.preset-sheets-data-validation/index.umd.min.js');

await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.preset-sheets-core.locales.zh-CN.js');
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.preset-sheets-drawing.locales.zhCN.js');
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.sheets-zen-editor.locales.zh-CN.js');
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.preset-sheets-data-validation.locales.zh-CN.js');
await addScript(`./_content/BootstrapBlazor.UniverSheet/univer/univerjs.preset-sheets-core/locales/${lang}.js`);
await addScript(`./_content/BootstrapBlazor.UniverSheet/univer/univerjs.preset-sheets-drawing/locales/${lang}.js`);
await addScript(`./_content/BootstrapBlazor.UniverSheet/univer/univerjs.sheets-zen-editor/locales/${lang}.js`);
await addScript(`./_content/BootstrapBlazor.UniverSheet/univer/univerjs.preset-sheets-data-validation/locales/${lang}.js`);

await addLink('./_content/BootstrapBlazor.UniverSheet/univer/css/univer-sheet.bundle.css');
await addLink('./_content/BootstrapBlazor.UniverSheet/univer/univer-sheet.bundle.css');
}


export async function createUniverSheetAsync(sheet) {
await loadAssets();

await loadAssets(sheet.lang);
const { el } = sheet;
const { LocaleType, merge } = UniverCore;
const { createUniver } = UniverPresets;
Expand All @@ -31,18 +31,18 @@ export async function createUniverSheetAsync(sheet) {
const { UniverSheetsZenEditorPlugin } = UniverSheetsZenEditor
const { UniverSheetsDataValidationPlugin } = UniverSheetsDataValidation
const { UniverSheetsDataValidationUIPlugin } = UniverSheetsDataValidationUi
const { defaultTheme } = UniverDesign;

const lang = sheet.lang.replace('-', '')
const langStr = lang.charAt(0).toUpperCase() + lang.slice(1)
const options = {
theme: sheet.options.theme ?? defaultTheme,
locale: sheet.options.lang ?? LocaleType.ZH_CN,
theme: UniverDesign[sheet.theme] ?? UniverDesign.defaultTheme, //'defaultTheme' | greenTheme
locale: lang,
locales: {
[LocaleType.ZH_CN]: merge(
[lang]: merge(
{},
UniverPresetSheetsCoreZhCN,
UniverPresetSheetsDrawingZhCN,
UniverSheetsZenEditorZhCN,
UniverSheetsDataValidationUiZhCN,
window[`UniverPresetSheetsCore${langStr}`],
window[`UniverPresetSheetsDrawing${langStr}`],
window[`UniverSheetsZenEditor${langStr}`],
window[`UniverSheetsDataValidationUi${langStr}`],
),
},
plugins: [
Expand All @@ -51,7 +51,7 @@ export async function createUniverSheetAsync(sheet) {
UniverSheetsDataValidationUIPlugin,
]
};
const plugins = sheet.options.plugins ?? {
const plugins = sheet.plugins ?? {
DefaultPlugin: '_content/BootstrapBlazor.UniverSheet/plugin.js'
};
for (const name in plugins) {
Expand All @@ -70,9 +70,9 @@ export async function createUniverSheetAsync(sheet) {
...options
});

const { data } = sheet.options.data || {};
if (data) {
const option = typeof data === 'string' ? JSON.parse(data) : data;
const { workbookData } = sheet.data || {};
if (workbookData) {
const option = typeof workbookData === 'string' ? JSON.parse(workbookData) : workbookData;
univerAPI.createWorkbook(option);
}
else {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@import 'univerjs.preset-sheets-core/index.css';
@import 'univerjs.preset-sheets-drawing/index.css';
@import 'univerjs.sheets-zen-editor/index.css';
@import 'univerjs.preset-sheets-data-validation/index.css';

.bb-univer-sheet {
width: 100%;
height: 100%;
overflow: hidden;
}

.univer-fixed {
position: absolute;
}

.univer-theme {
position: relative;
z-index: 1200;
}

.univer-theme [role="toolbar"] > div {
justify-content: flex-start;
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading