Installation
TabooTyper can be included in your project via either CDN or npm.
Using CDN
Add the following script to your HTML:
<script src="https://cdn.jsdelivr.net/gh/sumeetghimire/TabooTyper/index.js"></script>
Using npm
To install TabooTyper via npm, run the following command in your project directory:
npm install taboo-typer
Then, import it into your JavaScript file:
import TabooTyper from 'taboo-typer';
Usage
To initialize TabooTyper, create a new instance and configure it according to your needs:
<script>
new TabooTyper({
selector: "textarea, input",
bannedWords: { "dumb": "not smart", "stupid": "silly", "hate": "dislike", "bad": "unpleasant" },
masked: false,
maskCharacter: "#",
caseSensitive: false,
trackFrequency: true,
highlight: true,
suggestions: true,
contextSensitive: true,
warningStyle: "",
popupBackgroundColor: 'red',
popupTextColor: 'white'
});
</script>
Settings Explanation
- selector: Targets elements like input and textarea.
- bannedWords: Object mapping words to their replacements.
- masked: If true, words are replaced with a masking character.
- maskCharacter: The character used for masking banned words.
- caseSensitive: If true, the filter considers case sensitivity.
- trackFrequency: Enables frequency tracking of banned words.
- highlight: Highlights banned words in the input.
- suggestions: Provides alternative suggestions for banned words.
- contextSensitive: Enables context-aware filtering.
- warningStyle: Custom styling for the warning message.
- popupBackgroundColor: Sets the background color of the warning popup.
- popupTextColor: Sets the text color of the warning popup.
Additional Features
TabooTyper offers various features to enhance your content moderation experience:
- Real-Time Filtering: TabooTyper instantly filters out banned words as users type.
- Context-Aware Filtering: The filter adapts based on the context of the word in the sentence.
- Frequency Tracking: Keep track of how often banned words are used in a particular input field.
- Customizable Warning Styles: You can customize the appearance of warning popups.