From 96e81a63b57f2d280c188b48bd071c72eaff9b2d Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Wed, 21 Aug 2024 17:20:50 +0400 Subject: [PATCH] Remove default line-height from mj-text --- .prettierrc | 10 ++++++++++ src/components/Text.ts | 24 ++++++++++++++++++------ tests/specs/issue-367.test.ts | 21 ++++++++++----------- 3 files changed, 38 insertions(+), 17 deletions(-) create mode 100644 .prettierrc diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..0f303c9 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,10 @@ +{ + "endOfLine": "lf", + "insertPragma": false, + "requirePragma": false, + "trailingComma": "all", + "tabWidth": 2, + "useTabs": false, + "singleQuote": true, + "printWidth": 120 +} diff --git a/src/components/Text.ts b/src/components/Text.ts index 2cf11bc..4f4642e 100644 --- a/src/components/Text.ts +++ b/src/components/Text.ts @@ -20,10 +20,23 @@ export default (editor: Editor, { coreMjmlModel, coreMjmlView }: ComponentPlugin draggable: componentsToQuery([typeColumn, typeHero]), highlightable: false, stylable: [ - 'height', 'font-style', 'font-size', 'font-weight', 'font-family', 'color', - 'line-height', 'letter-spacing', 'text-decoration', 'align', 'text-transform', - 'padding', 'padding-top', 'padding-left', 'padding-right', 'padding-bottom', - 'container-background-color' + 'height', + 'font-style', + 'font-size', + 'font-weight', + 'font-family', + 'color', + 'line-height', + 'letter-spacing', + 'text-decoration', + 'align', + 'text-transform', + 'padding', + 'padding-top', + 'padding-left', + 'padding-right', + 'padding-bottom', + 'container-background-color', ], 'style-default': { 'padding-top': '10px', @@ -31,8 +44,7 @@ export default (editor: Editor, { coreMjmlModel, coreMjmlView }: ComponentPlugin 'padding-right': '25px', 'padding-left': '25px', 'font-size': '13px', - 'line-height': '22px', - 'align': 'left', + align: 'left', }, }, }, diff --git a/tests/specs/issue-367.test.ts b/tests/specs/issue-367.test.ts index d167078..0b6ad15 100644 --- a/tests/specs/issue-367.test.ts +++ b/tests/specs/issue-367.test.ts @@ -1,5 +1,5 @@ -import grapesjs, { Editor } from "grapesjs"; -import grapesJSMJML from "../../src"; +import grapesjs, { Editor } from 'grapesjs'; +import grapesJSMJML from '../../src'; const rawMjml = ` @@ -25,29 +25,29 @@ const rawMjml = ` `; // https://github.com/GrapesJS/mjml/issues/367 -describe("Line Height", () => { +describe('Line Height', () => { let editor: Editor; beforeEach((done) => { const e = grapesjs.init({ - container: "#gjs", + container: '#gjs', plugins: [grapesJSMJML], }); editor = e; editor.getModel().loadOnStart(); - editor.on("change:readyLoad", () => done()); + editor.on('change:readyLoad', () => done()); }); afterEach(() => { editor.destroy(); }); - test("Editor exists", () => { + test('Editor exists', () => { expect(editor).toBeTruthy(); }); - test("should expect default line height as 22px and export correctly in html", () => { + test('should expect default line height as 22px and export correctly in html', () => { editor.addComponents(rawMjml); const mjmlComponent = editor.getComponents().at(0); @@ -56,11 +56,10 @@ describe("Line Height", () => { const mjmlColumn = mjmlSection.components().at(0); const mjmlText = mjmlColumn.components().at(0); - const defaultLineHeight = "22px"; - const lineHeight = mjmlText.getAttributes()["line-height"]; - expect(lineHeight).toBe(defaultLineHeight); + const lineHeight = mjmlText.getAttributes()['line-height']; + expect(lineHeight).toBe(undefined); - const { errors, html } = editor.Commands.run("mjml-code-to-html"); + const { errors, html } = editor.Commands.run('mjml-code-to-html'); expect(errors).toHaveLength(0); expect(html).toMatchSnapshot();