diff --git a/README.md b/README.md index 80cb25a0..0074569f 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Contains Form component powered by angular. This component expects a configurat --- ## Getting started -How to use @project-sunbird/common-form-elements in your projects +How to use @tekdi/common-form-elements-full in your projects ## Table of Contents @@ -34,7 +34,7 @@ npm link ``` 3. Link the library to your project ```console -npm link @project-sunbird/common-form-elements +npm link @tekdi/common-form-elements-full ``` --- diff --git a/projects/common-form-elements/package.json b/projects/common-form-elements/package.json index 178dfce3..bf66b389 100644 --- a/projects/common-form-elements/package.json +++ b/projects/common-form-elements/package.json @@ -1,6 +1,6 @@ { - "name": "@project-sunbird/common-form-elements", - "version": "8.0.6", + "name": "@tekdi/common-form-elements-full", + "version": "8.0.0-beta.2", "peerDependencies": { "@angular/common": ">=16.2.12", "@angular/core": ">=16.2.12", @@ -23,4 +23,4 @@ "registry": "https://registry.npmjs.org/", "access": "public" } -} +} \ No newline at end of file diff --git a/projects/common-form-elements/src/lib/dynamic-form/dynamic-form.component.ts b/projects/common-form-elements/src/lib/dynamic-form/dynamic-form.component.ts index b78143bd..3c58031d 100644 --- a/projects/common-form-elements/src/lib/dynamic-form/dynamic-form.component.ts +++ b/projects/common-form-elements/src/lib/dynamic-form/dynamic-form.component.ts @@ -256,8 +256,6 @@ export class DynamicFormComponent implements OnInit, OnChanges, OnDestroy { break; } - formValueList.push(defaultVal); - if (element.validations && element.validations.length) { element.validations.forEach((data, i) => { if (element.inputType === 'dialcode') { return false; } @@ -322,11 +320,13 @@ export class DynamicFormComponent implements OnInit, OnChanges, OnDestroy { } }); } - formValueList.push(Validators.compose(validationList)); - return formValueList; + const validatorsFn = Validators.compose(validationList); + const formState = + element.editable === false + ? { value: defaultVal, disabled: true } + : defaultVal; + return [formState, validatorsFn]; } - - fetchContextTerms(config: FieldConfig, context) { return _.get(_.find(config, {'code': context}), 'terms') || null; } @@ -454,4 +454,4 @@ export class DynamicFormComponent implements OnInit, OnChanges, OnDestroy { } } -} +} \ No newline at end of file diff --git a/projects/common-form-elements/src/lib/dynamic-multiple-dropdown/dynamic-multiple-dropdown.component.html b/projects/common-form-elements/src/lib/dynamic-multiple-dropdown/dynamic-multiple-dropdown.component.html index b539a160..a2169e10 100644 --- a/projects/common-form-elements/src/lib/dynamic-multiple-dropdown/dynamic-multiple-dropdown.component.html +++ b/projects/common-form-elements/src/lib/dynamic-multiple-dropdown/dynamic-multiple-dropdown.component.html @@ -55,7 +55,7 @@ -
+
  • @@ -68,4 +68,4 @@
- + \ No newline at end of file diff --git a/projects/common-form-elements/src/lib/dynamic-multiple-dropdown/dynamic-multiple-dropdown.component.ts b/projects/common-form-elements/src/lib/dynamic-multiple-dropdown/dynamic-multiple-dropdown.component.ts index 312d2b77..0a81a4d5 100644 --- a/projects/common-form-elements/src/lib/dynamic-multiple-dropdown/dynamic-multiple-dropdown.component.ts +++ b/projects/common-form-elements/src/lib/dynamic-multiple-dropdown/dynamic-multiple-dropdown.component.ts @@ -181,7 +181,10 @@ export class DynamicMultipleDropdownComponent implements OnInit, OnChanges, OnDe const finalValue = this.tempValue.toList().toJS(); this.formControlRef.patchValue(this.isMultiple ? finalValue : finalValue[0]); this.formControlRef.markAsDirty(); - this.showModal = false; + // Auto-close only on mobile or when single-select; keep open for multi-select on web + if (this.platform === "mobile" || !this.isMultiple) { + this.showModal = false; + } } openModal(event) { @@ -385,4 +388,4 @@ export class DynamicMultipleDropdownComponent implements OnInit, OnChanges, OnDe this.resetMasterSelected(); } } -} +} \ No newline at end of file diff --git a/projects/common-form-elements/src/lib/dynamic-richtext/dynamic-richtext.component.ts b/projects/common-form-elements/src/lib/dynamic-richtext/dynamic-richtext.component.ts index 12ae82f6..492ac88c 100644 --- a/projects/common-form-elements/src/lib/dynamic-richtext/dynamic-richtext.component.ts +++ b/projects/common-form-elements/src/lib/dynamic-richtext/dynamic-richtext.component.ts @@ -86,6 +86,12 @@ export class DynamicRichtextComponent implements OnInit, AfterViewInit { fontSize: this.editorConfig.fontSize, isReadOnly: this.editorConfig.isReadOnly, removePlugins: this.editorConfig.removePlugins, + typing: { + transformations: { + // Disable smart quotes so that single quotes/apostrophes are not auto-converted + remove: ["quotes", "quotesPrimary", "quotesSecondary"], + }, + }, wordCount: { onUpdate: stats => { this.characterCount = stats.characters; @@ -105,7 +111,34 @@ export class DynamicRichtextComponent implements OnInit, AfterViewInit { editor.model.document.on('change', (eventInfo, batch) => { this.formControlRef.markAsTouched(); this.formControlRef.richTextCharacterCount = this.characterCount; - this.formControlRef.patchValue(editor.getData()); + const rawHtml = editor.getData(); + const sanitizedHtml = this.replaceDoubleQuotesInText(rawHtml); + this.formControlRef.patchValue(sanitizedHtml); }); } + private replaceDoubleQuotesInText(html: string): string { + if (!html) { + return html; + } + try { + const parser = new DOMParser(); + const doc = parser.parseFromString(html, "text/html"); + const traverse = (node: Node) => { + for (let i = 0; i < node.childNodes.length; i++) { + const child = node.childNodes[i]; + if (child.nodeType === Node.TEXT_NODE) { + if (child.textContent) { + child.textContent = child.textContent.replace(/"/g, "'"); + } + } else { + traverse(child); + } + } + }; + traverse(doc.body); + return doc.body.innerHTML.replace(/=\"([^\"]*)\"/g, "='$1'"); + } catch (e) { + return html.replace(/"/g, "'"); + } + } } diff --git a/projects/common-form-elements/src/lib/keywords/keywords.component.html b/projects/common-form-elements/src/lib/keywords/keywords.component.html index 3359007c..31c1d5e7 100644 --- a/projects/common-form-elements/src/lib/keywords/keywords.component.html +++ b/projects/common-form-elements/src/lib/keywords/keywords.component.html @@ -3,7 +3,7 @@ + [disable]="disabled" [separatorKeys]="[',']">
@@ -20,7 +20,6 @@ -