From 69bf3d9d8197ab211d4c1c5d23ac829c01fcddcd Mon Sep 17 00:00:00 2001 From: Timo Dittmann Date: Mon, 25 Jan 2021 13:25:22 +0100 Subject: [PATCH] Added word spacing to text formatting tools --- badges/coverage-badge.svg | 2 +- badges/tests-badge.svg | 2 +- .../ui/__snapshots__/scenario.js.snap | 70 +++++++++++++++++++ cypress/integration/ui/scenario.js | 8 +++ cypress/integration/unit/sanitize.js | 10 +++ src/editor/images/svg_edit_icons.svg | 18 +++++ 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 | 1 + 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 | 1 + 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 | 32 +++++++++ src/svgcanvas/elem-get-set.js | 32 +++++++++ src/svgcanvas/sanitize.js | 2 +- src/svgcanvas/svgcanvas.js | 20 +++++- 70 files changed, 320 insertions(+), 61 deletions(-) diff --git a/badges/coverage-badge.svg b/badges/coverage-badge.svg index 24d5755f..b9a72568 100644 --- a/badges/coverage-badge.svg +++ b/badges/coverage-badge.svg @@ -1 +1 @@ -Statements 53.1%Statements 53.1%Branches 41.93%Branches 41.93%Lines 53.92%Lines 53.92%Functions 60.63%Functions 60.63% +Statements 53.21%Statements 53.21%Branches 42.09%Branches 42.09%Lines 54.02%Lines 54.02%Functions 60.7%Functions 60.7% diff --git a/badges/tests-badge.svg b/badges/tests-badge.svg index 3c631ddc..054a703a 100644 --- a/badges/tests-badge.svg +++ b/badges/tests-badge.svg @@ -1 +1 @@ -TestsTests151/151151/151 \ No newline at end of file +TestsTests153/153153/153 \ 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 16495423..aef0794a 100644 --- a/cypress/integration/ui/__snapshots__/scenario.js.snap +++ b/cypress/integration/ui/__snapshots__/scenario.js.snap @@ -494,6 +494,7 @@ exports[`use various parts of svg-edit > check tool_star #0`] = ` font-weight="bold" text-decoration=" underline overline line-through" letter-spacing="150" + word-spacing="10" > B @@ -587,6 +588,7 @@ exports[`use various parts of svg-edit > check tool_polygon #0`] = ` font-weight="bold" text-decoration=" underline overline line-through" letter-spacing="150" + word-spacing="10" > B @@ -1113,3 +1115,71 @@ exports[`use various parts of svg-edit > check tool_letter_spacing #0`] = ` `; + +exports[`use various parts of svg-edit > check tool_word_spacing #0`] = ` + + + Layer 1 + + + B + + + B + + + +`; diff --git a/cypress/integration/ui/scenario.js b/cypress/integration/ui/scenario.js index fb6ddec9..f634450a 100644 --- a/cypress/integration/ui/scenario.js +++ b/cypress/integration/ui/scenario.js @@ -114,6 +114,14 @@ describe('use various parts of svg-edit', function () { .type('{enter}', {force: true}); testSnapshot(); }); + it('check tool_word_spacing', function () { + cy.get('#svg_1').click({force: true}); + cy.get('#word_spacing') + .type('{selectall}', {force: true}) + .type('10', {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 5842eea4..82726ee3 100644 --- a/cypress/integration/unit/sanitize.js +++ b/cypress/integration/unit/sanitize.js @@ -46,4 +46,14 @@ describe('sanitize', function () { assert.equal(text.getAttribute('text-decoration'), 'underline'); }); + + it('Test sanitizeSvg() does not strip word-spacing attribute from text', function () { + const text = document.createElementNS(NS.SVG, 'text'); + text.setAttribute('word-spacing', '10'); + svg.append(text); + + sanitize.sanitizeSvg(text); + + assert.equal(text.getAttribute('word-spacing'), '10'); + }); }); diff --git a/src/editor/images/svg_edit_icons.svg b/src/editor/images/svg_edit_icons.svg index 37b1070b..82f68a7c 100644 --- a/src/editor/images/svg_edit_icons.svg +++ b/src/editor/images/svg_edit_icons.svg @@ -1093,6 +1093,24 @@ + + + + + + + + + + + + Layer 1 + A B + + + + + diff --git a/src/editor/index.html b/src/editor/index.html index fda522c3..a6f4a341 100644 --- a/src/editor/index.html +++ b/src/editor/index.html @@ -344,6 +344,20 @@ +
+ + +