mathlive icon indicating copy to clipboard operation
mathlive copied to clipboard

keybinding command switchMode should insert the prefix in the previous mode and the suffix with the new mode

Open EmaGht opened this issue 1 year ago • 1 comments

Use case

Being able to write quoted text while autmatically entering text mode

Actual Behavior

With a configuration as follows:

{ key: 'shift+[Digit2]', ifPlatform: 'windows', command: ['switchMode', 'text', "", "\""], ifMode: "math" },
{ key: 'shift+[Digit2]', ifPlatform: 'windows', command: ['switchMode', 'math', "\"", ""], ifMode: "text" }

I'm trying to switch between math mode and text mode while adding a " for extra visual clarity as it's difficult for a user to notice he is writing actual text otherwise.

The first half is actually possible using

{ key: 'shift+[Digit2]', ifPlatform: 'windows', command: ['switchMode', 'text', "\""], ifMode: "math" },

As the prefix gets added using the new mode, which is "text", but when i type " again it gets added by this keybinding

{ key: 'shift+[Digit2]', ifPlatform: 'windows', command: ['switchMode', 'math', "\"", ""], ifMode: "text" }

in math mode, breaking the visual

Expected Behavior

Be able to write the prefix from "switchMode" in the previous mode, while writing the suffix in the next mode.

I guess what i'm asking is using previousMode instead of mode here

Environment

Is this a regression: did it use to work in a previous version? no

MathLive version latest

Operating System windows

Browser all

EmaGht avatar May 15 '24 09:05 EmaGht

The SwitchMode command has two optional arguments. The first one is a "prefix" that is rendered in the current mode, and the second one is a "suffix" that is rendered in the new mode. So, you should use it to do what you want.

However, the implementation is currently broken and needs to be fixed.

arnog avatar May 24 '24 15:05 arnog