mirror of
https://github.com/codex-team/editor.js
synced 2024-05-23 08:42:25 +02:00
61 lines
1.1 KiB
JavaScript
61 lines
1.1 KiB
JavaScript
/**
|
|
* Codex Sanitizer
|
|
*/
|
|
|
|
module.exports = (function (sanitizer) {
|
|
|
|
/** HTML Janitor library */
|
|
let janitor = require('html-janitor');
|
|
|
|
/** Codex Editor */
|
|
let editor = codex.editor;
|
|
|
|
sanitizer.prepare = function () {
|
|
|
|
if (editor.settings.sanitizer && !editor.core.isEmpty(editor.settings.sanitizer)) {
|
|
|
|
Config.CUSTOM = editor.settings.sanitizer;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
/**
|
|
* Basic config
|
|
*/
|
|
var Config = {
|
|
|
|
/** User configuration */
|
|
CUSTOM : null,
|
|
|
|
BASIC : {
|
|
|
|
tags: {
|
|
p: {},
|
|
a: {
|
|
href: true,
|
|
target: '_blank',
|
|
rel: 'nofollow'
|
|
},
|
|
i: {},
|
|
b: {},
|
|
strong: {},
|
|
em: {},
|
|
span: {}
|
|
}
|
|
}
|
|
};
|
|
|
|
sanitizer.Config = Config;
|
|
|
|
sanitizer.init = function () {
|
|
|
|
let configuration = Config.CUSTOM || Config.BASIC;
|
|
|
|
return new janitor(configuration);
|
|
|
|
};
|
|
|
|
return sanitizer;
|
|
|
|
})({}); |