Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Feb 22, 2024

Conversation

stevermeister
Copy link
Owner

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

@stevermeister
Copy link
Owner Author

@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
Copy link
Collaborator

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

@stevermeister
Copy link
Owner Author

@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
Copy link
Collaborator

Got it! LGTM!

@stevermeister
Copy link
Owner Author

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
Copy link
Collaborator

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
Copy link
Owner Author

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

Copy link

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

@stevermeister stevermeister merged commit b0ec4ea into master Feb 22, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants