Merge pull request #398 from Hexastack/fix/truncate-long-messages
Some checks are pending
Build and Push Docker Images / paths-filter (push) Waiting to run
Build and Push Docker Images / build-and-push (push) Blocked by required conditions

fix: truncate long messages in visual editor
This commit is contained in:
Med Marrouchi 2024-12-03 14:28:30 +01:00 committed by GitHub
commit acf3663bd5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -30,6 +30,7 @@ import SimpleTextIcon from "@/app-components/svg/toolbar/SimpleTextIcon";
import TriggerIcon from "@/app-components/svg/TriggerIcon"; import TriggerIcon from "@/app-components/svg/TriggerIcon";
import { IBlockFull, Pattern } from "@/types/block.types"; import { IBlockFull, Pattern } from "@/types/block.types";
import { BlockPorts, BlockTypes, TBlock } from "@/types/visual-editor.types"; import { BlockPorts, BlockTypes, TBlock } from "@/types/visual-editor.types";
import { truncate } from "@/utils/text";
import { NodeModel } from "./NodeModel"; import { NodeModel } from "./NodeModel";
@ -360,7 +361,7 @@ class NodeWidget extends React.Component<
color={this.config.color} color={this.config.color}
size="21px" size="21px"
/> />
{this.props.node.message[0]} {truncate(this.props.node.message[0])}
</div> </div>
) : null} ) : null}
{[BlockTypes.quickReplies, BlockTypes.buttons].includes( {[BlockTypes.quickReplies, BlockTypes.buttons].includes(
@ -375,7 +376,7 @@ class NodeWidget extends React.Component<
{ {
//TODO: need to be updated //TODO: need to be updated
// @ts-ignore // @ts-ignore
this.props.node.message.text truncate(this.props.node.message.text)
} }
</div> </div>
) : null} ) : null}

View File

@ -0,0 +1,11 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/
export const truncate = (text: string, length = 300) => {
return text.length > length ? text.substring(0, length) + "..." : text;
};