Obtener el valor de un TinyMCE textarea


Tengo un editor de noticias para mi sitio con el que estoy usando TinyMCE. Lo que me gustaría poder hacer es tener un botón (fuera del propio editor TinyMCE) en el que pueda hacer clic para escanear el área de texto en busca de cualquier imagen, luego enumerar esas imágenes como opciones para usar para una imagen en miniatura para dicho artículo de noticias.

Para una idea de lo que quiero decir, por favor vea este enlace aquí: https://docs.google.com/leaf?id=0B05m73kzudwPNzUwZjkyNmItYjZkMy00NTdlLTlkNDctOGRhYThjMzNjNTM5&hl=en_US

Mi el problema es ese documento.getElementById('NewsArticle').el valor no devuelve nada cuando hay texto en el área de texto

El otro problema potencial es que lo que se muestra en el área de texto no es código real, sino imágenes, etc. también, por lo que no estaba seguro de que funcionaría en primer lugar, pero desde que se envía el formulario, el valor de los datos[Noticias][artículo] vuelve al texto, pensé que podría haber una oportunidad.

Si alguien sabe cómo obtener el contenido o el código para el TinyMCE textarea, o tiene una solución mejor, me interesaría escuchar

Author: Tim, 2011-07-01

4 answers

TinyMCE tiene una api para acceder al contenido desde el editor.

Este código tomará el html del editor activo:

// Get the HTML contents of the currently active editor
tinyMCE.activeEditor.getContent();

// Get the raw contents of the currently active editor
tinyMCE.activeEditor.getContent({format : 'raw'});

// Get content of a specific editor:
tinyMCE.get('content id').getContent()
 123
Author: Matthew Manela,
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-06-30 22:29:06

Utilice la sintaxis siguiente, que eliminará el carácter no deseado de su área de texto de entrada....

(((tinyMCE.get('YourTextAreaId').getContent()).replace(/(&nbsp;)*/g, "")).replace(/(<p>)*/g, "")).replace(/<(\/)?p[^>]*>/g, "");
 6
Author: Milan,
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
2016-12-02 12:57:54

Intenta

window.parent.tinymce.get('contentID').getContent();

Por alguna razón, la llamada estándar de valores tinymce.get() no funcionó para mí, así que probé esto y funciona. :)

 4
Author: XtraSimplicity,
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
2013-12-10 22:25:52
var temp = tinymce.get('textAreaName').save();
console.log(temp);

O

var temp =tinymce.get('textAreaName').getContent();
console.log(temp);
 2
Author: sujithklr93,
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
2016-09-22 09:57:59