c-w / mathquill4quill

Power-up Quill's formula editing via the MathQuill editor
https://justamouse.com/mathquill4quill
Apache License 2.0
139 stars 33 forks source link

How to add custom operators #93

Closed aman123shi closed 1 year ago

aman123shi commented 1 year ago

i have described the problem here https://stackoverflow.com/questions/75525816/how-to-write-the-second-value-of-custom-operators-array-in-mathquill-editor

c-w commented 1 year ago

There's two parts to an operator button: the LaTeX that gets shown on the button and the content that gets inserted into the editor when the button is clicked. Let's take an example operator button definition like ["\\pi", "3.14"]. This will render the symbol π on the button and when the button is clicked will insert "3.14" into the editor.

aman123shi commented 1 year ago

i want to insert a placeholder of characters that are displayed on the button to be inserted on the editor then i can edit it for example i have this 2 x 2 matrix Latex [String.raw\begin{bmatrix}a & b \\c & d \end{bmatrix}, 'what to put here'] this will display matrix on the button but don't know what to put for the second value

c-w commented 1 year ago

What approaches have you tried?

aman123shi commented 1 year ago

for eg this Logarithm LaTex will give me a log symbol with editable a and b values for the second value of the array i just copied the latex value and remove a and b from the curly braces and it worked. ["\log{a}{b}", "\log{}{}"] i just want to know if there is a general rule that i can use for other Latex values this approach worked for some Latex values but didn't work for others

c-w commented 1 year ago

Could you provide some examples where your approach failed?

aman123shi commented 1 year ago

[ String.raw\begin{bmatrix}a & b \\c & d \end{bmatrix}, String.raw\begin{bmatrix}{} & {} \\{} & {} \end{bmatrix},], this 2x2 matrix latex will render on the Button but when i click it , it won't give me Editable Matrix on the editor it's just blank. but the above Logarithm latex will give me editable log symbol with a and b value then i will substitute with my value and hit save i get my log symbol with my values on the editor

c-w commented 1 year ago

Matrices specifically aren't supported by MathQuill which is used to render the formulae in the editor. See https://github.com/c-w/mathquill4quill/issues/52 for additional detail.

Resolving this issue since the problem is a limitation of an upstream dependency and not of mathquill4quill itself. Feel free to re-open if you have any additional questions or concerns.