Skip to content

Commit

Permalink
fix(sheet): inline format menu display error when paste (#1482)
Browse files Browse the repository at this point in the history
* fix(sheet): inline format menu display error when paste

* fix: font size menu
  • Loading branch information
Jocs authored and yuanbin committed Mar 19, 2024
1 parent d376ff0 commit 836bec4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/core/src/sheets/range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down
2 changes: 1 addition & 1 deletion packages/sheets-ui/src/controllers/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 836bec4

Please sign in to comment.