Search code examples
asp.net-mvcjquery-pluginsjwysiwyg

Jquery wysiwyg editor remove formatting plugin (rmFormat) not working


I've downloaded and implemented the following plugin: https://github.com/jwysiwyg/jwysiwyg

Now I don't want users to be able to format the text entered into the plugin, just basic bold itallics and paragraphs. So I've tried to implement the rmFormat plugin

$('textarea.wysiwyg').wysiwyg({
        brIE: true,
        rmUnusedControls: true,
        controls: {
            bold: { visible: true },
            italic: { visible: true },
            h3: { visible: true },
            removeFormat: { visible: true }
        },
        rmUnwantedBr: false,
        plugins: {
            rmFormat: {
                rmMsWordMarkup: true,
                enabled:true
            }
        }
    });

But well it just doesn't work! anyone any experience of this? If not anyone got any other suggestions of controls like this that allow very simple markup control only?

Site is MVC btw

Here's a fiddle

http://jsfiddle.net/KjVEt/69/


Solution

  • Liam , i have used this plugins and faced the same problems.So i have to write some custom code and it worked for me.

    I have written code in jquery.jwysiwyg.js file

     this.removeFormat = function () {
             ...
          // Get the current html strings from textarea
             var newContent = this.getContent();
            // it will remove all the html formatting applied on textarea
             newContent = newContent.replace(/<(.|\n)*?>/gi, '');
             // update new contents on textarea
             this.editorDoc.body.innerHTML = newContent;
             this.saveContent();
    
     return this;
    }