Add frontend note prompt API

This commit is contained in:
Benjamin Kaiser 2023-11-06 13:41:00 +10:00
parent 809ffa0c6e
commit e5adbaac62
4 changed files with 148 additions and 79 deletions

View file

@ -49,8 +49,7 @@
<div class="description">
<p>This is the main frontend API interface for scripts. All the properties and methods are published in the "api" object
available in the JS frontend notes. You can use e.g. <code>api.showMessage(api.startNote.title);</code></p>
<p>This is the main frontend API interface for scripts. All the properties and methods are published in the "api" object available in the JS frontend notes. You can use e.g. <code>api.showMessage(api.startNote.title);</code></p>
</div>
@ -462,7 +461,7 @@ available in the JS frontend notes. You can use e.g. <code>api.showMessage(api.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#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#line414">line 414</a>
</li></ul></dd>
@ -558,8 +557,7 @@ available in the JS frontend notes. You can use e.g. <code>api.showMessage(api.s
<div class="description">
day.js library for date manipulation.
See <a href="https://day.js.org">https://day.js.org</a> for documentation
day.js library for date manipulation. See <a href="https://day.js.org">https://day.js.org</a> for documentation
</div>
@ -632,6 +630,68 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<h4 class="name" id="getNoteAutocomplete"><span class="type-signature"></span>getNoteAutocomplete<span class="type-signature"></span></h4>
<div class="description">
Show prompt for selecting a note to the user.
</div>
<dl class="details">
<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#line378">line 378</a>
</li></ul></dd>
</dl>
<h4 class="name" id="originEntity"><span class="type-signature"></span>originEntity<span class="type-signature"> :object|null</span></h4>
@ -1275,8 +1335,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<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>
<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>
@ -1378,8 +1437,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<dt class="important tag-deprecated">Deprecated:</dt><dd><ul class="dummy"><li>you can now create/modify launchers in the top-left Menu -> Configure Launchbar
for special needs there's also backend API's createOrUpdateLauncher()</li></ul></dd>
<dt class="important tag-deprecated">Deprecated:</dt><dd><ul class="dummy"><li>you can now create/modify launchers in the top-left Menu -> Configure Launchbar for special needs there's also backend API's createOrUpdateLauncher()</li></ul></dd>
@ -1530,7 +1588,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<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#line417">line 417</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line422">line 422</a>
</li></ul></dd>
@ -1696,8 +1754,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<td class="description last">specify namespace of the handler for the cases where call for bind may be repeated.
If a handler with this ID exists, it's replaced by the new handler.</td>
<td class="description last">specify namespace of the handler for the cases where call for bind may be repeated. If a handler with this ID exists, it's replaced by the new handler.</td>
</tr>
@ -1738,7 +1795,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<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#line583">line 583</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line588">line 588</a>
</li></ul></dd>
@ -2157,7 +2214,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<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#line406">line 406</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line411">line 411</a>
</li></ul></dd>
@ -2469,7 +2526,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<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#line627">line 627</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line632">line 632</a>
</li></ul></dd>
@ -2624,7 +2681,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<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#line619">line 619</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line624">line 624</a>
</li></ul></dd>
@ -2730,7 +2787,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<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#line429">line 429</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line434">line 434</a>
</li></ul></dd>
@ -2840,7 +2897,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<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#line463">line 463</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line468">line 468</a>
</li></ul></dd>
@ -2946,7 +3003,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<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#line423">line 423</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line428">line 428</a>
</li></ul></dd>
@ -3052,7 +3109,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<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#line478">line 478</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>
@ -3162,7 +3219,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<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#line460">line 460</a>
</li></ul></dd>
@ -3268,7 +3325,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<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#line440">line 440</a>
</li></ul></dd>
@ -3334,8 +3391,7 @@ See <a href="https://day.js.org">https://day.js.org</a> for documentation
<div class="description">
Get access to the widget handling note detail. Methods like `getWidgetType()` and `getTypeWidget()` to get to the
implementation of actual widget type.
Get access to the widget handling note detail. Methods like `getWidgetType()` and `getTypeWidget()` to get to the implementation of actual widget type.
</div>
@ -3379,7 +3435,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#line472">line 472</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line477">line 477</a>
</li></ul></dd>
@ -3534,7 +3590,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#line487">line 487</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>
@ -3689,7 +3745,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#line531">line 531</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>
@ -3751,8 +3807,7 @@ implementation of actual widget type.
<div class="description">
Instance name identifies particular Trilium instance. It can be useful for scripts
if some action needs to happen on only one specific instance.
Instance name identifies particular Trilium instance. It can be useful for scripts if some action needs to happen on only one specific instance.
</div>
@ -3898,7 +3953,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#line447">line 447</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line452">line 452</a>
</li></ul></dd>
@ -4057,7 +4112,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#line549">line 549</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line554">line 554</a>
</li></ul></dd>
@ -4119,8 +4174,7 @@ if some action needs to happen on only one specific instance.
<div class="description">
Returns note by given noteId. If note is missing from the cache, it's loaded.
*
Returns note by given noteId. If note is missing from the cache, it's loaded. *
</div>
@ -4315,7 +4369,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#line441">line 441</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line446">line 446</a>
</li></ul></dd>
@ -4381,10 +4435,7 @@ if some action needs to happen on only one specific instance.
<div class="description">
Returns list of notes. If note is missing from the cache, it's loaded.
This is often used to bulk-fill the cache with notes which would have to be picked one by one
otherwise (by e.g. createLink())
Returns list of notes. If note is missing from the cache, it's loaded. This is often used to bulk-fill the cache with notes which would have to be picked one by one otherwise (by e.g. createLink())
</div>
@ -4626,7 +4677,7 @@ otherwise (by e.g. createLink())
<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#line522">line 522</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line527">line 527</a>
</li></ul></dd>
@ -4781,7 +4832,7 @@ otherwise (by e.g. createLink())
<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#line540">line 540</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line545">line 545</a>
</li></ul></dd>
@ -4936,7 +4987,7 @@ otherwise (by e.g. createLink())
<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#line558">line 558</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line563">line 563</a>
</li></ul></dd>
@ -5086,7 +5137,7 @@ otherwise (by e.g. createLink())
<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#line638">line 638</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line643">line 643</a>
</li></ul></dd>
@ -5771,7 +5822,7 @@ otherwise (by e.g. createLink())
<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#line502">line 502</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line507">line 507</a>
</li></ul></dd>
@ -5945,7 +5996,7 @@ otherwise (by e.g. createLink())
<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#line512">line 512</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line517">line 517</a>
</li></ul></dd>
@ -6100,7 +6151,7 @@ otherwise (by e.g. createLink())
<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#line612">line 612</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line617">line 617</a>
</li></ul></dd>
@ -6254,7 +6305,7 @@ otherwise (by e.g. createLink())
<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#line603">line 603</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line608">line 608</a>
</li></ul></dd>
@ -6453,13 +6504,7 @@ otherwise (by e.g. createLink())
<div class="description">
Executes given anonymous function on the backend.
Internally this serializes the anonymous function into string and sends it to backend via AJAX.
This function is meant for advanced needs where an async function is necessary.
In this case, the automatic request-scoped transaction management is not applied,
and you need to manually define transaction via api.transactional().
If you have a synchronous function, please use api.runOnBackend().
Executes given anonymous function on the backend. Internally this serializes the anonymous function into string and sends it to backend via AJAX. This function is meant for advanced needs where an async function is necessary. In this case, the automatic request-scoped transaction management is not applied, and you need to manually define transaction via api.transactional(). If you have a synchronous function, please use api.runOnBackend().
</div>
@ -6644,10 +6689,7 @@ If you have a synchronous function, please use api.runOnBackend().
<div class="description">
Executes given anonymous function on the backend.
Internally this serializes the anonymous function into string and sends it to backend via AJAX.
Please make sure that the supplied function is synchronous. Only sync functions will work correctly
with transaction management. If you really know what you're doing, you can call api.runAsyncOnBackendWithManualTransactionHandling()
Executes given anonymous function on the backend. Internally this serializes the anonymous function into string and sends it to backend via AJAX. Please make sure that the supplied function is synchronous. Only sync functions will work correctly with transaction management. If you really know what you're doing, you can call api.runAsyncOnBackendWithManualTransactionHandling()
</div>
@ -6832,8 +6874,7 @@ with transaction management. If you really know what you're doing, you can call
<div class="description">
This is a powerful search method - you can search by attributes and their values, e.g.:
"#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
This is a powerful search method - you can search by attributes and their values, e.g.: "#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
</div>
@ -6988,8 +7029,7 @@ with transaction management. If you really know what you're doing, you can call
<div class="description">
This is a powerful search method - you can search by attributes and their values, e.g.:
"#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
This is a powerful search method - you can search by attributes and their values, e.g.: "#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
</div>
@ -7237,7 +7277,7 @@ with transaction management. If you really know what you're doing, you can call
<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#line567">line 567</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line572">line 572</a>
</li></ul></dd>
@ -7388,7 +7428,7 @@ with transaction management. If you really know what you're doing, you can call
<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#line494">line 494</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line499">line 499</a>
</li></ul></dd>
@ -8408,7 +8448,7 @@ with transaction management. If you really know what you're doing, you can call
<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#line382">line 382</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>
@ -8568,7 +8608,7 @@ with transaction management. If you really know what you're doing, you can call
<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#line391">line 391</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line396">line 396</a>
</li></ul></dd>
@ -8612,11 +8652,7 @@ with transaction management. If you really know what you're doing, you can call
<div class="description">
Trilium runs in a backend and frontend process, when something is changed on the backend from a script,
frontend will get asynchronously synchronized.
This method returns a promise which resolves once all the backend -> frontend synchronization is finished.
Typical use case is when a new note has been created, we should wait until it is synced into frontend and only then activate it.
Trilium runs in a backend and frontend process, when something is changed on the backend from a script, frontend will get asynchronously synchronized. This method returns a promise which resolves once all the backend -> frontend synchronization is finished. Typical use case is when a new note has been created, we should wait until it is synced into frontend and only then activate it.
</div>
@ -8660,7 +8696,7 @@ Typical use case is when a new note has been created, we should wait until it is
<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#line595">line 595</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line600">line 600</a>
</li></ul></dd>

View file

@ -23,9 +23,15 @@ async function prompt(props) {
appContext.triggerCommand("showPromptDialog", {...props, callback: res}));
}
async function promptNoteAutocomplete(props) {
return new Promise(res =>
appContext.triggerCommand("showAddLinkDialog", {...props, callback: res}));
}
export default {
info,
confirm,
confirmDeleteNoteBoxWithNote,
prompt
prompt,
promptNoteAutocomplete
};

View file

@ -372,6 +372,11 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
*/
this.showPromptDialog = dialogService.prompt;
/**
* Show prompt for selecting a note to the user.
*/
this.getNoteAutocomplete = dialogService.promptNoteAutocomplete;
/**
* Trigger command. This is a very low-level API which should be avoided if possible.
*

View file

@ -77,30 +77,52 @@ export default class AddLinkDialog extends BasicWidget {
const linkTitle = this.getLinkType() === 'reference-link' ? null : this.$linkTitle.val();
if (this.textTypeWidget) {
this.textTypeWidget.addLink(this.$autoComplete.getSelectedNotePath(), linkTitle);
}
if (this.resolve) {
this.resolve({
isExternal: false,
link: this.$autoComplete.getSelectedNotePath(),
title: linkTitle
});
}
}
else if (this.$autoComplete.getSelectedExternalLink()) {
this.$widget.modal('hide');
if (this.textTypeWidget) {
this.textTypeWidget.addLink(this.$autoComplete.getSelectedExternalLink(), this.$linkTitle.val());
}
if (this.resolve) {
this.resolve({
isExternal: false,
link: this.$autoComplete.getSelectedExternalLink(),
title: this.$linkTitle.val()
});
}
}
else {
logError("No link to add.");
if (this.resolve) {
this.resolve(false);
}
}
return false;
});
}
async showAddLinkDialogEvent({textTypeWidget, text = ''}) {
async showAddLinkDialogEvent({textTypeWidget, text = '', callback}) {
this.textTypeWidget = textTypeWidget;
this.resolve = callback;
this.$addLinkTitleSettings.toggle(!this.textTypeWidget.hasSelection());
this.$addLinkTitleSettings.toggle(this.textTypeWidget ? !this.textTypeWidget.hasSelection() : false);
this.$addLinkTitleSettings.find('input[type=radio]').on('change', e => this.updateTitleSettingsVisibility(e));
// with selection hyperlink is implied
if (this.textTypeWidget.hasSelection()) {
if (this.textTypeWidget && this.textTypeWidget.hasSelection()) {
this.$addLinkTitleSettings.find("input[value='hyper-link']").prop("checked", true);
}
else {
@ -121,7 +143,7 @@ export default class AddLinkDialog extends BasicWidget {
};
noteAutocompleteService.initNoteAutocomplete(this.$autoComplete, {
allowExternalLinks: true,
allowExternalLinks: false,
allowCreatingNotes: true
});