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:
Pavel Dohnal
2020-03-17 11:24:13 +01:00
committed by Veljko V
parent ca88ef3359
commit 8c104d2842
2 changed files with 9 additions and 2 deletions

View File

@@ -147,6 +147,7 @@ export const formBodyToBlocksFactory = (colorDefinitions, customFields = []) =>
mapped.attributes.textColor = textColorSlug;
mapped.attributes.customTextColor = !textColorSlug ? item.params.text_color : undefined;
}
let level = 2;
switch (item.id) {
case 'email':
return {
@@ -154,12 +155,18 @@ export const formBodyToBlocksFactory = (colorDefinitions, customFields = []) =>
name: 'mailpoet-form/email-input',
};
case 'heading':
if (item.params && has(item.params, 'level')) {
level = parseInt(item.params.level, 10);
if (Number.isNaN(level)) {
level = 2;
}
}
return {
...mapped,
attributes: {
...mapped.attributes,
content: item.params?.content || '',
level: item.params?.level || 2,
level,
align: item.params?.align,
anchor: item.params?.anchor,
className: item.params?.class_name,