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

feat: markdown formatting using keyboard shortcut #4058

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

Conversation

Abhi-Bohora
Copy link
Contributor

@Abhi-Bohora Abhi-Bohora commented Jan 9, 2025

Changes

linked Issue: 1624

The pr which I raise before which got merged caused some issue as mentioned here so this new pr aims to fix that.

This PR has all the logic implemented same as this pr and keyboard shortcuts functions the same expect for the link command we use ctrl+k now to follow common community convention as suggested. And there was a issue while pasting the content in textarea, browser would ask permission at first. now the issue should not be there, i have moved the logic to make user selected word to link, if a link is paste over a selected word to handleLinkPaste fn and only trigger when onPaste and decided not to touch default browser paste functionality.

sorry for the inconvenience...😅 thanks

Events

Did you introduce any new tracking events?

Experiment

Did you introduce any new experiments?

Manual Testing

Caution

Please make sure existing components are not breaking/affected by this PR

Copy link

vercel bot commented Jan 9, 2025

@Abhi-Bohora is attempting to deploy a commit to the Daily Dev Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Member

@sshanzel sshanzel left a comment

Choose a reason for hiding this comment

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

I realized one thing about our existing keydown commands, we might want to check whether they would still work and how we can incorporate the changes with it together.

@@ -317,15 +418,47 @@ export const useMarkdownInput = ({
};

const onPaste: ClipboardEventHandler<HTMLTextAreaElement> = (e) => {
if (!e.clipboardData.files?.length || !isUploadEnabled) {
if (!e.clipboardData.files?.length && !isUploadEnabled) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to change this to && because this || was was giving me early return and logic below can't be applied. please let me know if this breaks something, seems to work fine when i tested

@Abhi-Bohora
Copy link
Contributor Author

@sshanzel Hy I have moved the logic in useMarkdownInput and text formatting works fine. And the some of the existing onKeyCommands like navigating through mention user list, enter to select mention etc seems to be working fine, I may have missed something to test...please let me know if anything 🙏

and about this lint error this seems to be coming from already existing code so i decided not to change anything...😅

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

Successfully merging this pull request may close these issues.

2 participants