Editor de Texto em JSP

6 respostas
aureliolima

Pessoal, estou procurando uma forma de fazer um editor de texto em JSP para alguns formulários, tipo este do guj, que escrevi este texto…

A minha intenção é pegar o conteúdo do textfield e gravar como blob, no oracle.

Alguma idéia?

Agradeço desde já…

Abraços!!!

6 Respostas

eldercrul

cara eu já usei o Tinymce, ele é feito em javascript.

aureliolima

Eh bem completinho… era isso mesmo q eu precisava…

achei um tutorial bem bom pro TinyMCE:

http://marcelowd.wordpress.com/2009/01/13/instalando-o-tinymce-no-seu-site/

Pra persistir os dados no banco, como vc fez, nao sei bem como gravar como blob no oracle, se puder me dar mais uma ajuda, hehehe?

valew cara…

[ ]'s

aureliolima

jah ta gravando no banco, hehehehe

só agora q fui ver…

abs

aureliolima

Sabe se o tinymce tem algum contador de caracteres???

eldercrul

pronto no próprio tinymce acredito q nao tenha,
mas ele tem vários plugins para baixar no site, e também tem bastante
gente q cria plugins novos, eu procurei por ‘character counter’ no site e parece
que alguém já fez um plugin, ou tem uma solução.

http://tinymce.moxiecode.com/search.php?searchquery=character+counter

aureliolima

blza… achei o plugin… :smiley: vo testá-lo…

segue abaixo o código que achei no fórum do TINYMCE…

“I decided to write a very simple plugin for character count down. I started with the word count plugin and made several tweeks to rework it for displaying a character count down based on some character limit. To use this code, you need to create a js var called charlimit. Set this variable to the maximum amount of allowed characters. I’m not claiming this to be the BEST solution, but it met my needs.” Por: fozapd.

<script type="text/javascript"> var charlimit = 3000; tinyMCE.init({ // General options mode : "textareas", theme : "advanced", plugins : "charcount,advlink,print,contextmenu,paste", .......

/**
 * $Id: editor_plugin_src.js 201 2009-09-14 15:56:56Z sfreeman $
 *
 * @author Scott Freeman The Scientist
 * @copyright Copyright © 2009, The Scientist, All rights reserved.
 */

(function() {
    tinymce.create('tinymce.plugins.CharCount', {
        block : 0,
        id : null,        
        countre : null,
        cleanre : null,
        init : function(ed, url) {
            var t = this, last = 0;
            t.countre = ed.getParam('wordcount_countregex', /\S\s+/g);
            t.cleanre = ed.getParam('wordcount_cleanregex', /[0-9.(),;:!?%#$¿'"_+=\\/-]*/g);
            t.id = ed.id + '-char-count';

            ed.onPostRender.add(function(ed, cm) {
                var row, id;

                // Add it to the specified id or the theme advanced path
                id = ed.getParam('charcount_target_id');
                if (!id) {
                    row = tinymce.DOM.get(ed.id + '_path_row');

                    if (row)
                        tinymce.DOM.add(row.parentNode, 'div', {'style': 'float: right'}, ed.getLang('charcount.chars', 'Characters Remaining: ') + '<span id="' + t.id + '">' + charlimit + '</span>');
                } else
                    tinymce.DOM.add(id, 'span', {}, '<span id="' + t.id + '">' + charlimit + '</span>');
            });

            ed.onInit.add(function(ed) {
                ed.selection.onSetContent.add(function() {
                    t._count(ed);
                });

                t._count(ed);
            });

            ed.onSetContent.add(function(ed) {
                t._count(ed);
            });

            ed.onKeyUp.add(function(ed, e) {
                if (e.keyCode == last)
                    return;
                t._count(ed);
                last = e.keyCode;
            });
        },

        _count : function(ed) {
            var t = this, tc = 0;

            // Keep multiple calls from happening at the same time
            if (t.block)
                return;

            t.block = 1;

            setTimeout(function() {
                var tx = ed.getContent({format : 'raw'});
                var tx_len = 0;
                var originalText = ed.getContent({format : 'raw'});
                if (tx) {
                    tx_len = tx.length;
                    tx = tx.replace(/<.[^<>]*?>/g, ' ').replace(/ | /gi, ' '); // remove html tags and space chars
                    //tx = tx.replace(t.cleanre, ''); // remove numbers and punctuation
                    tc = charlimit-tx.length+1;
                    tx_len = tx_len - tx.length;
                    
                } else {
                    tc = charlimit;
                }
                
                tinymce.DOM.setHTML(t.id, tc.toString());
                if(tc<0){
                    alert(charlimit+' character limit reached!');
                    originalText = originalText.substring(0,charlimit+tx_len-3);
                    ed.setContent(originalText);
                    var originalText2 = ed.getContent({format : 'raw'});
                    originalText2 = originalText2.replace(/<.[^<>]*?>/g, ' ').replace(/ | /gi, ' '); // remove html tags and space chars
                    tc = charlimit-originalText2.length+1;                    
                    tinymce.DOM.setHTML(t.id, tc.toString());
                }
                setTimeout(function() {t.block = 0;}, 60);
            }, 1);
        },

        getInfo: function() {
            return {
                longname : 'Char Count plugin',
                author : 'Moxiecode Systems AB',
                authorurl : 'http://tinymce.moxiecode.com',
                infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/charcount',
                version : tinymce.majorVersion + "." + tinymce.minorVersion
            };
        }
    });

    tinymce.PluginManager.add('charcount', tinymce.plugins.CharCount);
})();
Criado 22 de outubro de 2009
Ultima resposta 24 de out. de 2009
Respostas 6
Participantes 2