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

Bug: $insertDataTransferForRichText doesn't use selection parameter #6278

Open
SamVgaard opened this issue Jun 8, 2024 · 0 comments
Open

Comments

@SamVgaard
Copy link

The changes from Pull Request #5954 to $insertDataTransferForRichText now result in the selection parameter not being utilized for 'text/plain' dataTranfers.

Lexical version: 0.16.0

Steps To Reproduce

  1. Call $insertDataTransferForRichText(dataTransfer, selection, editor) where the dataTransfer is of type 'text/plain' and selection is some RangeSelection but not the current selection, i.e. not selection !== $getSelection()

The current behavior

$insertDataTransferForRichText inserts text from the dataTransfer parameter to the current selection ($getSelection())

The expected behavior

$insertDataTransferForRichText should insert text from the dataTransfer parameter to the selection parameter as per the function description

/**
 * @param dataTransfer an object conforming to the [DataTransfer interface] (https://html.spec.whatwg.org/multipage/dnd.html#the-datatransfer-interface)
 * @param selection the selection to use as the insertion point for the content in the DataTransfer object
 * @param editor the LexicalEditor the content is being inserted into.
 */

For context, I was using this function for a "replace all" function for a find and replace tool. Naturally I don't want to set the current selection to each selection to be replaced; I just want to iteratively create range selections to replace with rich text.

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

No branches or pull requests

1 participant