Skip to content

Commit 9bc86a9

Browse files
committed
Upgrade to Angular 22
1 parent 5a8ea83 commit 9bc86a9

15 files changed

Lines changed: 2707 additions & 2391 deletions

.github/workflows/npm_publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- uses: actions/checkout@v4 # Updated to use v2
1313
- uses: actions/setup-node@v4 # Updated to use v3
1414
with:
15-
node-version: 20
15+
node-version: 24
1616
registry-url: 'https://registry.npmjs.org/' # Added for npm to configure auth
1717
- name: Install Angular CLI
1818
run: npm install -g @angular/cli @angular/core

package-lock.json

Lines changed: 2629 additions & 2343 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@
1212
},
1313
"private": true,
1414
"dependencies": {
15-
"@angular/animations": "^21.0.0",
16-
"@angular/common": "^21.0.0",
17-
"@angular/compiler": "^21.0.0",
18-
"@angular/core": "^21.0.0",
19-
"@angular/forms": "^21.0.0",
20-
"@angular/platform-browser": "^21.0.0",
21-
"@angular/platform-browser-dynamic": "^21.0.0",
22-
"@angular/router": "^21.0.0",
15+
"@angular/animations": "^22.0.0",
16+
"@angular/common": "^22.0.0",
17+
"@angular/compiler": "^22.0.0",
18+
"@angular/core": "^22.0.0",
19+
"@angular/forms": "^22.0.0",
20+
"@angular/platform-browser": "^22.0.0",
21+
"@angular/platform-browser-dynamic": "^22.0.0",
22+
"@angular/router": "^22.0.0",
2323
"core-js": "^3.19.3",
2424
"rxjs": "^6.5.5",
2525
"tslib": "^2.2.0",
2626
"zone.js": "^0.15.0"
2727
},
2828
"devDependencies": {
29-
"@angular-devkit/build-angular": "^21.0.0",
30-
"@angular/cli": "^21.1.4",
31-
"@angular/compiler-cli": "^21.0.0",
29+
"@angular-devkit/build-angular": "^22.0.0",
30+
"@angular/cli": "^22.0.0",
31+
"@angular/compiler-cli": "^22.0.0",
3232
"@types/jasmine": "^5.1.4",
3333
"@types/node": "^20.10.5",
3434
"@typescript-eslint/eslint-plugin": "5.36.2",
@@ -37,15 +37,16 @@
3737
"eslint-plugin-import": "latest",
3838
"eslint-plugin-jsdoc": "latest",
3939
"eslint-plugin-prefer-arrow": "latest",
40+
"istanbul-lib-instrument": "^6.0.3",
4041
"jasmine-core": "^5.1.1",
4142
"jasmine-spec-reporter": "^7.0.0",
4243
"karma": "^6.4.2",
4344
"karma-chrome-launcher": "^3.2.0",
4445
"karma-coverage-istanbul-reporter": "^3.0.3",
4546
"karma-jasmine": "^5.1.0",
4647
"karma-jasmine-html-reporter": "^2.1.0",
47-
"ng-packagr": "^21.1.0",
48+
"ng-packagr": "^22.0.0-rc.0",
4849
"ts-node": "^1.7.1",
49-
"typescript": "^5.9.3"
50+
"typescript": "^6.0.3"
5051
}
51-
}
52+
}

projects/ngx-wig/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngx-wig",
3-
"version": "21.0.0",
3+
"version": "22.0.0",
44
"description": "Light-weight WYSIWYG Editor for Angular",
55
"keywords": [
66
"Angular",
@@ -14,9 +14,9 @@
1414
},
1515
"homepage": "https://github.com/stevermeister/ngx-wig",
1616
"peerDependencies": {
17-
"@angular/common": "^21.0.0",
18-
"@angular/core": "^21.0.0",
19-
"@angular/forms": "^21.0.0"
17+
"@angular/common": "^22.0.0",
18+
"@angular/core": "^22.0.0",
19+
"@angular/forms": "^22.0.0"
2020
},
2121
"dependencies": {
2222
"tslib": "^2.2.0"

projects/ngx-wig/src/lib/ngx-wig-filter-styles.service.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { Injectable } from "@angular/core";
1+
import { Service } from "@angular/core";
22

3-
@Injectable({
4-
providedIn: "root",
5-
})
3+
@Service()
64
export class NgxWigFilterStylesService {
75
constructor() {}
86
public filter(htmlString: string): string {

projects/ngx-wig/src/lib/ngx-wig-filter.service.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { Injectable } from '@angular/core';
1+
import { Service } from '@angular/core';
22

3-
@Injectable({
4-
providedIn: 'root'
5-
})
3+
@Service()
64
export class NgxWigFilterService {
75
constructor() {}
86
public filter(content: string): string {
@@ -57,7 +55,7 @@ export class NgxWigFilterService {
5755
// --- Helper: Mark underlined spans by class or inline style ---
5856
private _markUnderlineSpans(html: string, underlineClasses: string[]): string {
5957
if (underlineClasses.length > 0) {
60-
html = html.replace(/<span([^>]*)class=["']([^"']+)["']([^>]*)>([\s\S]*?)<\/span>/gi, (match, p1, classAttr, p3, content) => {
58+
html = html.replace(/<span([^>]*)class=["']([^"']+)["']([^>]*)>([\s\S]*?)<\/span>/gi, (match, p1, classAttr: string, p3, content) => {
6159
const classes = classAttr.split(/\s+/);
6260
if (classes.some(cls => underlineClasses.includes(cls)) && classes.every(cls => underlineClasses.includes(cls) || cls === 's2' || cls === 's3')) {
6361
return `<u>${content}</u>`;

projects/ngx-wig/src/lib/ngx-wig.component.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, signal, ViewChild } from '@angular/core';
1+
import { Component, signal, ViewChild, ChangeDetectionStrategy } from '@angular/core';
22
import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';
33
import { FormsModule } from '@angular/forms';
44

@@ -12,6 +12,7 @@ const mockWindow = {};
1212
template: `<ngx-wig
1313
[(ngModel)]="text">
1414
</ngx-wig>`,
15+
changeDetection: ChangeDetectionStrategy.Eager,
1516
standalone: false
1617
})
1718
class TestNgModelHostComponent {
@@ -27,6 +28,7 @@ class TestNgModelHostComponent {
2728
buttons="bold,italic"
2829
[disabled]="false">
2930
</ngx-wig>`,
31+
changeDetection: ChangeDetectionStrategy.Eager,
3032
standalone: false
3133
})
3234
class TestHostComponent {

projects/ngx-wig/src/lib/ngx-wig.component.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
signal,
1717
viewChild,
1818
viewChildren,
19+
ChangeDetectionStrategy
1920
} from "@angular/core";
2021
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from "@angular/forms";
2122
import { CommandFunction, TButton } from "./config";
@@ -36,10 +37,11 @@ import { NgxWigToolbarService } from "./ngx-wig-toolbar.service";
3637
},
3738
],
3839
encapsulation: ViewEncapsulation.None,
40+
changeDetection: ChangeDetectionStrategy.Eager,
3941
standalone: false,
4042
})
4143
export class NgxWigComponent
42-
implements OnInit, OnChanges, OnDestroy, ControlValueAccessor
44+
implements OnInit, OnChanges, ControlValueAccessor
4345
{
4446
public readonly content = model<string>();
4547

@@ -71,8 +73,6 @@ export class NgxWigComponent
7173
public readonly hasFocus = signal(false);
7274
public readonly toolbarButtonIndex = signal<number>(0);
7375

74-
private readonly _mutationObserver: MutationObserver;
75-
7676
private readonly toolbarButtonElems = viewChildren("toolbarButton", {
7777
read: ElementRef,
7878
});
@@ -82,7 +82,7 @@ export class NgxWigComponent
8282
@Optional() private readonly _filterService: NgxWigFilterService,
8383
// cannot set Document here - Angular issue - https://github.com/angular/angular/issues/20351
8484
@Inject(DOCUMENT) private readonly document: Document,
85-
@Inject("WINDOW") private readonly window,
85+
@Inject("WINDOW") private readonly window: Window,
8686
) {}
8787

8888
private executeCommand(command: string, value: string = ""): boolean {
@@ -159,12 +159,6 @@ export class NgxWigComponent
159159
}
160160
}
161161

162-
public ngOnDestroy(): void {
163-
if (this._mutationObserver) {
164-
this._mutationObserver.disconnect();
165-
}
166-
}
167-
168162
public onContentChange(newContent: string): void {
169163
this.content.set(this.isInnerTextEmpty(newContent) ? "" : newContent);
170164

@@ -385,12 +379,11 @@ export class NgxWigComponent
385379
target?.nativeElement.focus();
386380
}
387381

388-
private pasteHtmlAtCaret(html) {
389-
let sel;
382+
private pasteHtmlAtCaret(html: string) {
390383
let range;
391384

392385
if (window.getSelection) {
393-
sel = window.getSelection();
386+
const sel = window.getSelection()!;
394387
if (sel.getRangeAt && sel.rangeCount) {
395388
range = sel.getRangeAt(0);
396389
range.deleteContents();

projects/ngx-wig/tsconfig.lib.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
"angularCompilerOptions": {
1616
"skipTemplateCodegen": true,
1717
"strictMetadataEmit": true,
18+
"extendedDiagnostics": {
19+
"checks": {
20+
"nullishCoalescingNotNullable": "suppress",
21+
"optionalChainNotNullable": "suppress"
22+
}
23+
},
1824
"fullTemplateTypeCheck": true,
1925
"strictInjectionParameters": true,
2026
"enableResourceInlining": true

projects/ngx-wig/tsconfig.lib.prod.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
"declarationMap": false
55
},
66
"angularCompilerOptions": {
7-
"compilationMode": "partial"
7+
"compilationMode": "partial",
8+
"extendedDiagnostics": {
9+
"checks": {
10+
"nullishCoalescingNotNullable": "suppress",
11+
"optionalChainNotNullable": "suppress"
12+
}
13+
}
814
}
915
}

0 commit comments

Comments
 (0)