Skip to content

Commit

Permalink
fix: fix range theme fromjson
Browse files Browse the repository at this point in the history
  • Loading branch information
ybzky committed Mar 8, 2025
1 parent b366151 commit 99a8a88
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions packages/sheets/src/model/range-theme-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export class SheetRangeThemeModel extends Disposable {
toJson(unitId: string) {
// deserialize registered range theme style rule
const ruleMap = this._ensureRangeThemeStyleRuleMap(unitId);
// deserialize custom range theme style
// deserialize custom range theme style
const rangeThemeStyleMap = this._ensureRangeThemeStyleMap(unitId);

if (rangeThemeStyleMap.size === 0 && ruleMap.size === 0) {
Expand All @@ -237,17 +237,11 @@ export class SheetRangeThemeModel extends Disposable {
});
}

fromJSON(json: ISheetRangeThemeModelJSON) {
const { rangeThemeStyleRuleMap, rangeThemeStyleMapJson } = json;
fromJSON(unitId: string, json: ISheetRangeThemeModelJSON) {
const { rangeThemeStyleRuleMap: rangeThemeStyleRuleMapJSON, rangeThemeStyleMapJson } = json;

this._rangeThemeStyleMap.clear();
this._rangeThemeStyleRuleMap.clear();
this._rTreeCollection.clear();
if (!rangeThemeStyleRuleMap || !rangeThemeStyleMapJson) {
return;
}
Object.keys(rangeThemeStyleRuleMap).forEach((key) => {
const ruleMap = rangeThemeStyleRuleMap[key];
Object.keys(rangeThemeStyleRuleMapJSON).forEach((key) => {
const ruleMap = rangeThemeStyleRuleMapJSON[key];
const { themeName, rangeInfo } = ruleMap;
this.registerRangeThemeRule(themeName, rangeInfo);
const rTreeCollection = this._ensureRTreeCollection(rangeInfo.unitId);
Expand All @@ -258,7 +252,7 @@ export class SheetRangeThemeModel extends Disposable {
const styleMap = rangeThemeStyleMapJson[key];
const style = new RangeThemeStyle(styleMap.name);
style.fromJson(styleMap);
this._ensureRangeThemeStyleMap(key).set(style.getName(), style);
this._ensureRangeThemeStyleMap(unitId).set(style.getName(), style);
});
}

Expand Down Expand Up @@ -286,8 +280,8 @@ export class SheetRangeThemeModel extends Disposable {
},
businesses: [UniverInstanceType.UNIVER_SHEET],
pluginName: SHEET_RANGE_THEME_MODEL_PLUGIN,
onLoad: (_unitId, resources) => {
this.fromJSON(resources);
onLoad: (unitId, resources) => {
this.fromJSON(unitId, resources);
},
onUnLoad: (unitId) => {
this.deleteUnitId(unitId);
Expand Down

0 comments on commit 99a8a88

Please sign in to comment.