Make sure level is always number
Gutenberg compares it using === and the toolbar in the sidebar doesn't work [MAILPOET-2613]
This commit is contained in:
@@ -147,6 +147,7 @@ export const formBodyToBlocksFactory = (colorDefinitions, customFields = []) =>
|
|||||||
mapped.attributes.textColor = textColorSlug;
|
mapped.attributes.textColor = textColorSlug;
|
||||||
mapped.attributes.customTextColor = !textColorSlug ? item.params.text_color : undefined;
|
mapped.attributes.customTextColor = !textColorSlug ? item.params.text_color : undefined;
|
||||||
}
|
}
|
||||||
|
let level = 2;
|
||||||
switch (item.id) {
|
switch (item.id) {
|
||||||
case 'email':
|
case 'email':
|
||||||
return {
|
return {
|
||||||
@@ -154,12 +155,18 @@ export const formBodyToBlocksFactory = (colorDefinitions, customFields = []) =>
|
|||||||
name: 'mailpoet-form/email-input',
|
name: 'mailpoet-form/email-input',
|
||||||
};
|
};
|
||||||
case 'heading':
|
case 'heading':
|
||||||
|
if (item.params && has(item.params, 'level')) {
|
||||||
|
level = parseInt(item.params.level, 10);
|
||||||
|
if (Number.isNaN(level)) {
|
||||||
|
level = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
...mapped,
|
...mapped,
|
||||||
attributes: {
|
attributes: {
|
||||||
...mapped.attributes,
|
...mapped.attributes,
|
||||||
content: item.params?.content || '',
|
content: item.params?.content || '',
|
||||||
level: item.params?.level || 2,
|
level,
|
||||||
align: item.params?.align,
|
align: item.params?.align,
|
||||||
anchor: item.params?.anchor,
|
anchor: item.params?.anchor,
|
||||||
className: item.params?.class_name,
|
className: item.params?.class_name,
|
||||||
|
@@ -409,7 +409,7 @@ describe('Form Body To Blocks', () => {
|
|||||||
params: {
|
params: {
|
||||||
text_color: '#f78da7',
|
text_color: '#f78da7',
|
||||||
content: 'Content',
|
content: 'Content',
|
||||||
level: 1,
|
level: '1',
|
||||||
anchor: 'anchor',
|
anchor: 'anchor',
|
||||||
align: 'right',
|
align: 'right',
|
||||||
class_name: 'class',
|
class_name: 'class',
|
||||||
|
Reference in New Issue
Block a user