Skip to content

Commit df1e19a

Browse files
committed
pre-release v1.0.8
- store path for selected tree node - handle links on windows
1 parent 29e1e29 commit df1e19a

File tree

9 files changed

+223
-82
lines changed

9 files changed

+223
-82
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ The custom equations dialog with categories tree
9898

9999
## Release Notes
100100

101+
### 1.0.8
102+
103+
- For the last selected node in the tree of the *Custom Equations* dialog the path is stored to reproduce this node over invocations.
104+
- Some buttons (links) are equipped with tool tips and click handlers to enable for instance the invocation of the *issues* page in the Internet.
105+
101106
### 1.0.7
102107

103108
- Bug fix: *Custom Equations* dialog did not work properly.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "joplin-plugin-katex-input-helper",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"scripts": {
55
"dist": "webpack --env joplin-plugin-config=buildMain && webpack --env joplin-plugin-config=buildExtraScripts && webpack --env joplin-plugin-config=createArchive",
66
"prepare": "npm run dist",

src/assets/dialog.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ <h3>Katex Input Helper</h3>
3333
<hr/>
3434
</div>
3535
<div id="form">
36-
<form name="KATEX" method="post">
36+
<form id="KATEX" name="KATEX" method="post">
3737
<input id="hidden" name="hidden" type="hidden" value="" />
3838
</form>
3939
<div id="formula"></div>
@@ -234,11 +234,10 @@ <h3>Katex Input Helper</h3>
234234
<a href="#" title="a" class="easyui-linkbutton easyui-tooltip" iconcls="icon-link" id="btHTML_A"></a>
235235
<a href="#" title="img" class="easyui-linkbutton easyui-tooltip" iconcls="icon-picture" id="btHTML_IMG"></a>
236236
</div>
237-
<div id="divMathTextInput" class="center easyui-panel" data-options="region:'center',split:false,noheader:true,fit:true">
237+
<div id="divMathTextInput" class="center easyui-panel" data-options="region:'center',split:false,noheader:true">
238238
<form action="#" method="post" id="formMathTextInput">
239239
<fieldset>
240-
<textarea id="mathTextInput" name="equation"
241-
rows="30" cols="30" dir="ltr"></textarea>
240+
<textarea id="mathTextInput" name="equation" rows="30" cols="30" dir="ltr"></textarea>
242241
</fieldset>
243242
</form>
244243
</div>

src/assets/js/dialog.css

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,20 @@ h3 {
100100
margin: 0;
101101
padding: 0;
102102
overflow: hidden;
103-
}
104-
105-
#formMathTextInput {
106-
margin: 0;
107-
padding: 0;
108-
}
109103

110-
#mathTextInput {
111-
margin: 0;
112-
padding: 2px;
113-
border: none;
114-
overflow: auto;
104+
#formMathTextInput {
105+
margin: 0;
106+
padding: 0;
107+
height: 100%;
108+
109+
#mathTextInput {
110+
margin: 0;
111+
padding: 2px;
112+
border: none;
113+
overflow: auto;
114+
height: 100%;
115+
}
116+
}
115117
}
116118

117119
#mathVisualOutput {

src/assets/js/dialog.js

Lines changed: 92 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class Documentations {
107107
*/
108108
class KatexInputHelper {
109109

110-
version = "1.0.6";
110+
version = "1.0.7";
111111
codeType = 'Latex';
112112
saveOptionInCookies = false;
113113
isBuild = false;
@@ -571,6 +571,13 @@ class KatexInputHelper {
571571
});
572572

573573
this.math.setEditorInstance(this.codeMirrorEditor);
574+
575+
$('#divMathTextInput').panel({
576+
onResize: function(width, height) {
577+
vme.codeMirrorEditor.setSize(width, height);
578+
vme.codeMirrorEditor.refresh();
579+
}
580+
});
574581
}
575582

576583
/**
@@ -707,6 +714,17 @@ class KatexInputHelper {
707714
await vme.setUniCodesValues(0x25A0, 0x25FF);
708715
}
709716
});
717+
718+
$('body').on('click', '#btCOPYRIGHT', async function(event) {
719+
event.preventDefault();
720+
await vme.openInformationTab(0);
721+
vme.setFocus();
722+
});
723+
724+
$('body').on('click', '#btTITLE_EDITION_SYNTAX,#btENCLOSE_TYPE', async function(event) {
725+
event.preventDefault();
726+
vme.setFocus();
727+
});
710728

711729
// TEST: MAIL
712730
$('body')
@@ -1092,7 +1110,6 @@ class KatexInputHelper {
10921110
* - setting document language
10931111
* - setting the RTL style
10941112
* - localize all entries of the UI (using *span[locate]*)
1095-
* - additional statements could not be assigned to this task => TODO: separate?
10961113
*/
10971114
async onLocaleChanged(localizer) {
10981115
this.localType = this.localizer.currentLocale;
@@ -1112,38 +1129,20 @@ class KatexInputHelper {
11121129
}
11131130
});
11141131

1115-
// PLACEMENT in Language resources, may be replaced!!
1116-
$("#btCOPYRIGHT").click(async function(event) {
1117-
event.preventDefault();
1118-
await vme.openInformationTab(0);
1119-
vme.setFocus();
1120-
});
1121-
1122-
// TODO: Remove?
1123-
$("#btTITLE_EDITION_SYNTAX").click(function(event) {
1124-
event.preventDefault();
1125-
vme.setFocus();
1126-
});
1127-
1128-
// TODO: HTML mode deactivated, remove completely?
11291132
vme.switchHtmlMode(vme.encloseAllFormula);
1130-
$("#btENCLOSE_TYPE").click(function(event) {
1131-
event.preventDefault();
1132-
vme.setFocus();
1133-
});
11341133

11351134
this.printCodeType();
11361135
}
11371136

11381137
/**
11391138
* @abstract Handlers for the HTML toolbar buttons.
11401139
*
1141-
* This is the only place, where the ColorPicker is used.
1140+
* This is the only place, where the ColorPicker is used. The click events
1141+
* are assigned to static Html content, no need to re-invoke this in
1142+
* *onLocaleChanged*.
11421143
*/
11431144
htmlToolbarButtons() {
11441145

1145-
// TODO: it seems this code has nothing to do with language, but perhaps the visual appearance
1146-
// depends on ltr - style. There seems to be no switch.
11471146
$("#btHTML_STRONG").click(function(event) { event.preventDefault(); vme.tag("<strong>", "</strong>"); });
11481147
$("#btHTML_EM").click(function(event) { event.preventDefault(); vme.tag("<em>", "</em>"); });
11491148
$("#btHTML_U").click(function(event) { event.preventDefault(); vme.tag("<u>", "</u>"); });
@@ -1466,59 +1465,93 @@ class KatexInputHelper {
14661465
vme.symbolPanelsLoaded.push(fPanelID);
14671466
$(fPanel).html(`<img src='js/jquery-easyui/themes/default/images/loading.gif' />`);
14681467
$(fPanel).load(
1469-
`formulas/` + fPanelID + ".html",
1468+
`formulas/${fPanelID}.html`,
14701469
async function() {
14711470
await vme.initialiseSymbolContent(fPanelID);
1472-
$("#" + fPanelID + " a.more").click(
1473-
async function(event) {
1474-
event.preventDefault();
1475-
await vme.initialiseUImoreDialogs(fPanelID);
1476-
}
1477-
);
14781471
vme.themes.activateStyle(vme.style)
14791472
}
14801473
);
1474+
$(`#${fPanelID}`).on('click', 'a.more',
1475+
async function(event) {
1476+
event.preventDefault();
1477+
await vme.initialiseUImoreDialogs(fPanelID);
1478+
}
1479+
);
14811480
}
14821481
}
14831482
vme.setFocus();
14841483
}
14851484
});
14861485
var p = $(accordionID).accordion('getSelected');
14871486
if (p) { p.panel('collapse', false); }
1488-
this.math.updateHeaders(); // TODO: maybe this must be done only once, optimize!
1487+
this.math.updateHeaders();
14891488
}
14901489

1490+
/**
1491+
* @abstract The routine equips the entries in the given panel with functionality.
1492+
*
1493+
* This is:
1494+
* - tool tip
1495+
* - info line
1496+
* - click event
1497+
*/
14911498
async initialiseSymbolContent(fPanelID) {
14921499
var vme = this;
1493-
function getSymbol(obj) {
1494-
if (typeof ($(obj).attr("lbegin")) != "undefined" && typeof ($(obj).attr("lend")) != "undefined") {
1495-
return $(obj).attr("lbegin") + $(obj).attr("lend");
1496-
} else if (typeof ($(obj).attr("latex")) != "undefined") {
1497-
return $(obj).attr("latex");
1498-
} else {
1499-
return vme.getLocalText("NO_LATEX");
1500-
}
1501-
};
1502-
$("#" + fPanelID + " a.s")
1503-
.addClass("easyui-tooltip")
1504-
.attr("title", function(index, attr) { return getSymbol(this); })
1505-
.mouseover(function(event) { $("#divInformation").html(getSymbol(this)); })
1506-
.mouseout(function(event) { $("#divInformation").html("&nbsp;"); })
1507-
.click(function(event) {
1508-
console.debug(`click event`);
1509-
event.preventDefault();
1510-
if (typeof ($(this).attr("lbegin")) != "undefined" && typeof ($(this).attr("lend")) != "undefined") {
1511-
vme.tag($(this).attr("lbegin"), $(this).attr("lend"));
1512-
} else if (typeof ($(this).attr("latex")) != "undefined") {
1513-
vme.insert($(this).attr("latex"));
1514-
} else {
1515-
$.messager.show({
1516-
title: "<span class='rtl-title-withicon'>" + vme.getLocalText("INFORMATION") + "</span>",
1517-
msg: vme.getLocalText("NO_LATEX") });
1518-
}
1500+
/**
1501+
* @abstract Given an anchor object, determines and returns the included
1502+
* LATEX code used as info for tool tip and info line.
1503+
*/
1504+
function getSymbol(a) {
1505+
var info = beginEndInfo(a);
1506+
if (info !== null) return info[0] + info[1];
1507+
info = latex(a);
1508+
if (info !== null) return info;
1509+
return vme.getLocalText("NO_LATEX");
1510+
};
1511+
1512+
/**
1513+
* @abstract Returns the begin to end info of an anchor.
1514+
*/
1515+
function beginEndInfo(a) {
1516+
if (typeof ($(a).attr("lbegin")) != "undefined" && typeof ($(a).attr("lend")) != "undefined")
1517+
return [$(a).attr("lbegin"), $(a).attr("lend")];
1518+
return null;
1519+
}
1520+
1521+
/**
1522+
* @abstract Returns the latex info of an anchor.
1523+
*/
1524+
function latex(a) {
1525+
if (typeof ($(a).attr("latex")) != "undefined")
1526+
return $(a).attr("latex");
1527+
}
1528+
1529+
$(`#${fPanelID} a.s`)
1530+
.addClass("easyui-tooltip")
1531+
.attr("title", function(index, attr) { return getSymbol(this); })
1532+
.mouseover(function(event) { $("#divInformation").html(getSymbol(this)); })
1533+
.mouseout(function(event) { $("#divInformation").html("&nbsp;"); })
1534+
.click(function(event) {
1535+
event.preventDefault();
1536+
var info = beginEndInfo(this);
1537+
if (info !== null) {
1538+
vme.tag(...info);
1539+
return;
1540+
}
1541+
info = latex(this);
1542+
if (info !== null) {
1543+
vme.insert(info);
1544+
return;
1545+
}
1546+
$.messager.show({
1547+
title: "<span class='rtl-title-withicon'>" + vme.getLocalText("INFORMATION") + "</span>",
1548+
msg: vme.getLocalText("NO_LATEX")
15191549
});
1520-
// link with more class -> needs image handling
1521-
$("#" + fPanelID + " a.more")
1550+
});
1551+
1552+
// this is solely for a single ...more button linking to a dialog
1553+
// containing more formulae.
1554+
$(`#${fPanelID} a.more`)
15221555
.addClass("easyui-tooltip")
15231556
.attr("title", function(index, attr) { return "Loading more formulae"; });
15241557

src/assets/js/math.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ class MathFormulae {
7777

7878
/**
7979
* Updates Tables in Panels or Dialogs by translating contained Math. Although this is a Math
80-
* method, it also updates some image references. TODO: implement SRP (single responsibility principle)
80+
* method, it also updates some image references. TODO: implement SRP (single responsibility
81+
* principle)
8182
*/
8283
async updateTables() {
8384
try {
@@ -207,7 +208,6 @@ class MathFormulae {
207208
a.addClass("easyui-tooltip s");
208209

209210
// TODO: TEST: TRIAL WITH JAVASCRIPT
210-
// .attr("title", function(index, attr) { return getSymbol(a); })
211211
if (javascript) {
212212
a.attr("href", "javascript:void(0)")
213213
.tooltip({

0 commit comments

Comments
 (0)