diff --git a/assets/popup.html b/assets/popup.html index c097077..e5602ab 100644 --- a/assets/popup.html +++ b/assets/popup.html @@ -1,6 +1,7 @@ + @@ -20,6 +21,10 @@ color: #444; } + textarea { + height: calc(1.5em + .75rem + calc(var(--bs-border-width))) + } + button { width: 100%; } @@ -74,6 +79,10 @@ margin: 0 auto; } + #swapTerms { + text-align: right; + } + Search and Replace @@ -87,14 +96,17 @@
- +
-
-

+
+
+
- +

@@ -124,10 +136,14 @@
- +
- +
@@ -143,10 +159,12 @@ -
+
q
- +
@@ -163,7 +181,9 @@
-
Version 1.6.9
+
+ Version 1.6.10 +
diff --git a/manifest.json b/manifest.json index 9d1699f..7bcbe08 100644 --- a/manifest.json +++ b/manifest.json @@ -46,6 +46,6 @@ "https://*/*" ], "update_url": "http://clients2.google.com/service/update2/crx", - "version": "1.6.9", + "version": "1.6.10", "options_page": "assets/options.html" } diff --git a/package-lock.json b/package-lock.json index 4f88caa..87860f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "search_and_replace", - "version": "1.6.9", + "version": "1.6.10", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "search_and_replace", - "version": "1.6.9", + "version": "1.6.10", "devDependencies": { "@types/chrome": "*", "@types/jest": "^27.0.2", diff --git a/package.json b/package.json index b3c6ac1..182e209 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "search_and_replace", - "version": "1.6.9", + "version": "1.6.10", "resolutions": { "author": "Chris Taylor " }, diff --git a/src/constants.ts b/src/constants.ts index 1d1136b..0911078 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -15,6 +15,6 @@ export const RICH_TEXT_EDITOR_GENERIC: RichTextEditor = { export const RICH_TEXT_EDITORS: RichTextEditor[] = [RICH_TEXT_EDITOR_TINY_MCE, RICH_TEXT_EDITOR_GENERIC] export const HINTS = { - wordpress6: 'Hint: WordPress 6+ detected. Check "Only change visible content?" when editing posts.', - gmail: 'Hint: Gmail detected. Check "Only change visible content?" when editing draft emails.', + wordpress6: 'Hint: WordPress 6+ detected. Check "Visible content only?" when editing posts.', + gmail: 'Hint: Gmail detected. Check "Visible content only?" when editing draft emails.', } diff --git a/src/popup.ts b/src/popup.ts index a458899..04a4271 100644 --- a/src/popup.ts +++ b/src/popup.ts @@ -86,6 +86,13 @@ window.addEventListener('DOMContentLoaded', function () { // Click handler for historyContent element. Will take the search term and replace term from the history item and populate the input fields ;(document.getElementById('historyContent')).addEventListener('click', historyItemClickHandler) + + // Click handler for swapping terms + ;(document.getElementById('swapTerms')).addEventListener('click', function (e) { + const searchTerm = document.getElementById('searchTerm') + const replaceTerm = document.getElementById('replaceTerm') + swapTerms(searchTerm, replaceTerm) + }) }) async function storeTermsHandler(e) { @@ -197,7 +204,7 @@ function tabQueryCallback(msg) { if ('searchTermCount' in msg) { ;(( document.getElementById('searchTermCount') - )).innerHTML = `

${msg['searchTermCount']} matches

` + )).innerHTML = `${msg['searchTermCount']} matches` } const hintsElement = document.getElementById('hints') @@ -309,6 +316,15 @@ function constructSearchReplaceHistory(searchReplaceInstance?: SearchReplaceInst return historyItems } +function swapTerms(source: HTMLTextAreaElement, target: HTMLTextAreaElement) { + const sourceText = source.value + source.value = target.value + target.value = sourceText + storeTerms({}, true) + .then((r) => console.log(r)) + .catch((e) => console.error(e)) +} + function getHistoryItemsFromListItemsElements(history: HTMLElement): SearchReplaceInstance[] { return Array.from(history.getElementsByTagName('li')).map((item) => ({ searchTerm: item.getAttribute('data-searchTerm') || '',