Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
```
---

Expand Down
6 changes: 3 additions & 3 deletions projects/common-form-elements/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -23,4 +23,4 @@
"registry": "https://registry.npmjs.org/",
"access": "public"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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<any>, context) {
return _.get(_.find(config, {'code': context}), 'terms') || null;
}
Expand Down Expand Up @@ -454,4 +454,4 @@ export class DynamicFormComponent implements OnInit, OnChanges, OnDestroy {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</div>
</div>

<div class="sb-modal-dropdown-web" *ngIf="platform === 'web'" [hidden]="!showModal" >
<div class="sb-modal-dropdown-web" *ngIf="platform === 'web'" [hidden]="!showModal" (click)="$event.stopPropagation()">
<ul *ngIf="!isDependsEmpty">
<li (click)="checkUncheckAll()">
<input type="checkbox" [checked]="masterSelected">
Expand All @@ -68,4 +68,4 @@
</ul>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -385,4 +388,4 @@ export class DynamicMultipleDropdownComponent implements OnInit, OnChanges, OnDe
this.resetMasterSelected();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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, "'");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<tag-input class="sb-keywordbox" [formControl]="formControlRef" [modelAsStrings]="true" [(ngModel)]='items'
[placeholder]="field.placeholder || 'Enter Keyword'" [secondaryPlaceholder]="field.placeholder || 'Enter Keyword'"
[disable]="disabled"></tag-input>
[disable]="disabled" [separatorKeys]="[',']"></tag-input>
<ng-container *ngFor="let validation of validations">
<div class="cf-error"
*ngIf="(validation.type && (validation.type).toLowerCase() && validation.message && formControlRef.errors && formControlRef.errors[(validation.type).toLowerCase()] && (formControlRef.dirty || formControlRef.touched))">
Expand All @@ -20,7 +20,6 @@

<tag-input-dropdown [appendToBody]="false" [showDropdownIfEmpty]="true" [autocompleteItems]="field?.options"
[identifyBy]="'label'" [displayBy]="'label'"></tag-input-dropdown>

</tag-input>
<ng-container *ngFor="let validation of validations">
<div class="cf-error"
Expand Down