Cómo reemplazar dinámicamente el contenido en TinyMCE?
Quiero reemplazar todas las palabras clave {baseurl}
a la url adecuada en el editor TinyMCE. ¿Cómo puedo hacer eso?
Por ejemplo, si el usuario agrega HTML en el editor <img src="{baseurl}/image.jpg" />
quiero ver esta imagen en el editor TinyMCE, por lo que se reemplazará por <img src="http://mydomain.com
/image.jpg" />
¿Alguna idea?
23
2 answers
Aquí está el código que reemplazará el contenido de su editor. Pero usted tendrá que hacer esta acción en el momento correcto.
var editor = tinymce.get('my_editor_id'); // use your own editor id here - equals the id of your textarea
var content = editor.getContent();
content = content.replace(/{\$baseurl}/g, 'http://mydomain.com');
editor.setContent(content);
47
Author: Thariama,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-12-15 09:30:30
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-12-15 09:30:30
Con esta solución pude modificar el contenido sobre la marcha, sin reemplazar el contenido como un todo:
tinymce.init({
setup: (editor)=>{
editor.on('init', ()=>{
$(editor.contentDocument).find('a').prop('title', 'my new title');
});
}
});
Tal vez ayude a alguien:)
0
Author: jaheraho,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-29 18:36:17
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-29 18:36:17