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

Problem when using insertContent with a text node list #2770

Closed
1 of 2 tasks
GitHubish opened this issue May 9, 2022 · 7 comments · Fixed by #3790
Closed
1 of 2 tasks

Problem when using insertContent with a text node list #2770

GitHubish opened this issue May 9, 2022 · 7 comments · Fixed by #3790
Assignees
Labels
Type: Bug The issue or pullrequest is related to a bug
Milestone

Comments

@GitHubish
Copy link

What’s the bug you are facing?

I just found a regression. When I paste text in my editor, I call the server so it can parse it. I just saw that it doesn't work anymore I had a result showing :
image

I thought the problem was coming from somewhere else but in fact when I execute this piece of code in a blank project I also have the problem. Before it was working.

editor
              .chain()
              .insertContent([
                {
                  type: 'text',
                  text: 'Second paragraph',
                },
                {
                  type: 'text',
                  text: 'First paragraph',
                }
              ])
              .focus()
              .run();

Demo here : https://codesandbox.io/s/tiptap-demo-tailwind-forked-ewe285?file=/src/index.js

Which browser was this experienced in? Are any special extensions installed?

Chrome 100, Safari, Firefox Latest

How can we reproduce the bug on our side?

Use this code :

editor
              .chain()
              .insertContent([
                {
                  type: 'text',
                  text: 'Second paragraph',
                },
                {
                  type: 'text',
                  text: 'First paragraph',
                }
              ])
              .focus()
              .run();

Can you provide a CodeSandbox?

https://codesandbox.io/s/tiptap-demo-tailwind-forked-ewe285?file=/src/index.js

What did you expect to happen?

It used to insert the nodes without any problem.

Anything to add? (optional)

No response

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. 💖
@GitHubish GitHubish added the Type: Bug The issue or pullrequest is related to a bug label May 9, 2022
@gazben
Copy link

gazben commented Jun 9, 2022

Text insertContent seems to broken for me as well.

@GitHubish What was the last version where it worked for you?

@GitHubish
Copy link
Author

@gazben It's hard to say, I couldn't necessarily find when it stopped working, it was a very specific part of my application for which the tests were not yet developed. Maybe version 2.0.0-beta.168 or 2.0.0-beta.170... In my tests the insertContent method does not crash but just does nothing. For example adding several Nodes in the paragraph where there is the cursor does not work although it was before.

My use case is a copy/paste. I intercept the event to send the text to the server so that it can parse it and send me back a rich content (JSON format). For example a text with an @mention will be automatically transformed by the server as Slack would do and thus send me back the necessary information to display the mention.

@gazben
Copy link

gazben commented Jun 10, 2022

he insertContent method does not crash but just does nothing

yepp same for me, I'll try older versions

@sebinemeth
Copy link

sebinemeth commented Jun 13, 2022

Hi all, I am working on the same issue as @gazben, and I found a fix:
Change the object syntax to the string param syntax: editor.chain().insertContent({ type: 'text', text: 'foo' }) does not work but editor.chain().insertContent('foo') does, hope it helps. I could not find documentation for it though...

@GitHubish
Copy link
Author

On my side, following the previous solution proposed by @sebinemeth I had to convert my JSON to HTML using the generateHTML method. Clearly not adapted...

I hope that the Tiptap team will consult this ticket to give us a feedback.

@bdbch bdbch self-assigned this Sep 14, 2022
@github-actions
Copy link
Contributor

This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Info: Stale The issue or pullrequest has not been updated in a while and might be stale label Feb 20, 2023
@bdbch bdbch added this to the 2.0.0 Release milestone Feb 24, 2023
@bdbch
Copy link
Member

bdbch commented Feb 24, 2023

Just pushed a fix for this

@github-actions github-actions bot removed the Info: Stale The issue or pullrequest has not been updated in a while and might be stale label Feb 26, 2023
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

Successfully merging a pull request may close this issue.

4 participants