Personal Data Protection
![]()
Release 2.4.0 and above.
A 'Personal Data Protection' plugin that filters personal information such as resident registration numbers, emails, and phone numbers and replaces them with *.

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 personalDataProtection.min.js"></script>
<link rel="stylesheet" href="url of personalDataProtection.min.css">
UI
Using the plugin name 'personalDataProtection', you can add a button to the toolbar area or the menu area.
Add to Toolbar
// Editor configuration
//...
'editor.toolbar': [
//...,
'personalDataProtection',
//...
],
// ...
Add to Menu
// Editor configuration
//...
'editor.menu.definition': {
//...,
'tools': [
//...,
'personalDataProtection',
//...
],
//...
},
//...
Config Setting
Release 2.15.0 and above.
You can add or modify personal data protection inspection rules.
Setting
| Key | Description |
|---|---|
'personalDataProtection.config' | Adds or modifies personal data protection inspection rules. |
'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: Type name of the personal information detection rule.regExp: Regular expression to inspect personal data protection. ex)/([a-z0-9_\-\.]+)@([a-z0-9_\-\.]+)\.([a-z]{2,5})/gimessages: Per-language labels. Falls back to the type name when missing; falls back to English if a specific language is missing.replaceText: Custom replacement function. Receives the matched text, the replacement character, and the regex; must return a string. If omitted, the entire match is replaced with the replacement character.
Default Settings
// 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: '이메일'
}
}
}
Configuration Example
{ // 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]
<table> <thead> <tr><th><code>phoneNumber</code> configuration result</th><th><code>company_name_check</code> configuration result</th></tr> </thead> <tbody> <tr> <td>

API
editor.checkPersonalData(callback)
Release 2.13.0 and above.
Runs the personal data detection scan and reports the result through callback.
| Parameter | Type | Description |
|---|---|---|
callback | function(result: boolean) | true if no matches (pass); false if matches were found (fail). |
editor.checkPersonalData(function (result) {
if (!result) {
// Detection found something — open the personal-data dialog.
editor.getUIManager().showDialog('personalDataProtection');
}
});