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

Prosemirror-Model: Add missing optional target argument to serializeFragment function #64

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mmackeyatl
Copy link

Adding missing optional "target" argument type to serializeFragment function as per issue raised in DefinitelyTyped repo (@types-prosemirror-model):
DefinitelyTyped/DefinitelyTyped#57668

@marijnh
Copy link
Member

marijnh commented Jan 24, 2022

That's intentionally private. Did you need it in a real-world use case?

@mmackeyatl
Copy link
Author

We're trying to write a custom serializer for clipboardSerializer to add some logic. For this we also needed to manually call serializeFragment ourselves as we want to preserve the original serializer's logic too.

customSerializer.serializeFragment = (content, options, target) => {
  if (thing) {
    let newContent;
    return originalSerializeFragment(newContent, options, target);
  }
  return originalSerializeFragment(content, options, target);
};

@marijnh
Copy link
Member

marijnh commented Feb 7, 2022

Subclassing stuff is not generally supported in this library. It seems like this use case could also be handled by a pre-processing pass on the content, no?

@mmackeyatl
Copy link
Author

mmackeyatl commented Feb 8, 2022

How/where could we do the pre-processing pass on the content when we need to transform what's being written to the clipboard?

marijnh added a commit to ProseMirror/prosemirror-view that referenced this pull request Feb 8, 2022
@marijnh
Copy link
Member

marijnh commented Feb 8, 2022

That's a good point. I've updated the docs in attached patch to clarify that only the serializeFragment method of clipboardSerializer will be called, and you may provide an alternative object that provides that method. Does that help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants