Skip to content

Commit

Permalink
Place selected text into 'Search' text field.
Browse files Browse the repository at this point in the history
  • Loading branch information
FelisDiligens committed Jan 25, 2023
1 parent d4c2c03 commit c45cf97
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ joplin.plugins.register({
await joplin.contentScripts.onMessage("SearchAndReplace", async (message: any) => {
switch (message.name) {
case "openDialog":
// Get selected text:
let selectedText = await joplin.commands.execute('selectedText');

// "Recall" last form data:
dialogSearchAndReplace.useTemplate({
"pattern": sanitizeHTML(dialogLastFormData.pattern),
"pattern": selectedText.length > 0 ? sanitizeHTML(selectedText) : sanitizeHTML(dialogLastFormData.pattern),
"replacement": sanitizeHTML(dialogLastFormData.replacement),
"useregex": dialogLastFormData.useregex == "on" ? "checked" : "",
"caseinsensitive": dialogLastFormData.caseinsensitive == "on" ? "checked" : ""
Expand Down

0 comments on commit c45cf97

Please sign in to comment.