From fb584f7d8beca676fbb27f0dd95336b9d2811393 Mon Sep 17 00:00:00 2001 From: Jeronimo Date: Mon, 14 Oct 2024 13:02:31 +0200 Subject: [PATCH 1/2] Reactivity added To make the component react to changes --- .../lwc/inputRichTextFSC/inputRichTextFSC.js | 61 +++++++++++-------- 1 file changed, 36 insertions(+), 25 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 10c1171d6..8c9f3bb1f 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 @@ -2,13 +2,25 @@ // 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 +// 14/10/24 Jeroen Burgers Added reactivity import { LightningElement, api, track } from 'lwc'; export default class inputRichTextFSC_LWC extends LightningElement { //Input and Output Attributes for Flow - @api value; //set empty in connectedCallback if undefined. + _value; + @api + set value(newValue) { + if (newValue !== this._value) { + this._value = newValue; + this.connectedCallback(); + } + } + get value() { + return this._value; + } + @api disableAdvancedTools = false; @api disallowedWordsList; @api disallowedSymbolsList; @@ -84,13 +96,13 @@ export default class inputRichTextFSC_LWC extends LightningElement { regTerm = ''; applyTerm = ''; instructions = '1) Find and Replace: Use Magnifying Glass, Enter Terms and Use Check Mark. '+ - '2) Auto Replace: If your Admin has configured it, Use Merge Icon to replace suggested terms.'; + '2) Auto Replace: If your Admin has configured it, Use Merge Icon to replace suggested terms.'; //Begin functionality //Set initial values on load connectedCallback() { - + //use sessionStorage to fetch and restore latest value before validation failure. if(sessionStorage){ if(sessionStorage.getItem('tempValue')){ @@ -103,58 +115,57 @@ export default class inputRichTextFSC_LWC extends LightningElement { this.formats = this.enabledFormats.split(',').map(function(item) { return item.trim(); }); - } + } if(!this.disableAdvancedTools){ - console.log('disableAdvancedTools is false, in connected callback'); - (this.value != undefined) ? this.richText = this.value : this.richText = ''; + (this.value !== undefined) ? this.richText = this.value : this.richText = ''; this.characterCount = this.richText.length; - if(this.disallowedSymbolsList != undefined){ + if(this.disallowedSymbolsList !== undefined){ this.disallowedSymbolsArray = this.disallowedSymbolsList.replace(/\s/g,'').split(','); for(let i=0; i 0){ this.characterCap = true; } } } - - //Handle updates to Rich Text field with no enhanced features + + //Handle updates to Rich Text field with no enhanced features handleValueChange(event) { this.value = event.target.value; } @@ -163,12 +174,12 @@ export default class inputRichTextFSC_LWC extends LightningElement { handleTextChange(event) { this.runningBlockedInput = []; this.isValidCheck = true; - if (this.symbolsNotAllowed != undefined || this.wordsNotAllowed != undefined) { + if (this.symbolsNotAllowed !== undefined || this.wordsNotAllowed !== undefined) { this.interimValue = (event.target.value).toLowerCase(); this.interimValue = this.interimValue.replace(/(<([^>]+)>)/ig, ""); - + //Symbol check section - if (this.symbolsNotAllowed != undefined) { + if (this.symbolsNotAllowed !== undefined) { let matchesSymbol = this.interimValue.match(this.symbolsNotAllowed); if (matchesSymbol != null && matchesSymbol.length > 0) { for(let i = 0; i < matchesSymbol.length; i++){ @@ -180,7 +191,7 @@ export default class inputRichTextFSC_LWC extends LightningElement { } } - if (this.wordsNotAllowed != undefined) { + if (this.wordsNotAllowed !== undefined) { let matchesWords = this.interimValue.match(this.wordsNotAllowed); if (matchesWords != null && matchesWords.length > 0) { for(let i = 0; i < matchesWords.length; i++){ @@ -213,7 +224,7 @@ export default class inputRichTextFSC_LWC extends LightningElement { }else{ this.errorMessage = 'Warning - Invalid Symbols/Words found: '+this.runningBlockedInput.toString(); } - + } //Set css on Character count if passing character limit @@ -277,4 +288,4 @@ export default class inputRichTextFSC_LWC extends LightningElement { return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); } -} \ No newline at end of file +} From f1be1b8224e10dce7490454ebe2e1332974bd34d Mon Sep 17 00:00:00 2001 From: Jeronimo Date: Mon, 14 Oct 2024 13:04:20 +0200 Subject: [PATCH 2/2] Update inputRichTextFSC.js-meta.xml --- .../default/lwc/inputRichTextFSC/inputRichTextFSC.js-meta.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 da482fd49..0af121168 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 @@ -1,6 +1,6 @@ - 56.0 + 62.0 true lightning__FlowScreen @@ -21,4 +21,4 @@ - \ No newline at end of file +