mirror of
https://github.com/zadam/trilium.git
synced 2025-11-06 13:26:01 +01:00
more impl for search actions
This commit is contained in:
39
src/public/app/widgets/search_actions/execute_script.js
Normal file
39
src/public/app/widgets/search_actions/execute_script.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import SpacedUpdate from "../../services/spaced_update.js";
|
||||
import AbstractAction from "./abstract_action.js";
|
||||
|
||||
const TPL = `
|
||||
<tr>
|
||||
<td>
|
||||
Execute script:
|
||||
</td>
|
||||
<td>
|
||||
<div style="display: flex; align-items: center">
|
||||
<div style="margin-right: 15px;" class="text-nowrap">Script: </div>
|
||||
|
||||
<input type="text"
|
||||
class="form-control script"
|
||||
placeholder="note.title = note.title + '- suffix';"/>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<span class="bx bx-x icon-action" data-action-conf-del></span>
|
||||
</td>
|
||||
</tr>`;
|
||||
|
||||
export default class ExecuteScriptSearchAction extends AbstractAction {
|
||||
static get actionName() { return "executeScript"; }
|
||||
|
||||
doRender() {
|
||||
const $action = $(TPL);
|
||||
const $script = $action.find('.script');
|
||||
$script.val(this.actionDef.script || "");
|
||||
|
||||
const spacedUpdate = new SpacedUpdate(async () => {
|
||||
await this.saveAction({ script: $script.val() });
|
||||
}, 1000)
|
||||
|
||||
$script.on('input', () => spacedUpdate.scheduleUpdate());
|
||||
|
||||
return $action;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user