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

The parseOptions parameter of setContent does not work. #2315

Closed
1 of 2 tasks
SF-Simon opened this issue Dec 25, 2021 · 1 comment
Closed
1 of 2 tasks

The parseOptions parameter of setContent does not work. #2315

SF-Simon opened this issue Dec 25, 2021 · 1 comment
Labels
Type: Bug The issue or pullrequest is related to a bug

Comments

@SF-Simon
Copy link

What’s the bug you are facing?

We want to replace everything in the editor with spaces. Therefore, we use the parseOptions parameter for configuration.

But it didn't work.

How can we reproduce the bug on our side?

          this.editor
            .chain()
            .setContent(newContent, false, {
              parseOptions: {
                preserveWhitespace: "full",
              },
            })
            .focus(focusPosition)
            .run();

Execute the above code, the content of the editor is replaced, but there are no white space characters.

Can you provide a CodeSandbox?

No response

What did you expect to happen?

As the document says, it can keep all spaces in the new content.

Anything to add? (optional)

It is normal for me to use the code below, but it is an insert, not a replacement.

          this.editor
            .chain()
            .insertContent(newContent, {
              parseOptions: {
                preserveWhitespace: "full",
              },
            })
            .focus()
            .run();

Did you update your dependencies?

  • Yes, I’ve updated my dependencies to use the latest version of all packages.

Are you sponsoring us?

  • Yes, I’m a sponsor. 💖
@SF-Simon SF-Simon added the Type: Bug The issue or pullrequest is related to a bug label Dec 25, 2021
@philippkuehn
Copy link
Contributor

Right now, parseOptions is the third parameter of the setContent command. So this should work:

this.editor
  .chain()
  .setContent(newContent, false, {
    preserveWhitespace: "full",
  })
  .focus(focusPosition)
  .run();

This may change in the future if we refactor some commands as part of #2087

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug The issue or pullrequest is related to a bug
Projects
None yet
Development

No branches or pull requests

2 participants