Map heading colours
[MAILPOET-2613]
This commit is contained in:
@ -142,6 +142,11 @@ export const formBodyToBlocksFactory = (colorDefinitions, customFields = []) =>
|
||||
if (item.params) {
|
||||
mapped.attributes.label = item.params.label ? item.params.label : '';
|
||||
}
|
||||
if (item.params && has(item.params, 'text_color')) {
|
||||
const textColorSlug = mapColorSlug(colorDefinitions, item.params.text_color);
|
||||
mapped.attributes.textColor = textColorSlug;
|
||||
mapped.attributes.customTextColor = !textColorSlug ? item.params.text_color : undefined;
|
||||
}
|
||||
switch (item.id) {
|
||||
case 'email':
|
||||
return {
|
||||
@ -152,10 +157,10 @@ export const formBodyToBlocksFactory = (colorDefinitions, customFields = []) =>
|
||||
return {
|
||||
...mapped,
|
||||
attributes: {
|
||||
...mapped.attributes,
|
||||
content: item.params?.content || '',
|
||||
level: item.params?.level || 2,
|
||||
align: item.params?.align,
|
||||
textColor: item.params?.text_color,
|
||||
anchor: item.params?.anchor,
|
||||
className: item.params?.class_name,
|
||||
},
|
||||
|
@ -242,7 +242,6 @@ describe('Blocks to Form Body', () => {
|
||||
expect(input.params.content).to.be.equal('');
|
||||
expect(input.params.level).to.be.equal(2);
|
||||
expect(input.params.align).to.be.equal('left');
|
||||
expect(input.params.text_color).to.be.equal('#000');
|
||||
expect(input.params.anchor).to.be.be.null;
|
||||
expect(input.params.class_name).to.be.null;
|
||||
});
|
||||
@ -256,7 +255,7 @@ describe('Blocks to Form Body', () => {
|
||||
content: 'Heading content',
|
||||
level: 3,
|
||||
align: 'center',
|
||||
textColor: 'red',
|
||||
customTextColor: '#123',
|
||||
anchor: 'anchor',
|
||||
className: 'class',
|
||||
},
|
||||
@ -265,7 +264,7 @@ describe('Blocks to Form Body', () => {
|
||||
expect(input.params.content).to.be.equal('Heading content');
|
||||
expect(input.params.level).to.be.equal(3);
|
||||
expect(input.params.align).to.be.equal('center');
|
||||
expect(input.params.text_color).to.be.equal('red');
|
||||
expect(input.params.text_color).to.be.equal('#123');
|
||||
expect(input.params.anchor).to.be.equal('anchor');
|
||||
expect(input.params.class_name).to.be.equal('class');
|
||||
});
|
||||
|
@ -407,7 +407,7 @@ describe('Form Body To Blocks', () => {
|
||||
...headingInput,
|
||||
position: '1',
|
||||
params: {
|
||||
text_color: 'vivid-red',
|
||||
text_color: '#f78da7',
|
||||
content: 'Content',
|
||||
level: 1,
|
||||
anchor: 'anchor',
|
||||
@ -422,6 +422,6 @@ describe('Form Body To Blocks', () => {
|
||||
expect(block.attributes.align).to.be.equal('right');
|
||||
expect(block.attributes.className).to.be.equal('class');
|
||||
expect(block.attributes.anchor).to.be.equal('anchor');
|
||||
expect(block.attributes.textColor).to.be.equal('vivid-red');
|
||||
expect(block.attributes.customTextColor).to.be.equal('#f78da7');
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user