mirror of
https://github.com/codex-team/editor.js
synced 2024-06-28 02:10:31 +02:00
* raw plugin added * Try to paste raw html to raw plugin * insert text/plain to native area instead of contenteditable element * styles updated * rename variable * fixed raw backspace click handler * paste code * Replace mask with two svg icons * Toolbox leaf fix * Remove data in example.html * Toolbar and caret behavior improvments * upd * Upd * new bundle due the local merge
51 lines
765 B
JavaScript
51 lines
765 B
JavaScript
/**
|
|
* Plugin for CodeX.Editor
|
|
* Implements RAW-data block
|
|
*/
|
|
var rawPlugin = function (plugin) {
|
|
|
|
var editor = codex.editor;
|
|
|
|
plugin.render = function (data) {
|
|
|
|
var input = editor.draw.node('TEXTAREA', 'raw-plugin__input', {});
|
|
|
|
input.placeholder = 'Вставьте HTML код';
|
|
|
|
if (data && data.html) {
|
|
input.value = data.html;
|
|
}
|
|
|
|
return input;
|
|
|
|
};
|
|
|
|
plugin.save = function (block) {
|
|
|
|
return {
|
|
html: block.value
|
|
};
|
|
|
|
};
|
|
|
|
plugin.validate = function (data) {
|
|
|
|
if (data.html.trim() === '') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
plugin.destroy = function () {
|
|
|
|
rawPlugin = null;
|
|
|
|
};
|
|
|
|
return plugin;
|
|
|
|
}({}); |