Skip to content

Commit

Permalink
Build v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hrushikeshrv committed Mar 17, 2024
1 parent ec1517e commit 0ab9e26
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 21 deletions.
9 changes: 6 additions & 3 deletions docs/examples/add-custom-function.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,14 @@
</div>
<script>
const equationTable = document.querySelector('#equation-table');
const mjxgui = new MJXGUI('#mjxgui-button', function () {
const mjxgui = new MJXGUI('#mjxgui-button', function (
latex,
instance,
) {
let tr = document.createElement('tr');
tr.innerHTML += `
<td>$$ ${mjxgui.getLatex()} $$</td>
<td class="latex-cell">${mjxgui.getLatex()}</td>
<td>$$ ${latex} $$</td>
<td class="latex-cell">${latex}</td>
`;
equationTable.appendChild(tr);

Expand Down
9 changes: 6 additions & 3 deletions docs/examples/add-custom-symbol.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,14 @@
</div>
<script>
const equationTable = document.querySelector('#equation-table');
const mjxgui = new MJXGUI('#mjxgui-button', function () {
const mjxgui = new MJXGUI('#mjxgui-button', function (
latex,
instance,
) {
let tr = document.createElement('tr');
tr.innerHTML += `
<td>$$ ${mjxgui.getLatex()} $$</td>
<td class="latex-cell">${mjxgui.getLatex()}</td>
<td>$$ ${latex} $$</td>
<td class="latex-cell">${latex}</td>
`;
equationTable.appendChild(tr);

Expand Down
7 changes: 5 additions & 2 deletions docs/examples/basic-example.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,13 @@ <h3 style="font-family: monospace">Inserted Equations:</h3>
</div>
<script>
const eqnOutput = document.querySelector('#equation-output');
const mjxgui = new MJXGUI('#mjxgui-button', function () {
const mjxgui = new MJXGUI('#mjxgui-button', function (
latex,
instance,
) {
MathJax.typesetClear([eqnOutput]);

eqnOutput.innerHTML += '$$' + mjxgui.getLatex() + '$$' + '<br>';
eqnOutput.innerHTML += '$$' + latex + '$$' + '<br>';

MathJax.typesetPromise([eqnOutput]).then(() => {});
});
Expand Down
11 changes: 11 additions & 0 deletions docs/examples/form-equation-input.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@
},
};
</script>
<style>
table,
tr,
td {
border: 1px solid;
border-collapse: collapse;
}
td {
padding: 10px;
}
</style>
<script
id="MathJax-script"
async
Expand Down
9 changes: 6 additions & 3 deletions docs/examples/insert-equation-and-latex.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,14 @@
</div>
<script>
const equationTable = document.querySelector('#equation-table');
const mjxgui = new MJXGUI('#mjxgui-button', function () {
const mjxgui = new MJXGUI('#mjxgui-button', function (
latex,
instance,
) {
let tr = document.createElement('tr');
tr.innerHTML += `
<td>$$ ${mjxgui.getLatex()} $$</td>
<td class="latex-cell">${mjxgui.getLatex()}</td>
<td>$$ ${latex} $$</td>
<td class="latex-cell">${latex}</td>
`;
equationTable.appendChild(tr);

Expand Down
10 changes: 6 additions & 4 deletions docs/js/mjxgui.js
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,9 @@ const symbolLatexMap = {
perp: '\\perp',
angle: '\\angle',
angmsd: '\\measuredangle',
Leftarrow: '\\Leftarrow',
Rightarrow: '\\Rightarrow',
Leftrightarrow: '\\Leftrightarrow',
rightarrow: '\\to',
leftarrow: '\\gets',
leftrightarrow: '\\leftrightarrow',
Expand Down Expand Up @@ -841,7 +844,7 @@ const functionComponentMap = {
class MJXGUI {
constructor(
elementSelector,
successCallback = function () {},
successCallback = function (latex, instance) {},
options = {},
) {
this.selector = elementSelector;
Expand Down Expand Up @@ -1005,7 +1008,7 @@ class MJXGUI {
'._mjxgui_save_equation',
);
saveEquationButton.addEventListener('click', () => {
this.successCallback();
this.successCallback(this.getLatex(), this);
this.hideUI();
this.clearEquation();
});
Expand Down Expand Up @@ -1137,8 +1140,7 @@ class MJXGUI {
function () {},
options,
);
widget.successCallback = function () {
const latex = widget.getLatex();
widget.successCallback = function (latex, instance) {
if (latex.length > 0) {
// Set input value and show equation preview
inp.value = latex;
Expand Down
10 changes: 6 additions & 4 deletions src/mjxgui.js
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,9 @@ const symbolLatexMap = {
perp: '\\perp',
angle: '\\angle',
angmsd: '\\measuredangle',
Leftarrow: '\\Leftarrow',
Rightarrow: '\\Rightarrow',
Leftrightarrow: '\\Leftrightarrow',
rightarrow: '\\to',
leftarrow: '\\gets',
leftrightarrow: '\\leftrightarrow',
Expand Down Expand Up @@ -841,7 +844,7 @@ const functionComponentMap = {
class MJXGUI {
constructor(
elementSelector,
successCallback = function () {},
successCallback = function (latex, instance) {},
options = {},
) {
this.selector = elementSelector;
Expand Down Expand Up @@ -1005,7 +1008,7 @@ class MJXGUI {
'._mjxgui_save_equation',
);
saveEquationButton.addEventListener('click', () => {
this.successCallback();
this.successCallback(this.getLatex(), this);
this.hideUI();
this.clearEquation();
});
Expand Down Expand Up @@ -1137,8 +1140,7 @@ class MJXGUI {
function () {},
options,
);
widget.successCallback = function () {
const latex = widget.getLatex();
widget.successCallback = function (latex, instance) {
if (latex.length > 0) {
// Set input value and show equation preview
inp.value = latex;
Expand Down
4 changes: 2 additions & 2 deletions src/mjxgui.min.js

Large diffs are not rendered by default.

0 comments on commit 0ab9e26

Please sign in to comment.