disable html parsing for long texts
This commit is contained in:
parent
9f2c5dc5f7
commit
820a99e5d1
|
|
@ -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<TextWidgetProps, WidgetState> {
|
||||
static getPropertyPaneConfig() {
|
||||
return [
|
||||
|
|
@ -264,7 +266,20 @@ class TextWidget extends BaseWidget<TextWidgetProps, WidgetState> {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 (
|
||||
<WidgetStyleContainer
|
||||
{...pick(this.props, [
|
||||
|
|
@ -277,7 +292,7 @@ class TextWidget extends BaseWidget<TextWidgetProps, WidgetState> {
|
|||
<TextComponent
|
||||
backgroundColor={this.props.backgroundColor}
|
||||
bottomRow={this.props.bottomRow}
|
||||
disableLink={this.props.disableLink || false}
|
||||
disableLink={disableLink}
|
||||
fontSize={this.props.fontSize}
|
||||
fontStyle={this.props.fontStyle}
|
||||
isLoading={this.props.isLoading}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user