Froala Documentation
- Getting Started
- Browser Support
- Languages Support
- Shortcuts
- Activation
- Examples
- Customize the Editor
- Use-cases
- Plugins
- APIs
- Development Frameworks
- Server Integrations
- Server SDKs
- Migration Guides
- Changelog
- Tutorials
Find and Replace Plugin
The Find and Replace plugin allows users to quickly locate specific text within a document and replace it with new content. This feature enhances the editing process by streamlining text modifications, increasing efficiency, and ensuring consistency throughout the document. It is especially useful for making bulk content changes without manually searching through the text.
Plugin options:
enableMatchCase Boolean |
If set to true, case-sensitive search will be enabled by default when the plugin is initialized. Default: false |
enableMatchWholeWord Boolean |
If set to true, the `match whole word` search will be enabled by default when the plugin is initialized.
Default: false |
showFindAndReplace Boolean |
If set to true, the Find and Replace popup will be displayed automatically when the editor is initialized.
Default: false |
Plugin methods:
findReplace.findMatches (searchText) returns: - |
Finds all matches of searchText in the editor content and highlights them.
● searchText: The text you are looking for. Type: String |
findReplace.findNextMatch (index) returns: - |
Navigates to the match with the given index and highlights it as the current match in focus.
● index: The index of the search text. Type: Integer |
findReplace.findPreviousMatch (index) returns: - |
Navigates to the match at the specified index in a circular backward manner and highlights it as the current match in focus.
● index: The index of the search text. Type: Integer |
findReplace.replaceMatch (replaceText) returns: - |
Replaces all matches with the given replaceText
● replaceText: The text to replace the search text. Type: String |
findReplace.replaceMatches (replaceText) returns: - |
Finds all matches of searchText in the editor content and highlights them.
● searchText: The text you are looking for. Type: String |
findReplace.getMatchesCount () returns: Integer |
Returns the total number of matches found |
findReplace.getCurrentMatch() returns: string/null |
Returns the text content of the current match. |
findReplace.getCurrentMatchIndex () returns: Integer |
Returns the index of the current match in focus or -1 if no match is selected. |
findReplace.showPopup () returns: - |
Show Find and Replace popup. |
findReplace.hidePopup () returns: - |
Hide Find and Replace popup. |
Plugin events:
findandreplace.beforeClose () |
Triggered before closing the Find and Replace popup. |
findandreplace.beforeOnReplace () |
Triggered before replacing the matching content. |
findandreplace.onReplace ([{ oldValue: oldText, newValue: replaceText }]) |
Triggered on successful replace of match. |
findandreplace.onReplaceAll (([{ oldValue: oldText, newValue: replaceText }]) |
Triggered on successful replacement of all the matches. |
Add Plugin to your code:
Plugin name: findReplace
Plugin JS Script: ../js/plugins/find_and_replace.min.js
Or from CDN https://cdn.jsdelivr.net/npm/froala-editor@latest/js/plugins/find_and_replace.min.js
Plugin CSS link: ../css/plugins/find_and_replace.min.css
Or from CDN https://cdn.jsdelivr.net/npm/froala-editor@latest/css/plugins/find_and_replace.min.css