Forbidden Word Detection

Forbidden word icon

Release 2.15.0 and above.

A 'Forbidden Word Detection' plugin that detects configured forbidden words or filters forbidden words and replaces them with a configured character.

Forbidden word detection example

How to Use

Loading Plugin Files

<!-- The SynapEditor object must exist for this to take effect,
     so include after the editor script files. -->
<script src="url of forbiddenWordDetection.min.js"></script>
<link rel="stylesheet" href="url of forbiddenWordDetection.min.css">

Configure the Plugin

// Editor configuration
//...
'forbiddenWordDetection.config': {
    'words': ['fool', 'haha'], // Enter forbidden words to configure as an array.
    'replaceText': '♡' // Set the text to change to. (default: '*') Even if a multi-character text is set, it is changed to the first character. ex) When '!@' is set, result: 'hello' -> '!!'
},
// ...

UI

Using the plugin name 'forbiddenWordDetection', you can add a button to the toolbar area or the menu area.

Add to Toolbar

// Editor configuration
//...
'editor.toolbar': [
    //...,
    'forbiddenWordDetection',
    //...
],
// ...

Add to Menu

// Editor configuration
//...
'editor.menu.definition': {
    //...,
    'tools': [
        //...,
        'forbiddenWordDetection',
        //...
    ],
    //...
},
//...

API

editor.checkForbiddenWord(callback)

Inspects forbidden words and returns the result through the callback function received as an argument.

Parameters:

nameTypeDescription
callbackFunctionCallback function to receive the personal data inspection result. When the inspection result passes, result: true is delivered as an argument; when the inspection result fails, the forbidden word that violated the rule is delivered as the word argument.
// Alert when a forbidden word is found
editor.checkForbiddenWord(function (result, word) {
    if (!result) {
        window.alert(word + ' is not allowed.');
    }
});

// Open the dialog when a forbidden word is found
editor.checkForbiddenWord(function (result) {
    if (!result) {
        editor.getUIManager().showDialog('forbiddenWordDetection');
    }
});