From 1e190330892f233be66604f35855b80b648582c3 Mon Sep 17 00:00:00 2001 From: WebCoder49 Date: Sun, 18 Feb 2024 10:35:16 +0000 Subject: [PATCH] Add find-and-replace plugin to plugins README and d.ts --- code-input.d.ts | 19 +++++++++++++++++++ plugins/README.md | 7 +++++++ plugins/find-and-replace.js | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/code-input.d.ts b/code-input.d.ts index 52582a1..4261e0e 100644 --- a/code-input.d.ts +++ b/code-input.d.ts @@ -123,6 +123,25 @@ export namespace plugins { constructor(delayMs: number); } + /** + * Add Find-and-Replace (Ctrl+F for find, Ctrl+H for replace by default) functionality to the code editor. + * Files: find-and-replace.js / find-and-replace.css + */ + class FindAndReplace extends Plugin { + /** + * Create a find-and-replace command plugin to pass into a template + * @param {boolean} useCtrlF Should Ctrl+F be overriden for find-and-replace find functionality? If not, you can trigger it yourself using (instance of this plugin)`.showPrompt(code-input element, false)`. + * @param {boolean} useCtrlH Should Ctrl+H be overriden for find-and-replace replace functionality? If not, you can trigger it yourself using (instance of this plugin)`.showPrompt(code-input element, true)`. + */ + constructor(useCtrlF?: boolean, useCtrlH?: boolean); + /** + * Show a find-and-replace dialog. + * @param {codeInput.CodeInput} codeInputElement the `` element. + * @param {boolean} replacePartExpanded whether the replace part of the find-and-replace dialog should be expanded + */ + showPrompt(codeInput: CodeInput, replacePartExpanded: boolean): void; + } + /** * Add basic Go-To-Line (ctrl-G by default) functionality to the code editor. * Files: go-to-line.js / go-to-line.css diff --git a/plugins/README.md b/plugins/README.md index 5ccb55e..9c26a26 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -29,6 +29,13 @@ Files: [autodetect.js](./autodetect.js) [🚀 *CodePen Demo*](https://codepen.io/WebCoder49/pen/eYLyMae) +### Find and Replace +Add Find-and-Replace (Ctrl+F for find, Ctrl+H for replace by default, or when JavaScript triggers it) functionality to the code editor. + +Files: [find-and-replace.js](./find-and-replace.js) / [find-and-replace.css](./find-and-replace.css) + +[🚀 *CodePen Demo*](https://codepen.io/WebCoder49/pen/oNVVBBz) + ### Go To Line Add a feature to go to a specific line when a line number is given (or column as well, in the format line no:column no) that appears when (optionally) Ctrl+G is pressed or when JavaScript triggers it. diff --git a/plugins/find-and-replace.js b/plugins/find-and-replace.js index e698422..26919e3 100644 --- a/plugins/find-and-replace.js +++ b/plugins/find-and-replace.js @@ -1,5 +1,5 @@ /** - * Add basic Find-and-Replace (Ctrl+F for find, Ctrl+H for by default) functionality to the code editor. + * Add Find-and-Replace (Ctrl+F for find, Ctrl+H for replace by default) functionality to the code editor. * Files: find-and-replace.js / find-and-replace.css */ codeInput.plugins.FindAndReplace = class extends codeInput.Plugin {