Fix saving class name attributes for divider and custom html blocks
[MAILPOET-2746]
This commit is contained in:
committed by
Veljko V
parent
162b968f09
commit
e9c3049576
@@ -228,7 +228,9 @@ export const blocksToFormBodyFactory = (colorDefinitions, customFields = []) =>
|
||||
id: 'divider',
|
||||
type: 'divider',
|
||||
name: 'Divider',
|
||||
params: '',
|
||||
params: {
|
||||
class_name: block.attributes.className || null,
|
||||
},
|
||||
};
|
||||
case 'mailpoet-form/html':
|
||||
return {
|
||||
@@ -239,6 +241,7 @@ export const blocksToFormBodyFactory = (colorDefinitions, customFields = []) =>
|
||||
params: {
|
||||
text: block.attributes && block.attributes.content ? block.attributes.content : '',
|
||||
nl2br: block.attributes && block.attributes.nl2br ? '1' : '0',
|
||||
class_name: block.attributes.className || null,
|
||||
},
|
||||
};
|
||||
default:
|
||||
|
@@ -176,7 +176,7 @@ describe('Blocks to Form Body', () => {
|
||||
expect(divider.id).to.be.equal('divider');
|
||||
expect(divider.name).to.be.equal('Divider');
|
||||
expect(divider.type).to.be.equal('divider');
|
||||
expect(divider.params).to.be.equal('');
|
||||
expect(divider.params).to.deep.equal({ class_name: null });
|
||||
});
|
||||
|
||||
it('Should map multiple dividers', () => {
|
||||
@@ -447,6 +447,16 @@ describe('Blocks to Form Body', () => {
|
||||
const [mappedEmail] = formBlocksToBody([email]);
|
||||
expect(mappedEmail.params.class_name).to.be.equal('my-class-3');
|
||||
|
||||
const divider = { ...dividerBlock };
|
||||
divider.attributes.className = 'my-class-4';
|
||||
const [mappedDivider] = formBlocksToBody([divider]);
|
||||
expect(mappedDivider.params.class_name).to.be.equal('my-class-4');
|
||||
|
||||
const html = { ...customHtmlBlock };
|
||||
html.attributes.className = 'my-class-5';
|
||||
const [mappedHtml] = formBlocksToBody([html]);
|
||||
expect(mappedHtml.params.class_name).to.be.equal('my-class-5');
|
||||
|
||||
const customField = {
|
||||
created_at: '2019-12-10T15:05:06+00:00',
|
||||
id: 1,
|
||||
|
Reference in New Issue
Block a user