Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/arnog/mathlive
Browse files Browse the repository at this point in the history
  • Loading branch information
arnog committed Sep 27, 2024
2 parents 42f80bd + 395a51a commit 0f7dfbf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
32 changes: 16 additions & 16 deletions src/editor-mathfield/mathfield-private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1716,26 +1716,20 @@ If you are using Vue, this may be because you are using the runtime-only build o
// don't do that for custom elements, so we do it ourselves. @futureweb
//

// Wait for the window/document visibility to change
// Wait for the window focus to change
// (the mathfield gets blurred before the window)
const controller = new AbortController();
const signal = controller.signal;
document.addEventListener(
'visibilitychange',
window.addEventListener(
'blur',
() => {
if (document.visibilityState === 'hidden') {
document.addEventListener(
'visibilitychange',
() => {
if (
isValidMathfield(this) &&
document.visibilityState === 'visible'
)
this.focus({ preventScroll: true });
},
{ once: true, signal }
);
}
window.addEventListener(
'focus',
() => {
if (isValidMathfield(this)) this.focus({ preventScroll: true });
},
{ once: true, signal }
);
},
{ once: true, signal }
);
Expand All @@ -1745,6 +1739,12 @@ If you are using Vue, this may be because you are using the runtime-only build o
document.addEventListener('focusin', () => controller.abort(), {
once: true,
});

// If user clicks anywhere, cancel the refocus (covers case where
// click doesn't cause an element to come into focus)
document.addEventListener('click', () => controller.abort(), {
once: true,
});
}
}

Expand Down
17 changes: 8 additions & 9 deletions src/formats/atom-to-ascii-math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,12 @@ export function atomToAsciiMath(
result += atomToAsciiMath(genfracAtom.below, options);
result += ')';
} else {
// No bar line, i.e. \choose, etc...
result += '(' + atomToAsciiMath(genfracAtom.above, options) + '),';
result += '(' + atomToAsciiMath(genfracAtom.below, options) + ')';
// No bar line, for \choose
result += '((';
result += atomToAsciiMath(genfracAtom.above, options);
result += ') choose (';
result += atomToAsciiMath(genfracAtom.below, options);
result += '))';
}

if (genfracAtom.leftDelim || genfracAtom.rightDelim) {
Expand Down Expand Up @@ -372,12 +375,8 @@ export function atomToAsciiMath(
const rows: string[] = [];
for (const row of array) {
const cells: string[] = [];
for (const cell of row)
cells.push(
rowDelim[0] + atomToAsciiMath(cell, options) + rowDelim[1]
);

rows.push(cells.join(','));
for (const cell of row) cells.push(atomToAsciiMath(cell, options));
rows.push(rowDelim[0] + cells.join(',') + rowDelim[1]);
}

const delim = {
Expand Down

0 comments on commit 0f7dfbf

Please sign in to comment.