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

fix(extension-code-block): #3604 paste code from vscode #3606

Merged

Conversation

aliasliao
Copy link
Contributor

@aliasliao aliasliao commented Jan 8, 2023

fixes #3604 , #3321

This line (L267) causes the wrong insertion position:
https://github.com/ueberdosis/tiptap/blob/main/packages/extension-code-block/src/code-block.ts#L267

tr.setSelection(TextSelection.near(tr.doc.resolve(Math.max(0, tr.selection.from - 2))))

Removing L267 can fix the bug.
But I think the better solution is to replace selection with a text node, rather than imperatively inserting the copied content : )

cc @bdbch

@netlify
Copy link

netlify bot commented Jan 8, 2023

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit c0f119b
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/6646ede29235660008563049
😎 Deploy Preview https://deploy-preview-3606--tiptap-embed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@aliasliao aliasliao changed the title fix(extension-code-block): paste code from vscode fix(extension-code-block): #3604 paste code from vscode Jan 8, 2023
@aliasliao aliasliao force-pushed the fix/code-block-paste-from-vscode branch from 8b48050 to d9a672e Compare February 9, 2023 15:35
@aliasliao
Copy link
Contributor Author

@bdbch Can you help to review this?

bdbch
bdbch previously approved these changes Mar 2, 2023
Copy link
Member

@bdbch bdbch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@svenadlung cc

@bdbch bdbch added Status: Review Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. labels Mar 29, 2023
@aliasliao
Copy link
Contributor Author

@svenadlung need your review, please

@aliasliao aliasliao force-pushed the fix/code-block-paste-from-vscode branch from ac5174a to 62fff76 Compare April 5, 2023 04:35
@svenadlung
Copy link
Member

@aliasliao Thank you. I'll have a look next week due to public holidays.

@svenadlung
Copy link
Member

@aliasliao Sorry for the delay. There is a small difference in some cases. In that case the cursor after pasting is not in the code node, but in the following node. Can you please check again?

@aliasliao aliasliao force-pushed the fix/code-block-paste-from-vscode branch 2 times, most recently from da0bc06 to 62fff76 Compare May 24, 2023 14:08
@aliasliao aliasliao force-pushed the fix/code-block-paste-from-vscode branch from 62fff76 to c959c18 Compare May 24, 2023 14:10
@aliasliao
Copy link
Contributor Author

aliasliao commented May 24, 2023

@aliasliao Sorry for the delay. There is a small difference in some cases. In that case the cursor after pasting is not in the code node, but in the following node. Can you please check again?

@svenadlung Hi, I have fixed (mostly) this issue in the latest commit. Could you please help to review it?

There is one last case that I found hard to handle: if there is a CodeBlock after the cursor before pasting, the cursor remains inside that CodeBlock after pasting instead of moving to the newly created code block.

nperez0111
nperez0111 previously approved these changes May 17, 2024
Copy link

@nperez0111 nperez0111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nperez0111 nperez0111 merged commit daa5e52 into ueberdosis:main May 17, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong insertion position when pasting code from VSCode
4 participants