Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(core): 1. styles.getStyleByCell 2. collaboration url example

dushusir541548cc4e5c
diff --git a/examples/univer-preact-ts/src/index.ts b/examples/univer-preact-ts/src/index.ts
index 9ab8e745ef..21895bc179 100644
--- a/examples/univer-preact-ts/src/index.ts
+++ b/examples/univer-preact-ts/src/index.ts
@@ -6,11 +6,11 @@ import { ISheetPluginConfig, SheetPlugin } from '@univer/base-sheets';
import { IDocPluginConfig, DocPlugin } from '@univer/base-docs';
import { ISlidePluginConfig, SlidePlugin } from '@univer/base-slides';
import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';
+import { CollaborationPlugin, ICollaborationPluginConfig } from '@univer/common-plugin-collaboration';
import { DEFAULT_FORMULA_DATA, FormulaPlugin, IFormulaConfig } from '@univer/sheets-plugin-formula';
import { INumfmtPluginConfig, NumfmtPlugin } from '@univer/sheets-plugin-numfmt';
import { ClipboardPlugin } from '@univer/sheets-plugin-clipboard';
import { ImportXlsxPlugin } from '@univer/sheets-plugin-import-xlsx';
-import { CollaborationPlugin, ICollaborationPluginConfig } from '@univer/common-plugin-collaboration';
interface ISheetPropsCustom {
coreConfig?: Partial<IWorkbookConfig>;
@@ -119,6 +119,7 @@ export * as BaseSheets from '@univer/base-sheets';
export * as BaseDocs from '@univer/base-docs';
export * as BaseSlides from '@univer/base-slides';
export * as CommonPluginData from '@univer/common-plugin-data';
+export * as CommonPluginCollaboration from '@univer/common-plugin-collaboration';
export * as SheetsPluginFormula from '@univer/sheets-plugin-formula';
export * as SheetsPluginNumfmt from '@univer/sheets-plugin-numfmt';
export * as SheetsPluginClipboard from '@univer/sheets-plugin-clipboard';
diff --git a/examples/univer-preact-ts/src/main.tsx b/examples/univer-preact-ts/src/main.tsx
index 21684b30eb..c09403e38d 100644
--- a/examples/univer-preact-ts/src/main.tsx
+++ b/examples/univer-preact-ts/src/main.tsx
@@ -62,7 +62,7 @@ univerSheetCustom({
coreConfig: defaultWorkbookData,
baseSheetsConfig: sheetConfig,
collaborationConfig: {
- url: 'ws://localhost:8448/ws',
+ url: 'ws://luckysheet.lashuju.com/ws',
},
});
diff --git a/examples/univer-sheet-ts/src/main.tsx b/examples/univer-sheet-ts/src/main.tsx
index c175f4b0cc..bc58d44669 100644
--- a/examples/univer-sheet-ts/src/main.tsx
+++ b/examples/univer-sheet-ts/src/main.tsx
@@ -48,7 +48,7 @@ const uiDefaultConfigDemo = {
// const univerSheetDemo = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA_DEMO1);
// const univerSheetDemo = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA_DEMO2);
// const univerSheetDemo = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA_DEMO3);
-const univerSheetDemo = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA_DEMO4);
+const univerSheetDemo = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA_DEMO);
univerSheetDemo.installPlugin(new RenderEngine());
univerSheetDemo.installPlugin(new UniverComponentSheet());
univerSheetDemo.installPlugin(new SheetPlugin(uiDefaultConfigDemo));
diff --git a/packages/common-plugin-collaboration/src/Controller/CollaborationController.ts b/packages/common-plugin-collaboration/src/Controller/CollaborationController.ts
index cd7139c431..c96912aebb 100644
--- a/packages/common-plugin-collaboration/src/Controller/CollaborationController.ts
+++ b/packages/common-plugin-collaboration/src/Controller/CollaborationController.ts
@@ -113,19 +113,19 @@ export class CollaborationController {
}
}
onError(data) {
- // console.log('onError====', data);
+ console.log('onError====', data);
}
onOpen(data) {
- // console.log('onOpen====', data);
+ console.log('onOpen====', data);
}
onClose(data) {
- // console.log('onClose====', data);
+ console.log('onClose====', data);
}
onRetry(data) {
- // console.log('onRetry====', data);
+ console.log('onRetry====', data);
}
onDestroy(data) {
- // console.log('onDestroy====', data);
+ console.log('onDestroy====', data);
}
refresh(config) {
diff --git a/packages/core/src/Shared/Migrate/Migrate.ts b/packages/core/src/Shared/Migrate/Migrate.ts
index 0c4dd7d259..abe4fffc2b 100644
--- a/packages/core/src/Shared/Migrate/Migrate.ts
+++ b/packages/core/src/Shared/Migrate/Migrate.ts
@@ -273,6 +273,8 @@ export function migrate(config: any): Partial<IWorkbookConfig> {
// 显示值
if (cell.hasOwnProperty('m')) {
newCell.m = cell.m;
+ }else{
+ newCell.m = String(cell.v || '')
}
const cellStyle: IStyleData = {};
diff --git a/packages/core/src/Sheets/Apply/SetRangeData.ts b/packages/core/src/Sheets/Apply/SetRangeData.ts
index 64d6ac75c7..89bb043d1c 100644
--- a/packages/core/src/Sheets/Apply/SetRangeData.ts
+++ b/packages/core/src/Sheets/Apply/SetRangeData.ts
@@ -59,7 +59,7 @@ export function SetRangeData(
// update style
// use null to clear style
- const old = cell.s ? styles.get(cell.s) : null;
+ const old = styles.getStyleByCell(cell);
// store old data
const oldCellStyle = transformStyle(
diff --git a/packages/core/src/Sheets/Apply/SetRangeStyle.ts b/packages/core/src/Sheets/Apply/SetRangeStyle.ts
index 3b69e9b51f..b6d3908058 100644
--- a/packages/core/src/Sheets/Apply/SetRangeStyle.ts
+++ b/packages/core/src/Sheets/Apply/SetRangeStyle.ts
@@ -31,7 +31,7 @@ export function SetRangeStyle(
for (let c = startColumn; c <= endColumn; c++) {
const cell = cellMatrix.getValue(r, c) || {};
// use null to clear style
- const old = cell.s ? styles.get(cell.s) : null;
+ const old = styles.getStyleByCell(cell);
if (old == null) {
// clear
diff --git a/packages/core/src/Sheets/Domain/Range.ts b/packages/core/src/Sheets/Domain/Range.ts
index e993683d39..d0f5e0f5c3 100644
--- a/packages/core/src/Sheets/Domain/Range.ts
+++ b/packages/core/src/Sheets/Domain/Range.ts
@@ -274,11 +274,7 @@ export class Range {
row.map((cell: Nullable<ICellData>) => {
const styles = this._context.getWorkBook().getStyles();
let rgbColor: string = DEFAULT_STYLES.bg?.rgb!;
-
- if (cell?.s) {
- rgbColor = styles.get(cell?.s)?.bg?.rgb!;
- }
-
+ rgbColor = styles.getStyleByCell(cell)?.bg?.rgb!;
return rgbColor;
})
);
@@ -380,8 +376,9 @@ export class Range {
return this.getValues().map((row) =>
row.map((cell: Nullable<ICellData>) => {
const styles = this._context.getWorkBook().getStyles();
+ const cellStyle = styles.getStyleByCell(cell)
return (
- (cell?.s && styles.get(cell.s)?.cl?.rgb) ||
+ cellStyle?.cl?.rgb ||
DEFAULT_STYLES.cl?.rgb
);
})
@@ -773,10 +770,7 @@ export class Range {
return this.getValues().map((row) =>
row.map((cell: Nullable<ICellData>) => {
const styles = this._context.getWorkBook().getStyles();
- if (cell && cell.s) {
- return styles.get(cell.s);
- }
- return null;
+ return styles.getStyleByCell(cell);
})
);
}
@@ -2157,7 +2151,7 @@ export class Range {
stylesMatrix.setValue(
r,
c,
- cell.s ? styles.get(cell.s) : {}
+ styles.getStyleByCell(cell) || {}
);
})
);
@@ -2314,8 +2308,8 @@ export class Range {
value.map((row, r) =>
row.map((cell, c) => {
cell = cell as ICellData;
- stylesMatrix.setValue(r, c, cell.s ? styles.get(cell.s) : {});
- return cell.s ? styles.get(cell.s) : {};
+ stylesMatrix.setValue(r, c, styles.getStyleByCell(cell) || {});
+ return styles.getStyleByCell(cell) || {};
})
);
diff --git a/packages/core/src/Sheets/Domain/Worksheet.ts b/packages/core/src/Sheets/Domain/Worksheet.ts
index e337321626..a3b6c8d69d 100644
--- a/packages/core/src/Sheets/Domain/Worksheet.ts
+++ b/packages/core/src/Sheets/Domain/Worksheet.ts
@@ -1320,7 +1320,7 @@ export class Worksheet {
tr.forEach((row, column) => {
const cell = matrix.getValue(row, column);
if (cell) {
- const cellStyle = styles.get(cell.s);
+ const cellStyle = styles.getStyleByCell(cell);
if (cellStyle) {
const copy: IStyleData = Tools.deepClone(cellStyle);
if (copy.bd) {
@@ -1333,7 +1333,7 @@ export class Worksheet {
br.forEach((row, column) => {
const cell = matrix.getValue(row, column);
if (cell) {
- const cellStyle = styles.get(cell.s);
+ const cellStyle = styles.getStyleByCell(cell);
if (cellStyle) {
const copy: IStyleData = Tools.deepClone(cellStyle);
if (copy.bd) {
@@ -1346,7 +1346,7 @@ export class Worksheet {
lr.forEach((row, column) => {
const cell = matrix.getValue(row, column);
if (cell) {
- const cellStyle = styles.get(cell.s);
+ const cellStyle = styles.getStyleByCell(cell);
if (cellStyle) {
const copy: IStyleData = Tools.deepClone(cellStyle);
if (copy.bd) {
@@ -1359,7 +1359,7 @@ export class Worksheet {
rr.forEach((row, column) => {
const cell = matrix.getValue(row, column);
if (cell) {
- const cellStyle = styles.get(cell.s);
+ const cellStyle = styles.getStyleByCell(cell);
if (cellStyle) {
const copy: IStyleData = Tools.deepClone(cellStyle);
if (copy.bd) {