Foros del Web » Programando para Internet » Javascript »

pequeño deditor de txt

Estas en el tema de pequeño deditor de txt en el foro de Javascript en Foros del Web. Hola foro!!! a ver si me podéis ayudar con esto En mi web puedo modificar todas las tablas de mi BD para añadir noticias, temas ...
  #1 (permalink)  
Antiguo 09/12/2003, 05:30
Avatar de X3mdesign  
Fecha de Ingreso: octubre-2003
Ubicación: Madrid
Mensajes: 649
Antigüedad: 20 años, 6 meses
Puntos: 2
pequeño deditor de txt

Hola foro!!!

a ver si me podéis ayudar con esto

En mi web puedo modificar todas las tablas de mi BD para añadir noticias, temas de cultura, gastronomía, etc. pero es un coñ*zo el tenes que meter a mano las etiquetas de HTML para formatearlo, tampoco me recoge los retornos de carro teniendo que poner <br><br> o <p></p> para que aparezca así en la web.

Hay algun tutorial o alguna web que "preste" el código para poder hacer el editor??

Muchas gracias!!!!
__________________
Nippon-Tour, tu portal sobre Japón
¿Te gusta el manga, haces tus propios dibujos? Visita FanArt de Nippon-Tour
  #2 (permalink)  
Antiguo 09/12/2003, 05:48
Ex Colaborador
 
Fecha de Ingreso: junio-2002
Mensajes: 9.091
Antigüedad: 21 años, 10 meses
Puntos: 16
Hola,

Para los saltos de linea, mira esta FAQ: http://www.forosdelweb.com/showthrea...770#post245770

Y sobre un editor WYSIWYG (editor visual), pues no se hace con PHP, sino con Javascript o flash (tecnologias del lado del cliente), asi que mejor busca en esos foros (en javascript ya se ha tratado varias veces).

Saludos.
__________________
Josemi

Aprendiz de mucho, maestro de poco.
  #3 (permalink)  
Antiguo 09/12/2003, 05:57
Avatar de X3mdesign  
Fecha de Ingreso: octubre-2003
Ubicación: Madrid
Mensajes: 649
Antigüedad: 20 años, 6 meses
Puntos: 2
gracias!!! voy a ver qué encuentro ;)
__________________
Nippon-Tour, tu portal sobre Japón
¿Te gusta el manga, haces tus propios dibujos? Visita FanArt de Nippon-Tour
  #4 (permalink)  
Antiguo 09/12/2003, 06:10
Avatar de txarly  
Fecha de Ingreso: marzo-2003
Ubicación: Eibar (Gipuzkoa)
Mensajes: 455
Antigüedad: 21 años, 2 meses
Puntos: 2
Un editor WYSIWYG muy bueno hecho con HTML y Javascript lo puedes encontrar aquí

htmlarea

Un saludo
Txarly
__________________
¿Por qué Uri Geller doblaba cucharas?
  #5 (permalink)  
Antiguo 09/12/2003, 08:36
Avatar de epplestun  
Fecha de Ingreso: octubre-2001
Mensajes: 1.621
Antigüedad: 22 años, 6 meses
Puntos: 5
En la pagina www.mozilla.org tienes la API para hacer un editor haciendo uso de JS. Yo tengo hecho uno con esa API y me funciona perfectamente.
__________________
Usuario registrado de Linux #288725
  #6 (permalink)  
Antiguo 09/12/2003, 08:44
Avatar de epplestun  
Fecha de Ingreso: octubre-2001
Mensajes: 1.621
Antigüedad: 22 años, 6 meses
Puntos: 5
Aqui te dejo la parte de js, es una API muy sencilla.

Código PHP:
<script language="JavaScript">
    
/*
       +----------------------------------------------------------------------+
       | DikodeRTE v.0.0.1                                                    |
       +----------------------------------------------------------------------+
       | Copyright (c) 2001-2003 DIkode                                       |
       +----------------------------------------------------------------------+
       | This source file is subject to version 2.02 of the PHP license,      |
       | that is bundled with this package in the file LICENSE, and is        |
       | available at through the world-wide-web at                           |
       | php.net/license/2_02.txt.                                 |
       | If you did not receive a copy of the PHP license and are unable to   |
       | obtain it through the world-wide-web, please send a note to          |
       | [email][email protected][/email] so we can mail you a copy immediately.               |
       +----------------------------------------------------------------------+
       | Authors: Ivan Rodriguez Espada   <[email protected]>              |
       +----------------------------------------------------------------------+
    */
    /*
     * Inicializa el editor
     */
    
function start() {
        
document.getElementById('edit').contentWindow.document.designMode "on";
    }
    
    
/*
     * Indica el estilo que queremos dar a nuestra letra
     */
    
function estilo(estilo) { 
        switch(
estilo) {
            case 
"Bold":
                
document.getElementById('edit').contentWindow.document.execCommand("Bold"falsenull);
                break;
            case 
"Italic":
                
document.getElementById('edit').contentWindow.document.execCommand("Italic"falsenull);
                break;
            case 
"Underline":
                
document.getElementById('edit').contentWindow.document.execCommand("Underline"falsenull);
                break;
            case 
"Superscript":
                
document.getElementById('edit').contentWindow.document.execCommand("Superscript"falsenull);
                break;
            case 
"Subscript":
                
document.getElementById('edit').contentWindow.document.execCommand("Subscript"falsenull);
                break;
            case 
"Strikethrough":
                
document.getElementById('edit').contentWindow.document.execCommand("Strikethrough"falsenull);
                break;
            default: break;
        }
        
document.getElementById('edit').contentWindow.focus();
    }
    
    
/*
     * Genera una ventana Modal
     */
    
function VentanaMod(urlanchoalto) {
        var 
anchoVentana ancho;
        var 
altoVentana  alto;
        var 
izquierda = ((screen.width-anchoVentana)/2);
        var 
arriba    = ((screen.height-altoVentana)/2);
        
window.open(url'Enlace''width='+anchoVentana+',height='+altoVentana',left=' izquierda ',top=' arriba);
    }    

    
/*
     * Alinea el documento
     */
    
function alinear(opcion) {
        switch(
opcion) {
            case 
"Justifycenter":
                
document.getElementById('edit').contentWindow.document.execCommand("Justifycenter"falsenull);
                break;
            case 
"Justifyfull":
                
document.getElementById('edit').contentWindow.document.execCommand("Justifyfull"falsenull);
                break;
            case 
"Justifyleft":
                
document.getElementById('edit').contentWindow.document.execCommand("Justifyleft"falsenull);
                break;
            case 
"Justifyright":
                
document.getElementById('edit').contentWindow.document.execCommand("Justifyright"falsenull);
                break;
            default: break;
        }
        
document.getElementById('edit').contentWindow.focus();
    }
    
    
/*
     * Funciones de edicion
     */
    
function edicion(estilo) { 
        switch(
estilo) {
            case 
"Paste":
                
document.getElementById('edit').contentWindow.document.execCommand("Paste"falsenull);
                break;
            case 
"Copy":
                
document.getElementById('edit').contentWindow.document.execCommand("Copy"falsenull);
                break;
            case 
"Cut":
                
document.getElementById('edit').contentWindow.document.execCommand("Cut"falsenull);
                break;
            case 
"Undo":
                
document.getElementById('edit').contentWindow.document.execCommand("Undo"falsenull);
                break;
            case 
"Redo":
                
document.getElementById('edit').contentWindow.document.execCommand("Redo"falsenull);
                break;
            default: break;
        }
        
document.getElementById('edit').contentWindow.focus();
    }
    
    
/*
     * Funciones de listas
     */
    
function listas(estilo) { 
        switch(
estilo) {
            case 
"Insertorderedlist":
                
document.getElementById('edit').contentWindow.document.execCommand("Insertorderedlist"falsenull);
                break;
            case 
"Insertunorderedlist":
                
document.getElementById('edit').contentWindow.document.execCommand("Insertunorderedlist"falsenull);
                break;
            default: break;
        }
        
document.getElementById('edit').contentWindow.focus();
    }    
    
    
/*
     * Funciones de margen
     */
    
function margen(estilo) { 
        switch(
estilo) {
            case 
"Outdent":
                
document.getElementById('edit').contentWindow.document.execCommand("Outdent"falsenull);
                break;
            case 
"Indent":
                
document.getElementById('edit').contentWindow.document.execCommand("Indent"falsenull);
                break;
            default: break;
        }
        
document.getElementById('edit').contentWindow.focus();
    }

    
/*
     * Funciones de estilo de fuente
     */    
    
function select(selectname)    {
        var 
cursel document.getElementById(selectname).selectedIndex;
        if (
cursel != 0) {
            var 
selected document.getElementById(selectname).options[cursel].value;
            
document.getElementById('edit').contentWindow.document.execCommand(selectnamefalseselected);
            
document.getElementById(selectname).selectedIndex 0;
        }
        
document.getElementById('edit').contentWindow.focus();
    }
    
    
/*
     * Inserta una linea horizontal
     */
    
function linea() {
        
document.getElementById('edit').contentWindow.document.execCommand("Inserthorizontalrule"falsenull);
        
document.getElementById('edit').contentWindow.focus();
    }
    
    function 
codigo() {
        var 
html document.getElementById('edit').contentWindow.document.body.innerHTML;
        
document.enlace.HTML.value html;
    }
    
</script> 
Eso seria el JS.

Luego tan solo tienes que añadir un iframe de esta manera:

Código:
<body onLoad="start()">
<iframe id="edit" width="100%" height="400px"  frameborder="1"></iframe>
</body>
Ummmmmm cuando acabe de trabajar monto el editor y lo cuelgo por ahi con el code explicado a ve si os sirve de algo

Saludillos!!!
__________________
Usuario registrado de Linux #288725

Última edición por epplestun; 09/12/2003 a las 08:45
  #7 (permalink)  
Antiguo 09/12/2003, 09:10
Avatar de X3mdesign  
Fecha de Ingreso: octubre-2003
Ubicación: Madrid
Mensajes: 649
Antigüedad: 20 años, 6 meses
Puntos: 2
sin palabras me dejas epplestun, pero... entonces el JS lo tengo que poner en mi documento, no?? donde se introducen los textos... y en el mismo lugar el iframe que comentas... no?? y los botones para pinchar y que se modifique el texto??


muchas gracias de nuevo !!!!
__________________
Nippon-Tour, tu portal sobre Japón
¿Te gusta el manga, haces tus propios dibujos? Visita FanArt de Nippon-Tour
  #8 (permalink)  
Antiguo 09/12/2003, 09:20
Avatar de epplestun  
Fecha de Ingreso: octubre-2001
Mensajes: 1.621
Antigüedad: 22 años, 6 meses
Puntos: 5
Bueno, a ve la API la tienes, tan solo tienes que hacer los botones llamando a las funciones de JS, aqui te dejo un ejemplo:

Código:
<table width="100%" cellpadding="2" cellspacing="2" border="0">
					<tr>
						<td>
						<select id="formatblock" onchange="select(this.id);" style="font-size:10; font-family:verdana">
		  					<option value="<p>">Normal</option>
		  					<option value="<p>">Paragraph</option>
		 					<option value="<h1>">Heading 1 <H1></option>
							<option value="<h2>">Heading 2 <H2></option>
		  					<option value="<h3>">Heading 3 <H3></option>
		  					<option value="<h4>">Heading 4 <H4></option>
		  					<option value="<h5>">Heading 5 <H5></option>
		 					<option value="<h6>">Heading 6 <H6></option>
		  					<option value="<address>">Address <ADDR></option>
		  					<option value="<pre>">Formatted <PRE></option>
						</select>
						</td>
						<td>
						<select id="fontname" onchange="select(this.id);" style="font-size:10; font-family:verdana">
							<option value="Font">Font</option>
							<option value="Arial">Arial</option>
							<option value="Courier">Courier</option>
							<option value="Verdana">Verdana</option>
						</select>
						</td>
						<td>
						<select unselectable="on" id="fontsize" onchange="select(this.id);" style="font-size:10; font-family:verdana">
							<option value="Size">Size</option>
							<option value="1">1</option>
							<option value="2">2</option>
							<option value="3">3</option>
							<option value="4">4</option>
							<option value="5">5</option>
							<option value="6">6</option>
							<option value="7">7</option>  
						</select>
						</td>
						<td width="20"><a href=# onclick="estilo('Bold')"><img src="imagenes/bold.png" border="0"></a></td>
						<td width="20"><a href=# onclick="estilo('Italic')"><img src="imagenes/italic.png" border="0" ></a></td>
						<td width="20"><a href=# onclick="estilo('Underline')"><img src="imagenes/underline.png" border="0"></a></td>
						<td width="20"><a href=# onclick="alinear('Justifyleft')"><img src="imagenes/justifyleft.png" border="0"></a></td>
						<td width="20"><a href=# onclick="alinear('Justifycenter')"><img src="imagenes/justifycenter.png" border="0"></a></td>
						<td width="20"><a href=# onclick="alinear('Justifyright')"><img src="imagenes/justifyright.png" border="0"></a></td>
						<td width="20"><a href=# onclick="listas('Insertorderedlist')"><img src="imagenes/number.png" border="0"></a></td>
						<td width="20"><a href=# onclick="listas('Insertunorderedlist')"><img src="imagenes/list.png" border="0"></a></td>
						<td width="20"><a href=# onclick="margen('Outdent')"><img src="imagenes/outdent.png" border="0"></a></td>
						<td width="20"><a href=# onclick="margen('Indent')"><img src="imagenes/indent.png" border="0"></a></td>
						<td width="20"><a href=# onclick="linea()"><img src="imagenes/rule.png" border="0"></a></td>
					</tr>
					<tr>
						<td colspan="16">
						<iframe id="edit" width="100%" height="400px"  frameborder="1"></iframe>
						</td>
					</tr>
					<tr>
						<td colspan="16" align="center"><input type="submit" value="Bidali" class="formulario"></td>
					</tr>
					</table>
Con ese code tienes para insertar cualquier cosa, solo faltaria el tema de los enlaces y de las imagenes que es igual de sencillo lo unico que antes no lo puse, cuando llege a casa te lo monto para que veas como funciona
__________________
Usuario registrado de Linux #288725
  #9 (permalink)  
Antiguo 09/12/2003, 09:45
Ex Colaborador
 
Fecha de Ingreso: junio-2002
Mensajes: 9.091
Antigüedad: 21 años, 10 meses
Puntos: 16
Bueno, creo que este mensaje ya merece ser movido al foro de javascript.

Saludos desde PHP.
__________________
Josemi

Aprendiz de mucho, maestro de poco.
  #10 (permalink)  
Antiguo 09/12/2003, 09:53
Avatar de X3mdesign  
Fecha de Ingreso: octubre-2003
Ubicación: Madrid
Mensajes: 649
Antigüedad: 20 años, 6 meses
Puntos: 2
perdona de nuevo, epplestun, pero cómo se usa el API?? es como un include()??? te refieres a eso?? no estoy tan familiarizado con esto.... sorry :-$
__________________
Nippon-Tour, tu portal sobre Japón
¿Te gusta el manga, haces tus propios dibujos? Visita FanArt de Nippon-Tour
  #11 (permalink)  
Antiguo 09/12/2003, 09:58
Avatar de epplestun  
Fecha de Ingreso: octubre-2001
Mensajes: 1.621
Antigüedad: 22 años, 6 meses
Puntos: 5
Primero, pedir disculpas, no me fije que el post estaba en el foro de PHP perdona josemi.

Bien, tan solo tienes que copiar el codigo JS con todo como te lo puse y listo, es decir, metes el code js en el html.

Código PHP:
<html>
<
head>
<!--
aki pones el code-->
<
script language="JavaScript">
//aki el resto de code usea toda la API
</script>
</head>
<body>
</body>
</html> 
Como puedes ver solo se trata de eso, es mu sencillo.
__________________
Usuario registrado de Linux #288725

Última edición por epplestun; 09/12/2003 a las 09:59
  #12 (permalink)  
Antiguo 08/01/2004, 06:53
Avatar de X3mdesign  
Fecha de Ingreso: octubre-2003
Ubicación: Madrid
Mensajes: 649
Antigüedad: 20 años, 6 meses
Puntos: 2
Hola Epplestum de nuevo, he retomado el post... y me da un error en el código... he subido el html creado a http://nippon-tour.webcindario.com/error.htm pero... me doy por vencido... porque es un lío... si no te importa me gustaría mandarte el php a un mail para que le echaras un vistazo...

gracias de nuevo!!!!

P.D.: sabes que no estás obligado a nada
__________________
Nippon-Tour, tu portal sobre Japón
¿Te gusta el manga, haces tus propios dibujos? Visita FanArt de Nippon-Tour
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 01:47.