Skip to content

Commit

Permalink
fix(docs): wrong font family in menu (#3232)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jocs authored Aug 29, 2024
1 parent c2f417c commit f896261
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/docs-ui/src/controllers/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export function BoldMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
const textRun = getFontStyleAtCursor(accessor);

if (textRun == null) {
subscriber.next(false);
return;
}

Expand Down Expand Up @@ -260,6 +261,7 @@ export function ItalicMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
const textRun = getFontStyleAtCursor(accessor);

if (textRun == null) {
subscriber.next(false);
return;
}

Expand Down Expand Up @@ -297,6 +299,7 @@ export function UnderlineMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
const textRun = getFontStyleAtCursor(accessor);

if (textRun == null) {
subscriber.next(false);
return;
}

Expand Down Expand Up @@ -334,6 +337,7 @@ export function StrikeThroughMenuItemFactory(accessor: IAccessor): IMenuButtonIt
const textRun = getFontStyleAtCursor(accessor);

if (textRun == null) {
subscriber.next(false);
return;
}

Expand Down Expand Up @@ -370,6 +374,7 @@ export function SubscriptMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
const textRun = getFontStyleAtCursor(accessor);

if (textRun == null) {
subscriber.next(false);
return;
}

Expand Down Expand Up @@ -406,6 +411,7 @@ export function SuperscriptMenuItemFactory(accessor: IAccessor): IMenuButtonItem
const textRun = getFontStyleAtCursor(accessor);

if (textRun == null) {
subscriber.next(false);
return;
}

Expand Down Expand Up @@ -452,6 +458,7 @@ export function FontFamilySelectorMenuItemFactory(accessor: IAccessor): IMenuSel
const textRun = getFontStyleAtCursor(accessor);

if (textRun == null) {
subscriber.next(defaultValue);
return;
}

Expand Down Expand Up @@ -497,6 +504,7 @@ export function FontSizeSelectorMenuItemFactory(accessor: IAccessor): IMenuSelec
const textRun = getFontStyleAtCursor(accessor);

if (textRun == null) {
subscriber.next(DEFAULT_SIZE);
return;
}

Expand Down Expand Up @@ -910,14 +918,8 @@ function getFontStyleAtCursor(accessor: IAccessor) {

let textRun;

for (let i = 0; i < textRuns.length; i++) {
for (let i = textRuns.length - 1; i >= 0; i--) {
const curTextRun = textRuns[i];
const nextTextRun = textRuns[i + 1];

if (nextTextRun && nextTextRun.st === nextTextRun.ed && startOffset === nextTextRun.st) {
textRun = nextTextRun;
break;
}

if (curTextRun.st <= startOffset && startOffset <= curTextRun.ed) {
textRun = curTextRun;
Expand Down

0 comments on commit f896261

Please sign in to comment.