ExtJS 4: HtmlEditor Clear All Tags Button

Posted By Vitalii | February 02, 2014 | ExtJS 4.2.2
0 3592
We can make this button as a simple plugin for HtmlEditor.

Js Code

Ext.define('Ext.form.plugin.ClearTags', {
    regex: /(<([^>]+)>)/ig,
    regexSpaces: /(\s|&nbsp;)+/g,
    ...
    onRender: function () {
        ...
        tb.add({
            ...
            handler: function () {
                var value = ed.getValue() || '',
                    result = value.replace(me.regex, ' ').replace(me.regexSpaces, ' ');
                ed.setValue(result);
            }
        });
    }
});
            

ExtJS 3: HtmlEditor Clear All Tags Button

Posted By Vitalii | February 02, 2014 | ExtJS 3.4.0
0 3229
We can make this button as a simple plugin for HtmlEditor.

Js Code

Ext.form.plugin.ClearTags = Ext.extend(Ext.util.Observable, {
    regex: /(<([^>]+)>)/ig,
    regexSpaces: /(\s|&nbsp;)+/g,
    ...
    onRender: function () {
        ...
        tb.addButton({
            ...
            handler: function () {
                var value = ed.getValue() || '',
                    result = value.replace(me.regex, ' ').replace(me.regexSpaces, ' ');
                ed.setValue(result);
            }
        });
    }
});