/**
* rmFormat plugin
*
* Depends on jWYSIWYG
*/
(function ($) {
if (undefined === $.wysiwyg) {
throw "wysiwyg.rmFormat.js depends on $.wysiwyg";
}
/*
* Wysiwyg namespace: public properties and methods
*/
var rmFormat = {
name: "rmFormat",
version: "",
defaults: {
rules: {
heading: false,
table: false,
/*
* rmAttr - { "all" | object with names } remove all
* attributes or attributes with following names
*
* rmWhenEmpty - if element contains no text or { \s, \n,
,
}
* then it will be removed
*
* rmWhenNoAttr - if element contains no attributes (i.e. Some Text)
* then it will be removed
*/
msWordMarkup: {
enabled: false,
tags: {
"a": {
rmWhenEmpty: true
},
"b": {
rmWhenEmpty: true
},
"div": {
rmWhenEmpty: true,
rmWhenNoAttr: true
},
"em": {
rmWhenEmpty: true
},
"font": {
rmAttr: {
"face": "",
"size": ""
},
rmWhenEmpty: true,
rmWhenNoAttr: true
},
"h1": {
rmAttr: "all",
rmWhenEmpty: true
},
"h2": {
rmAttr: "all",
rmWhenEmpty: true
},
"h3": {
rmAttr: "all",
rmWhenEmpty: true
},
"h4": {
rmAttr: "all",
rmWhenEmpty: true
},
"h5": {
rmAttr: "all",
rmWhenEmpty: true
},
"h6": {
rmAttr: "all",
rmWhenEmpty: true
},
"i": {
rmWhenEmpty: true
},
"p": {
rmAttr: "all",
rmWhenEmpty: true
},
"span": {
rmAttr: {
lang: ""
},
rmWhenEmpty: true,
rmWhenNoAttr: true
},
"strong": {
rmWhenEmpty: true
},
"u": {
rmWhenEmpty: true
}
}
}
}
},
options: {},
enabled: false,
debug: false,
domRemove: function (node) {
// replace h1-h6 with p
if (this.options.rules.heading) {
if (node.nodeName.toLowerCase().match(/^h[1-6]$/)) {
// in chromium change this to
// $(node).replaceWith($('