From a33a140e5d236978af87d9e15c5033ace149b9ed Mon Sep 17 00:00:00 2001 From: Jhon Vente Date: Tue, 13 Feb 2024 09:45:31 -0500 Subject: [PATCH] fix: custom size of the iframe with fileds data --- .../customTinyMcePlugins/embedIframePlugin.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/editors/sharedComponents/TinyMceWidget/customTinyMcePlugins/embedIframePlugin.js b/src/editors/sharedComponents/TinyMceWidget/customTinyMcePlugins/embedIframePlugin.js index a3fbc0b54..04057ca3a 100644 --- a/src/editors/sharedComponents/TinyMceWidget/customTinyMcePlugins/embedIframePlugin.js +++ b/src/editors/sharedComponents/TinyMceWidget/customTinyMcePlugins/embedIframePlugin.js @@ -89,9 +89,11 @@ function tinyMCEEmbedIframePlugin(editor) { onChange(api, field) { const { name } = field; const data = api.getData(); - const { sizeType } = data; + const { sizeType, ...fields } = data; + const isSizeTypeFiled = name === 'sizeType'; + const hasCustomSize = sizeType === 'inline'; - if (sizeType !== 'inline' && name === 'sizeType') { + if (!hasCustomSize && isSizeTypeFiled) { const { body: { tabs: [generalTab], @@ -102,11 +104,11 @@ function tinyMCEEmbedIframePlugin(editor) { (item) => item.type !== 'sizeinput', ); - defaultConfig.initialData = { sizeType }; + defaultConfig.initialData = { ...fields, sizeType }; api.redial(defaultConfig); } - if (sizeType === 'inline' && name === 'sizeType') { + if (hasCustomSize && isSizeTypeFiled) { const { body: { tabs: [generalTab], @@ -126,7 +128,7 @@ function tinyMCEEmbedIframePlugin(editor) { ]; } - defaultConfig.initialData = { sizeType }; + defaultConfig.initialData = { ...fields, sizeType }; api.redial(defaultConfig); } },