금칙어 검출

1.00

2.15.0 버전부터 지원합니다.

설정한 금칙어를 검출하거나, 금칙어를 지정한 문자로 바꾸는 '금칙어 검출' 플러그인입니다.

1.00

사용 방법

플러그인 파일 불러오기

<!-- 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">

플러그인 구성

// 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

플러그인 이름 'forbiddenWordDetection'을 사용하여 툴바 영역이나 메뉴 영역에 버튼을 추가할 수 있습니다.

툴바에 추가

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

메뉴에 추가

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

API

editor.checkForbiddenWord(callback)

금칙어를 검사하고 콜백 함수로 결과를 전달합니다.

Parameters:

이름타입설명
callback함수개인정보 검사 결과를 받는 콜백 함수입니다. 검사 결과가 통과하면 result: true가 인자로 전달되고, 검사 결과가 실패하면 규칙을 위반한 금칙어가 word 인자로 전달됩니다.
// 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');
    }
});