/**
 * Editor enriquecido simplificado (reemplazo de wp.editor).
 */
(function () {
	'use strict';

	window.wp = window.wp || {};
	wp.editor = wp.editor || {};

	wp.editor.initialize = function (id, settings) {
		var el = document.getElementById(id);
		if (!el || typeof tinymce === 'undefined') return;
		tinymce.init(Object.assign({
			target: el,
			menubar: false,
			plugins: 'lists link table code',
			toolbar: 'undo redo | bold italic | bullist numlist | link | code',
			height: 300,
			language: 'es'
		}, settings && settings.tinymce ? settings.tinymce : {}));
	};

	wp.editor.remove = function (id) {
		if (typeof tinymce !== 'undefined') {
			var ed = tinymce.get(id);
			if (ed) ed.remove();
		}
	};
})();
