stevermeister / ngx-wig

Angular(also Angular 17) WYSIWYG HTML Rich Text Editor (from ngWig - https://github.com/stevermeister/ngWig)
Apache License 2.0
229 stars 51 forks source link

make possible to filter content that is provided to editor (for example via copy-paste) #200

Closed stevermeister closed 9 months ago

stevermeister commented 9 months ago

for instance to prevent the situation when extra styles were copy-pasted

stevermeister commented 9 months ago

@bampakoa what do you think about this?

especially this part:

    if (this._filterService){
      this.pasteHtmlAtCaret(this._filterService.filter(text));
    } else {
      this.pasteHtmlAtCaret(text);
    }

the idea is to use Filter as a Strategy pattern and keep the default one with the method filter that will do nothing, but I did not manage to create it in such a way that it's possible to overwrite

bampakoa commented 9 months ago

@stevermeister how about having a separate dropdown option for pasting content as text (no styles), just like MS Word does?

stevermeister commented 9 months ago

@bampakoa I believe it's not only Word, it looks like it's already a standard. Screenshot 2024-02-20 at 17 24 10

still: 1) this feature is not only about styles, but any filtering/modification 2) for some old-school users it's still a challenge to do a paste and keep the right styles (we have a real use-case for our business application at Studytube)

bampakoa commented 9 months ago

Got it! LGTM!

stevermeister commented 9 months ago

actually I was asking more not about the feature itself, but more about architectural design.

I want to always apply the filter:

this.pasteHtmlAtCaret(this._filterService.filter(text));

(without any if's) and having default as an empty one

but provide a possibility to overwrite in applications that uses ngx-wig

bampakoa commented 9 months ago

Oh I see 🙂 Sorry for the confusion! Having the filter method applying the default behavior without an indication seems a bit magic. I would change it as follows to be more explicit:

this.pasteHtmlAtCaret(this._filterService.filter({ value: text, mode: 'keepStyles' }));

stevermeister commented 9 months ago

ok, good, will keep it as it is :)

sonarcloud[bot] commented 9 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud