-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Patrizio Bekerle <[email protected]>
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import QtQml 2.0 | ||
import QOwnNotesTypes 1.0 | ||
|
||
/** | ||
* This script allows just send a written command to the AI completer to replace the selected text, but showing the differences first. | ||
*/ | ||
Script { | ||
/** | ||
* Initializes the custom actions | ||
*/ | ||
function init() { | ||
script.registerCustomAction("run-ai-command", "AI Command", "", "network-server-database", true, true, false); | ||
} | ||
|
||
/** | ||
* This function is invoked when a custom action is triggered | ||
* in the menu or via button | ||
* | ||
* @param identifier string the identifier defined in registerCustomAction | ||
*/ | ||
function customActionInvoked(identifier) { | ||
if (identifier !== "run-ai-command") { | ||
return; | ||
} | ||
|
||
let command = script.inputDialogGetText("AI Command", "Please enter a command"); | ||
|
||
if (command === '') { | ||
return; | ||
} | ||
|
||
const text = script.noteTextEditSelectedText(); | ||
const aiResult = script.aiComplete( | ||
"Execute the following command on the Markdown text afterwards, just output the result. " + | ||
command + ":\n\n" + text); | ||
let dialogResult = script.textDiffDialog("AI Command", "Resulting text", text, aiResult); | ||
|
||
if (dialogResult === '') { | ||
return; | ||
} | ||
|
||
script.noteTextEditWrite(dialogResult); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "AI Command", | ||
"identifier": "ai-command", | ||
"script": "ai-command.qml", | ||
"authors": ["@pbek"], | ||
"platforms": ["linux", "macos", "windows"], | ||
"version": "0.1.0", | ||
"minAppVersion": "24.11.4", | ||
"description" : "This script allows just send a written command to the AI completer to replace the selected text, but showing the differences first." | ||
} |