Ver Mensaje Individual
  #6 (permalink)  
Antiguo 09/12/2003, 08:44
Avatar de epplestun
epplestun
 
Fecha de Ingreso: octubre-2001
Mensajes: 1.621
Antigüedad: 24 años, 10 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", false, null);
                break;
            case 
"Italic":
                
document.getElementById('edit').contentWindow.document.execCommand("Italic", false, null);
                break;
            case 
"Underline":
                
document.getElementById('edit').contentWindow.document.execCommand("Underline", false, null);
                break;
            case 
"Superscript":
                
document.getElementById('edit').contentWindow.document.execCommand("Superscript", false, null);
                break;
            case 
"Subscript":
                
document.getElementById('edit').contentWindow.document.execCommand("Subscript", false, null);
                break;
            case 
"Strikethrough":
                
document.getElementById('edit').contentWindow.document.execCommand("Strikethrough", false, null);
                break;
            default: break;
        }
        
document.getElementById('edit').contentWindow.focus();
    }
    
    
/*
     * Genera una ventana Modal
     */
    
function VentanaMod(url, ancho, alto) {
        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", false, null);
                break;
            case 
"Justifyfull":
                
document.getElementById('edit').contentWindow.document.execCommand("Justifyfull", false, null);
                break;
            case 
"Justifyleft":
                
document.getElementById('edit').contentWindow.document.execCommand("Justifyleft", false, null);
                break;
            case 
"Justifyright":
                
document.getElementById('edit').contentWindow.document.execCommand("Justifyright", false, null);
                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", false, null);
                break;
            case 
"Copy":
                
document.getElementById('edit').contentWindow.document.execCommand("Copy", false, null);
                break;
            case 
"Cut":
                
document.getElementById('edit').contentWindow.document.execCommand("Cut", false, null);
                break;
            case 
"Undo":
                
document.getElementById('edit').contentWindow.document.execCommand("Undo", false, null);
                break;
            case 
"Redo":
                
document.getElementById('edit').contentWindow.document.execCommand("Redo", false, null);
                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", false, null);
                break;
            case 
"Insertunorderedlist":
                
document.getElementById('edit').contentWindow.document.execCommand("Insertunorderedlist", false, null);
                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", false, null);
                break;
            case 
"Indent":
                
document.getElementById('edit').contentWindow.document.execCommand("Indent", false, null);
                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(selectname, false, selected);
            
document.getElementById(selectname).selectedIndex = 0;
        }
        
document.getElementById('edit').contentWindow.focus();
    }
    
    
/*
     * Inserta una linea horizontal
     */
    
function linea() {
        
document.getElementById('edit').contentWindow.document.execCommand("Inserthorizontalrule", false, null);
        
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