From 9593f4e6e047a29c8069685ff5ef426f8bb1780b Mon Sep 17 00:00:00 2001 From: Declan Date: Fri, 2 Aug 2024 00:07:31 +0930 Subject: [PATCH 1/3] remove html from character count in inputRichTextFSC --- .../main/default/lwc/inputRichTextFSC/inputRichTextFSC.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/flow_screen_components/richTextInputFSC/force-app/main/default/lwc/inputRichTextFSC/inputRichTextFSC.js b/flow_screen_components/richTextInputFSC/force-app/main/default/lwc/inputRichTextFSC/inputRichTextFSC.js index 433edc1a9..6ecac1920 100644 --- a/flow_screen_components/richTextInputFSC/force-app/main/default/lwc/inputRichTextFSC/inputRichTextFSC.js +++ b/flow_screen_components/richTextInputFSC/force-app/main/default/lwc/inputRichTextFSC/inputRichTextFSC.js @@ -1,6 +1,7 @@ // 06/25/21 Eric Smith Added a Required attribute and increased the bottom margin to better match standard components // 07/02/21 Eric Smith Added a Required * to the Input Label if Required is True // 04/04/23 Clifford Beul Added disabled categories and optional overwrite of formats +// 01/08/24 Declan Toohey Modified character count calculation to not include HTML characters in character count import { LightningElement, api, track } from 'lwc'; @@ -193,7 +194,9 @@ export default class inputRichTextFSC_LWC extends LightningElement { this.isValidCheck = true; this.richText = event.target.value; } - this.characterCount = this.richText.length; + + //Regex <[^>]*> removes any HTML from the word count + this.characterCount = this.richText.replace(/<[^>]*>/ig, "").length; if(this.characterCap && this.characterCount > this.characterLimit){ this.isValidCheck = false; } From 5aa1b1a4aeb0844bae5a19e1addb7a28363ba6e2 Mon Sep 17 00:00:00 2001 From: Declan Date: Fri, 2 Aug 2024 00:44:28 +0930 Subject: [PATCH 2/3] add option to count html chars --- .../main/default/lwc/inputRichTextFSC/inputRichTextFSC.js | 5 +++++ .../lwc/inputRichTextFSC/inputRichTextFSC.js-meta.xml | 1 + 2 files changed, 6 insertions(+) diff --git a/flow_screen_components/richTextInputFSC/force-app/main/default/lwc/inputRichTextFSC/inputRichTextFSC.js b/flow_screen_components/richTextInputFSC/force-app/main/default/lwc/inputRichTextFSC/inputRichTextFSC.js index 6ecac1920..dc526dcac 100644 --- a/flow_screen_components/richTextInputFSC/force-app/main/default/lwc/inputRichTextFSC/inputRichTextFSC.js +++ b/flow_screen_components/richTextInputFSC/force-app/main/default/lwc/inputRichTextFSC/inputRichTextFSC.js @@ -19,6 +19,7 @@ export default class inputRichTextFSC_LWC extends LightningElement { @api required = false; @api disabledCategories = ''; @api enabledFormats; + @api includeHTMLCharacterCount = false; formats = ['font', 'size', 'bold', 'italic', 'underline', 'strike', 'list', 'indent', 'align', 'link', @@ -197,6 +198,10 @@ export default class inputRichTextFSC_LWC extends LightningElement { //Regex <[^>]*> removes any HTML from the word count this.characterCount = this.richText.replace(/<[^>]*>/ig, "").length; + if (this.includeHTMLCharacterCount) { + this.characterCount = this.richText.length; + } + if(this.characterCap && this.characterCount > this.characterLimit){ this.isValidCheck = false; } diff --git a/flow_screen_components/richTextInputFSC/force-app/main/default/lwc/inputRichTextFSC/inputRichTextFSC.js-meta.xml b/flow_screen_components/richTextInputFSC/force-app/main/default/lwc/inputRichTextFSC/inputRichTextFSC.js-meta.xml index 672fcc25c..f73fac1f1 100644 --- a/flow_screen_components/richTextInputFSC/force-app/main/default/lwc/inputRichTextFSC/inputRichTextFSC.js-meta.xml +++ b/flow_screen_components/richTextInputFSC/force-app/main/default/lwc/inputRichTextFSC/inputRichTextFSC.js-meta.xml @@ -18,6 +18,7 @@ + \ No newline at end of file From 8075f9237243f64e85f24b251b3405daa73d10c7 Mon Sep 17 00:00:00 2001 From: Declan Date: Fri, 2 Aug 2024 13:45:56 +0930 Subject: [PATCH 3/3] changing logic from include to exclude --- .../default/lwc/inputRichTextFSC/inputRichTextFSC.js | 10 +++++----- .../lwc/inputRichTextFSC/inputRichTextFSC.js-meta.xml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/flow_screen_components/richTextInputFSC/force-app/main/default/lwc/inputRichTextFSC/inputRichTextFSC.js b/flow_screen_components/richTextInputFSC/force-app/main/default/lwc/inputRichTextFSC/inputRichTextFSC.js index dc526dcac..10c1171d6 100644 --- a/flow_screen_components/richTextInputFSC/force-app/main/default/lwc/inputRichTextFSC/inputRichTextFSC.js +++ b/flow_screen_components/richTextInputFSC/force-app/main/default/lwc/inputRichTextFSC/inputRichTextFSC.js @@ -19,7 +19,7 @@ export default class inputRichTextFSC_LWC extends LightningElement { @api required = false; @api disabledCategories = ''; @api enabledFormats; - @api includeHTMLCharacterCount = false; + @api excludeHTMLCharacterCount = false; formats = ['font', 'size', 'bold', 'italic', 'underline', 'strike', 'list', 'indent', 'align', 'link', @@ -196,10 +196,10 @@ export default class inputRichTextFSC_LWC extends LightningElement { this.richText = event.target.value; } - //Regex <[^>]*> removes any HTML from the word count - this.characterCount = this.richText.replace(/<[^>]*>/ig, "").length; - if (this.includeHTMLCharacterCount) { - this.characterCount = this.richText.length; + this.characterCount = this.richText.length; + if (this.excludeHTMLCharacterCount) { + //Regex <[^>]*> removes any HTML from the word count + this.characterCount = this.richText.replace(/<[^>]*>/ig, "").length; } if(this.characterCap && this.characterCount > this.characterLimit){ diff --git a/flow_screen_components/richTextInputFSC/force-app/main/default/lwc/inputRichTextFSC/inputRichTextFSC.js-meta.xml b/flow_screen_components/richTextInputFSC/force-app/main/default/lwc/inputRichTextFSC/inputRichTextFSC.js-meta.xml index f73fac1f1..da482fd49 100644 --- a/flow_screen_components/richTextInputFSC/force-app/main/default/lwc/inputRichTextFSC/inputRichTextFSC.js-meta.xml +++ b/flow_screen_components/richTextInputFSC/force-app/main/default/lwc/inputRichTextFSC/inputRichTextFSC.js-meta.xml @@ -18,7 +18,7 @@ - + \ No newline at end of file