clipboardTextParser(text, $context)?


i’m trying to handle this scenario:

  • a user copies an embed code (typically, on youtube)
  • then pastes it into the editor

However, the pasted snippet is html markup pasted as text/plain.

clipboardTextParser(text) -> slice would do the job, but it cannot parse the text properly because it’s missing the $context variable.

Would you accept a PR with this change ?

Here’s the PR:

Yes, that makes sense. Merged!

Cool !

However, having no less than FIVE hooks in parseFromClipboard looks like suspicious design.

Couldn’t it be simplified ?

Also to make the conversation easier, here’s what i did that motivated the pull request:

Do you have any specific proposal?

I don’t know, maybe simply allow overriding the whole parseFromClipboard function ?

That would make it impossible to ‘mix in’ transformers from different addons, and would require people overriding it to get all the details, such as pasting into code and creating the proper slice, right in their implementations. If you want to completely redefine paste behavior, you can already do that with handlePaste.