UPDATE: Add clear formatting

Fixes #267
This commit is contained in:
Nicolás Hatcher
2025-02-03 23:31:04 +01:00
committed by Nicolás Hatcher Andrés
parent 42d557d485
commit 8a54f45d75
8 changed files with 171 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ import {
PaintRoller,
Percent,
Redo2,
RemoveFormatting,
Strikethrough,
Tags,
Type,
@@ -65,6 +66,7 @@ type ToolbarProperties = {
onFillColorPicked: (hex: string) => void;
onNumberFormatPicked: (numberFmt: string) => void;
onBorderChanged: (border: BorderOptions) => void;
onClearFormatting: () => void;
fillColor: string;
fontColor: string;
bold: boolean;
@@ -360,6 +362,19 @@ function Toolbar(properties: ToolbarProperties) {
<Tags />
</StyledButton>
<Divider />
<StyledButton
type="button"
$pressed={false}
disabled={!canEdit}
onClick={() => {
properties.onClearFormatting();
}}
title={t("toolbar.clear_formatting")}
>
<RemoveFormatting />
</StyledButton>
<ColorPicker
color={properties.fontColor}
onChange={(color): void => {

View File

@@ -527,6 +527,20 @@ const Workbook = (props: { model: Model; workbookState: WorkbookState }) => {
onTextColorPicked={onTextColorPicked}
onFillColorPicked={onFillColorPicked}
onNumberFormatPicked={onNumberFormatPicked}
onClearFormatting={() => {
const {
sheet,
range: [rowStart, columnStart, rowEnd, columnEnd],
} = model.getSelectedView();
model.rangeClearFormatting(
sheet,
rowStart,
columnStart,
rowEnd,
columnEnd,
);
setRedrawId((id) => id + 1);
}}
onBorderChanged={(border: BorderOptions): void => {
const {
sheet,

View File

@@ -3,6 +3,7 @@
"redo": "Redo",
"undo": "Undo",
"copy_styles": "Copy styles",
"clear_formatting": "Clear formatting",
"euro": "Format as Euro",
"percentage": "Format as Percentage",
"bold": "Bold",