From 36c9056ddcf33d59b975fe853b6998cab8ba857b Mon Sep 17 00:00:00 2001 From: in312ham Date: Fri, 19 Jul 2024 12:52:11 +0200 Subject: [PATCH 1/2] Make onPaste also support text of type text/plain --- projects/ngx-wig/src/lib/ngx-wig.component.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/projects/ngx-wig/src/lib/ngx-wig.component.ts b/projects/ngx-wig/src/lib/ngx-wig.component.ts index 66c1e97..0d067bf 100644 --- a/projects/ngx-wig/src/lib/ngx-wig.component.ts +++ b/projects/ngx-wig/src/lib/ngx-wig.component.ts @@ -153,13 +153,18 @@ export class NgxWigComponent } else { this.pasteHtmlAtCaret(changes['content'].currentValue); } - + } } onPaste(event: ClipboardEvent) { event.preventDefault(); - const text = event.clipboardData?.getData('text/html') ?? ''; + + let text = event.clipboardData?.getData('text/html') ?? ''; + if (text.length == 0) { + text = event.clipboardData?.getData('text/plain') ?? ''; + } + if (this._filterService){ this.pasteHtmlAtCaret(this._filterService.filter(text)); } else { From 59522068824ad7050262eef403db1177aa1b8845 Mon Sep 17 00:00:00 2001 From: in312ham Date: Mon, 22 Jul 2024 08:04:15 +0200 Subject: [PATCH 2/2] Make onPaste also support text of type text/plain --- projects/ngx-wig/src/lib/ngx-wig.component.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/projects/ngx-wig/src/lib/ngx-wig.component.ts b/projects/ngx-wig/src/lib/ngx-wig.component.ts index 0d067bf..ba06ffc 100644 --- a/projects/ngx-wig/src/lib/ngx-wig.component.ts +++ b/projects/ngx-wig/src/lib/ngx-wig.component.ts @@ -160,10 +160,7 @@ export class NgxWigComponent onPaste(event: ClipboardEvent) { event.preventDefault(); - let text = event.clipboardData?.getData('text/html') ?? ''; - if (text.length == 0) { - text = event.clipboardData?.getData('text/plain') ?? ''; - } + const text = event.clipboardData?.getData('text/html') || event.clipboardData?.getData('text/plain') || ''; if (this._filterService){ this.pasteHtmlAtCaret(this._filterService.filter(text));