From 92eac95627398bfed94d4c9f5f9be622c901422b Mon Sep 17 00:00:00 2001 From: Timo Dittmann Date: Mon, 25 Jan 2021 07:39:48 +0100 Subject: [PATCH] Added letter spacing to text formatting tools --- badges/coverage-badge.svg | 2 +- badges/tests-badge.svg | 2 +- .../ui/__snapshots__/scenario.js.snap | 69 ++++++++++++++++ cypress/integration/ui/scenario.js | 8 ++ cypress/integration/unit/sanitize.js | 30 +++++++ src/editor/images/svg_edit_icons.svg | 17 ++++ src/editor/index.html | 14 ++++ src/editor/locale.js | 1 + src/editor/locale/lang.af.js | 3 +- src/editor/locale/lang.ar.js | 3 +- src/editor/locale/lang.az.js | 3 +- src/editor/locale/lang.be.js | 3 +- src/editor/locale/lang.bg.js | 3 +- src/editor/locale/lang.ca.js | 3 +- src/editor/locale/lang.cs.js | 3 +- src/editor/locale/lang.cy.js | 3 +- src/editor/locale/lang.da.js | 3 +- src/editor/locale/lang.de.js | 3 +- src/editor/locale/lang.el.js | 3 +- src/editor/locale/lang.en.js | 3 +- src/editor/locale/lang.es.js | 3 +- src/editor/locale/lang.et.js | 3 +- src/editor/locale/lang.fa.js | 3 +- src/editor/locale/lang.fi.js | 3 +- src/editor/locale/lang.fr.js | 3 +- src/editor/locale/lang.fy.js | 3 +- src/editor/locale/lang.ga.js | 3 +- src/editor/locale/lang.gl.js | 3 +- src/editor/locale/lang.he.js | 3 +- src/editor/locale/lang.hi.js | 3 +- src/editor/locale/lang.hr.js | 3 +- src/editor/locale/lang.hu.js | 3 +- src/editor/locale/lang.hy.js | 3 +- src/editor/locale/lang.id.js | 3 +- src/editor/locale/lang.is.js | 3 +- src/editor/locale/lang.it.js | 3 +- src/editor/locale/lang.ja.js | 3 +- src/editor/locale/lang.ko.js | 3 +- src/editor/locale/lang.lt.js | 3 +- src/editor/locale/lang.lv.js | 3 +- src/editor/locale/lang.mk.js | 3 +- src/editor/locale/lang.ms.js | 3 +- src/editor/locale/lang.mt.js | 3 +- src/editor/locale/lang.nl.js | 3 +- src/editor/locale/lang.no.js | 3 +- src/editor/locale/lang.pl.js | 3 +- src/editor/locale/lang.pt-BR.js | 3 +- src/editor/locale/lang.pt-PT.js | 3 +- src/editor/locale/lang.ro.js | 3 +- src/editor/locale/lang.ru.js | 3 +- src/editor/locale/lang.sk.js | 3 +- src/editor/locale/lang.sl.js | 3 +- src/editor/locale/lang.sq.js | 3 +- src/editor/locale/lang.sr.js | 3 +- src/editor/locale/lang.sv.js | 3 +- src/editor/locale/lang.sw.js | 3 +- src/editor/locale/lang.test.js | 3 +- src/editor/locale/lang.th.js | 3 +- src/editor/locale/lang.tl.js | 3 +- src/editor/locale/lang.tr.js | 3 +- src/editor/locale/lang.uk.js | 3 +- src/editor/locale/lang.vi.js | 3 +- src/editor/locale/lang.yi.js | 3 +- src/editor/locale/lang.zh-CN.js | 3 +- src/editor/locale/lang.zh-HK.js | 3 +- src/editor/locale/lang.zh-TW.js | 3 +- src/editor/svgedit.js | 80 +++++++++++++------ src/svgcanvas/elem-get-set.js | 32 ++++++++ src/svgcanvas/sanitize.js | 2 +- src/svgcanvas/svgcanvas.js | 21 ++++- 70 files changed, 365 insertions(+), 87 deletions(-) diff --git a/badges/coverage-badge.svg b/badges/coverage-badge.svg index cc106eca..24d5755f 100644 --- a/badges/coverage-badge.svg +++ b/badges/coverage-badge.svg @@ -1 +1 @@ -Statements 53.05%Statements 53.05%Branches 41.79%Branches 41.79%Lines 53.87%Lines 53.87%Functions 60.57%Functions 60.57% +Statements 53.1%Statements 53.1%Branches 41.93%Branches 41.93%Lines 53.92%Lines 53.92%Functions 60.63%Functions 60.63% diff --git a/badges/tests-badge.svg b/badges/tests-badge.svg index c4904976..3c631ddc 100644 --- a/badges/tests-badge.svg +++ b/badges/tests-badge.svg @@ -1 +1 @@ -TestsTests147/147147/147 \ No newline at end of file +TestsTests151/151151/151 \ No newline at end of file diff --git a/cypress/integration/ui/__snapshots__/scenario.js.snap b/cypress/integration/ui/__snapshots__/scenario.js.snap index bb8ccc0a..16495423 100644 --- a/cypress/integration/ui/__snapshots__/scenario.js.snap +++ b/cypress/integration/ui/__snapshots__/scenario.js.snap @@ -493,6 +493,7 @@ exports[`use various parts of svg-edit > check tool_star #0`] = ` font-style="italic" font-weight="bold" text-decoration=" underline overline line-through" + letter-spacing="150" > B @@ -585,6 +586,7 @@ exports[`use various parts of svg-edit > check tool_polygon #0`] = ` font-style="italic" font-weight="bold" text-decoration=" underline overline line-through" + letter-spacing="150" > B @@ -1044,3 +1046,70 @@ exports[`use various parts of svg-edit > check tool_text_decoration_linethrough `; + +exports[`use various parts of svg-edit > check tool_letter_spacing #0`] = ` + + + Layer 1 + + + B + + + B + + + +`; diff --git a/cypress/integration/ui/scenario.js b/cypress/integration/ui/scenario.js index d69e0716..fb6ddec9 100644 --- a/cypress/integration/ui/scenario.js +++ b/cypress/integration/ui/scenario.js @@ -106,6 +106,14 @@ describe('use various parts of svg-edit', function () { .click({force: true}); testSnapshot(); }); + it('check tool_letter_spacing', function () { + cy.get('#svg_1').click({force: true}); + cy.get('#letter_spacing') + .type('{selectall}', {force: true}) + .type('150', {force: true}) + .type('{enter}', {force: true}); + testSnapshot(); + }); it('check tool_star', function () { cy.get('#tool_star') .click({force: true}); diff --git a/cypress/integration/unit/sanitize.js b/cypress/integration/unit/sanitize.js index 4ff4f853..5842eea4 100644 --- a/cypress/integration/unit/sanitize.js +++ b/cypress/integration/unit/sanitize.js @@ -16,4 +16,34 @@ describe('sanitize', function () { assert.equal(rect.getAttribute('stroke'), 'blue'); assert.equal(rect.getAttribute('stroke-width'), '40'); }); + + it('Test sanitizeSvg() does not strip letter-spacing attribute from text', function () { + const text = document.createElementNS(NS.SVG, 'text'); + text.setAttribute('letter-spacing', '150'); + svg.append(text); + + sanitize.sanitizeSvg(text); + + assert.equal(text.getAttribute('letter-spacing'), '150'); + }); + + it('Test sanitizeSvg() does not strip text-anchor attribute from text', function () { + const text = document.createElementNS(NS.SVG, 'text'); + text.setAttribute('text-anchor', 'end'); + svg.append(text); + + sanitize.sanitizeSvg(text); + + assert.equal(text.getAttribute('text-anchor'), 'end'); + }); + + it('Test sanitizeSvg() does not strip text-decoration attribute from text', function () { + const text = document.createElementNS(NS.SVG, 'text'); + text.setAttribute('text-decoration', 'underline'); + svg.append(text); + + sanitize.sanitizeSvg(text); + + assert.equal(text.getAttribute('text-decoration'), 'underline'); + }); }); diff --git a/src/editor/images/svg_edit_icons.svg b/src/editor/images/svg_edit_icons.svg index 45f178f2..37b1070b 100644 --- a/src/editor/images/svg_edit_icons.svg +++ b/src/editor/images/svg_edit_icons.svg @@ -1076,6 +1076,23 @@ + + + + + + + + + + + + ab + + + + + diff --git a/src/editor/index.html b/src/editor/index.html index fb3792d0..fda522c3 100644 --- a/src/editor/index.html +++ b/src/editor/index.html @@ -330,6 +330,20 @@
+
+ + +