Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(sheet): inline format menu display error when paste (#1482)
Ran Luoc66f9e18d420
diff --git a/packages/core/src/sheets/range.ts b/packages/core/src/sheets/range.tsindex 8b4720b12f..667e15b16f 100644--- a/packages/core/src/sheets/range.ts+++ b/packages/core/src/sheets/range.ts@@ -427,6 +427,16 @@ export class Range {* Returns the font size in point size of the cell in the top-left corner of the range.*/getFontSize(): number {+ const { p } = this.getValue() ?? {};++ if (p && Array.isArray(p.body?.textRuns) && p.body.textRuns.length > 0) {+ if (p.body.textRuns.some((textRun) => textRun?.ts?.fs != null)) {+ return Math.max(...p.body.textRuns.map((textRun) => textRun?.ts?.fs || 0));+ } else {+ return this.getFontSizes()[0][0];+ }+ }+return this.getFontSizes()[0][0];}diff --git a/packages/sheets-ui/src/controllers/menu/menu.ts b/packages/sheets-ui/src/controllers/menu/menu.tsindex d8cc5f103c..49d9041b17 100644--- a/packages/sheets-ui/src/controllers/menu/menu.ts+++ b/packages/sheets-ui/src/controllers/menu/menu.ts@@ -1227,7 +1227,7 @@ function getFontStyleAtCursor(accessor: IAccessor) {const { startOffset } = activeTextRange;- const textRun = textRuns.find(({ st, ed }) => startOffset >= st && startOffset < ed);+ const textRun = textRuns.find(({ st, ed }) => startOffset >= st && startOffset <= ed);return textRun;}