Open ashu12chi opened 4 months ago
What is the problem with using a custom ClipboardSerializer?
There are multiple reasons due to which we don't want to use custom ClipboardSerializer
:
Additionally, the use case we want to handle here should be fairly common e.g. When we copy any content from MS Office apps like MS Word or MS Excel, it also add <style>
and <meta>
tags.
Our use case is simple which requires the manipulation on the final generated HTML and we does not want to interfere with the default clipboard serialization of ProseMirror.
You can call to the default serializer, and then do your own transformations on the result.
The ProseMirror performs further operation on the obtained document fragment (ref), and it this final html that we want to transform before it’s passed to clipboard.
That just adds an attribute, one that you shouldn't be interfering with anyway.
Additionally, the use case we want to handle here should be fairly common e.g. When we copy any content from MS Office apps like MS Word or MS Excel, it also add
Hi,
This is duplicate of this discussion.
We have custom styles that I want to append to the html content as
<style>
tag when it’s copied from editor. We also want to add a<meta>
tag, so that it indicates that the source of content currently in clipboard is from my editor component along with other meta data.We want a callback similar to
transformPastedHTML
which can have following signature:This callback can be added here and it will help us in manipulating the copied HTML just before adding it to the clipboard without dealing with custom
ClipboardSerializer
.