From bd35bf89e8593ede9448d076fe445ef20cb97748 Mon Sep 17 00:00:00 2001 From: Harsh Singh Date: Wed, 8 Nov 2023 14:23:24 +0530 Subject: [PATCH 1/3] prevent ft class names from being removed --- fastn-js/js/utils.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fastn-js/js/utils.js b/fastn-js/js/utils.js index b32e64ee65..5ec1f080e5 100644 --- a/fastn-js/js/utils.js +++ b/fastn-js/js/utils.js @@ -1,4 +1,5 @@ let fastn_utils = { + ftClassNames: ["ft_column", "ft_row"], htmlNode(kind) { let node = "div"; let css = []; @@ -104,7 +105,8 @@ let fastn_utils = { const classesToRemove = []; for (const className of iterativeClassList) { - if (!className.startsWith('__') && + if (!className.startsWith('__') && + !this.ftClassNames.includes(className) && className !== extraCodeData?.language && className !== extraCodeData?.theme ) { From 1b3921c3390304b8cd29c023d66eb701a922acbd Mon Sep 17 00:00:00 2001 From: Harsh Singh Date: Wed, 8 Nov 2023 15:15:48 +0530 Subject: [PATCH 2/3] convert ftClassNames into a map --- fastn-js/js/dom.js | 6 ++++++ fastn-js/js/utils.js | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/fastn-js/js/dom.js b/fastn-js/js/dom.js index e75dbe2595..5ffedb52fb 100644 --- a/fastn-js/js/dom.js +++ b/fastn-js/js/dom.js @@ -2,6 +2,12 @@ let fastn_dom = {}; fastn_dom.styleClasses = ""; +fastn_dom.InternalClass = { + FT_COLUMN: 'ft_column', + FT_ROW: 'ft_row', + FULL: "full", +}; + fastn_dom.codeData = { availableThemes: {}, addedCssFile: [] diff --git a/fastn-js/js/utils.js b/fastn-js/js/utils.js index 5ec1f080e5..4348e406e4 100644 --- a/fastn-js/js/utils.js +++ b/fastn-js/js/utils.js @@ -1,16 +1,15 @@ let fastn_utils = { - ftClassNames: ["ft_column", "ft_row"], htmlNode(kind) { let node = "div"; let css = []; let attributes = {}; if (kind === fastn_dom.ElementKind.Column) { - css.push("ft_column"); + css.push(fastn_dom.InternalClass.FT_COLUMN); } else if (kind === fastn_dom.ElementKind.Document) { - css.push("ft_column"); - css.push("full"); + css.push(fastn_dom.InternalClass.FT_COLUMN); + css.push(fastn_dom.InternalClass.FULL); } else if (kind === fastn_dom.ElementKind.Row) { - css.push("ft_row"); + css.push(fastn_dom.InternalClass.FT_ROW); } else if (kind === fastn_dom.ElementKind.IFrame) { node = "iframe"; // To allow fullscreen support @@ -102,11 +101,12 @@ let fastn_utils = { if (ssr) { iterativeClassList = iterativeClassList.getClasses(); } + const internalClassNames = Object.values(fastn_dom.InternalClass); const classesToRemove = []; for (const className of iterativeClassList) { if (!className.startsWith('__') && - !this.ftClassNames.includes(className) && + !internalClassNames.includes(className) && className !== extraCodeData?.language && className !== extraCodeData?.theme ) { From 27cdfe70310fb8d48fb00b73c2b8f88377bd4444 Mon Sep 17 00:00:00 2001 From: Harsh Singh Date: Wed, 8 Nov 2023 15:52:05 +0530 Subject: [PATCH 3/3] changed class full -> ft_full_size --- fastn-js/js/dom.js | 2 +- fastn-js/js/utils.js | 2 +- ftd/ftd-js.css | 2 +- ftd/t/js/22-document.html | 2 +- ftd/t/js/41-document-favicon.html | 2 +- ftd/t/js/72-document-breakpoint.html | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fastn-js/js/dom.js b/fastn-js/js/dom.js index 5ffedb52fb..cae4c94ce1 100644 --- a/fastn-js/js/dom.js +++ b/fastn-js/js/dom.js @@ -5,7 +5,7 @@ fastn_dom.styleClasses = ""; fastn_dom.InternalClass = { FT_COLUMN: 'ft_column', FT_ROW: 'ft_row', - FULL: "full", + FT_FULL_SIZE: "ft_full_size", }; fastn_dom.codeData = { diff --git a/fastn-js/js/utils.js b/fastn-js/js/utils.js index 4348e406e4..a205e63eaa 100644 --- a/fastn-js/js/utils.js +++ b/fastn-js/js/utils.js @@ -7,7 +7,7 @@ let fastn_utils = { css.push(fastn_dom.InternalClass.FT_COLUMN); } else if (kind === fastn_dom.ElementKind.Document) { css.push(fastn_dom.InternalClass.FT_COLUMN); - css.push(fastn_dom.InternalClass.FULL); + css.push(fastn_dom.InternalClass.FT_FULL_SIZE); } else if (kind === fastn_dom.ElementKind.Row) { css.push(fastn_dom.InternalClass.FT_ROW); } else if (kind === fastn_dom.ElementKind.IFrame) { diff --git a/ftd/ftd-js.css b/ftd/ftd-js.css index 250014eba6..ff39a1d267 100644 --- a/ftd/ftd-js.css +++ b/ftd/ftd-js.css @@ -132,7 +132,7 @@ pre code { justify-content: start } -.full { +.ft_full_size { width: 100%; height: 100%; } diff --git a/ftd/t/js/22-document.html b/ftd/t/js/22-document.html index b64f427435..238bc79bc3 100644 --- a/ftd/t/js/22-document.html +++ b/ftd/t/js/22-document.html @@ -17,7 +17,7 @@ -
This is document component
diff --git a/ftd/t/js/41-document-favicon.html b/ftd/t/js/41-document-favicon.html index 60ef9936a7..9f3565ec0a 100644 --- a/ftd/t/js/41-document-favicon.html +++ b/ftd/t/js/41-document-favicon.html @@ -17,7 +17,7 @@ -
This is some text
-
Mobile text