Skip to content

Commit 80fa50d

Browse files
harasunu-narayanJapnitSinghDevjyothigayathri
authored
Update to v4.1.0 (#526)
- Support for Angular 15 and Ivy - Fixed, pasting rich content in safari does not work as expected - Fixed, empty paragraphs getting created when merging cells if the table is wrapped using `html.wrap` - Fixed, table row with `display: none` style applied does not get's counted - Fixed, TypeError: Cannot read properties of undefined (reading 'which') - Fixed, font size does not work when `contenteditable="false"` is used - Fixed, errors while dragging a `div` block tries to drop in its own container - Fixed, editor content scrolls up while pressing backspace in `iframe` mode - Fixed, incorrect behavior on iPad safari when backspacing on korean text - Fixed, Toolbar Sizes / Responsiveness is not relative to editor width - Fixed, viewport jumps to top when toggling between fullScreen - Fixed, text overlapping on emoticons - Fixed, inconsistent API for uploading files - Fixed, adding new row does not work with table header - Fixed, the toolbarBottom on mobile devices - Fixed, markdown UI breaks when enabling the iframe option - Fixed, accessibility features are not working for special character - Fixed, accessibility features are not working for emoticons - Fixed, hovering over the toolbar buttons generates lot of errors in console - Fixed, font formatting gets reset after inserting a table - Fixed, spacing and number lists are not respected when pasting from MS Word - Updated thirdparty plugins in examples - Fixed, editor freezes when pasting a large content - Fixed, support typescript definitions - Fixed, image alignment does not work as expected inside existing Iframe --------- Co-authored-by: Japnit Singh <japnit.singhahluwalia@accolitedigital.com> Co-authored-by: jyothigayathri <jyothi.potti@accolitedigital.com>
1 parent 1182c0b commit 80fa50d

File tree

9 files changed

+91
-58
lines changed

9 files changed

+91
-58
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![npm](https://img.shields.io/npm/dm/angular-froala-wysiwyg.svg)](https://www.npmjs.com/package/angular-froala-wysiwyg)
55
[![npm](https://img.shields.io/npm/l/angular-froala-wysiwyg.svg)](https://www.npmjs.com/package/angular-froala-wysiwyg)
66

7-
>Angular 4 to Angular 9 bindings for Froala WYSIWYG Editor.
7+
>Angular 15+ versions bindings for Froala WYSIWYG Editor.
88
99
![WYSIWYG HTML Editor](https://raw.githubusercontent.com/froala/wysiwyg-editor/v2/editor.jpg)
1010

@@ -38,6 +38,12 @@ You will need CSS styles
3838
<link href="node_modules/froala-editor/css/froala_editor.pkgd.min.css" rel="stylesheet">
3939
```
4040

41+
>Note : In case you want to use font-awesome icons , you can use them by installing it.
42+
- Run ` npm install font-awesome `
43+
- Or in `index.hml` add given cdn
44+
`<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">`
45+
46+
4147
## Update editor instructions
4248

4349
```bash

angular.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
"build": {
2525
"builder": "@angular-devkit/build-angular:browser",
2626
"options": {
27+
"allowedCommonJsDependencies":[
28+
"froala-editor",
29+
"core-js",
30+
"zone.js"
31+
],
2732
"outputPath": "dist-demo",
2833
"index": "projects/demo/src/index.html",
2934
"main": "projects/demo/src/main.ts",
@@ -83,11 +88,11 @@
8388
"projectType": "application"
8489
}
8590
},
86-
"defaultProject": "angular-froala-wysiwyg-demo",
91+
8792
"schematics": {
8893
"@schematics/angular:component": {
8994
"prefix": "",
90-
"styleext": "css"
95+
"style": "css"
9196
},
9297
"@schematics/angular:directive": {
9398
"prefix": ""

package.json

Lines changed: 25 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "angular-froala-wysiwyg-base",
3-
"version": "4.0.19",
4-
"description": "Angular 4, 5, 6, 7, 8, 9, 10, 11 and 12 bindings for Froala WYSIWYG HTML rich text editor",
3+
"version": "4.1.0",
4+
"description": "Angular 15+ versions bindings for Froala WYSIWYG HTML rich text editor",
55
"main": "bundles/angular-froala-wysiwyg.umd.js",
66
"typings": "index.d.ts",
77
"module": "index.js",
@@ -16,24 +16,8 @@
1616
"url": "https://github.com/froala/angular-froala-wysiwyg.git"
1717
},
1818
"keywords": [
19-
"angular4",
20-
"angular5",
21-
"angular6",
22-
"angular7",
23-
"angular8",
24-
"angular9",
25-
"angular10",
26-
"angular11",
27-
"angular12",
28-
"ng4",
29-
"ng5",
30-
"ng6",
31-
"ng7",
32-
"ng8",
33-
"ng9",
34-
"ng10",
35-
"ng11",
36-
"ng12",
19+
"angular15",
20+
"ng15",
3721
"froala",
3822
"html",
3923
"text",
@@ -51,33 +35,33 @@
5135
},
5236
"dependencies": {
5337
"font-awesome": "^4.7.0",
54-
"froala-editor": "^4.0.19",
55-
"tslib": "^2.0.0"
38+
"froala-editor": "^4.1.0",
39+
"tslib": "^2.5.0"
5640
},
5741
"peerDependencies": {},
5842
"devDependencies": {
59-
"@angular-devkit/build-angular": "^0.1102.12",
60-
"@angular/cli": "^11.2.12",
61-
"@angular/common": "^11.2.13",
62-
"@angular/compiler": "^11.2.13",
63-
"@angular/compiler-cli": "^11.2.13",
64-
"@angular/core": "^11.2.13",
65-
"@angular/forms": "^11.2.13",
66-
"@angular/language-service": "^11.2.13",
67-
"@angular/platform-browser": "^11.2.13",
68-
"@angular/platform-browser-dynamic": "^11.2.13",
69-
"@angular/router": "^11.2.13",
70-
"core-js": "^2.6.11",
71-
"@types/marked": "0.0.28",
72-
"@types/node": "7.0.0",
43+
"@angular-devkit/build-angular": "^15.0.0",
44+
"@angular/cli": "^15.0.0",
45+
"@angular/common": "^15.0.0",
46+
"@angular/compiler": "^15.0.0",
47+
"@angular/compiler-cli": "^15.0.0",
48+
"@angular/core": "^15.0.0",
49+
"@angular/forms": "^15.0.0",
50+
"@angular/language-service": "^15.0.0",
51+
"@angular/platform-browser": "^15.0.0",
52+
"@angular/platform-browser-dynamic": "^15.0.0",
53+
"@angular/router": "^15.0.0",
54+
"core-js": "~2.6.11",
55+
"@types/marked": "4.0.8",
56+
"@types/node": "^16.13.0",
7357
"@types/tapable": "^1.0.4",
74-
"@types/webpack": "^4.39.5",
58+
"@types/webpack": "^5.28.0",
7559
"classlist.js": "^1.1.20150312",
76-
"ng-packagr": "^11.2.4",
60+
"ng-packagr": "^15.0.0",
7761
"rxjs": "^6.5.3",
7862
"ts-helpers": "^1.1.1",
79-
"typescript": "4.0.5",
80-
"zone.js": "~0.10.3",
81-
"tsickle": "^0.39.1"
63+
"typescript": "~4.8.2",
64+
"zone.js": "~0.12.0",
65+
"tsickle": "^0.46.3"
8266
}
8367
}

projects/demo/src/app/app.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ import FroalaEditor from 'froala-editor';
6666
<form [formGroup]="form" (ngSubmit)="onSubmit()">
6767
<div *ngIf="formModel.invalid"> Name is too short. </div>
6868
<h3>Textarea with formControlName and froalaModel</h3>
69-
<textarea id="sample9-1" [froalaEditor] formControlName="formModel" [(froalaModel)]="formControls.formModel"></textarea>
69+
<textarea id="sample9-1" [froalaEditor] formControlName="formModel" [(froalaModel)]="form.formModel"></textarea>
7070
<h4>Rendered Content:</h4>
7171
<div [froalaView]="form.value.formModel"></div>
7272
<h3>Textarea only with formControlName</h3>
@@ -127,6 +127,10 @@ export class AppComponent implements OnInit {
127127
}
128128
}
129129
public myTitle: string;
130+
onBlurMethod()
131+
{
132+
console.log(this.myTitle);
133+
}
130134

131135

132136
// Sample 2 model
@@ -187,7 +191,7 @@ export class AppComponent implements OnInit {
187191
formControls = {
188192
formModel: new FormControl('Hello World', Validators.minLength(2)),
189193
};
190-
form = new FormGroup(this.formControls);
194+
form:any = new FormGroup(this.formControls);
191195
get formModel(): any { return this.form.get('formModel'); }
192196
onSubmit(): void {
193197
console.log(this.form.value);

projects/demo/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
],
1212
"module": "esnext",
1313
"moduleResolution": "node",
14-
"target": "es2015",
14+
"target": "ES2022",
1515
"baseUrl": ".",
1616
"sourceMap": true,
1717
"typeRoots": [

projects/library/ng-package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
33
"dest": "../../dist",
44
"deleteDestPath": true,
5-
"whitelistedNonPeerDependencies": [
5+
"allowedNonPeerDependencies": [
66
"froala-editor"
77
],
88
"lib": {

projects/library/package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
{
22
"name": "angular-froala-wysiwyg",
3-
"version": "4.0.19",
3+
"repository": {
4+
"type": "git",
5+
"url": "https://github.com/froala/angular-froala-wysiwyg.git",
6+
"directory":"projects/library"
7+
},
8+
"version": "4.1.0",
49
"dependencies": {
5-
"froala-editor": "4.0.19"
10+
"froala-editor": "4.1.0"
611
}
712
}

projects/library/src/editor/editor.directive.ts

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,17 @@ export class FroalaEditorDirective implements ControlValueAccessor {
5252
}
5353

5454
// Begin ControlValueAccesor methods.
55-
onChange = (_) => {
55+
onChange = (_: any) => {
5656
};
5757
onTouched = () => {
5858
};
5959

6060
// Form model content changed.
6161
writeValue(content: any): void {
6262
this.updateEditor(content);
63+
if(content){
64+
this.setup();
65+
}
6366
}
6467

6568
registerOnChange(fn: (_: any) => void): void {
@@ -131,12 +134,29 @@ export class FroalaEditorDirective implements ControlValueAccessor {
131134
this.updateEditor(content);
132135
}
133136

134-
// Update editor with model contents.
135-
private updateEditor(content: any) {
136-
if (JSON.stringify(this._oldModel) == JSON.stringify(content)) {
137-
return;
138-
}
139-
137+
private stringify(obj) {
138+
let cache = [];
139+
let str = JSON.stringify(obj, function(key, value) {
140+
if (typeof value === "object" && value !== null) {
141+
if (cache.indexOf(value) !== -1) {
142+
// Circular reference found, discard key
143+
return;
144+
}
145+
// Store value in our collection
146+
cache.push(value);
147+
}
148+
return value;
149+
});
150+
cache = null; // reset the cache
151+
return str;
152+
}
153+
154+
// Update editor with model contents.
155+
private updateEditor(content: any) {
156+
if (this.stringify(this._oldModel) == this.stringify(content)) {
157+
return;
158+
}
159+
140160
if (!this._hasSpecialTag) {
141161
this._oldModel = content;
142162
} else {
@@ -351,6 +371,15 @@ export class FroalaEditorDirective implements ControlValueAccessor {
351371
// TODO not sure if ngOnInit is executed after @inputs
352372
ngAfterViewInit() {
353373
// check if output froalaInit is present. Maybe observers is private and should not be used?? TODO how to better test that an output directive is present.
374+
this.setup();
375+
}
376+
377+
private initialized = false;
378+
private setup() {
379+
if (this.initialized) {
380+
return;
381+
}
382+
this.initialized = true;
354383
if (!this.froalaInit.observers.length) {
355384
this.createEditor();
356385
} else {

projects/library/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"types": []
2020
},
2121
"angularCompilerOptions": {
22-
"enableIvy": false,
22+
"compilationMode": "partial",
2323
"annotateForClosureCompiler": true,
2424
"strictMetadataEmit": true,
2525
"skipTemplateCodegen": true,

0 commit comments

Comments
 (0)