|
Last change
on this file since 9af201e was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.5 KB
|
| Line | |
|---|
| 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 | * Remove editors namespaces, elements and attributes.
|
|---|
| 18 | *
|
|---|
| 19 | * @example
|
|---|
| 20 | * <svg xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd">
|
|---|
| 21 | * <sodipodi:namedview/>
|
|---|
| 22 | * <path sodipodi:nodetypes="cccc"/>
|
|---|
| 23 | *
|
|---|
| 24 | * @param {Object} item current iteration item
|
|---|
| 25 | * @param {Object} params plugin params
|
|---|
| 26 | * @return {Boolean} if false, item will be filtered out
|
|---|
| 27 | *
|
|---|
| 28 | * @author Kir Belevich
|
|---|
| 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 | // <svg xmlns:sodipodi="">
|
|---|
| 45 | item.removeAttr(attr.name);
|
|---|
| 46 | }
|
|---|
| 47 | });
|
|---|
| 48 |
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | // <* sodipodi:*="">
|
|---|
| 52 | item.eachAttr(function(attr) {
|
|---|
| 53 | if (prefixes.indexOf(attr.prefix) > -1) {
|
|---|
| 54 | item.removeAttr(attr.name);
|
|---|
| 55 | }
|
|---|
| 56 | });
|
|---|
| 57 |
|
|---|
| 58 | // <sodipodi:*>
|
|---|
| 59 | if (prefixes.indexOf(item.prefix) > -1) {
|
|---|
| 60 | return false;
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.