1 | 'use strict';
|
2 |
|
3 | exports.type = 'perItem';
|
4 |
|
5 | exports.active = true;
|
6 |
|
7 | exports.description = 'removes editors namespaces, elements and attributes';
|
8 |
|
9 | var editorNamespaces = require('./_collections').editorNamespaces,
|
10 | prefixes = [];
|
11 |
|
12 | exports.params = {
|
13 | additionalNamespaces: []
|
14 | };
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | exports.fn = function(item, params) {
|
31 |
|
32 | if (Array.isArray(params.additionalNamespaces)) {
|
33 | editorNamespaces = editorNamespaces.concat(params.additionalNamespaces);
|
34 | }
|
35 |
|
36 | if (item.elem) {
|
37 |
|
38 | if (item.isElem('svg')) {
|
39 |
|
40 | item.eachAttr(function(attr) {
|
41 | if (attr.prefix === 'xmlns' && editorNamespaces.indexOf(attr.value) > -1) {
|
42 | prefixes.push(attr.local);
|
43 |
|
44 |
|
45 | item.removeAttr(attr.name);
|
46 | }
|
47 | });
|
48 |
|
49 | }
|
50 |
|
51 |
|
52 | item.eachAttr(function(attr) {
|
53 | if (prefixes.indexOf(attr.prefix) > -1) {
|
54 | item.removeAttr(attr.name);
|
55 | }
|
56 | });
|
57 |
|
58 |
|
59 | if (prefixes.indexOf(item.prefix) > -1) {
|
60 | return false;
|
61 | }
|
62 |
|
63 | }
|
64 |
|
65 | };
|