Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(formula): subtotal count #2452

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Prev Previous commit
fix(sheet): copy rich text remove style
  • Loading branch information
Dushusir committed Jun 18, 2024
commit 0282dbecb1fa9a74a928bf1dbae816a37193fa0e
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import type { ICellData, IMutationInfo, Workbook } from '@univerjs/core';
import {
DEFAULT_EMPTY_DOCUMENT_VALUE,
Disposable,
isFormulaId,
isFormulaString,
Expand Down Expand Up @@ -231,6 +232,13 @@ export function getSetCellFormulaMutations(
}
}

// If there is rich text, remove the style
const richText = getCellRichText(value);
if (richText) {
valueObject.p = null;
valueObject.v = richText;
}

valueMatrix.setValue(range.rows[row], range.cols[col], valueObject);
});
// set cell value and style
Expand Down Expand Up @@ -260,3 +268,19 @@ export function getSetCellFormulaMutations(
redos: redoMutationsInfo,
};
}

function getCellRichText(cell: ICellData) {
if (cell?.p) {
const body = cell?.p.body;

if (body == null) {
return;
}

const data = body.dataStream;
const lastString = data.substring(data.length - 2, data.length);
const newDataStream = lastString === DEFAULT_EMPTY_DOCUMENT_VALUE ? data.substring(0, data.length - 2) : data;

return newDataStream;
}
}
Loading