reimplementation of frontend's api.addButtonToToolbar() to smoothen the upgrade

This commit is contained in:
zadam 2022-12-17 21:46:51 +01:00
parent 967919b400
commit 5af506e268
14 changed files with 382 additions and 161 deletions

View File

@ -1226,7 +1226,7 @@ See addLabel, addRelation for more specific methods.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1162">line 1162</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1174">line 1174</a>
</li></ul></dd>
@ -1513,7 +1513,7 @@ See addLabel, addRelation for more specific methods.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1183">line 1183</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1195">line 1195</a>
</li></ul></dd>
@ -1692,7 +1692,7 @@ returned.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1196">line 1196</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1208">line 1208</a>
</li></ul></dd>
@ -1927,7 +1927,7 @@ returned.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1281">line 1281</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1293">line 1293</a>
</li></ul></dd>
@ -2127,7 +2127,7 @@ returned.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1295">line 1295</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1307">line 1307</a>
</li></ul></dd>
@ -2389,7 +2389,7 @@ returned.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1077">line 1077</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1089">line 1089</a>
</li></ul></dd>
@ -2495,7 +2495,7 @@ returned.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line997">line 997</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1009">line 1009</a>
</li></ul></dd>
@ -2669,7 +2669,7 @@ returned.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line585">line 585</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line600">line 600</a>
</li></ul></dd>
@ -2847,7 +2847,7 @@ returned.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line596">line 596</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line611">line 611</a>
</li></ul></dd>
@ -3674,7 +3674,7 @@ returned.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line728">line 728</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line740">line 740</a>
</li></ul></dd>
@ -3931,7 +3931,7 @@ returned.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line526">line 526</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line541">line 541</a>
</li></ul></dd>
@ -4089,7 +4089,7 @@ returned.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line550">line 550</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line565">line 565</a>
</li></ul></dd>
@ -4259,7 +4259,7 @@ returned.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line625">line 625</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line640">line 640</a>
</li></ul></dd>
@ -4426,7 +4426,7 @@ returned.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line617">line 617</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line632">line 632</a>
</li></ul></dd>
@ -4532,7 +4532,7 @@ returned.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line695">line 695</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line707">line 707</a>
</li></ul></dd>
@ -4712,7 +4712,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line607">line 607</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line622">line 622</a>
</li></ul></dd>
@ -4977,7 +4977,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line667">line 667</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line682">line 682</a>
</li></ul></dd>
@ -5132,7 +5132,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line532">line 532</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line547">line 547</a>
</li></ul></dd>
@ -5290,7 +5290,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line556">line 556</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line571">line 571</a>
</li></ul></dd>
@ -5460,7 +5460,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line641">line 641</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line656">line 656</a>
</li></ul></dd>
@ -5627,7 +5627,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line633">line 633</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line648">line 648</a>
</li></ul></dd>
@ -5782,7 +5782,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line544">line 544</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line559">line 559</a>
</li></ul></dd>
@ -5940,7 +5940,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line568">line 568</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line583">line 583</a>
</li></ul></dd>
@ -6110,7 +6110,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line657">line 657</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line672">line 672</a>
</li></ul></dd>
@ -6558,7 +6558,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line538">line 538</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line553">line 553</a>
</li></ul></dd>
@ -6716,7 +6716,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line562">line 562</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line577">line 577</a>
</li></ul></dd>
@ -6886,7 +6886,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line649">line 649</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line664">line 664</a>
</li></ul></dd>
@ -7101,7 +7101,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line855">line 855</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line867">line 867</a>
</li></ul></dd>
@ -7309,7 +7309,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line878">line 878</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line890">line 890</a>
</li></ul></dd>
@ -7411,7 +7411,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line938">line 938</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line950">line 950</a>
</li></ul></dd>
@ -7513,7 +7513,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line824">line 824</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line836">line 836</a>
</li></ul></dd>
@ -7615,7 +7615,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1039">line 1039</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1051">line 1051</a>
</li></ul></dd>
@ -7811,7 +7811,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1023">line 1023</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1035">line 1035</a>
</li></ul></dd>
@ -8037,7 +8037,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line470">line 470</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line485">line 485</a>
</li></ul></dd>
@ -8333,7 +8333,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line499">line 499</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line514">line 514</a>
</li></ul></dd>
@ -8562,7 +8562,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line576">line 576</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line591">line 591</a>
</li></ul></dd>
@ -8760,7 +8760,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line506">line 506</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line521">line 521</a>
</li></ul></dd>
@ -8958,7 +8958,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line520">line 520</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line535">line 535</a>
</li></ul></dd>
@ -9156,7 +9156,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line513">line 513</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line528">line 528</a>
</li></ul></dd>
@ -9306,7 +9306,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1098">line 1098</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1110">line 1110</a>
</li></ul></dd>
@ -10228,7 +10228,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1142">line 1142</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1154">line 1154</a>
</li></ul></dd>
@ -10408,7 +10408,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1257">line 1257</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1269">line 1269</a>
</li></ul></dd>
@ -10588,7 +10588,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1265">line 1265</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1277">line 1277</a>
</li></ul></dd>
@ -10783,7 +10783,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1347">line 1347</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1359">line 1359</a>
</li></ul></dd>
@ -11015,7 +11015,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1111">line 1111</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1123">line 1123</a>
</li></ul></dd>
@ -11195,7 +11195,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1241">line 1241</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1253">line 1253</a>
</li></ul></dd>
@ -11355,7 +11355,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1249">line 1249</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1261">line 1261</a>
</li></ul></dd>
@ -11597,7 +11597,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1208">line 1208</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1220">line 1220</a>
</li></ul></dd>
@ -11808,7 +11808,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1224">line 1224</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1236">line 1236</a>
</li></ul></dd>
@ -12019,7 +12019,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1233">line 1233</a>
<a href="becca_entities_note.js.html">becca/entities/note.js</a>, <a href="becca_entities_note.js.html#line1245">line 1245</a>
</li></ul></dd>

View File

@ -360,7 +360,7 @@ class Note extends AbstractEntity {
/** @returns {boolean} true if this note is JavaScript (code or attachment) */
isJavaScript() {
return (this.type === "code" || this.type === "file")
return (this.type === "code" || this.type === "file" || this.type === 'launcher')
&amp;&amp; (this.mime.startsWith("application/javascript")
|| this.mime === "application/x-javascript"
|| this.mime === "text/javascript");
@ -400,6 +400,8 @@ class Note extends AbstractEntity {
* @returns {Attribute[]} all note's attributes, including inherited ones
*/
getAttributes(type, name) {
this.__validateTypeName(type, name);
this.__getAttributes([]);
if (type &amp;&amp; name) {
@ -489,6 +491,19 @@ class Note extends AbstractEntity {
return this.inheritableAttributeCache;
}
__validateTypeName(type, name) {
if (type &amp;&amp; type !== 'label' &amp;&amp; type !== 'relation') {
throw new Error(`Unrecognized attribute type '${type}'. Only 'label' and 'relation' are possible values.`);
}
if (name) {
const firstLetter = name.charAt(0);
if (firstLetter === '#' || firstLetter === '~') {
throw new Error(`Detect '#' or '~' in the attribute's name. In the API, attribute names should be set without these characters.`);
}
}
}
/**
* @param type
* @param name
@ -693,10 +708,7 @@ class Note extends AbstractEntity {
* @returns {Attribute[]} note's "owned" attributes - excluding inherited ones
*/
getOwnedAttributes(type = null, name = null, value = null) {
// it's a common mistake to include # or ~ into attribute name
if (name &amp;&amp; ["#", "~"].includes(name[0])) {
name = name.substr(1);
}
this.__validateTypeName(type, name);
if (type &amp;&amp; name &amp;&amp; value !== undefined &amp;&amp; value !== null) {
return this.ownedAttributes.filter(attr => attr.type === type &amp;&amp; attr.name === name &amp;&amp; attr.value === value);

View File

@ -1212,13 +1212,16 @@
<h4 class="name" id="addButtonToToolbar"><span class="type-signature"></span>addButtonToToolbar<span class="signature">()</span><span class="type-signature"></span></h4>
<h4 class="name" id="addButtonToToolbar"><span class="type-signature"></span>addButtonToToolbar<span class="signature">(opts)</span><span class="type-signature"></span></h4>
<div class="description">
Adds a new launcher to the launchbar. If the launcher (id) already exists, it will be updated.
</div>
@ -1228,6 +1231,56 @@
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>opts</code></td>
<td class="type">
<span class="param-type"><a href="global.html#CreateOrUpdateLauncherOptions">CreateOrUpdateLauncherOptions</a></span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
@ -1248,7 +1301,7 @@
<dt class="important tag-deprecated">Deprecated:</dt><dd><ul class="dummy"><li>this API has no effect anymore. Use bookmarks or launchpad shortcuts instead.</li></ul></dd>
<dt class="important tag-deprecated">Deprecated:</dt><dd><ul class="dummy"><li>you can now create/modify launchers in the</li></ul></dd>
@ -1262,7 +1315,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line119">line 119</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line124">line 124</a>
</li></ul></dd>
@ -1399,7 +1452,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line322">line 322</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line332">line 332</a>
</li></ul></dd>
@ -1538,7 +1591,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line310">line 310</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line320">line 320</a>
</li></ul></dd>
@ -1746,7 +1799,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line515">line 515</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line525">line 525</a>
</li></ul></dd>
@ -2110,7 +2163,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line301">line 301</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line311">line 311</a>
</li></ul></dd>
@ -2243,7 +2296,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line241">line 241</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line251">line 251</a>
</li></ul></dd>
@ -2353,7 +2406,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line368">line 368</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line378">line 378</a>
</li></ul></dd>
@ -2459,7 +2512,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line339">line 339</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line349">line 349</a>
</li></ul></dd>
@ -2565,7 +2618,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line394">line 394</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line404">line 404</a>
</li></ul></dd>
@ -2675,7 +2728,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line360">line 360</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line370">line 370</a>
</li></ul></dd>
@ -2786,7 +2839,7 @@ implementation of actual widget type.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line377">line 377</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line387">line 387</a>
</li></ul></dd>
@ -2890,7 +2943,7 @@ implementation of actual widget type.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line329">line 329</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line339">line 339</a>
</li></ul></dd>
@ -2998,7 +3051,7 @@ implementation of actual widget type.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line384">line 384</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line394">line 394</a>
</li></ul></dd>
@ -3166,7 +3219,7 @@ implementation of actual widget type.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line348">line 348</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line358">line 358</a>
</li></ul></dd>
@ -3303,7 +3356,7 @@ implementation of actual widget type.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line403">line 403</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line413">line 413</a>
</li></ul></dd>
@ -3460,7 +3513,7 @@ implementation of actual widget type.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line455">line 455</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line465">line 465</a>
</li></ul></dd>
@ -3615,7 +3668,7 @@ implementation of actual widget type.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line464">line 464</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line474">line 474</a>
</li></ul></dd>
@ -3722,7 +3775,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line234">line 234</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line244">line 244</a>
</li></ul></dd>
@ -3877,7 +3930,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line482">line 482</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line492">line 492</a>
</li></ul></dd>
@ -4033,7 +4086,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line206">line 206</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line216">line 216</a>
</li></ul></dd>
@ -4234,7 +4287,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line218">line 218</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line228">line 228</a>
</li></ul></dd>
@ -4340,7 +4393,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line445">line 445</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line455">line 455</a>
</li></ul></dd>
@ -4495,7 +4548,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line473">line 473</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line483">line 483</a>
</li></ul></dd>
@ -4650,7 +4703,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line491">line 491</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line501">line 501</a>
</li></ul></dd>
@ -4800,7 +4853,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line552">line 552</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line562">line 562</a>
</li></ul></dd>
@ -5289,7 +5342,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line248">line 248</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line258">line 258</a>
</li></ul></dd>
@ -5397,7 +5450,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line415">line 415</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line425">line 425</a>
</li></ul></dd>
@ -5553,7 +5606,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line426">line 426</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line436">line 436</a>
</li></ul></dd>
@ -5709,7 +5762,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line435">line 435</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line445">line 445</a>
</li></ul></dd>
@ -5846,7 +5899,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line542">line 542</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line552">line 552</a>
</li></ul></dd>
@ -6000,7 +6053,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line533">line 533</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line543">line 543</a>
</li></ul></dd>
@ -6086,7 +6139,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line288">line 288</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line298">line 298</a>
</li></ul></dd>
@ -6223,7 +6276,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line226">line 226</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line236">line 236</a>
</li></ul></dd>
@ -6384,7 +6437,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line144">line 144</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line154">line 154</a>
</li></ul></dd>
@ -6492,7 +6545,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line172">line 172</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line182">line 182</a>
</li></ul></dd>
@ -6630,7 +6683,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line194">line 194</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line204">line 204</a>
</li></ul></dd>
@ -6786,7 +6839,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line182">line 182</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line192">line 192</a>
</li></ul></dd>
@ -6941,7 +6994,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line500">line 500</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line510">line 510</a>
</li></ul></dd>
@ -7092,7 +7145,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line409">line 409</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line419">line 419</a>
</li></ul></dd>
@ -7229,7 +7282,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line264">line 264</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line274">line 274</a>
</li></ul></dd>
@ -7366,7 +7419,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line256">line 256</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line266">line 266</a>
</li></ul></dd>
@ -7526,7 +7579,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line273">line 273</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line283">line 283</a>
</li></ul></dd>
@ -7686,7 +7739,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line282">line 282</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line292">line 292</a>
</li></ul></dd>
@ -7778,7 +7831,7 @@ Typical use case is when new note has been created, we should wait until it is s
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line526">line 526</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line536">line 536</a>
</li></ul></dd>

View File

@ -1103,7 +1103,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line514">line 514</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line531">line 531</a>
</li></ul></dd>
@ -1281,7 +1281,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line536">line 536</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line553">line 553</a>
</li></ul></dd>
@ -2150,7 +2150,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line576">line 576</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line593">line 593</a>
</li></ul></dd>
@ -2305,7 +2305,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line600">line 600</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line617">line 617</a>
</li></ul></dd>
@ -2472,7 +2472,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line395">line 395</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line412">line 412</a>
</li></ul></dd>
@ -2582,7 +2582,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line727">line 727</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line744">line 744</a>
</li></ul></dd>
@ -2756,7 +2756,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line503">line 503</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line520">line 520</a>
</li></ul></dd>
@ -2934,7 +2934,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line525">line 525</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line542">line 542</a>
</li></ul></dd>
@ -3289,7 +3289,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line570">line 570</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line587">line 587</a>
</li></ul></dd>
@ -3444,7 +3444,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line594">line 594</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line611">line 611</a>
</li></ul></dd>
@ -3611,7 +3611,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line387">line 387</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line404">line 404</a>
</li></ul></dd>
@ -3766,7 +3766,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line582">line 582</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line599">line 599</a>
</li></ul></dd>
@ -3921,7 +3921,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line606">line 606</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line623">line 623</a>
</li></ul></dd>
@ -4088,7 +4088,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line468">line 468</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line485">line 485</a>
</li></ul></dd>
@ -4651,7 +4651,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line588">line 588</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line605">line 605</a>
</li></ul></dd>
@ -4806,7 +4806,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line618">line 618</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line635">line 635</a>
</li></ul></dd>
@ -4976,7 +4976,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line628">line 628</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line645">line 645</a>
</li></ul></dd>
@ -5127,7 +5127,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line612">line 612</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line629">line 629</a>
</li></ul></dd>
@ -5294,7 +5294,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line476">line 476</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line493">line 493</a>
</li></ul></dd>
@ -5400,7 +5400,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line771">line 771</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line788">line 788</a>
</li></ul></dd>
@ -5513,7 +5513,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line716">line 716</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line733">line 733</a>
</li></ul></dd>
@ -5619,7 +5619,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line706">line 706</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line723">line 723</a>
</li></ul></dd>
@ -5721,7 +5721,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line642">line 642</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line659">line 659</a>
</li></ul></dd>
@ -5895,7 +5895,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line485">line 485</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line502">line 502</a>
</li></ul></dd>
@ -6152,7 +6152,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line552">line 552</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line569">line 569</a>
</li></ul></dd>
@ -6330,7 +6330,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line494">line 494</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line511">line 511</a>
</li></ul></dd>
@ -6485,7 +6485,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line546">line 546</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line563">line 563</a>
</li></ul></dd>
@ -6640,7 +6640,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line558">line 558</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line575">line 575</a>
</li></ul></dd>
@ -6795,7 +6795,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line564">line 564</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line581">line 581</a>
</li></ul></dd>
@ -6903,7 +6903,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line699">line 699</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line716">line 716</a>
</li></ul></dd>
@ -6987,7 +6987,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line766">line 766</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line783">line 783</a>
</li></ul></dd>
@ -7093,7 +7093,7 @@ This note's representation is used in note tree and is kept in Froca.</div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line758">line 758</a>
<a href="entities_note_short.js.html">entities/note_short.js</a>, <a href="entities_note_short.js.html#line775">line 775</a>
</li></ul></dd>

View File

@ -382,6 +382,8 @@ class NoteShort {
return a.isSearch ? 1 : -1;
} else if (a.isArchived !== b.isArchived) {
return a.isArchived ? 1 : -1;
} else if (a.isHidden !== b.isHidden) {
return a.isHidden ? 1 : -1;
} else {
return a.notePath.length - b.notePath.length;
}
@ -391,6 +393,8 @@ class NoteShort {
}
__filterAttrs(attributes, type, name) {
this.__validateTypeName(type, name);
if (!type &amp;&amp; !name) {
return attributes;
} else if (type &amp;&amp; name) {
@ -408,6 +412,19 @@ class NoteShort {
return attrs.filter(attr => attr.isInheritable);
}
__validateTypeName(type, name) {
if (type &amp;&amp; type !== 'label' &amp;&amp; type !== 'relation') {
throw new Error(`Unrecognized attribute type '${type}'. Only 'label' and 'relation' are possible values.`);
}
if (name) {
const firstLetter = name.charAt(0);
if (firstLetter === '#' || firstLetter === '~') {
throw new Error(`Detect '#' or '~' in the attribute's name. In the API, attribute names should be set without these characters.`);
}
}
}
/**
* @param {string} [name] - label name to filter
* @returns {Attribute[]} all note's labels (attributes with type label), including inherited ones
@ -784,7 +801,7 @@ class NoteShort {
/** @returns {boolean} true if this note is JavaScript (code or attachment) */
isJavaScript() {
return (this.type === "code" || this.type === "file")
return (this.type === "code" || this.type === "file" || this.type === 'launcher')
&amp;&amp; (this.mime.startsWith("application/javascript")
|| this.mime === "application/x-javascript"
|| this.mime === "text/javascript");

View File

@ -194,7 +194,7 @@
<h4 class="name" id="ToolbarButtonOptions">ToolbarButtonOptions</h4>
<h4 class="name" id="CreateOrUpdateLauncherOptions">CreateOrUpdateLauncherOptions</h4>
@ -241,6 +241,38 @@
<tbody>
<tr>
<td class="name"><code>id</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">id of the button, used to identify the old instances of this button to be replaced
ID is optional because of BC, but not specifying it is deprecated. ID can be alphanumeric only.</td>
</tr>
<tr>
<td class="name"><code>title</code></td>

View File

@ -134,7 +134,9 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
};
/**
* @typedef {Object} ToolbarButtonOptions
* @typedef {Object} CreateOrUpdateLauncherOptions
* @property {string} [id] - id of the button, used to identify the old instances of this button to be replaced
* ID is optional because of BC, but not specifying it is deprecated. ID can be alphanumeric only.
* @property {string} title
* @property {string} [icon] - name of the boxicon to be used (e.g. "time" for "bx-time" icon)
* @property {function} action - callback handling the click on the button
@ -142,9 +144,17 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
*/
/**
* @deprecated this API has no effect anymore. Use bookmarks or launchpad shortcuts instead.
* Adds a new launcher to the launchbar. If the launcher (id) already exists, it will be updated.
*
* @deprecated you can now create/modify launchers in the
* @param {CreateOrUpdateLauncherOptions} opts
*/
this.addButtonToToolbar = () => console.warn("api.addButtonToToolbar() calls are deprecated and have no effect");
this.addButtonToToolbar = async opts => {
const {action, ...reqBody} = opts;
reqBody.action = action.toString();
await server.put('special-notes/api-script-launcher', reqBody);
};
function prepareParams(params) {
if (!params) {

View File

@ -332,7 +332,7 @@ class Note extends AbstractEntity {
/** @returns {boolean} true if this note is JavaScript (code or attachment) */
isJavaScript() {
return (this.type === "code" || this.type === "file")
return (this.type === "code" || this.type === "file" || this.type === 'launcher')
&& (this.mime.startsWith("application/javascript")
|| this.mime === "application/x-javascript"
|| this.mime === "text/javascript");
@ -372,6 +372,8 @@ class Note extends AbstractEntity {
* @returns {Attribute[]} all note's attributes, including inherited ones
*/
getAttributes(type, name) {
this.__validateTypeName(type, name);
this.__getAttributes([]);
if (type && name) {
@ -461,6 +463,19 @@ class Note extends AbstractEntity {
return this.inheritableAttributeCache;
}
__validateTypeName(type, name) {
if (type && type !== 'label' && type !== 'relation') {
throw new Error(`Unrecognized attribute type '${type}'. Only 'label' and 'relation' are possible values.`);
}
if (name) {
const firstLetter = name.charAt(0);
if (firstLetter === '#' || firstLetter === '~') {
throw new Error(`Detect '#' or '~' in the attribute's name. In the API, attribute names should be set without these characters.`);
}
}
}
/**
* @param type
* @param name
@ -665,10 +680,7 @@ class Note extends AbstractEntity {
* @returns {Attribute[]} note's "owned" attributes - excluding inherited ones
*/
getOwnedAttributes(type = null, name = null, value = null) {
// it's a common mistake to include # or ~ into attribute name
if (name && ["#", "~"].includes(name[0])) {
name = name.substr(1);
}
this.__validateTypeName(type, name);
if (type && name && value !== undefined && value !== null) {
return this.ownedAttributes.filter(attr => attr.type === type && attr.name === name && attr.value === value);

View File

@ -365,6 +365,8 @@ class NoteShort {
}
__filterAttrs(attributes, type, name) {
this.__validateTypeName(type, name);
if (!type && !name) {
return attributes;
} else if (type && name) {
@ -382,6 +384,19 @@ class NoteShort {
return attrs.filter(attr => attr.isInheritable);
}
__validateTypeName(type, name) {
if (type && type !== 'label' && type !== 'relation') {
throw new Error(`Unrecognized attribute type '${type}'. Only 'label' and 'relation' are possible values.`);
}
if (name) {
const firstLetter = name.charAt(0);
if (firstLetter === '#' || firstLetter === '~') {
throw new Error(`Detect '#' or '~' in the attribute's name. In the API, attribute names should be set without these characters.`);
}
}
}
/**
* @param {string} [name] - label name to filter
* @returns {Attribute[]} all note's labels (attributes with type label), including inherited ones
@ -758,7 +773,7 @@ class NoteShort {
/** @returns {boolean} true if this note is JavaScript (code or attachment) */
isJavaScript() {
return (this.type === "code" || this.type === "file")
return (this.type === "code" || this.type === "file" || this.type === 'launcher')
&& (this.mime.startsWith("application/javascript")
|| this.mime === "application/x-javascript"
|| this.mime === "text/javascript");

View File

@ -106,7 +106,9 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
};
/**
* @typedef {Object} ToolbarButtonOptions
* @typedef {Object} CreateOrUpdateLauncherOptions
* @property {string} [id] - id of the button, used to identify the old instances of this button to be replaced
* ID is optional because of BC, but not specifying it is deprecated. ID can be alphanumeric only.
* @property {string} title
* @property {string} [icon] - name of the boxicon to be used (e.g. "time" for "bx-time" icon)
* @property {function} action - callback handling the click on the button
@ -114,9 +116,19 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
*/
/**
* @deprecated this API has no effect anymore. Use bookmarks or launchpad shortcuts instead.
* Adds a new launcher to the launchbar. If the launcher (id) already exists, it will be updated.
*
* @deprecated you can now create/modify launchers in the top-left Menu -> Configure Launchbar
* @param {CreateOrUpdateLauncherOptions} opts
*/
this.addButtonToToolbar = () => console.warn("api.addButtonToToolbar() calls are deprecated and have no effect");
this.addButtonToToolbar = async opts => {
console.warn("api.addButtonToToolbar() has been deprecated since v0.58 and may be removed in the future. Use Menu -> Configure Launchbar to create/update launchers instead.");
const {action, ...reqBody} = opts;
reqBody.action = action.toString();
await server.put('special-notes/api-script-launcher', reqBody);
};
function prepareParams(params) {
if (!params) {

View File

@ -6,12 +6,16 @@ export default class ScriptLauncher extends AbstractLauncher {
this.title(this.launcherNote.title)
.icon(this.launcherNote.getIcon())
.onClick(this.handler);
.onClick(() => this.launch());
}
async launch() {
const script = await this.launcherNote.getRelationTarget('script');
if (this.launcherNote.hasLabel('scriptInLauncherContent')) {
await this.launcherNote.executeScript();
} else {
const script = await this.launcherNote.getRelationTarget('script');
await script.executeScript();
await script.executeScript();
}
}
}
}

View File

@ -74,6 +74,10 @@ function resetLauncher(req) {
return specialNotesService.resetLauncher(req.params.noteId);
}
function createOrUpdateScriptLauncherFromApi(req) {
return specialNotesService.createOrUpdateScriptLauncherFromApi(req.body);
}
module.exports = {
getInboxNote,
getDayNote,
@ -86,5 +90,6 @@ module.exports = {
createSearchNote,
saveSearchNote,
createLauncher,
resetLauncher
resetLauncher,
createOrUpdateScriptLauncherFromApi
};

View File

@ -343,6 +343,7 @@ function register(app) {
apiRoute(POST, '/api/special-notes/save-search-note', specialNotesRoute.saveSearchNote);
apiRoute(POST, '/api/special-notes/launchers/:noteId/reset', specialNotesRoute.resetLauncher);
apiRoute(POST, '/api/special-notes/launchers/:parentNoteId/:launcherType', specialNotesRoute.createLauncher);
apiRoute(PUT, '/api/special-notes/api-script-launcher', specialNotesRoute.createOrUpdateScriptLauncherFromApi);
// :filename is not used by trilium, but instead used for "save as" to assign a human-readable filename
route(GET, '/api/images/:noteId/:filename', [auth.checkApiAuthOrElectron], imageRoute.returnImage);

View File

@ -143,6 +143,19 @@ function getHoistedNote() {
return becca.getNote(cls.getHoistedNoteId());
}
function createScriptLauncher(parentNoteId, forceNoteId = null) {
const note = noteService.createNewNote({
noteId: forceNoteId,
title: "Script Launcher",
type: 'launcher',
content: '',
parentNoteId: parentNoteId
}).note;
note.addRelation('template', 'lbTplScriptLauncher');
return note;
}
function createLauncher(parentNoteId, launcherType) {
let note;
@ -156,14 +169,7 @@ function createLauncher(parentNoteId, launcherType) {
note.addRelation('template', 'lbTplNoteLauncher');
} else if (launcherType === 'script') {
note = noteService.createNewNote({
title: "Script Launcher",
type: 'launcher',
content: '',
parentNoteId: parentNoteId
}).note;
note.addRelation('template', 'lbTplScriptLauncher');
note = createScriptLauncher(parentNoteId);
} else if (launcherType === 'customWidget') {
note = noteService.createNewNote({
title: "Widget Launcher",
@ -215,6 +221,47 @@ function resetLauncher(noteId) {
hiddenSubtreeService.checkHiddenSubtree();
}
/**
* This exists to ease transition into the new launchbar, but it's not meant to be a permanent functionality.
* Previously, the launchbar was fixed and the only way to add buttons was through this API, so a lot of buttons have been
* created just to fill this user hole.
*
* Another use case would be for script-packages (of which only few exists) which could this way register automatically
* into the launchbar. For such use cases this might be a usable replacement, but I'm not yet clear on that.
*/
function createOrUpdateScriptLauncherFromApi(opts) {
const launcherId = opts.id || ("tb" + opts.title.replace(/[^[a-z0-9]/gi, ""));
if (!opts.title) {
throw new Error("Title is mandatory property to create or update a launcher.");
} else if (!/^[a-z0-9]+$/i.test(launcherId)) {
throw new Error(`Launcher ID can be alphanumeric only, '${launcherId}' given`);
}
const launcherNote = becca.getNote(launcherId)
|| createScriptLauncher('lbVisibleLaunchers', launcherId);
launcherNote.title = opts.title;
launcherNote.setContent("(" + opts.action + ")()");
launcherNote.setLabel('scriptInLauncherContent'); // there's no target note, the script is in the launcher's content
launcherNote.mime = 'application/javascript;env=frontend';
launcherNote.save();
if (opts.shortcut) {
launcherNote.setLabel('keyboardShortcut', opts.shortcut);
} else {
launcherNote.removeLabel('keyboardShortcut');
}
if (opts.icon) {
launcherNote.setLabel('iconClass', "bx bx-" + opts.icon);
} else {
launcherNote.removeLabel('iconClass');
}
return launcherNote;
}
module.exports = {
getInboxNote,
createSqlConsole,
@ -222,5 +269,6 @@ module.exports = {
createSearchNote,
saveSearchNote,
createLauncher,
resetLauncher
resetLauncher,
createOrUpdateScriptLauncherFromApi
};