Skip to content

Commit

Permalink
fix: user keybindings should overwrite default
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanChain committed Nov 27, 2023
1 parent 71b6891 commit 39344d3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/ml-tweak.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import type { MathfieldElement } from 'mathlive'
import type { MathfieldElement, Keybinding } from 'mathlive'

export function configureMF(mfe: MathfieldElement) {
mfe.smartFence = logseq.settings?.smartFence ?? true
mfe.smartMode = logseq.settings?.smartMode ?? false
mfe.smartSuperscript = logseq.settings?.smartSuperscript ?? false
try {
mfe.keybindings = [
...mfe.keybindings,
...mfe.keybindings.filter(
(keybinding) =>
!logseq.settings?.keybindings.some((k: Keybinding) => (
k.key === keybinding.key &&
k.ifMode === keybinding.ifMode &&
k.ifLayout === keybinding.ifLayout &&
k.ifPlatform === keybinding.ifPlatform
)),
),
...logseq.settings?.keybindings,
]
} catch (err) {
Expand Down

0 comments on commit 39344d3

Please sign in to comment.