From 9b8250d6c49b79eb92d990bdd8080e7de25b07d8 Mon Sep 17 00:00:00 2001 From: GreLI Date: Mon, 16 Mar 2015 15:09:15 +0300 Subject: [PATCH] Remove standard descriptions. Resolves #302 --- plugins/removeDesc.js | 18 +++++++++++++----- test/plugins/removeDesc.01.svg | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/plugins/removeDesc.js b/plugins/removeDesc.js index 40ecdb34..a6066413 100644 --- a/plugins/removeDesc.js +++ b/plugins/removeDesc.js @@ -2,11 +2,18 @@ exports.type = 'perItem'; -exports.active = false; +exports.active = true; + +exports.params = { + removeAny: false +}; + +var standardDescs = /^Created with/; /** - * Remove . - * Disabled by default cause it may be used for accessibility. + * Removes . + * Removes only standard editors content or empty elements 'cause it can be used for accessibility. + * Enable parameter 'removeAny' to remove any description. * * https://developer.mozilla.org/en-US/docs/Web/SVG/Element/desc * @@ -15,8 +22,9 @@ exports.active = false; * * @author Daniel Wabyick */ -exports.fn = function(item) { +exports.fn = function(item, params) { - return !item.isElem('desc'); + return !item.isElem('desc') || !(params.removeAny || item.isEmpty() || + standardDescs.test(item.content[0].text)); }; diff --git a/test/plugins/removeDesc.01.svg b/test/plugins/removeDesc.01.svg index cafe5830..7b174d5d 100644 --- a/test/plugins/removeDesc.01.svg +++ b/test/plugins/removeDesc.01.svg @@ -1,5 +1,5 @@ - ... + Created with Sketch.