From 820a99e5d17f6369a5cfb75e0924b4d7867df493 Mon Sep 17 00:00:00 2001 From: Preet Sidhu Date: Fri, 15 Apr 2022 10:03:38 -0400 Subject: [PATCH] disable html parsing for long texts --- .../src/widgets/TextWidget/widget/index.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/client/src/widgets/TextWidget/widget/index.tsx b/app/client/src/widgets/TextWidget/widget/index.tsx index f58ef521b8..746bb37d49 100644 --- a/app/client/src/widgets/TextWidget/widget/index.tsx +++ b/app/client/src/widgets/TextWidget/widget/index.tsx @@ -5,6 +5,7 @@ import WidgetStyleContainer, { } from "components/designSystems/appsmith/WidgetStyleContainer"; import { TextSize } from "constants/WidgetConstants"; +import { countOccurrences } from "workers/helpers"; import { ValidationTypes } from "constants/WidgetValidation"; import { DerivedPropertiesMap } from "utils/WidgetFactory"; @@ -14,6 +15,7 @@ import TextComponent, { TextAlign } from "../component"; import { AutocompleteDataType } from "utils/autocomplete/TernServer"; import { OverflowTypes } from "../constants"; +const MAX_HTML_PARSING_LENGTH = 5000; class TextWidget extends BaseWidget { static getPropertyPaneConfig() { return [ @@ -264,7 +266,20 @@ class TextWidget extends BaseWidget { ]; } + /** + * Disable html parsing for long continuous texts + * @returns boolean + */ + shouldDisableLink = (): boolean => { + const text = this.props.text || ""; + const count: number = countOccurrences(text, "\n", false); + return count === 0 && text.length > MAX_HTML_PARSING_LENGTH; + }; + getPageView() { + const disableLink: boolean = this.props.disableLink + ? true + : this.shouldDisableLink(); return ( {