Skip to content

Commit

Permalink
fix: remove empty objects from a style
Browse files Browse the repository at this point in the history
  • Loading branch information
ybzky committed Dec 17, 2024
1 parent 4738a66 commit 15811a0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/sheets/src/basics/cell-style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

import { normalizeTextRuns, Tools } from '@univerjs/core';
import type { IBorderData, ICellData, IDocumentData, IKeyValue, IParagraph, IStyleData, ITextRun, ITextStyle, Nullable, Styles } from '@univerjs/core';
import { normalizeTextRuns, Tools } from '@univerjs/core';

export function handleStyle(styles: Styles, oldVal: ICellData, newVal: ICellData) {
// use null to clear style
Expand All @@ -36,6 +36,13 @@ export function handleStyle(styles: Styles, oldVal: ICellData, newVal: ICellData
// then remove null
if (merge) {
Tools.removeNull(merge);

// remove empty object
Object.entries(merge).forEach(([key, val]) => {
if (typeof val === 'object' && val !== null && Object.keys(val).length === 0) {
delete merge[key as keyof IStyleData];
}
});
}

if (Tools.isEmptyObject(merge)) {
Expand Down

0 comments on commit 15811a0

Please sign in to comment.