editor.js/plugins/raw/raw.js
George Berezhnoy c87eddc7c3 raw plugin added (#163)
* 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
2017-02-27 14:44:22 +03:00

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;
}({});