Skip to content

Commit

Permalink
[FIX] export: Fix default style ignored at export
Browse files Browse the repository at this point in the history
The default style values ignored at export were targetting the font
color black (#000000) as the default value. However, the default value
is the simple absence of value (or rather an empty string) as we should
be able to differentiate it from a choice from the user to set the font
color to black (e.g. when the cell is also receiving its style from a CF
or a table).

closes #5008

Task: 4178743
X-original-commit: 6cc0b14
Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
Signed-off-by: Rémi Rahir (rar) <[email protected]>
  • Loading branch information
rrahir committed Sep 20, 2024
1 parent e41fd95 commit 4945129
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export const DEFAULT_STYLE = {
underline: false,
fontSize: 10,
fillColor: "",
textColor: "#000000",
textColor: "",
} satisfies Required<Style>;

export const DEFAULT_VERTICAL_ALIGN = DEFAULT_STYLE.verticalAlign;
Expand Down
8 changes: 8 additions & 0 deletions tests/cells/style_plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ describe("styles", () => {
expect(data.styles).toEqual({});
});

test("textColor black(#000000) is exported as non default style", () => {
const model = new Model();
setStyle(model, "A1", { textColor: "#000000" });
const data = model.exportData();
expect(data.sheets[0].styles.A1).toBe(1);
expect(data.styles).toEqual({ 1: { textColor: "#000000" } });
});

test("only non default style values are exported", () => {
const model = new Model();
setStyle(model, "A1", {
Expand Down

0 comments on commit 4945129

Please sign in to comment.