简体   繁体   English

jQuery所见即所得编辑器删除格式插件(rmFormat)不起作用

[英]Jquery wysiwyg editor remove formatting plugin (rmFormat) not working

I've downloaded and implemented the following plugin: https://github.com/jwysiwyg/jwysiwyg 我已经下载并实现了以下插件: 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 所以我尝试实现rmFormat插件

$('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 网站是MVC btw

Here's a fiddle 这是一个小提琴

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

Liam , i have used this plugins and faced the same problems.So i have to write some custom code and it worked for me. 利亚姆(Liam),我使用了这些插件,并且遇到了同样的问题。因此,我必须编写一些自定义代码,并且对我有用。

I have written code in jquery.jwysiwyg.js file 我已经在jquery.jwysiwyg.js文件中编写了代码

 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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM