개인정보 보호
![]()
2.4.0 버전부터 지원합니다.
주민등록번호, 이메일, 전화번호와 같은 개인정보를 필터링하여 *로 대체하는 '개인정보 보호' 플러그인입니다.

사용 방법
플러그인 파일 불러오기
<!-- The SynapEditor object must exist for this to take effect,
so include after the editor script files. -->
<script src="url of personalDataProtection.min.js"></script>
<link rel="stylesheet" href="url of personalDataProtection.min.css">
UI
플러그인 이름 'personalDataProtection'을 사용하여 툴바 영역이나 메뉴 영역에 버튼을 추가할 수 있습니다.
툴바에 추가
// Editor configuration
//...
'editor.toolbar': [
//...,
'personalDataProtection',
//...
],
// ...
메뉴에 추가
// Editor configuration
//...
'editor.menu.definition': {
//...,
'tools': [
//...,
'personalDataProtection',
//...
],
//...
},
//...
구성 설정
2.15.0 버전부터 지원합니다.
개인정보 보호 검사 규칙을 추가하거나 수정할 수 있습니다.
설정
| 키 | 설명 |
|---|---|
'personalDataProtection.config' | 개인정보 보호 검사 규칙을 추가하거나 수정합니다. |
'personalDataProtection.config': {
[type]: {
regExp: RegExp,
messages: {
en: string,
ko: string,
ja: string,
zh: string,
zh_tw: string,
vi: string,
}
},
replaceText: function(text: string, replaceChar: string, regExp: RegExp): string
}
type: 개인정보 검사 규칙의 타입 이름입니다.regExp: 개인정보를 검사하는 정규식입니다. 예)/([a-z0-9_\-\.]+)@([a-z0-9_\-\.]+)\.([a-z]{2,5})/gimessages: 언어별 라벨입니다. 없으면 타입 이름을 사용하고, 특정 언어의 라벨만 없으면 영어 라벨을 사용합니다.replaceText: 사용자 정의 대체 함수입니다. 일치한 텍스트, 대체 문자, 정규식을 인자로 받고 문자열을 반환해야 합니다. 생략하면 일치한 텍스트 전체를 대체 문자로 바꿉니다.
기본 설정
// synapeditor.config.js
{ // Default settings of the personal data protection plugin
'regNumber': {
regExp: /(([0-9]{2})(0[1-9]|1[0-2])(0[1-9]|[1,2][0-9]|3[0,1]))([- .]?)([0-9]{7})/g,
messages: {
en: 'Registration Number',
ko: '주민등록번호'
}
},
'phoneNumber': {
regExp: /\+?(((0|82)((2|31|32|33|41|42|43|44|51|52|53|54|55|61|62|63|64|11|12|13|14|15|16|17|18|19|70|80)[-) .]?)([0-9]{3,4}))|((0|82)10[-) .]?[0-9]{4}))[- .]?([0-9]{4})/g,
messages: {
en: 'Phone Number',
ko: '전화번호'
}
},
'email': {
regExp: /([a-z0-9_\-\.]+)@([a-z0-9_\-\.]+)\.([a-z]{2,5})/gi,
messages: {
en: 'E-Mail',
ko: '이메일'
}
}
}
구성 예시
{ // Config example
'personalDataProtection.config': {
'phoneNumber': { // Modify existing personal data protection settings
replaceText: function(text, replaceChar, regExp) {
var index = 0;
return text.replace(/\d+/g, function (match) {
return index++ === 1 ? match.replace(/\d/g, replaceChar) : match;
});
}
},
'company_name_check': { // Add a new rule
regExp: /synapsoft/gi,
messages: {
en: 'Company Name',
ko: '회사명',
ja: '会社名',
zh: '公司名称',
zh_tw: '公司名稱',
vi: 'Tên công ty'
},
replaceText: function(text, replaceChar) {
return text.replace(/[s]/gi, replaceChar);
}
}
}
}
[config setting example applied result]
phoneNumber 구성 결과 | company_name_check 구성 결과 |
|---|---|
![]() | ![]() |
API
editor.checkPersonalData(callback)
2.13.0 버전부터 지원합니다.
개인정보 검사를 실행하고 결과를 callback으로 전달합니다.
| 매개변수 | 타입 | 설명 |
|---|---|---|
callback | function(result: boolean) | 일치하는 항목이 없으면 true(통과), 있으면 false(실패)입니다. |
editor.checkPersonalData(function (result) {
if (!result) {
// Detection found something — open the personal-data dialog.
editor.getUIManager().showDialog('personalDataProtection');
}
});

